Add all deploy scripts
Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
parent
9c04d318a2
commit
5544eca83b
10
.env.example
10
.env.example
@ -1,4 +1,8 @@
|
|||||||
ETHERSCAN_KEY=
|
|
||||||
RPC_URL=
|
RPC_URL=
|
||||||
PK=
|
PRIVATE_KEY=
|
||||||
use_latest_block=false
|
ETHERSCAN_KEY=
|
||||||
|
LATEST_BLOCK=false
|
||||||
|
|
||||||
|
# For deploying the proposal
|
||||||
|
REGISTRY_IMPL_ADDRESS=
|
||||||
|
STAKING_ADDRESS=
|
@ -13,7 +13,10 @@ abstract contract Delegation is Core {
|
|||||||
|
|
||||||
function delegate(address to) external {
|
function delegate(address to) external {
|
||||||
address previous = delegatedTo[msg.sender];
|
address previous = delegatedTo[msg.sender];
|
||||||
require(to != msg.sender && to != address(this) && to != address(0) && to != previous, "Governance: invalid delegatee");
|
require(
|
||||||
|
to != msg.sender && to != address(this) && to != address(0) && to != previous,
|
||||||
|
"Governance: invalid delegatee"
|
||||||
|
);
|
||||||
if (previous != address(0)) {
|
if (previous != address(0)) {
|
||||||
emit Undelegated(msg.sender, previous);
|
emit Undelegated(msg.sender, previous);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,10 @@ contract Governance is Initializable, Configuration, Delegation, EnsResolve {
|
|||||||
string memory description
|
string memory description
|
||||||
) internal virtual override(Delegation) returns (uint256) {
|
) internal virtual override(Delegation) returns (uint256) {
|
||||||
uint256 votingPower = lockedBalance[proposer];
|
uint256 votingPower = lockedBalance[proposer];
|
||||||
require(votingPower >= PROPOSAL_THRESHOLD, "Governance::propose: proposer votes below proposal threshold");
|
require(
|
||||||
|
votingPower >= PROPOSAL_THRESHOLD,
|
||||||
|
"Governance::propose: proposer votes below proposal threshold"
|
||||||
|
);
|
||||||
// target should be a contract
|
// target should be a contract
|
||||||
require(Address.isContract(target), "Governance::propose: not a contract");
|
require(Address.isContract(target), "Governance::propose: not a contract");
|
||||||
|
|
||||||
@ -153,7 +156,8 @@ contract Governance is Initializable, Configuration, Delegation, EnsResolve {
|
|||||||
if (latestProposalId != 0) {
|
if (latestProposalId != 0) {
|
||||||
ProposalState proposersLatestProposalState = state(latestProposalId);
|
ProposalState proposersLatestProposalState = state(latestProposalId);
|
||||||
require(
|
require(
|
||||||
proposersLatestProposalState != ProposalState.Active && proposersLatestProposalState != ProposalState.Pending,
|
proposersLatestProposalState != ProposalState.Active &&
|
||||||
|
proposersLatestProposalState != ProposalState.Pending,
|
||||||
"Governance::propose: one live proposal per proposer, found an already active proposal"
|
"Governance::propose: one live proposal per proposer, found an already active proposal"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -182,7 +186,10 @@ contract Governance is Initializable, Configuration, Delegation, EnsResolve {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function execute(uint256 proposalId) public payable virtual {
|
function execute(uint256 proposalId) public payable virtual {
|
||||||
require(state(proposalId) == ProposalState.AwaitingExecution, "Governance::execute: invalid proposal state");
|
require(
|
||||||
|
state(proposalId) == ProposalState.AwaitingExecution,
|
||||||
|
"Governance::execute: invalid proposal state"
|
||||||
|
);
|
||||||
Proposal storage proposal = proposals[proposalId];
|
Proposal storage proposal = proposals[proposalId];
|
||||||
proposal.executed = true;
|
proposal.executed = true;
|
||||||
|
|
||||||
@ -266,7 +273,9 @@ contract Governance is Initializable, Configuration, Delegation, EnsResolve {
|
|||||||
return ProposalState.Pending;
|
return ProposalState.Pending;
|
||||||
} else if (getBlockTimestamp() <= proposal.endTime) {
|
} else if (getBlockTimestamp() <= proposal.endTime) {
|
||||||
return ProposalState.Active;
|
return ProposalState.Active;
|
||||||
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes + proposal.againstVotes < QUORUM_VOTES) {
|
} else if (
|
||||||
|
proposal.forVotes <= proposal.againstVotes || proposal.forVotes + proposal.againstVotes < QUORUM_VOTES
|
||||||
|
) {
|
||||||
return ProposalState.Defeated;
|
return ProposalState.Defeated;
|
||||||
} else if (proposal.executed) {
|
} else if (proposal.executed) {
|
||||||
return ProposalState.Executed;
|
return ProposalState.Executed;
|
||||||
|
@ -13,7 +13,11 @@ contract LoopbackProxy is TransparentUpgradeableProxy, EnsResolve {
|
|||||||
/**
|
/**
|
||||||
* @dev Initializes an upgradeable proxy backed by the implementation at `_logic`.
|
* @dev Initializes an upgradeable proxy backed by the implementation at `_logic`.
|
||||||
*/
|
*/
|
||||||
constructor(address _logic, bytes memory _data) public payable TransparentUpgradeableProxy(_logic, address(this), _data) {}
|
constructor(address _logic, bytes memory _data)
|
||||||
|
public
|
||||||
|
payable
|
||||||
|
TransparentUpgradeableProxy(_logic, address(this), _data)
|
||||||
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Override to allow admin (itself) access the fallback function.
|
* @dev Override to allow admin (itself) access the fallback function.
|
||||||
|
@ -39,40 +39,29 @@ const promptMessageBase = (middle) => `\n${middle}\n\nAre you sure you would lik
|
|||||||
async function deploy() {
|
async function deploy() {
|
||||||
const signer = await ethers.getSigner()
|
const signer = await ethers.getSigner()
|
||||||
|
|
||||||
const patchProposalContractsFactoryDeployer = (
|
if (process.env.STAKING_ADDRESS === undefined) throw Error('Missing STAKING_ADDRESS.')
|
||||||
await ethers.getContractFactory('PatchProposalContractsFactory')
|
|
||||||
).connect(signer)
|
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)
|
const patchProposalDeployer = (await ethers.getContractFactory('PatchProposal')).connect(signer)
|
||||||
|
|
||||||
let patchProposal, patchProposalContractsFactory
|
let patchProposal
|
||||||
|
|
||||||
if (await prompt(promptMessageBase('Continuing to PatchProposalContractsFactory deployment.'))) {
|
|
||||||
patchProposalContractsFactory = await patchProposalContractsFactoryDeployer.deploy()
|
|
||||||
console.log(deployedMessage('PatchProposalContractsFactory', 1, patchProposalContractsFactory.address))
|
|
||||||
} else {
|
|
||||||
return '\nDecided to stop at PatchProposalContractsFactory deployment.\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await prompt(promptMessageBase('Continuing to PatchProposal deployment.'))) {
|
if (await prompt(promptMessageBase('Continuing to PatchProposal deployment.'))) {
|
||||||
patchProposal = await patchProposalDeployer.deploy(patchProposalContractsFactory.address)
|
patchProposal = await patchProposalDeployer.deploy(stakingAddress, registryImplementationAddress)
|
||||||
console.log(deployedMessage('PatchProposal', 1, patchProposal.address))
|
console.log(deployedMessage('PatchProposal', 1, patchProposal.address))
|
||||||
} else {
|
} else {
|
||||||
return '\nDecided to stop at PatchProposal deployment.\n'
|
return '\nDecided to stop at PatchProposal deployment.\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
||||||
await hre.run('verify:verify', {
|
|
||||||
address: patchProposalContractsFactory.address,
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(verifiedMessage('PatchProposalContractsFactory'))
|
|
||||||
console.log('\nWaiting 5 seconds.\n')
|
|
||||||
await timeout(5)
|
|
||||||
|
|
||||||
await hre.run('verify:verify', {
|
await hre.run('verify:verify', {
|
||||||
address: patchProposal.address,
|
address: patchProposal.address,
|
||||||
constructorArguments: [patchProposalContractsFactory.address],
|
constructorArguments: [stakingAddress, registryImplementationAddress],
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(verifiedMessage('PatchProposal'))
|
console.log(verifiedMessage('PatchProposal'))
|
||||||
|
72
deploy/deployRegistryImplementation.js
Normal file
72
deploy/deployRegistryImplementation.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
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 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,
|
||||||
|
config.staking,
|
||||||
|
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,
|
||||||
|
constructorArguments: [config.TORN, config.governance, config.ens, config.staking, config.feeManager],
|
||||||
|
})
|
||||||
|
console.log(verifiedMessage('RelayerRegistry (Implementation)'))
|
||||||
|
} else {
|
||||||
|
return '\nDecided to stop at contract verification.\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deploy()
|
66
deploy/deployStaking.js
Normal file
66
deploy/deployStaking.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
let staking
|
||||||
|
|
||||||
|
if (await prompt(promptMessageBase('Continuing to TornadoStakingRewards deployment.'))) {
|
||||||
|
staking = await stakingDeployer.deploy(config.governance, config.TORN, config.registry)
|
||||||
|
console.log(deployedMessage('TornadoStakingRewards', 1, staking.address))
|
||||||
|
} else {
|
||||||
|
return '\nDecided to stop at TornadoStakingRewards deployment.\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await prompt(promptMessageBase('Continuing to contract verification.'))) {
|
||||||
|
await hre.run('verify:verify', {
|
||||||
|
address: staking.address,
|
||||||
|
constructorArguments: [config.governance, config.TORN, config.registry],
|
||||||
|
})
|
||||||
|
console.log(verifiedMessage('TornadoStakingRewards'))
|
||||||
|
} else {
|
||||||
|
return '\nDecided to stop at contract verification.\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deploy()
|
@ -8,8 +8,6 @@ require('hardhat-log-remover')
|
|||||||
require('hardhat-contract-sizer')
|
require('hardhat-contract-sizer')
|
||||||
require('solidity-coverage')
|
require('solidity-coverage')
|
||||||
|
|
||||||
const config = require('./config')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type import('hardhat/config').HardhatUserConfig
|
* @type import('hardhat/config').HardhatUserConfig
|
||||||
*/
|
*/
|
||||||
@ -61,7 +59,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
mainnet: {
|
mainnet: {
|
||||||
url: `${process.env.RPC_URL}`,
|
url: `${process.env.RPC_URL}`,
|
||||||
//accounts: [`${process.env.PK}`],
|
accounts: process.env.PRIVATE_KEY ? [`${process.env.PRIVATE_KEY}`] : undefined,
|
||||||
timeout: 9999999999,
|
timeout: 9999999999,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user