Skip to content

Implement updated bindings for hs client#88

Merged
JonoPrest merged 3 commits into
mainfrom
jp/use-new-hsc
Jul 30, 2024
Merged

Implement updated bindings for hs client#88
JonoPrest merged 3 commits into
mainfrom
jp/use-new-hsc

Conversation

@JonoPrest

Copy link
Copy Markdown
Collaborator

This fixes the int24 underflow issue reported by Jack on discord.

Until this: enviodev/hypersync-client-rust#34
is merged, released and updated at least in hs client node we can't merge this.

Unfortuantely the current signature model will break with collisions on event signatures (from multiple contracts) and it will break in the case that two contracts have the same event with different topic0.

So we can't include this yet.

@JonoPrest JonoPrest requested review from DZakh and JasoonS July 25, 2024 16:19

@DZakh DZakh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Comment on lines +13 to +25
let hscDecoder: ref<option<HyperSyncClient.Decoder.t>> = ref(None)
let getHscDecoder = () =>
switch hscDecoder.contents {
| Some(decoder) => decoder
| None =>
switch HyperSyncClient.Decoder.fromSignatures(T.config.allEventSignatures) {
| exception exn =>
exn->ErrorHandling.mkLogAndRaise(
~msg="Failed to instantiate a decoder from hypersync client, please double check your ABI or try using 'event_decoder: viem' config option",
)
| decoder => decoder
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let hscDecoder: ref<option<HyperSyncClient.Decoder.t>> = ref(None)
let getHscDecoder = () =>
switch hscDecoder.contents {
| Some(decoder) => decoder
| None =>
switch HyperSyncClient.Decoder.fromSignatures(T.config.allEventSignatures) {
| exception exn =>
exn->ErrorHandling.mkLogAndRaise(
~msg="Failed to instantiate a decoder from hypersync client, please double check your ABI or try using 'event_decoder: viem' config option",
)
| decoder => decoder
}
}
let hscDecoder: HyperSyncClient.Decoder.t = switch HyperSyncClient.Decoder.fromSignatures(T.config.allEventSignatures) {
| exception exn =>
exn->ErrorHandling.mkLogAndRaise(
~msg="Failed to instantiate a decoder from hypersync client, please double check your ABI or try using 'event_decoder: viem' config option",
)
| decoder => decoder
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DZakh I want this to be lazy and not required if viem decoder is chosen. Hence why I use a ref and a closure for a lazy instantiation/retrieval.

@JonoPrest JonoPrest changed the title [DO NOT MERGE] Implement updated bindings for hs client [Ready for merge] Implement updated bindings for hs client Jul 29, 2024
@JonoPrest JonoPrest changed the title [Ready for merge] Implement updated bindings for hs client Implement updated bindings for hs client Jul 30, 2024
@JonoPrest JonoPrest merged commit 33f896e into main Jul 30, 2024
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 this pull request may close these issues.

2 participants