Skip to content

aqua-sdk: HexString instance passed as a viem getLogs topic is silently dropped (empty topics filter) #95

Description

@EndPx

What happened

Passing an SDK HexString instance as a topic in viem's getLogs filter silently drops the topic — the request goes out as "topics": [] and returns unfiltered logs. The call succeeds, the result just quietly means something different (we concluded "the event doesn't exist" when the truth was "the filter never left the client"). Captured by wrapping fetch and comparing request bodies:

sent:  {"method":"eth_getLogs","params":[{"address":"0xd2A8…","topics":[],"fromBlock":"0x2c44b19",…}]}
meant: {"method":"eth_getLogs","params":[{"address":"0xd2A8…","topics":["0xd173a1d1…"],"fromBlock":"0x2c44b19",…}]}

Cause

viem requires primitive `0x${string}` for topics; the HexString class instance is not a string, so it is dropped. HexString.hexString (the raw value) is private, so the escape hatch String(topic) reads like reaching into internals.

Suggestion

Either brand HexString so it satisfies viem's `0x${string}` (a string template type), or export a HexLike = Hex | HexString conversion helper (e.g. HexString.toHex()) and document that SDK hex wrappers must be converted before entering viem filter objects. One docs warning next to the event-class examples would have saved us a debugging round.

Versions

  • @1inch/aqua-sdk 0.3.1 (@1inch/sdk-core 0.1.2), viem 2.56.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions