-
Notifications
You must be signed in to change notification settings - Fork 340
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
Cosmjs incompatibility with ES2018 #1144
Comments
Could you provide all error output you can get using the latest CosmJS release? As far as I can tell, we don't use BigInt/bigint directly. It might be a dependency though. |
I have the same issue. The full error is:
And I think it could be (but I'm not sure) a dependency because the only place I could find BigInt is the .pnp.cjs file at root generated by yarn. |
Is there a way to get a stacktrace for the error "ReferenceError: Can't find variable: BigInt"? |
At least for me that's the full console log from application start. I have to mention that it happens on the stargate branch of the library. proto-sign for examples works (with rn-nodeify) just fine. |
I've create a new React Native 0.64.3 project and installed @cosmjs/stargate and @cosmjs/proto-signing (strangely on latest RN version it fails to compile because some dependencies still use compile instead of implements on android). Both cosmjs packages are ^0.28.4 version. By try and catch and printing the exception I managed to get:
And finally:
|
Thanks. I don't see anything helpful in the logs. Don't know where the error is coming from. Any change you get bigint support in React Native? Looking at #1133 we probably have to use bigint numbers in some APIs soon in order to represent uint64. |
I think that we are going to get them eventually so going forward I don't see any problem with starting to use BigInt but as we don't know when we should fix that in this version first. I will investigate the problem further and get back to you |
Maybe you can create a Webpack debug bundle, this contains all dependency code in one file. Thenuse text search for |
I did a build with this project |
Very interesting, thank you. I was not aware of those usages. Seems like we reached the point where bigint support became a requirement for CosmJS when we migrated to @noble/hashes. In |
In which version did that happen? |
I found out that it is being used even in @confio/ics23 as a dependency and @confio/ics23 is a @cosmjs/stargate dependency. I think that part of the code is used as I have the same problem (BigInt variable not defined) in the 0.24.1 version that shouldn't be using @noble/hash directly. |
Right, I migrated to @noble/hashes in @confio/ics23 because this avoids pulling in all kind of very old node hashing libraries that caused issues with WebPack 5. You can probably pin the version of @confio/ics23 somehow. But this is only a very short term solution. |
We could try to build a version of @noble/hashes compatible with ES < 11 using https://www.npmjs.com/package/babel-plugin-transform-bigint and ship them both and so on up until @cosmjs/stargate and @cosmjs/crypto. As in the future we are going to drop ES < 11 compatibility we could:
Anyway for both we have to test @noble/hashes builded with the above babel transformer |
The issue with bigint and ES2018 is that TypeScript does not transpile the usage of native bigint to an alternative implementation as it does with other language features. So you either have to provide a polyfill or not use them. We did the later until recently when it slipped in via the new hashing implemention @noble/hashes. Honestly, bigint is around for 4 years now and I don't think we can go back from here without making significant sacrifices wrt. productivity and code quality. |
@giorgionocera Hello, how to introduce all this package? |
@giorgionocera Hey man, could you provide a demo that rn uses part of the packages included on cosmjs and it works well. THX! I cannot run rn with cosmjs. |
Hello, we created a fork of To use it, you have to install and run To recap:
Every time you install a package you have to delete
|
@giorgionocera I'll try, thanks for the reply |
Starting with CosmJS 0.29, we'll use BigInt in places where values exceed the safe integer range of |
I encountered this issue as well, but not from React native. Sentry provided me with an issue from a user on iOS 12. The user accessed my site from Mobile Safari version 12.1. We can see here that Mobile Safari doesn't support To make debugging easier, we can see that Chrome started support on version 67. So I went here and downloaded an older version of Chromium (version 65). This allowed me to reproduce the issue and get improved logs.
We can see that The range of users potentially effected by this is far greater than just React native. |
I see, that's unfortunate. But given the resource constraints and the requirement to move forward my the ecosystem, I don't see how we can maintain this library without BigInt mid term. We need integers that exceed the 53 bit range all over the place. The usage of Long causes problems for other users. The migration to @noble/hashes was a great improvement for getting rid of legazy modules. I think the way to go would be a JavaScript transpiler that replaces the usages of native BigInt with a library that implements it for older systems. |
Hi there, It is obviously an open source template! You all can use it, and, most importantly, can contribute in improving it! |
From CosmJS 0.30.0 onwards we target es2020 and make use of BigInt in more and more places. Happy to hear that there are solutins emerging for the React Native ecosystem. |
Hi everyone, I'm trying to create a new rn project including cosmjs. After the inclusion, if I try to use part of the packages included on cosmjs all works like a charm. However, if I try to import the tendermint-rpc package or the stargate one, the inclusion fails.
Giving a few debugging, I saw that the issue is linked to BigInt, which is on this repo, included as a native call (since it is available from ES10).
Maybe I'm missing something. Is there anyone who could help in including and using cosmjs (fully) inside a React Native project?
Useful information
React native version: 0.68.2
Tested with both cosmjs version: 0.24.0-alpha.25 and latest
Thank you.
The text was updated successfully, but these errors were encountered: