You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to be able to create a JsonRpcProvider and it not query eth_chainId all the time, but i noticed the method
getNetwork() of the provider always checks for the chain id has potentially changed in the rpc response from the one provided it the constructor.
Could it be possible to add a skip on that condition without me having to do the following.
rpcProvider.getNetwork = async function(this: ethers.providers.JsonRpcProvider): Promise<any> {
const network = await this._ready();
// Make sure we are still connected to the same network; this is
// only an external call for backends which can have the underlying
// network change spontaneously
// we don't want to do this. lol
//const currentNetwork = await this.detectNetwork();
// if (network.chainId !== currentNetwork.chainId) {
// // We are allowing network changes, things can get complex fast;
// // make sure you know what you are doing if you use "any"
// if (this.anyNetwork) {
// this._network = currentNetwork;
// // Reset all internal block number guards and caches
// this._lastBlockNumber = -2;
// this._fastBlockNumber = null;
// this._fastBlockNumberPromise = null;
// this._fastQueryDate = 0;
// this._emitted.block = -2;
// this._maxInternalBlockNumber = -1024;
// this._internalBlockNumber = null;
// // The "network" event MUST happen before this method resolves
// // so any events have a chance to unregister, so we stall an
// // additional event loop before returning from /this/ call
// this.emit("network", currentNetwork, network);
// await stall(0);
// return this._network;
// }
// const error = logger.makeError("underlying network changed", Logger.errors.NETWORK_ERROR, {
// event: "changed",
// network: network,
// detectedNetwork: currentNetwork
// });
// this.emit("error", error);
// throw error;
// }
return network;
};
}
Code Snippet
any call example this one.
provider.getGasPrice()
Contract ABI
N/A
Errors
N/A
Environment
node.js (older than v12)
Environment (Other)
all environments behave the same.
The text was updated successfully, but these errors were encountered:
Ethers Version
5.7.0
Search Terms
getNetwork() skip chain id
Describe the Problem
I want to be able to create a JsonRpcProvider and it not query eth_chainId all the time, but i noticed the method
getNetwork() of the provider always checks for the chain id has potentially changed in the rpc response from the one provided it the constructor.
Could it be possible to add a skip on that condition without me having to do the following.
Code Snippet
any call example this one. provider.getGasPrice()
Contract ABI
Errors
Environment
node.js (older than v12)
Environment (Other)
all environments behave the same.
The text was updated successfully, but these errors were encountered: