Skip to content

Commit 064b257

Browse files
committed
Init companion networks for non-deploy tasks
1 parent f58e1e8 commit 064b257

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/index.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
NetworkConfig,
1313
} from 'hardhat/types';
1414
import {createProvider} from 'hardhat/internal/core/providers/construction'; // TODO harhdat argument types not from internal
15+
import {LazyInitializationProviderAdapter} from "hardhat/internal/core/providers/lazy-initialization";
1516
import {Deployment, ExtendedArtifact} from '../types';
1617
import {extendEnvironment, task, subtask, extendConfig} from 'hardhat/config';
1718
import {HARDHAT_NETWORK_NAME, HardhatPluginError} from 'hardhat/plugins';
@@ -298,6 +299,7 @@ extendEnvironment((env) => {
298299
);
299300
}
300301
}
302+
initCompanionNetworks(env);
301303
log('ready');
302304
});
303305

@@ -349,7 +351,7 @@ function setupExtraSolcSettings(settings: {
349351
// addIfNotPresent(settings.outputSelection["*"][""], "ast");
350352
}
351353

352-
async function initCompanionNetworks(hre: HardhatRuntimeEnvironment) {
354+
function initCompanionNetworks(hre: HardhatRuntimeEnvironment) {
353355
hre.companionNetworks = {};
354356
for (const name of Object.keys(hre.network.companionNetworks)) {
355357
const networkName = hre.network.companionNetworks[name];
@@ -378,11 +380,13 @@ async function initCompanionNetworks(hre: HardhatRuntimeEnvironment) {
378380
throw new Error(`no network named ${networkName}`);
379381
}
380382

381-
network.provider = await createProvider(
382-
hre.config,
383-
networkName,
384-
hre.artifacts
385-
);
383+
network.provider = new LazyInitializationProviderAdapter(() => {
384+
return createProvider(
385+
hre.config,
386+
networkName,
387+
hre.artifacts
388+
);
389+
})
386390

387391
const networkDeploymentsManager = new DeploymentsManager(hre, network);
388392
deploymentsManager.addCompanionManager(name, networkDeploymentsManager);
@@ -443,7 +447,6 @@ subtask(TASK_DEPLOY_RUN_DEPLOY, 'deploy run only')
443447
if (typeof tags === 'string') {
444448
tags = tags.split(',');
445449
}
446-
await initCompanionNetworks(hre);
447450
await deploymentsManager.runDeploy(tags, {
448451
log: args.log,
449452
resetMemory: false,

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"strict": true,
1111
"rootDirs": ["./src", "./test"],
1212
"esModuleInterop": true,
13-
"resolveJsonModule": true
13+
"resolveJsonModule": true,
14+
"skipLibCheck": true
1415
},
1516
"exclude": ["dist", "node_modules"],
1617
"include": ["./test", "./src", "types.ts"]

0 commit comments

Comments
 (0)