|
| 1 | +import { HardhatRuntimeEnvironment } from 'hardhat/types'; |
| 2 | +import { explorerUrl, proxyInterface } from '../upgradeUtils'; |
| 3 | +import { VoteType } from '../../script/proposal'; |
| 4 | +import { roninchainNetworks } from '../../configs/config'; |
| 5 | +import { network } from 'hardhat'; |
| 6 | +import { Maintenance__factory, Profile__factory } from '../../types'; |
| 7 | + |
| 8 | +const deploy = async ({ getNamedAccounts, deployments, ethers }: HardhatRuntimeEnvironment) => { |
| 9 | + if (!roninchainNetworks.includes(network.name!)) { |
| 10 | + return; |
| 11 | + } |
| 12 | + |
| 13 | + const { execute } = deployments; |
| 14 | + let { governor } = await getNamedAccounts(); // NOTE: Should double check the `governor` account in the `hardhat.config.ts` file |
| 15 | + console.log('Governor:', governor); |
| 16 | + |
| 17 | + // Upgrade Profile Contract |
| 18 | + const MaintenanceProxy = await deployments.get('MaintenanceProxy'); |
| 19 | + const MaintenanceLogic = await deployments.get('MaintenanceLogic'); |
| 20 | + const MaintenanceInstr = [proxyInterface.encodeFunctionData('upgradeTo', [MaintenanceLogic.address])]; |
| 21 | + console.info('ProfileInstr', MaintenanceInstr); |
| 22 | + |
| 23 | + // Propose the proposal |
| 24 | + const blockNumBefore = await ethers.provider.getBlockNumber(); |
| 25 | + const blockBefore = await ethers.provider.getBlock(blockNumBefore); |
| 26 | + const timestampBefore = blockBefore.timestamp; |
| 27 | + const proposalExpiryTimestamp = timestampBefore + 3600 * 24 * 10; // expired in 10 days |
| 28 | + |
| 29 | + const tx = await execute( |
| 30 | + 'RoninGovernanceAdmin', |
| 31 | + { from: governor, log: true }, |
| 32 | + 'proposeProposalForCurrentNetwork', |
| 33 | + proposalExpiryTimestamp, // expiryTimestamp |
| 34 | + [...MaintenanceInstr.map(() => MaintenanceProxy.address)], // targets |
| 35 | + [...MaintenanceInstr].map(() => 0), // values |
| 36 | + [...MaintenanceInstr], // datas |
| 37 | + [...MaintenanceInstr].map(() => 1_000_000), // gasAmounts |
| 38 | + VoteType.For // ballot type |
| 39 | + ); |
| 40 | + deployments.log(`${explorerUrl[network.name!]}/tx/${tx.transactionHash}`); |
| 41 | +}; |
| 42 | + |
| 43 | +// yarn hardhat deploy --tags 231103_UpgradeMaintenance --network ronin-testnet |
| 44 | +deploy.tags = ['231103_UpgradeMaintenance']; |
| 45 | + |
| 46 | +export default deploy; |
0 commit comments