-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
TypeError: Cannot convert a BigInt value to a number in react native #31
Comments
There is no "shim" for native bigints. You need to use environments which support bigints natively. We don't provide support for transpiled code |
I'm encountering the same problem. Unfortunately This is literally the only package in our deps causing this issue. The exact issue is this:
As a consequence we're going to have to fork the code and make adjustments... Which is not a big deal for us, but it will fragment the usage of this package. Edit: I would like to point out that you have already done some work for supporting certain execution environments, i.e.
This change would be along the same lines! |
So, what do you want? Change constants to some shitty computed value? How would you audit them after that? One of the primary reasons for creating the lib was auditability. This is a bug of bad parsers. Report it to appropriate repos. I've did everything I could to ease the burden. Don't want to do what's unnecessary. |
I had to do worse actually: What I'm suggesting here is maybe keep this second file on the side and add a I would rather work with you on this than against; if this package can just provide a react-native variant, that's more than enough, even if it's shitty. |
For those who will inevitably find themselves here: https://github.com/paulmillr/noble-secp256k1/pull/60/files |
Thanks for the pull request @lf94. Folks who run into the same problem could totally fork secp and use the solution. As i've mentioned, it uses Those who want to use this with React Native should report the issue to facebook/metro#359. As soon as they'll get enough exposure, they should do something. Maybe submit pull requests to Metro, and call FB developers via Twitter etc. I'm just a one guy trying to maintain this library. FB has more than enough resources to adjust their stuff to modern syntax. |
Yeah I totally understand. Thank you regardless for this excellent work you've done! Unfortunately that issue is 3 years old (we found that issue early on in our attempts to fix this) and I don't expect anything to happen any time soon... Hence why I've come to you. 🙂 (Edit: I've commented on the issue so at least my vote is cast...) To anyone else: you can use |
I believe it is not a good idea to fork this library. It's better to fix the source of the problem (not this lib). Open this file: node_modules/metro-react-native-babel-preset/src/configs/main.js And comment these lines so that the buggy transformer is not used: + //if (!isHermes && (isNull || src.indexOf("**") !== -1)) {
+ // extraPlugins.push([
+ // require("@babel/plugin-transform-exponentiation-operator"),
+ // ]);
+ //} And then run this command to make the patch permanent. Anyway @lf94 , this will not work on Android anyway, right? react-native on Android does not support BigInt (so far). |
It will work on Android through various means but in the end it all really sucks. Unfortunately avoiding BigInt is hard when it comes to cryptography. I believe it isn't a good idea either to fork the library but the choices are few and far between... |
Report this to FB. They need to move -- not us. |
@LeeAlephium I'd be very wary about using noble-secp256k1 with a BigInt polyfill for react-native & Android. Note that polyfills will give wrong results for this kind of thing: Maybe you were thinking in another way to go around |
I share the sentiment and warning to others. 👍 You must be very careful. I reiterate the whole situation sucks (and not because of noble-secp256k1 but because of FB)... |
Help is finally on the way. The combination of React Native 0.70 and Hermes will bring support for |
@steveluscher Even with RN 7.0.0 and hermes, this does not yet work by default. See my comment here on how to activate it: |
Yep! I know. I already have a PR going on against facebook/react-native#34589 I also updated the Solana Cookbook to this effect: solana-developers/solana-cookbook#435 |
75c244b makes sure bigint |
Any solution for this issue has been found yet ? |
@GabiDev45 upgrade to latest react native |
I already have it upgraded, tried everything discussed here, nothing seems to work. |
ITS 2023... IS IT JUST ME HAVING THIS ISSUE ? |
@horatiubran yes. 1. update react-native. 2. use noble-curves instead of noble-secp v2 |
May not be related, but some transpilers like babel will convert things like |
if i use this npm in react-native, the error will be like TypeError: Cannot convert a BigInt value to a number occurs. even I have tried shim.js added and imported big-int npm but still not working. please clarify this
// my code
The text was updated successfully, but these errors were encountered: