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

get_logs() returns no logs for structs #155

Open
4812571 opened this issue Nov 13, 2024 · 0 comments · May be fixed by #156
Open

get_logs() returns no logs for structs #155

4812571 opened this issue Nov 13, 2024 · 0 comments · May be fixed by #156

Comments

@4812571
Copy link

4812571 commented Nov 13, 2024

Attempting to use util/getLogs to get the logs of an event with a tuple in it's ABI will always yield no logs due to the wrong topic string being inferred from the ABI.

Example code:

const EVENT_CONFIRMED = 'MatchConfirmed(address indexed,(address,address,uint32),uint32,uint32,uint16)'

const logs = getLogs({
    target: '0xa40Ad3916237fa0FE11A500241fFA6eAc59CBD6A'
    eventAbi: EVENT_CONFIRMED,
    chain: 'arbitrum',
    fromBlock: 273893300,
    toBlock: 273900000,
})

console.log(logs.length) // always 0

This is due to a bug in the following internal function

  function toFilterTopic(topic) {
      if (typeof topic === 'string') {
          if (topic.startsWith('0x'))
              return topic;
          topic = new ethers_1.Interface([topic]);
      }
      const fragment = topic.fragments[0];
      return (0, ethers_1.id)(`${fragment.name}(${fragment.inputs.map((i) => i.type).join(',')})`);
  }

This function yields an incorrect topic string for ABIs with tuples in their signature.

expected: 0x40cdf7952f1870062f22e699acb978b97d3f41f739aa8b64d3b74c3f10654f83
actual: 0x49fa5e352a6e224cc24f6a14d90e9573aad1b2f8e0233e04d69baa5596af1371

See 'MatchConfirmed' event here: https://arbiscan.io/address/0xa40Ad3916237fa0FE11A500241fFA6eAc59CBD6A#events

@4812571 4812571 linked a pull request Nov 13, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant