-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'testnet' into release/v0.7.0
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/upgrades/REP-002/231103-upgrade-maintenance-contract.ts
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import { explorerUrl, proxyInterface } from '../upgradeUtils'; | ||
import { VoteType } from '../../script/proposal'; | ||
import { roninchainNetworks } from '../../configs/config'; | ||
import { network } from 'hardhat'; | ||
import { Maintenance__factory, Profile__factory } from '../../types'; | ||
|
||
const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => { | ||
if (!roninchainNetworks.includes(network.name!)) { | ||
return; | ||
} | ||
|
||
const { execute } = deployments; | ||
let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file | ||
console.log('Governor:', governor); | ||
|
||
// Upgrade Profile Contract | ||
const MaintenanceProxy = await deployments.get('MaintenanceProxy'); | ||
const MaintenanceLogic = await deployments.get('MaintenanceLogic'); | ||
const MaintenanceInstr = [proxyInterface.encodeFunctionData('upgradeTo', [MaintenanceLogic.address])]; | ||
console.info('ProfileInstr', MaintenanceInstr); | ||
|
||
// Propose the proposal | ||
const blockNumBefore = await ethers.provider.getBlockNumber(); | ||
const blockBefore = await ethers.provider.getBlock(blockNumBefore); | ||
const timestampBefore = blockBefore.timestamp; | ||
const proposalExpiryTimestamp = timestampBefore + 3600 * 24 * 10; // expired in 10 days | ||
|
||
const tx = await execute( | ||
'RoninGovernanceAdmin', | ||
{ from: governor, log: true }, | ||
'proposeProposalForCurrentNetwork', | ||
proposalExpiryTimestamp, // expiryTimestamp | ||
[...MaintenanceInstr.map(() => MaintenanceProxy.address)], // targets | ||
[...MaintenanceInstr].map(() => 0), // values | ||
[...MaintenanceInstr], // datas | ||
[...MaintenanceInstr].map(() => 1_000_000), // gasAmounts | ||
VoteType.For // ballot type | ||
); | ||
deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`); | ||
}; | ||
|
||
// yarn hardhat deploy --tags 231103_UpgradeMaintenance --network ronin-testnet | ||
deploy.tags = ['231103_UpgradeMaintenance']; | ||
|
||
export default deploy; |