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

useReadContract fails on browsers other than Chrome #548

Open
DaveVodrazka opened this issue Jan 8, 2025 · 0 comments · May be fixed by #549
Open

useReadContract fails on browsers other than Chrome #548

DaveVodrazka opened this issue Jan 8, 2025 · 0 comments · May be fixed by #549
Labels

Comments

@DaveVodrazka
Copy link

The problem stems from this:

function queryKey({
chain,
contract,
functionName,
args,
blockIdentifier,
}: { chain?: Chain; contract?: Contract } & CallArgs) {
return [
{
entity: "readContract",
chainId: chain?.name,
contract: contract?.address,
functionName,
args,
blockIdentifier,
},
] as const;
}

If args contains bigint the react-query will fail when it does JSON.stringify on queryKey (Chrome turns bigint into string and will successfully stringify it).
If ABI uses types such as core::integer::u128, you are forced to use bigint in args as string will throw error on build.

There needs to be some transformation that will replace bigints in the args with base10 string.

If anyone is facing this problem, I have bypassed it with this:

args: [
  bigIntValue.toString(10) as unknown as bigint,
],
@DaveVodrazka DaveVodrazka linked a pull request Jan 8, 2025 that will close this issue
@fracek fracek added the bug label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants