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

Error when try to useBalance with a blockNumber: "TypeError: Do not know how to serialize a BigInt" #4332

Closed
1 task done
mystist opened this issue Oct 10, 2024 · 2 comments
Labels
Needs Reproduction Misc: Needs Reproduction

Comments

@mystist
Copy link

mystist commented Oct 10, 2024

Check existing issues

Describe the bug

  const { data: blockNumber } = useBlockNumber({ watch: true })
  const { data: balanceData, isLoading } = useBalance({ address, blockNumber })

Code like this above will throw error: TypeError: Do not know how to serialize a BigInt

I've checked the reason and a workaround for now might be:

  const { data: blockNumber } = useBlockNumber({ watch: true })

  // wagmi will use the block number as query key of react-query, however, the bigint as key is not supported for now
  // https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L206
  const { data: balanceData, isLoading } = useBalance({ address, blockNumber: blockNumber?.toString() as any })

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

2.12.17

Viem Version

2.x

TypeScript Version

No response

Anything else?

No response

@tmm tmm added the Needs Reproduction Misc: Needs Reproduction label Oct 14, 2024
Copy link
Contributor

Hello @mystist.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants