Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parity with web3js in decoding #52

Closed
tbuckley54 opened this issue Jan 25, 2023 · 3 comments
Closed

Parity with web3js in decoding #52

tbuckley54 opened this issue Jan 25, 2023 · 3 comments

Comments

@tbuckley54
Copy link

using this abi

{
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "name": "specId",
        "type": "bytes32"
      },
      {
        "indexed": false,
        "name": "requester",
        "type": "address"
      },
      {
        "indexed": false,
        "name": "requestId",
        "type": "bytes32"
      },
      {
        "indexed": false,
        "name": "payment",
        "type": "uint256"
      },
      {
        "indexed": false,
        "name": "callbackAddr",
        "type": "address"
      },
      {
        "indexed": false,
        "name": "callbackFunctionId",
        "type": "bytes4"
      },
      {
        "indexed": false,
        "name": "cancelExpiration",
        "type": "uint256"
      },
      {
        "indexed": false,
        "name": "dataVersion",
        "type": "uint256"
      },
      {
        "indexed": false,
        "name": "data",
        "type": "bytes"
      }
    ],
    "name": "OracleRequest",
    "type": "event"
  }

with this event

{
    "logIndex": "0x82",
    "transactionIndex": "0x55",
    "transactionHash": "0xda2b8561b0074d954ea33a26692e93ebff9710d2220e0eb5003abdc468bb0d8d",
    "blockHash": "0x7203fb7525cc8fc2cfa53960013a56fce83f02594fcc691f27e324959d4f2d4e",
    "blockNumber": "0xb7b059",
    "address": "0x60B2582FB902Dff0B99c7AC30ABC08AaEfEEB309",
    "data": "0x000000000000000000000000f9fc2b4a0e487297b05285e9b3327f26e70c4e9b6b7ff4ffa51b345e8459b03fdb280ac7f99caaf432142a1b800c581d8b4ed39f00000000000000000000000000000000000000000000000000ee59ddf89580d6000000000000000000000000f9fc2b4a0e487297b05285e9b3327f26e70c4e9b042f2b650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000604e53520000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000976375726c787e68747470733a2f2f6d61726b65742e6c696e6b2f76312f6e6f6465732f66373662653531392d653431652d343861302d393433302d3437333139656461306634332f766572696669636174696f6e2f726573706f6e73653f746f6b656e3d663336613737333531626533346433323830333965623766643536626630303264706174686d726573706f6e7365546f6b656e",
    "topics": [
      "0xd8d7ecc4800d25fa53ce0372f13a416d98907a7ef3d8d3bdd79cf4fe75529c65",
      "0x3431373466353064613337333431306161363430326265313263626538636463"
    ],
    "type": null,
    "timestamp": 1615745574,
    "uuid": "9f04ac61-3d16-48de-917e-95d0a622f404",
    "additionalFields": {
      "removed": "false"
    }
  }

when using web3js web3.eth.abi.decodeLog produces this output

Result {
  '0': '0xd8d7ecc4800d25fa53ce0372f13a416d98907a7ef3d8d3bdd79cf4fe75529c65',
  '1': '0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b',
  '2': '0x6b7ff4ffa51b345e8459b03fdb280ac7f99caaf432142a1b800c581d8b4ed39f',
  '3': '67089854350328022',
  '4': '0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b',
  '5': '0x042f2b65',
  '6': '1615745874',
  '7': '1',
  '8': '0x6375726c787e68747470733a2f2f6d61726b65742e6c696e6b2f76312f6e6f6465732f66373662653531392d653431652d343861302d393433302d3437333139656461306634332f766572696669636174696f6e2f726573706f6e73653f746f6b656e3d663336613737333531626533346433323830333965623766643536626630303264706174686d726573706f6e7365546f6b656e',
  __length__: 9,
  specId: '0xd8d7ecc4800d25fa53ce0372f13a416d98907a7ef3d8d3bdd79cf4fe75529c65',
  requester: '0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b',
  requestId: '0x6b7ff4ffa51b345e8459b03fdb280ac7f99caaf432142a1b800c581d8b4ed39f',
  payment: '67089854350328022',
  callbackAddr: '0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b',
  callbackFunctionId: '0x042f2b65',
  cancelExpiration: '1615745874',
  dataVersion: '1',
  data: '0x6375726c787e68747470733a2f2f6d61726b65742e6c696e6b2f76312f6e6f6465732f66373662653531392d653431652d343861302d393433302d3437333139656461306634332f766572696669636174696f6e2f726573706f6e73653f746f6b656e3d663336613737333531626533346433323830333965623766643536626630303264706174686d726573706f6e7365546f6b656e'
}

but we get this error using headlong

tuple index 7: not enough bytes remaining: 151 < 160
@esaulpaugh
Copy link
Owner

esaulpaugh commented Jan 26, 2023

000000000000000000000000f9fc2b4a0e487297b05285e9b3327f26e70c4e9b
6b7ff4ffa51b345e8459b03fdb280ac7f99caaf432142a1b800c581d8b4ed39f
00000000000000000000000000000000000000000000000000ee59ddf89580d6
000000000000000000000000f9fc2b4a0e487297b05285e9b3327f26e70c4e9b
042f2b6500000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000604e5352
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000100
0000000000000000000000000000000000000000000000000000000000000097
6375726c787e68747470733a2f2f6d61726b65742e6c696e6b2f76312f6e6f64
65732f66373662653531392d653431652d343861302d393433302d3437333139
656461306634332f766572696669636174696f6e2f726573706f6e73653f746f
6b656e3d66333661373733353162653334643332383033396562376664353662
6630303264706174686d726573706f6e7365546f6b656e

The data length is not a multiple of 32 bytes. Try padding the end with zeroes so that the byte length is 448 and not 439. I like to use Integers.roundLengthUp(data.length, 32) to help with such things.

Resulting tuple is

[[52, 49, 55, 52, 102, 53, 48, 100, 97, 51, 55, 51, 52, 49, 48, 97, 97, 54, 52, 48, 50, 98, 101, 49, 50, 99, 98, 101, 56, 99, 100, 99], 0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b, [107, 127, -12, -1, -91, 27, 52, 94, -124, 89, -80, 63, -37, 40, 10, -57, -7, -100, -86, -12, 50, 20, 42, 27, -128, 12, 88, 29, -117, 78, -45, -97], 67089854350328022, 0xf9fc2b4a0E487297B05285e9B3327f26e70c4E9b, [4, 47, 43, 101], 1615745874, 1, [99, 117, 114, 108, 120, 126, 104, 116, 116, 112, 115, 58, 47, 47, 109, 97, 114, 107, 101, 116, 46, 108, 105, 110, 107, 47, 118, 49, 47, 110, 111, 100, 101, 115, 47, 102, 55, 54, 98, 101, 53, 49, 57, 45, 101, 52, 49, 101, 45, 52, 56, 97, 48, 45, 57, 52, 51, 48, 45, 52, 55, 51, 49, 57, 101, 100, 97, 48, 102, 52, 51, 47, 118, 101, 114, 105, 102, 105, 99, 97, 116, 105, 111, 110, 47, 114, 101, 115, 112, 111, 110, 115, 101, 63, 116, 111, 107, 101, 110, 61, 102, 51, 54, 97, 55, 55, 51, 53, 49, 98, 101, 51, 52, 100, 51, 50, 56, 48, 51, 57, 101, 98, 55, 102, 100, 53, 54, 98, 102, 48, 48, 50, 100, 112, 97, 116, 104, 109, 114, 101, 115, 112, 111, 110, 115, 101, 84, 111, 107, 101, 110]]

@esaulpaugh
Copy link
Owner

see #53

@esaulpaugh esaulpaugh reopened this Aug 22, 2023
@esaulpaugh
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants