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 })
|
|
|
|
|
2023-05-27 19:54:38 +03:00
|
|
|
function idToNetwork(id) {
|
|
|
|
switch (id) {
|
|
|
|
case 1:
|
|
|
|
return 'Mainnet'
|
|
|
|
case 3:
|
|
|
|
return 'Ropsten'
|
|
|
|
case 4:
|
|
|
|
return 'Rinkeby'
|
|
|
|
case 5:
|
|
|
|
return 'Goerli'
|
|
|
|
case 11155111:
|
|
|
|
return 'Sepolia'
|
|
|
|
default:
|
|
|
|
throw Error('\nChain Id could not be recognized. What network are you using?\n')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-25 19:31:55 +03:00
|
|
|
function _prompt(prompt, resolve) {
|
|
|
|
prompter.question(prompt, (answer) => {
|
|
|
|
if (answer == 'y') {
|
|
|
|
resolve(true)
|
2023-05-27 19:54:38 +03:00
|
|
|
} else {
|
2023-05-25 19:31:55 +03:00
|
|
|
resolve(false)
|
2023-05-27 19:54:38 +03:00
|
|
|
}
|
2023-05-25 19:31:55 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
2023-05-27 23:53:48 +03:00
|
|
|
if (process.env.STAKING_PROXY_ADDRESS === '') throw Error('Missing STAKING_PROXY_ADDRESS.')
|
2023-05-27 19:54:38 +03:00
|
|
|
|
2023-05-25 19:31:55 +03:00
|
|
|
const signer = await ethers.getSigner()
|
|
|
|
|
2023-05-27 19:54:38 +03:00
|
|
|
const _network = await ethers.provider.getNetwork()
|
2023-05-27 18:01:23 +03:00
|
|
|
|
|
|
|
const stakingProxyAddress = `${process.env.STAKING_PROXY_ADDRESS}`
|
|
|
|
|
2023-05-25 19:31:55 +03: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 18:01:23 +03:00
|
|
|
stakingProxyAddress,
|
2023-05-25 19:31:55 +03:00
|
|
|
config.feeManager,
|
|
|
|
)
|
2023-05-27 19:54:38 +03:00
|
|
|
console.log(deployedMessage('RelayerRegistry (Implementation)', _network.chainId, registry.address))
|
2023-05-25 19:31:55 +03:00
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at RelayerRegistry (Implementation) deployment.\n'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
2023-05-27 19:54:38 +03:00
|
|
|
console.log('\nWaiting 20 seconds.\n')
|
|
|
|
await timeout(20)
|
|
|
|
|
2023-05-25 19:31:55 +03:00
|
|
|
await hre.run('verify:verify', {
|
|
|
|
address: registry.address,
|
2023-05-27 18:01:23 +03:00
|
|
|
constructorArguments: [
|
|
|
|
config.TORN,
|
|
|
|
config.governance,
|
|
|
|
config.ens,
|
|
|
|
stakingProxyAddress,
|
|
|
|
config.feeManager,
|
|
|
|
],
|
2023-05-25 19:31:55 +03:00
|
|
|
})
|
2023-05-27 19:54:38 +03:00
|
|
|
console.log(verifiedMessage('RelayerRegistry (Implementation)', registry.address))
|
2023-05-25 19:31:55 +03:00
|
|
|
} else {
|
|
|
|
return '\nDecided to stop at contract verification.\n'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deploy()
|