From 64d37bcc70474c4d258316e2f928b24522d29f0e Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Tue, 18 May 2021 09:59:05 +0200 Subject: [PATCH] fix: Fix @tenderly/hardhat-tenderly to 1.1.0-beta.5 --- package.json | 2 +- tasks/misc/set-bre.ts | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 51a2818b..b9debafc 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "@nomiclabs/hardhat-ethers": "^2.0.0", "@nomiclabs/hardhat-waffle": "^2.0.0", "@openzeppelin/contracts": "3.1.0", - "@tenderly/hardhat-tenderly": "^1.1.0-beta.4", + "@tenderly/hardhat-tenderly": "1.1.0-beta.5", "@typechain/ethers-v4": "1.0.0", "@typechain/ethers-v5": "^2.0.0", "@typechain/truffle-v4": "2.0.2", diff --git a/tasks/misc/set-bre.ts b/tasks/misc/set-bre.ts index bdd853c3..fd5a60d6 100644 --- a/tasks/misc/set-bre.ts +++ b/tasks/misc/set-bre.ts @@ -1,11 +1,6 @@ import { task } from 'hardhat/config'; import { DRE, setDRE } from '../../helpers/misc-utils'; -import { EthereumNetworkNames } from '../../helpers/types'; -import { usingTenderly } from '../../helpers/tenderly-utils'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { formatEther } from 'ethers/lib/utils'; -import { fork } from 'child_process'; -import { env } from 'process'; task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction( async (_, _DRE) => { @@ -17,19 +12,21 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set process.env.TENDERLY === 'true' ) { console.log('- Setting up Tenderly provider'); + const net = _DRE.tenderly.network(); + if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) { console.log('- Connecting to a Tenderly Fork'); - (_DRE as any).tenderlyRPC.setFork(process.env.TENDERLY_FORK_ID); - (_DRE as any).tenderlyRPC.setHead(process.env.TENDERLY_HEAD_ID); + await net.setFork(process.env.TENDERLY_FORK_ID); + await net.setHead(process.env.TENDERLY_HEAD_ID); } else { console.log('- Creating a new Tenderly Fork'); - await (_DRE as any).tenderlyRPC.initializeFork(); + await net.initializeFork(); } - const provider = new _DRE.ethers.providers.Web3Provider((_DRE as any).tenderlyRPC); + const provider = new _DRE.ethers.providers.Web3Provider(net); _DRE.ethers.provider = provider; console.log('- Initialized Tenderly fork:'); - console.log(' - Fork: ', (_DRE as any).tenderlyRPC.getFork()); - console.log(' - Head: ', (_DRE as any).tenderlyRPC.getHead()); + console.log(' - Fork: ', net.getFork()); + console.log(' - Head: ', net.getHead()); } console.log('- Enviroment'); @@ -44,6 +41,7 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set } } console.log(' - Network :', _DRE.network.name); + setDRE(_DRE); return _DRE; }