2023-05-25 12:31:55 -04: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()
|
|
|
|
|
2023-05-27 11:01:23 -04:00
|
|
|
if (process.env.STAKING_PROXY_ADDRESS === undefined) throw Error('Missing STAKING_PROXY_ADDRESS.')
|
|
|
|
|
|
|
|
const stakingProxyAddress = `${process.env.STAKING_PROXY_ADDRESS}`
|
|
|
|
|
2023-05-25 12:31:55 -04:00
|
|
|
const registryImplementationDeployer = (await ethers.getContractFactory('RelayerRegistry')).connect(signer)
|
|
|
|
|
|
|
|
let registry
|
|
|
|
|
|
|
|
if (await prompt(promptMessageBase('Continuing to RelayerRegistry (Implementation) deployment.'))) {
|
|
|
|
registry = await registryImplementationDeployer.deploy(
|
|
|
|
config.TORN,
|
|
|
|
config.governance,
|
|
|
|
config.ens,
|
2023-05-27 11:01:23 -04:00
|
|
|
stakingProxyAddress,
|
2023-05-25 12:31:55 -04:00
|
|
|
config.feeManager,
|
|
|
|
)
|
|
|
|
console.log(deployedMessage('RelayerRegistry (Implementation)', 1, registry.address))
|
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at RelayerRegistry (Implementation) deployment.\n'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
|
|
|
await hre.run('verify:verify', {
|
|
|
|
address: registry.address,
|
2023-05-27 11:01:23 -04:00
|
|
|
constructorArguments: [
|
|
|
|
config.TORN,
|
|
|
|
config.governance,
|
|
|
|
config.ens,
|
|
|
|
stakingProxyAddress,
|
|
|
|
config.feeManager,
|
|
|
|
],
|
2023-05-25 12:31:55 -04:00
|
|
|
})
|
|
|
|
console.log(verifiedMessage('RelayerRegistry (Implementation)'))
|
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at contract verification.\n'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deploy()
|