-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CompensationClaims contract deployment (#498)
* update deploy script * ABI files * fix deploy script * tweak * Add ABIs to the DApp
- Loading branch information
Franck
authored
Jan 13, 2021
1 parent
2317bd2
commit 6e53f49
Showing
5 changed files
with
1,287 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,79 @@ | ||
const { isMainnet, isFork } = require("../test/helpers.js"); | ||
|
||
const { | ||
isMainnet, | ||
isRinkeby, | ||
isMainnetOrRinkebyOrFork, | ||
} = require("../test/helpers.js"); | ||
const { log } = require("../utils/deploy"); | ||
log, | ||
deployWithConfirmation, | ||
withConfirmation, | ||
executeProposal, | ||
sendProposal, | ||
} = require("../utils/deploy"); | ||
const { getTxOpts } = require("../utils/tx"); | ||
const { proposeArgs } = require("../utils/governor"); | ||
|
||
// Wait for 3 blocks confirmation on Mainnet/Rinkeby. | ||
const NUM_CONFIRMATIONS = isMainnet || isRinkeby ? 3 : 0; | ||
const deployName = "005_compensation_claims"; | ||
|
||
// | ||
// 1. Deploy new Single Asset Staking contract | ||
// Deploys the new OUSD CompensationClaims contract. | ||
// | ||
const compensationClaimsDeploy = async ({ getNamedAccounts, deployments }) => { | ||
console.log("Running 005_compensation_claims..."); | ||
const compensationClaimsDeploy = async ({ getNamedAccounts }) => { | ||
console.log(`Running ${deployName}...`); | ||
|
||
const { deploy } = deployments; | ||
const { governorAddr, deployerAddr, adjusterAddr } = await getNamedAccounts(); | ||
|
||
const sDeployer = ethers.provider.getSigner(deployerAddr); | ||
const sGovernor = ethers.provider.getSigner(governorAddr); | ||
|
||
// | ||
// Deploy the contract. | ||
// | ||
const OUSD = await ethers.getContract("OUSDProxy"); | ||
log(`Using OUSD address ${OUSD.address}`); | ||
log(`Using adjuster address ${adjusterAddr}`); | ||
|
||
// Deploy the claims contract proxy. | ||
let d = await deploy("CompensationClaims", { | ||
args: [OUSD.address, adjusterAddr], | ||
contract: "CompensationClaims", | ||
from: deployerAddr, | ||
}); | ||
|
||
await ethers.provider.waitForTransaction( | ||
d.receipt.transactionHash, | ||
NUM_CONFIRMATIONS | ||
); | ||
log("Deployed CompensationClaims", d); | ||
await deployWithConfirmation("CompensationClaims", [ | ||
OUSD.address, | ||
adjusterAddr, | ||
]); | ||
|
||
const claimsContract = await ethers.getContract("CompensationClaims"); | ||
|
||
// | ||
// Transfer governance of the CompensationClaims contract to the governor | ||
// - On Mainnet the governance transfer gets executed separately, via the multi-sig wallet. | ||
// - On other networks, this migration script can claim governance by the governor. | ||
// | ||
let t = await claimsContract | ||
.connect(sDeployer) | ||
.transferGovernance(governorAddr); | ||
await ethers.provider.waitForTransaction(t.hash, NUM_CONFIRMATIONS); | ||
|
||
await withConfirmation( | ||
claimsContract.connect(sDeployer).transferGovernance(governorAddr, await getTxOpts()) | ||
); | ||
log(`CompensationClaims transferGovernance(${governorAddr} called`); | ||
|
||
if (!isMainnetOrRinkebyOrFork) { | ||
t = await claimsContract | ||
.connect(sGovernor) // Claim governance with governor | ||
.claimGovernance(); | ||
await ethers.provider.waitForTransaction(t.hash, NUM_CONFIRMATIONS); | ||
log("Claimed governance for CompensationClaims"); | ||
} | ||
// Generate the governance proposal. | ||
const propDescription = "Claim ownership of CompensationClaims"; | ||
const propArgs = await proposeArgs([ | ||
{ | ||
contract: claimsContract, | ||
signature: "claimGovernance()", | ||
}, | ||
]); | ||
|
||
console.log("005_compensation_claims deploy done."); | ||
if (isMainnet) { | ||
// On Mainnet, only propose. The enqueue and execution are handled manually via multi-sig. | ||
log("Sending proposal to governor..."); | ||
await sendProposal(propArgs, propDescription); | ||
log("Proposal sent."); | ||
} else if (isFork) { | ||
// On Fork we can send the proposal then impersonate the guardian to execute it. | ||
log("Sending and executing proposal..."); | ||
await executeProposal(propArgs, propDescription); | ||
log("Proposal executed."); | ||
} else { | ||
// On other networks, claim governance using the governor account. | ||
await withConfirmation(claimsContract.connect(sGovernor).claimGovernance()); | ||
} | ||
|
||
console.log(`${deployName} deploy done.`); | ||
return true; | ||
}; | ||
|
||
compensationClaimsDeploy.id = "005_compensation_claims"; | ||
compensationClaimsDeploy.id = deployName; | ||
compensationClaimsDeploy.dependencies = ["core"]; | ||
|
||
// TODO(franck): enable Mainnet once we are ready to deploy. | ||
compensationClaimsDeploy.skip = () => isMainnet || isRinkeby; | ||
|
||
module.exports = compensationClaimsDeploy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.