Commit ef2fba12 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix[hardhat-ovm]: use correct url when creating ethers object (#938)

* fix[hardhat-ovm]: use correct url when creating ethers object

* chore: add changeset

* chore: rename changeset
Co-authored-by: default avatarGeorgios Konstantopoulos <me@gakonst.com>
parent 68871b7a
---
'@eth-optimism/hardhat-ovm': patch
---
Instantiate the harhat ethers provider using the Hardhat network config if no provider URL is set, and set the provider at the end, so that the overridden `getSigner` method is used.
...@@ -248,14 +248,13 @@ extendEnvironment(async (hre) => { ...@@ -248,14 +248,13 @@ extendEnvironment(async (hre) => {
// override the provider polling interval // override the provider polling interval
const provider = new ethers.providers.JsonRpcProvider( const provider = new ethers.providers.JsonRpcProvider(
(hre as any).ethers.provider.url (hre as any).ethers.provider.url || (hre as any).network.config.url
) )
provider.pollingInterval = interval provider.pollingInterval = interval
// the gas price is overriden to the user provided gasPrice or to 0. // the gas price is overriden to the user provided gasPrice or to 0.
provider.getGasPrice = async () => provider.getGasPrice = async () =>
ethers.BigNumber.from(hre.network.config.gasPrice || 0) ethers.BigNumber.from(hre.network.config.gasPrice || 0)
;(hre as any).ethers.provider = provider
// if the node is up, override the getSigners method's signers // if the node is up, override the getSigners method's signers
try { try {
...@@ -281,6 +280,9 @@ extendEnvironment(async (hre) => { ...@@ -281,6 +280,9 @@ extendEnvironment(async (hre) => {
;(hre as any).ethers.getSigners = () => signers ;(hre as any).ethers.getSigners = () => signers
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
} catch (e) {} } catch (e) {}
// Update the provider at the very end to avoid any weird issues.
;(hre as any).ethers.provider = provider
} }
} }
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment