wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.19k stars 292 forks source link

Init companion networks for all tasks #500

Closed tim-becker closed 9 months ago

tim-becker commented 10 months ago

Currently the companionNetworks are only initialized during the deploy task, making them unusable in other tasks (such as test, run, console, etc.)

This PR moves the companion network initialization to the extendEnvironment call, so it applies to all tasks. This required making the initCompanionNetworks function synchronous, which is doable by using hardhat's LazyInitializationProviderAdapter to construct the companion network providers.

Unfortunately this new dependency in ethers throws errors with the current tsconfig.json of this project, so this also modifies the tsconfig.json to silence those errors. Otherwise, running tsc fails with

node_modules/hardhat/internal/core/providers/lazy-initialization.d.ts:26:51 - error TS2304: Cannot find name 'EventListener'.

26     addListener(event: string | symbol, listener: EventListener): this;
                                                     ~~~~~~~~~~~~~

node_modules/hardhat/internal/core/providers/lazy-initialization.d.ts:27:42 - error TS2304: Cannot find name 'EventListener'.

27     on(event: string | symbol, listener: EventListener): this;
                                            ~~~~~~~~~~~~~

Found 2 errors in the same file, starting at: node_modules/hardhat/internal/core/providers/lazy-initialization.d.ts:26
tim-becker commented 9 months ago

For context, we need this because many of our scripts (which run via hardhat run) need to access contracts from multiple networks at once

tim-becker commented 9 months ago

Hi @wighawag, is there any chance of getting this merged?

wighawag commented 9 months ago

Included in v0.11.45 Thanks!