q9f / eth.rb

a straightforward library to build, sign, and broadcast ethereum transactions anywhere you can run ruby.
https://q9f.github.io/eth.rb
Apache License 2.0
196 stars 85 forks source link

Abi::Event.decode_log raised an error #247

Closed wuminzhe closed 1 month ago

wuminzhe commented 9 months ago

Abi::Event.decode_log failed:

 NoMethodError:
   undefined method `none?' for nil:NilClass

             elsif base_type == "tuple" && components.none?(&:dynamic?)

abi:

[
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "bytes32",
        "name": "msgHash",
        "type": "bytes32"
      },
      {
        "indexed": false,
        "internalType": "bytes32",
        "name": "root",
        "type": "bytes32"
      },
      {
        "components": [
          {
            "internalType": "address",
            "name": "channel",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "index",
            "type": "uint256"
          },
          {
            "internalType": "uint256",
            "name": "fromChainId",
            "type": "uint256"
          },
          {
            "internalType": "address",
            "name": "from",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "toChainId",
            "type": "uint256"
          },
          {
            "internalType": "address",
            "name": "to",
            "type": "address"
          },
          {
            "internalType": "bytes",
            "name": "encoded",
            "type": "bytes"
          }
        ],
        "indexed": false,
        "internalType": "struct Message",
        "name": "message",
        "type": "tuple"
      }
    ],
    "name": "MessageAccepted",
    "type": "event"
  }
]

log:

      log = {
        "address"=>"0x0000000000bd9dcfda5c60697039e2b3b28b079b", 
        "blockHash"=>"0xf9c70715305172f0d7ae0e335c38df5582c6138d96b742183c02a69ff3c11304", 
        "blockNumber"=>"0xddcb4d", 
        "data"=>"0xfc2a07bae9b75d5a817aa5ff752d263d213286dda48387a2e818814f4557d61200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000bd9dcfda5c60697039e2b3b28b079b00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000066eed0000000000000000000000000f14341a7f464320319025540e8fe48ad0fe5aec000000000000000000000000000000000000000000000000000000000000002b0000000000000000000000000000000000bd9dcfda5c60697039e2b3b28b079b00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000", 
        "logIndex"=>"0xcd", 
        "removed"=>false, 
        "topics"=>[
          "0xa047cf3271a6e55d76e7706ca90d011a4f2f641f7c46dfd31f6abe4cd94db53f", 
          "0xf654c17ea89108d7183eaf31c762fe0c125d476aa8130938d8a1895307b7db5a"
        ], 
        "transactionHash"=>"0x215e05a6260a5fbca5ebf866bf8612868c50691e0ff24be54f96f8192ca9b968", 
        "transactionIndex"=>"0x8c", 
      }
wuminzhe commented 8 months ago

https://github.com/wuminzhe/abi_coder_rb

I have an abi coder gem which passes the web3.js tests. @q9f or someone might be able to use it for abi de/encoding.

q9f commented 1 month ago

278