2023-05-25 19:31:55 +03:00
|
|
|
require('dotenv').config()
|
|
|
|
|
|
|
|
const config = require('../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()
|
|
|
|
|
|
|
|
const stakingDeployer = (await ethers.getContractFactory('TornadoStakingRewards')).connect(signer)
|
2023-05-27 18:01:23 +03:00
|
|
|
const proxyDeployer = (await ethers.getContractFactory('AdminUpgradeableProxy')).connect(signer)
|
2023-05-25 19:31:55 +03:00
|
|
|
|
2023-05-27 18:01:23 +03:00
|
|
|
let impl, proxy
|
2023-05-25 19:31:55 +03:00
|
|
|
|
2023-05-27 18:01:23 +03:00
|
|
|
if (await prompt(promptMessageBase('Continuing to TornadoStakingRewards (Implementation) deployment.'))) {
|
|
|
|
impl = await stakingDeployer.deploy(config.governance, config.TORN, config.registry)
|
|
|
|
console.log(deployedMessage('TornadoStakingRewards (Implementation)', 1, impl.address))
|
2023-05-25 19:31:55 +03:00
|
|
|
} else {
|
2023-05-27 18:01:23 +03:00
|
|
|
return '\nDecided to stop at TornadoStakingRewards (Implementation) deployment.\n'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (await prompt(promptMessageBase('Continuing to Staking Proxy deployment.'))) {
|
|
|
|
proxy = await proxyDeployer.deploy(impl.address, governance.address, [])
|
|
|
|
console.log(deployedMessage('Staking Proxy', 1, proxy.address))
|
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at Staking Proxy deployment.\n'
|
2023-05-25 19:31:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
|
|
|
await hre.run('verify:verify', {
|
2023-05-27 18:01:23 +03:00
|
|
|
address: impl.address,
|
2023-05-25 19:31:55 +03:00
|
|
|
constructorArguments: [config.governance, config.TORN, config.registry],
|
|
|
|
})
|
2023-05-27 18:01:23 +03:00
|
|
|
|
|
|
|
console.log(verifiedMessage('TornadoStakingRewards (Implementation)'))
|
|
|
|
console.log('\nWaiting 5 seconds.\n')
|
|
|
|
await timeout(5)
|
|
|
|
|
|
|
|
await hre.run('verify:verify', {
|
|
|
|
address: proxy.address,
|
|
|
|
constructorArguments: [impl.address, governance.address, []],
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(verifiedMessage('Staking Proxy'))
|
2023-05-25 19:31:55 +03:00
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at contract verification.\n'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deploy()
|