Way to reproduce the error:
const ethers = require('ethers'); // v5
const provider = new ethers.providers.JsonRpcProvider('http://localhost:7545');
provider._networkPromise.then(console.log).catch(console.log);
const contractDeployerWallet = new ethers.Wallet(
'privatekey',
provider
);
let contract = new ethers.Contract(
'0xc4cfb05119Ea1F59fb5a8F949288801491D00110',
require('./static/contracts/PlasmaManager_PlasmaManager.json').abi,
contractDeployerWallet
);
// turn on the ganache and get the contract deployed (with a known wallet
// so you can input the contract address above) using separate script
setTimeout(() => {
contract.functions
.submitBunchHeader()
.then(console.log);
}, 8000);
A CI test was failing because the ganache process and a node js process when simultaneously to start up, sometimes ganache takes bit more time to get started.
Error stack:
(node:17760) UnhandledPromiseRejectionWarning: TypeError: Cannot redefine property: _network
at Function.defineProperty (<anonymous>)
at Object.defineReadOnly (/Users/sohamzemse/soham/kmpards/ESNCoreProjects/kami/node_modules/@ethersproject/properties/lib/index.js:43:12)
at JsonRpcProvider.<anonymous> (/Users/sohamzemse/soham/kmpards/ESNCoreProjects/kami/node_modules/@ethersproject/providers/lib/base-provider.js:287:38)
at step (/Users/sohamzemse/soham/kmpards/ESNCoreProjects/kami/node_modules/@ethersproject/providers/lib/base-provider.js:46:23)
at Object.next (/Users/sohamzemse/soham/kmpards/ESNCoreProjects/kami/node_modules/@ethersproject/providers/lib/base-provider.js:27:53)
at fulfilled (/Users/sohamzemse/soham/kmpards/ESNCoreProjects/kami/node_modules/@ethersproject/providers/lib/base-provider.js:18:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:17760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17760) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
However if a call function is called before the transaction function, then it doesn't error.
setTimeout(async () => {
await contract.functions.name();
contract.functions
.submitBunchHeader()
.then(console.log);
}, 8000);
Sorry if this title is does not best describe the issue. I think I had written a better one in my previous attempt to write this issue and my MB went out of battery just before submitting :"(
Just seeing the error made me realize a case I don't check for. I'll get a fix for this up soon.
This should be fixed now in 5.0.0-beta.189. Please try it out and let me know if you still have any problems. :)
Thank you! It's working as expected now