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

bug: Error: Cannot convert a BigInt value to a number at toHex.js #553

Closed
1 task done
dushebaa opened this issue May 22, 2023 · 2 comments
Closed
1 task done

bug: Error: Cannot convert a BigInt value to a number at toHex.js #553

dushebaa opened this issue May 22, 2023 · 2 comments

Comments

@dushebaa
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.3.33

Current Behavior

Getting a "Cannot convert a BigInt value to a number" error while connecting to WalletConnect v2 provider at runtime due to invalid es compilation

Package-json browserslist config:
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
]

Expected Behavior

No response

Steps To Reproduce

No response

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

No response

Anything else?

Can be fixed by changing line 174 at toHex.js from
else maxValue = 2n ** (BigInt(size) * 8n) - 1n
to
else maxValue = BigInt(2 ** (size * 8) - 1);

@dushebaa dushebaa changed the title Error: Cannot convert a BigInt value to a number at toHex.js bug: Error: Cannot convert a BigInt value to a number at toHex.js May 22, 2023
@jxom
Copy link
Member

jxom commented May 22, 2023

This seems to happen due to the way the bundler treats bigint values according to the browserslist. While the proposed solution does fix it for that exact case, there could be other cases where we may perform operations on those values (ie. maxValue ** BigInt(2)) which would break.

The recommended solution would be to modify the browserslist to filter out very old browsers like IE and ancient Android browsers: hirosystems/stacks.js#1096 (comment)

@jxom jxom closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2023
Copy link
Contributor

github-actions bot commented Jun 2, 2024

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 Viem 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 Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants