UNPKG

@dydxfoundation/governance

Version:
37 lines (36 loc) 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.transferOwnerRole = void 0; const utils_1 = require("ethers/lib/utils"); const types_1 = require("../../types"); const get_deployer_address_1 = require("../deploy-config/get-deployer-address"); const logging_1 = require("../lib/logging"); const prompt_1 = require("../lib/prompt"); const util_1 = require("../lib/util"); async function transferOwnerRole({ starkProxyAddress, newOwnerRoleAddress, }) { (0, logging_1.log)(`*WARNING*: If you run this script and do not have ownership of address ${newOwnerRoleAddress}, you will not ` + `be able to perform actions that require OWNER_ROLE on stark proxy ${starkProxyAddress}.\n`); const deployer = await (0, get_deployer_address_1.getDeployerSigner)(); const deployerAddress = deployer.address; const ownerRoleHash = (0, utils_1.id)('OWNER_ROLE'); const starkProxy = new types_1.StarkProxyV1__factory(deployer).attach(starkProxyAddress); const deployerHasOwnerRole = await starkProxy.hasRole(ownerRoleHash, deployerAddress); if (!deployerHasOwnerRole) { throw new Error(`Deployer ${deployerAddress} does not have OWNER_ROLE on stark proxy ${starkProxyAddress}.`); } await (0, prompt_1.promptYes)(`Grant OWNER_ROLE on stark proxy ${starkProxyAddress} to ${newOwnerRoleAddress} (type yes to continue)?`); await (0, util_1.waitForTx)(await starkProxy.grantRole(ownerRoleHash, newOwnerRoleAddress)); const newAddressHasOwnerRole = await starkProxy.hasRole(ownerRoleHash, newOwnerRoleAddress); if (!newAddressHasOwnerRole) { throw new Error(`Failed to grant OWNER_ROLE on stark proxy ${starkProxyAddress} to ${newOwnerRoleAddress}.`); } (0, logging_1.log)(`Granted OWNER_ROLE on stark proxy ${starkProxyAddress} to ${newOwnerRoleAddress}.\n`); await (0, prompt_1.promptYes)(`Revoke OWNER_ROLE on stark proxy ${starkProxyAddress} from ${deployerAddress} (type yes to continue)?`); await (0, util_1.waitForTx)(await starkProxy.revokeRole(ownerRoleHash, deployerAddress)); const deployerHasOwnerRoleAfterRevoke = await starkProxy.hasRole(ownerRoleHash, deployerAddress); if (deployerHasOwnerRoleAfterRevoke) { throw new Error(`Failed to revoke OWNER_ROLE on stark proxy ${starkProxyAddress} from ${deployerAddress}.`); } (0, logging_1.log)(`Revoked OWNER_ROLE on stark proxy ${starkProxyAddress} from ${deployerAddress}.`); } exports.transferOwnerRole = transferOwnerRole;