diff --git a/tasks/createEIP1193.ts b/tasks/createEIP1193.ts deleted file mode 100644 index b82030a..0000000 --- a/tasks/createEIP1193.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Signer } from 'ethers' -import { EIP1193Provider } from 'zodiac-core' - -export default function ( - provider: EIP1193Provider, - signer: Signer -): EIP1193Provider { - return { - request: async ({ method, params }) => { - if (method == 'eth_sendTransaction') { - const { hash } = await signer.sendTransaction((params as any[])[0]) - return hash - } - - return provider.request({ method, params }) - }, - } -} diff --git a/tasks/mastercopy-deploy.ts b/tasks/mastercopy-deploy.ts index fc8cec2..27b3abe 100644 --- a/tasks/mastercopy-deploy.ts +++ b/tasks/mastercopy-deploy.ts @@ -1,7 +1,9 @@ import path from 'path' import { cwd } from 'process' import { readFileSync } from 'fs' +import { Signer } from 'ethers' import { task } from 'hardhat/config' +import { EthereumProvider } from 'hardhat/types' import { deployMastercopy, @@ -9,8 +11,6 @@ import { MastercopyArtifact, } from 'zodiac-core' -import createEIP1193 from './createEIP1193' - task( 'mastercopy:deploy', 'For every version entry on the artifacts file, deploys a mastercopy into the current network' @@ -44,3 +44,19 @@ async function deploy( console.log(`version ${version}: Deployed Mastercopy at at ${address}`) } } + +function createEIP1193( + provider: EthereumProvider, + signer: Signer +): EIP1193Provider { + return { + request: async ({ method, params }) => { + if (method == 'eth_sendTransaction') { + const { hash } = await signer.sendTransaction((params as any[])[0]) + return hash + } + + return provider.request({ method, params }) + }, + } +} diff --git a/tasks/mastercopy-verify.ts b/tasks/mastercopy-verify.ts index 4c85cec..521b119 100644 --- a/tasks/mastercopy-verify.ts +++ b/tasks/mastercopy-verify.ts @@ -3,13 +3,7 @@ import { cwd } from 'process' import { readFileSync } from 'fs' import { task } from 'hardhat/config' -import { - verifyMastercopy, - MastercopyArtifact, - EIP1193Provider, -} from 'zodiac-core' - -import createEIP1193 from './createEIP1193' +import { verifyMastercopy, MastercopyArtifact } from 'zodiac-core' const { ETHERSCAN_API_KEY } = process.env @@ -17,34 +11,28 @@ task( 'mastercopy:verify', 'Verifies all mastercopies from the artifacts file, in the block explorer corresponding to the current network' ).setAction(async (_, hre) => { + if (!ETHERSCAN_API_KEY) { + throw new Error('Missing ENV ETHERSCAN_API_KEY') + } + const mastercopies = JSON.parse( readFileSync(path.join(cwd(), 'mastercopies.json'), 'utf8') ) - const [signer] = await hre.ethers.getSigners() - - const provider = createEIP1193(hre.network.provider, signer) + const chainId = hre.network.config.chainId! for (const [version, artifact] of Object.entries(mastercopies)) { - await verify(version, artifact as MastercopyArtifact, provider) + await verify(version, artifact as MastercopyArtifact, chainId) } }) async function verify( version: string, artifact: MastercopyArtifact, - provider: EIP1193Provider + chainId: number ) { - const chainId = String( - Number(await provider.request({ method: 'eth_chainId' })) - ) - - if (!ETHERSCAN_API_KEY) { - throw new Error('Missing ENV ETHERSCAN_API_KEY') - } - const { noop } = await verifyMastercopy(artifact, { - network: chainId, + network: String(chainId), apiKey: ETHERSCAN_API_KEY as string, }) if (noop) {