UNPKG

@dydxfoundation/governance

Version:
38 lines (37 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createStarkProxyFixProposal = void 0; const utils_1 = require("ethers/lib/utils"); const types_1 = require("../../types"); const StarkProxyV2__factory_1 = require("../../types/factories/StarkProxyV2__factory"); const get_deployer_address_1 = require("../deploy-config/get-deployer-address"); const hre_1 = require("../hre"); const logging_1 = require("../lib/logging"); const util_1 = require("../lib/util"); async function createStarkProxyFixProposal({ proposalIpfsHashHex, governorAddress, shortTimelockAddress, starkProxyAddresses, starkProxyProxyAdminAddresses, starkProxyNewImplAddress, signer, }) { const hre = (0, hre_1.getHre)(); const deployer = signer || await (0, get_deployer_address_1.getDeployerSigner)(); const deployerAddress = deployer.address; (0, logging_1.log)(`Creating stark proxy fix proposal with proposer ${deployerAddress}.\n`); const governor = new types_1.DydxGovernor__factory(deployer).attach(governorAddress); const proposalId = await governor.getProposalsCount(); const values = new Array(starkProxyProxyAdminAddresses.length).fill('0'); const functionSignatures = new Array(starkProxyProxyAdminAddresses.length).fill('upgradeAndCall(address,address,bytes)'); const initializeCalldata = new utils_1.Interface(StarkProxyV2__factory_1.StarkProxyV2__factory.abi).encodeFunctionData('initialize', []); const calldatas = starkProxyAddresses.map((spAddress) => hre.ethers.utils.defaultAbiCoder.encode(['address', 'address', 'bytes'], [spAddress, starkProxyNewImplAddress, initializeCalldata])); const delegateCalls = new Array(starkProxyProxyAdminAddresses.length).fill(false); const proposal = [ shortTimelockAddress, starkProxyProxyAdminAddresses, values, functionSignatures, calldatas, delegateCalls, proposalIpfsHashHex, ]; await (0, util_1.waitForTx)(await governor.create(...proposal)); return { proposalId, }; } exports.createStarkProxyFixProposal = createStarkProxyFixProposal;