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

Cannot convert a BigInt value to a number #298

Open
irzhywau opened this issue Feb 17, 2023 · 9 comments
Open

Cannot convert a BigInt value to a number #298

irzhywau opened this issue Feb 17, 2023 · 9 comments
Labels

Comments

@irzhywau
Copy link

When I loaded the library I just got this error in a react app

import { recoverTypedSignature } from '@metamask/eth-sig-util';

I got this error when loading the page, the method is not even executed yet. any idea?

React version 18.2.0

@coderguy1998
Copy link

I have got the same error and I guess this is being produced by the @noble package being used internally, I'm using it in an Angular project and the by keeping the buildOptimiser as true it breaks (basically the prod server) but locally everything works fine.

@mcmire
Copy link

mcmire commented Feb 21, 2023

Hi @irzhywau, when you say you received this error in a React app, did you use create-react-app to create your app? Just so we can reliably reproduce this error.

@malaDev
Copy link

malaDev commented Feb 21, 2023

yes indeed I used create-react-app

@mcmire
Copy link

mcmire commented Feb 21, 2023

@malaDev Hmm, I'm not able to reproduce this in a fresh React app (create-react-app 5.0.1, React 18.2.0). I did get an error about Buffer not being available, but that's expected — you'll need the buffer package to get around this. But I didn't get the error you mentioned. Any chance you can push up a repo that reproduces this error?

@malaDev
Copy link

malaDev commented Feb 21, 2023

oh really

unfortunately it's a private repo. that's weird. do you have any idea which part can cause such an exception? any other lib?

@mcmire
Copy link

mcmire commented Feb 22, 2023

@malaDev It's possible that it's some other library. Do you have any other dependencies that you're using in your repo besides this library?

@malaDev
Copy link

malaDev commented Feb 22, 2023

I actually only get this error when I add the library, without it everything work smoothly

@mcmire
Copy link

mcmire commented Feb 22, 2023

@malaDev Right, but there may be an interaction between this library and another library you're using. If I know all of the libraries you're using then I am better able to reproduce this issue. Or, if there's a stack trace you can post, that may give me more information.

@keithchew
Copy link

keithchew commented Oct 27, 2023

Hi

I was also having this issue, and I tracked it down to v5.0.0 moving to @noble package (which uses BigInt).

https://github.com/MetaMask/eth-sig-util/releases

Changed
BREAKING: Removed support for Node v12 in favor of v14 (https://github.com/MetaMask/eth-json-rpc-middleware/pull/137)
Replace heavy crypto packages for lighter noble implementations via upgrading ethereumjs-util to latest (now called @ethereumjs/util) (https://github.com/MetaMask/eth-sig-util/pull/260)
Migrate to Yarn 3 (https://github.com/MetaMask/eth-sig-util/pull/264)

I pinned my version to the last version before this change:

"@metamask/eth-sig-util": "^4.0.1",

and all is good, my dapp supports safari < 14 again.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants