1
0
tornado-governance/deploy/deployPatch.js

74 lines
2.1 KiB
JavaScript
Raw Normal View History

require('dotenv').config()
const hre = require('hardhat')
const { ethers } = hre
const { createInterface } = require('readline')
const prompter = createInterface({ input: process.stdin, output: process.stdout })
function _prompt(prompt, resolve) {
prompter.question(prompt, (answer) => {
if (answer == 'y') {
resolve(true)
} else if (answer == 'n') {
resolve(false)
} else _prompt('', resolve)
})
}
function prompt(prompt) {
return new Promise((resolve) => _prompt(prompt, resolve))
}
function deployedMessage(name, chainId, address) {
return `\n${name} deployed on ${idToNetwork(chainId)} @ ${address}\n`
}
function verifiedMessage(name, address) {
return `\n${name} @ ${address} verified on Etherscan!\n`
}
function timeout(seconds) {
return new Promise((resolve) => setTimeout(resolve, seconds * 1000))
}
const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would like to continue? (y/n): `
async function deploy() {
const signer = await ethers.getSigner()
if (process.env.STAKING_ADDRESS === undefined) throw Error('Missing STAKING_ADDRESS.')
if (process.env.REGISTRY_IMPL_ADDRESS === undefined) throw Error('Missing REGISTRY_IMPL_ADDRESS.')
const stakingAddress = `${process.env.STAKING_ADDRESS}`
const registryImplementationAddress = `${process.env.REGISTRY_IMPL_ADDRESS}`
const patchProposalDeployer = (await ethers.getContractFactory('PatchProposal')).connect(signer)
let patchProposal
if (await prompt(promptMessageBase('Continuing to PatchProposal deployment.'))) {
patchProposal = await patchProposalDeployer.deploy(stakingAddress, registryImplementationAddress)
console.log(deployedMessage('PatchProposal', 1, patchProposal.address))
} else {
return '\nDecided to stop at PatchProposal deployment.\n'
}
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
await hre.run('verify:verify', {
address: patchProposal.address,
constructorArguments: [stakingAddress, registryImplementationAddress],
})
console.log(verifiedMessage('PatchProposal'))
} else {
return '\nDecided to stop at contract verification.\n'
}
}
deploy()