-
Notifications
You must be signed in to change notification settings - Fork 103
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
Failed to minify the code (during npm run build -- in a Electron/React app) #54
Comments
Hi bityogi, I'm not clear on what code from monero_wallet_utils could be considered inappropriate for a non-browser environment... it's working fine for me on both renderer and main processes. However, note that this file has been completely removed on the new branch called |
Hello @paulshapiro , I just tried the
The link above gives more information from the react-team as to what they are expecting for packages to be built properly. |
bityogi, How about using webpack to compile the code to ES5? Here's an example webpack config file where we compile everything to a single module for embedding in another webview. https://github.com/mymonero/mymonero-app-ios/tree/master/Modules/MyMoneroCore Have a look at these You could set this repo up as a submodule of your own. |
Hello @paulshapiro, We bootstrapped our app with create-react-app and that internally handles all the work of webpack. I can take control over webpack (by what is called However, I was able to upgrade to a I was able to successfully build the app with "mymonero-core-js" dependency from the "git+https://github.com/mymonero/mymonero-core-js.git#cpp" branch. But with this code, I get the following error as soon as the application loads:
|
I guess you're using Math.random somewhere. Given that it's not just me who is affected by this, I've gone back to emscripten about it to try to get a resolution. emscripten-core/emscripten#542 |
Thanks for your patience. By the way if you see a good way to improve the MyMonero core JS code so it doesn't complain under React, please let me know. |
For the moment, if you want to, you can get rid of that exception by removing the override of Math.random from cryptonote_utils/cryptonote_utils.js. The reason it's in there is to prevent emscripten from using Math.random as a source of entropy in case it's being run in an environment that doesn't have |
If it comes down to maintaining a fork of emscripten, the alternative is to replace |
Note, that if I reference the Not sure, if I get past this somehow that the error above from emscripten will not be there. Regardless, I am able to package both the What baffles me is that when I used the older version of We were at-least able to use the library and actually create XMR wallets. |
Where exactly is this code in |
Sorry, I was on the wrong branch ( I've gone ahead and changed the code, and it works!!! FYI, here is the repository that I'm using this for now: https://github.com/bityogi/mymonero-core-js Could we leave this issue open till it's either correct in this repo or upstream in |
OK, yes I'm still working on this issue. But I just want to make it clear that you should be extremely careful to verify what environment the random_device function is getting called in for your app – if it's using Math.random, that could mean your users' funds could get stolen. |
Thanks for the heads up. I'll definitely bring it up to the rest of the team and ensure we're using the right environment for the |
The clearest solution for the moment imo is just to edit MyMoneroCoreCpp.js and replace "Math.random()" with that scoped function I mentioned above. That would let you know right away if anything is accessing it in the wrong env. Talk soon! |
Hello @paulshapiro , Regarding Perhaps, this library does not need to be throwing an error if we are providing our own seed. The same applies to what I mentioned in #55 ; which I will mention to you on that thread. |
@bityogi, no, nothing is ever actually calling Math.random, I am simply PRing to emscripten the removal of the potential to ever call that method. All functions to create addresses or random seeds etc will necessarily flow through emscripten's random_device handler for /dev/random, and will be passed safely into random number generation which we have vetted. If you are generated your seeds in another manner, I recommend that you disclose the method of seed generation to your users. Thank you for your patience as I get a moment to amend the Math.random issue. |
By the way, I pushed the Math.random thing recently, so closing this for now until further activity |
We have an Electron app that is boot-strapped using create-react-app.
After referencing this module, the app will not compile anymore:
From react's documentation:
Is this something that you guys could help us out with?
The text was updated successfully, but these errors were encountered: