11import { task } from 'hardhat/config' ;
22import { DRE , setDRE } from '../../helpers/misc-utils' ;
3- import { EthereumNetworkNames } from '../../helpers/types' ;
4- import { usingTenderly } from '../../helpers/tenderly-utils' ;
53import { HardhatRuntimeEnvironment } from 'hardhat/types' ;
6- import { formatEther } from 'ethers/lib/utils' ;
7- import { fork } from 'child_process' ;
8- import { env } from 'process' ;
94
105task ( `set-DRE` , `Inits the DRE, to have access to all the plugins' objects` ) . setAction (
116 async ( _ , _DRE ) => {
@@ -17,19 +12,21 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
1712 process . env . TENDERLY === 'true'
1813 ) {
1914 console . log ( '- Setting up Tenderly provider' ) ;
15+ const net = _DRE . tenderly . network ( ) ;
16+
2017 if ( process . env . TENDERLY_FORK_ID && process . env . TENDERLY_HEAD_ID ) {
2118 console . log ( '- Connecting to a Tenderly Fork' ) ;
22- ( _DRE as any ) . tenderlyRPC . setFork ( process . env . TENDERLY_FORK_ID ) ;
23- ( _DRE as any ) . tenderlyRPC . setHead ( process . env . TENDERLY_HEAD_ID ) ;
19+ await net . setFork ( process . env . TENDERLY_FORK_ID ) ;
20+ await net . setHead ( process . env . TENDERLY_HEAD_ID ) ;
2421 } else {
2522 console . log ( '- Creating a new Tenderly Fork' ) ;
26- await ( _DRE as any ) . tenderlyRPC . initializeFork ( ) ;
23+ await net . initializeFork ( ) ;
2724 }
28- const provider = new _DRE . ethers . providers . Web3Provider ( ( _DRE as any ) . tenderlyRPC ) ;
25+ const provider = new _DRE . ethers . providers . Web3Provider ( net ) ;
2926 _DRE . ethers . provider = provider ;
3027 console . log ( '- Initialized Tenderly fork:' ) ;
31- console . log ( ' - Fork: ' , ( _DRE as any ) . tenderlyRPC . getFork ( ) ) ;
32- console . log ( ' - Head: ' , ( _DRE as any ) . tenderlyRPC . getHead ( ) ) ;
28+ console . log ( ' - Fork: ' , net . getFork ( ) ) ;
29+ console . log ( ' - Head: ' , net . getHead ( ) ) ;
3330 }
3431
3532 console . log ( '- Enviroment' ) ;
@@ -44,6 +41,7 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
4441 }
4542 }
4643 console . log ( ' - Network :' , _DRE . network . name ) ;
44+
4745 setDRE ( _DRE ) ;
4846 return _DRE ;
4947 }
0 commit comments