|
| 1 | +import { config } from "@sentry/core"; |
| 2 | +import { safeVerify } from "../../utils/safeVerify.mjs"; |
| 3 | + |
| 4 | +import { PoolBeaconAbi } from "@sentry/core"; |
| 5 | + |
| 6 | +// Find this in the deployed PoolProxyDeployer's public fields. This should reflect which set of proxies you want to change; staking pools, key buckets, or esXai buckets |
| 7 | +// https://arbiscan.io/address/0x68D78D1E81379EfD9C61f8E9131D52CE571AF4fD#readProxyContract |
| 8 | +const beaconAddress = "0x5f9D168d3435747335b1B3dC7e4d42e3510087C7"; |
| 9 | +const currentContractImplementationName = "StakingPool2"; |
| 10 | +const newContractImplementationName = "StakingPool3"; |
| 11 | + |
| 12 | +const REFEREE_ADDRESS = config.refereeAddress; |
| 13 | +const POOL_FACTORY_ADDRESS = config.poolFactoryAddress; |
| 14 | +const NODE_LICENSE_ADDRESS = config.nodeLicenseAddress; |
| 15 | + |
| 16 | +async function main() { |
| 17 | + |
| 18 | + // get the deployer |
| 19 | + const [deployer] = (await ethers.getSigners()); |
| 20 | + |
| 21 | + console.log("Upgrading Referee..."); |
| 22 | + const Referee11 = await ethers.getContractFactory("Referee11", deployer); |
| 23 | + console.log("Got Referee factory"); |
| 24 | + const referee11 = await upgrades.upgradeProxy(REFEREE_ADDRESS, Referee11); |
| 25 | + console.log("Referee upgraded to version 11"); |
| 26 | + |
| 27 | + console.log("Upgrading PoolFactory..."); |
| 28 | + const PoolFactory3 = await ethers.getContractFactory("PoolFactory3"); |
| 29 | + console.log("Got PoolFactory factory"); |
| 30 | + const poolFactory3 = await upgrades.upgradeProxy(POOL_FACTORY_ADDRESS, PoolFactory3); |
| 31 | + console.log("PoolFactory upgraded to version 3"); |
| 32 | + |
| 33 | + console.log("Upgrading NodeLicense..."); |
| 34 | + const NodeLicense10 = await ethers.getContractFactory("NodeLicense10"); |
| 35 | + console.log("Got NodeLicense factory"); |
| 36 | + const nodeLicense10 = await upgrades.upgradeProxy(NODE_LICENSE_ADDRESS, NodeLicense10); |
| 37 | + console.log("NodeLicense upgraded to version 10"); |
| 38 | + |
| 39 | + // UPGRADE PoolBeacon |
| 40 | + // Create instance of the beacon |
| 41 | + const beacon = new ethers.Contract(beaconAddress, PoolBeaconAbi, deployer); |
| 42 | + console.log("Found beacon:", await beacon.getAddress()); |
| 43 | + |
| 44 | + // Validate the new implementation is upgrade safe |
| 45 | + console.log("Validating upgrade viability..."); |
| 46 | + const CurrentImplementationFactory = await ethers.getContractFactory(currentContractImplementationName); |
| 47 | + const NewImplementationFactory = await ethers.getContractFactory(newContractImplementationName); |
| 48 | + await upgrades.validateUpgrade(CurrentImplementationFactory, NewImplementationFactory, { kind: "beacon" }); |
| 49 | + console.log("New implementation validated as upgrade safe"); |
| 50 | + |
| 51 | + // Deploy the new implementation |
| 52 | + console.log("Deploying the new implementation"); |
| 53 | + const NewImplementation = await ethers.deployContract(newContractImplementationName); |
| 54 | + await NewImplementation.waitForDeployment(); |
| 55 | + const newImplementationAddress = await NewImplementation.getAddress(); |
| 56 | + |
| 57 | + // Update the beacon with the new implementation address |
| 58 | + console.log("Updating the beacon with the new implementation address"); |
| 59 | + await beacon.update(newImplementationAddress); |
| 60 | + |
| 61 | + console.log("Verifying the new PoolBeacon implementation"); |
| 62 | + |
| 63 | + console.log("Starting verification... "); |
| 64 | + await safeVerify({ skipWaitForDeployTx: true, contractAddress: newImplementationAddress }); |
| 65 | + await safeVerify({ skipWaitForDeployTx: true, contract: referee11 }); |
| 66 | + await safeVerify({ skipWaitForDeployTx: true, contract: nodeLicense10 }); |
| 67 | + await safeVerify({ skipWaitForDeployTx: true, contract: poolFactory3 }); |
| 68 | + console.log("Verification complete "); |
| 69 | +} |
| 70 | + |
| 71 | +// We recommend this pattern to be able to use async/await everywhere |
| 72 | +// and properly handle errors. |
| 73 | +main().catch((error) => { |
| 74 | + console.error(error); |
| 75 | + process.exitCode = 1; |
| 76 | +}); |
0 commit comments