94 lines
2.8 KiB
JavaScript
94 lines
2.8 KiB
JavaScript
|
require('dotenv').config()
|
||
|
|
||
|
const hre = require('hardhat')
|
||
|
const config = require('../config')
|
||
|
const { createInterface } = require('readline')
|
||
|
|
||
|
const prompter = createInterface({ input: process.stdin, output: process.stdout })
|
||
|
|
||
|
function _prompt(promptMessage, predicate, resolve) {
|
||
|
prompter.question(promptMessage, (answer) => {
|
||
|
if (predicate(answer)) {
|
||
|
resolve(answer)
|
||
|
} else {
|
||
|
_prompt('', predicate, resolve)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
const addressPromptMessage = (contractName) =>
|
||
|
`\n\nPlease enter the deploy address of the ${contractName} contract (CTRL-D/C to exit): `
|
||
|
|
||
|
function addressPrompt(name) {
|
||
|
return new Promise((resolve) =>
|
||
|
_prompt(addressPromptMessage(name), (answer) => answer.length === 42 || answer === 'skip', resolve),
|
||
|
)
|
||
|
}
|
||
|
|
||
|
function happyVerifiedMessage(name, address) {
|
||
|
return `\n${name} @ ${address} successfully verified on Etherscan! 🥳\n`
|
||
|
}
|
||
|
|
||
|
function timeout(seconds) {
|
||
|
return new Promise((resolve) => setTimeout(resolve, seconds * 1000))
|
||
|
}
|
||
|
|
||
|
async function main() {
|
||
|
let minimalFactoryAddr = await addressPrompt('MinimalInstanceFactory')
|
||
|
let proposalFactoryAddr = await addressPrompt('InstanceProposalFactory')
|
||
|
let nativeCloneableImplAddr = await addressPrompt('ETH Instance Clone')
|
||
|
let erc20CloneableImplAddr = await addressPrompt('Token Instance Clone')
|
||
|
|
||
|
if (minimalFactoryAddr !== 'skip') {
|
||
|
await hre.run('verify:verify', {
|
||
|
address: minimalFactoryAddr,
|
||
|
constructorArguments: [config.verifier, config.hasher, config.merkleTreeHeight],
|
||
|
})
|
||
|
console.log(happyVerifiedMessage('MinimalInstanceFactory', minimalFactoryAddr))
|
||
|
}
|
||
|
|
||
|
console.log('\nWaiting 5 seconds.\n')
|
||
|
await timeout(5)
|
||
|
|
||
|
if (proposalFactoryAddr !== 'skip') {
|
||
|
await hre.run('verify:verify', {
|
||
|
address: proposalFactoryAddr,
|
||
|
constructorArguments: [
|
||
|
config.governance,
|
||
|
minimalFactoryAddr,
|
||
|
config.instanceRegistry,
|
||
|
config.UniswapV3Factory,
|
||
|
config.WETH,
|
||
|
config.TWAPSlotsMin,
|
||
|
],
|
||
|
})
|
||
|
console.log(happyVerifiedMessage('InstanceProposalFactory', proposalFactoryAddr))
|
||
|
}
|
||
|
|
||
|
console.log('\nWaiting 5 seconds.\n')
|
||
|
await timeout(5)
|
||
|
|
||
|
if (nativeCloneableImplAddr !== 'skip') {
|
||
|
await hre.run('verify:verify', {
|
||
|
address: nativeCloneableImplAddr,
|
||
|
constructorArguments: [config.verifier, config.hasher],
|
||
|
})
|
||
|
console.log(happyVerifiedMessage('ETHTornadoCloneable', nativeCloneableImplAddr))
|
||
|
}
|
||
|
|
||
|
console.log('\nWaiting 5 seconds.\n')
|
||
|
await timeout(5)
|
||
|
|
||
|
if (erc20CloneableImplAddr !== 'skip') {
|
||
|
await hre.run('verify:verify', {
|
||
|
address: erc20CloneableImplAddr,
|
||
|
constructorArguments: [config.verifier, config.hasher],
|
||
|
})
|
||
|
console.log(happyVerifiedMessage('ERC20TornadoCloneable', erc20CloneableImplAddr))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
main().then((res) => {
|
||
|
console.log(res ?? '\nScript succesfully finished.\n')
|
||
|
})
|