-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Warnings on require #556
Comments
What version of node are you using? How are you importing the ethers library? That indicates that the environment is missing a strong random number generator, such as It seems like your CLI may be importing the browser version. |
Also note, that in v5, any calls (mainly This means that on those environments, if a random source is unnecessary, there will be no issue and no warning. |
That explains it. Yes, for node, |
For the record, I ended up force-silencing the warnings with a It's a hack, but it works for us :) |
Eek. That feels... Not clean. :p I think you should be able to use But if you really want this, a slightly less worse option may be to use |
Don't I need to do
That doesn't seem to silence the warnings: #!/usr/bin/env node
global.randomBytes = require("crypto").randomBytes
const ethers = require("./ethers.min.js");
const sig = process.argv[2];
if (!sig) {
console.error("Usage: seth-abi <solidity-fragment>")
process.exit(1);
}
try {
console.log(JSON.stringify([ethers.utils.parseSignature(sig)]));
} catch (e) {
console.error(`seth-abi: error: ${e.message}`);
process.exit(1);
} still produces: ❯ result/bin/seth abi "foo()"
WARNING: Missing strong random number source; using weak randomBytes
Warning: XMLHttpRequest is not defined
[{"constant":false,"gas":null,"inputs":[],"name":"foo","outputs":[],"payable":false,"stateMutability":null,"type":"function"}] |
@ricmoo I am building an app on expo with ethers and am getting this warning. According to expo, expo-random is preinstalled and should do the job. How do I get ethers to use expo-random? |
Hmmm. Is it possible to set |
Would it be possible to use https://www.npmjs.com/package/randombytes or extend the Including ethers.js in a Webpack build and trying to shiv the packages |
That should already work, as I have a similar method as a browser shim. When using webpack, make sure you enable the browser mainField in your config, something like If you use v5, the module field should be enough, so you won’t need to adjust your webpack config if you are only using the umbrella package. :) Let me know if this helps. |
Updating |
in rollup.config.js
|
I'm using ethers.js in a node CLI tool, and I can't seem to disable warnings that are produced on load:
The code is here.
The options mentioned here don't work, because I think the warnings are produced on
require
, so beforeethers.errors.setLogLevel("off")
could take effect.Is there a way to completely disable these warnings?
The text was updated successfully, but these errors were encountered: