Commit 1896b7c7 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4003 from protocolwhisper/develop

Deleted unused variables from contracts-bedrock and add changeset
parents 66d56a47 9fda7d93
---
'@eth-optimism/contracts-bedrock': minor
---
Deleted Unused Variables fundAccount , impersonatedTx
...@@ -3,8 +3,7 @@ import assert from 'assert' ...@@ -3,8 +3,7 @@ import assert from 'assert'
import { ethers, Contract } from 'ethers' import { ethers, Contract } from 'ethers'
import { Provider } from '@ethersproject/abstract-provider' import { Provider } from '@ethersproject/abstract-provider'
import { Signer } from '@ethersproject/abstract-signer' import { Signer } from '@ethersproject/abstract-signer'
import { sleep, awaitCondition, getChainId } from '@eth-optimism/core-utils' import { sleep, getChainId } from '@eth-optimism/core-utils'
import { HttpNetworkConfig } from 'hardhat/types'
export interface DictatorConfig { export interface DictatorConfig {
globalConfig: { globalConfig: {
...@@ -196,71 +195,6 @@ export const getAdvancedContract = (opts: { ...@@ -196,71 +195,6 @@ export const getAdvancedContract = (opts: {
return contract return contract
} }
export const fundAccount = async (
hre: any,
address: string,
amount: ethers.BigNumber
) => {
if (!hre.deployConfig.isForkedNetwork) {
throw new Error('this method can only be used against a forked network')
}
console.log(`Funding account ${address}...`)
await hre.ethers.provider.send('hardhat_setBalance', [
address,
amount.toHexString(),
])
console.log(`Waiting for balance to reflect...`)
await awaitCondition(
async () => {
const balance = await hre.ethers.provider.getBalance(address)
return balance.gte(amount)
},
5000,
100
)
console.log(`Account successfully funded.`)
}
export const sendImpersonatedTx = async (opts: {
hre: any
contract: ethers.Contract
fn: string
from: string
gas: string
args: any[]
}) => {
if (!opts.hre.deployConfig.isForkedNetwork) {
throw new Error('this method can only be used against a forked network')
}
console.log(`Impersonating account ${opts.from}...`)
await opts.hre.ethers.provider.send('hardhat_impersonateAccount', [opts.from])
console.log(`Funding account ${opts.from}...`)
await fundAccount(opts.hre, opts.from, BIG_BALANCE)
console.log(`Sending impersonated transaction...`)
const tx = await opts.contract.populateTransaction[opts.fn](...opts.args)
const provider = new opts.hre.ethers.providers.JsonRpcProvider(
(opts.hre.network.config as HttpNetworkConfig).url
)
await provider.send('eth_sendTransaction', [
{
...tx,
from: opts.from,
gas: opts.gas,
},
])
console.log(`Stopping impersonation of account ${opts.from}...`)
await opts.hre.ethers.provider.send('hardhat_stopImpersonatingAccount', [
opts.from,
])
}
export const getContractFromArtifact = async ( export const getContractFromArtifact = async (
hre: any, hre: any,
name: string, name: string,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment