2020-11-18 18:18:02 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2021-01-15 15:48:54 +00:00
|
|
|
import { DRE, setDRE } from '../../helpers/misc-utils';
|
|
|
|
import { EthereumNetworkNames } from '../../helpers/types';
|
|
|
|
import { usingTenderly } from '../../helpers/tenderly-utils';
|
|
|
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
2020-05-29 14:55:31 +00:00
|
|
|
|
2020-11-05 12:44:20 +00:00
|
|
|
task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
|
|
|
|
async (_, _DRE) => {
|
2021-01-15 15:48:54 +00:00
|
|
|
if (DRE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
(_DRE as HardhatRuntimeEnvironment).network.name.includes('tenderly') ||
|
|
|
|
process.env.TENDERLY === 'true'
|
|
|
|
) {
|
|
|
|
console.log('- Setting up Tenderly provider');
|
|
|
|
await _DRE.tenderlyRPC.initializeFork();
|
|
|
|
console.log('- Initialized Tenderly fork');
|
|
|
|
const provider = new _DRE.ethers.providers.Web3Provider(_DRE.tenderlyRPC as any);
|
|
|
|
_DRE.ethers.provider = provider;
|
|
|
|
}
|
|
|
|
|
2020-11-05 12:44:20 +00:00
|
|
|
setDRE(_DRE);
|
|
|
|
return _DRE;
|
2020-07-13 08:54:08 +00:00
|
|
|
}
|
|
|
|
);
|