Skip to content

Commit

Permalink
fix: initialize hardhat provider (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio authored Jun 22, 2023
1 parent 573c611 commit bc688fb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/hardhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export const getHardhatBaseProvider = async (runtime: HardhatRuntimeEnvironment)
// Search by looking for the internal "_wrapped" variable. Base provider doesn't have this
// property (at least for now!).
let provider: any = runtime.network.provider;

if ('init' in provider) {
// Newer versions of Hardhat initialize the provider lazily, so we need to
// call provider.init() explicitly. This is a no-op if the provider is
// already initialized.
await provider.init();
}

while (provider._wrapped !== undefined) {
provider = provider._wrapped;

Expand Down

0 comments on commit bc688fb

Please sign in to comment.