Skip to content

Commit

Permalink
generate set admin data
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Jun 4, 2024
1 parent 7f6cb00 commit 40879dd
Showing 1 changed file with 101 additions and 2 deletions.
103 changes: 101 additions & 2 deletions l1-contracts/scripts/governance-accept-ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function main() {
await transferOwnership1StepTo(deployWallet, stmAddr, ownerAddress, true);
await transferOwnership1StepTo(deployWallet, l1SharedBridgeAddr, ownerAddress, true);
await transferOwnership1StepTo(deployWallet, bridgehubAddr, ownerAddress, true);
await transferOwnership1StepTo(deployWallet, proxyAdminAddr, ownerAddress, false);
// await transferOwnership1StepTo(deployWallet, proxyAdminAddr, ownerAddress, false);
});

program
Expand Down Expand Up @@ -104,9 +104,79 @@ async function main() {
console.log("Calldata for execution: ", executeData);
});

await program.parseAsync(process.argv);

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎··`

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎··`

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎··`

Check failure on line 107 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

program
.command("transfer-pending-admin")
.option("--private-key <private-key>")
.option("--gas-price <gas-price>")
.option("--nonce <nonce>")
.option("--owner-address <owner-address>")
.option("--stm-addr <stateTransitionManagerAddr>")
.option("--bridgehub-addr <bridgehubAddr>")
.option("--only-verifier")
.action(async (cmd) => {
const deployWallet = cmd.privateKey
? new Wallet(cmd.privateKey, provider)
: Wallet.fromMnemonic(
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const ownerAddress = ethers.utils.getAddress(cmd.ownerAddress);
console.log(`Using owner address: ${ownerAddress}`);

const gasPrice = cmd.gasPrice
? parseUnits(cmd.gasPrice, "gwei")
: (await provider.getGasPrice()).mul(GAS_MULTIPLIER);
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

const nonce = cmd.nonce ? parseInt(cmd.nonce) : await deployWallet.getTransactionCount();
console.log(`Using nonce: ${nonce}`);

const stmAddr = ethers.utils.getAddress(cmd.stmAddr);
console.log("Using STM address: ", stmAddr);
const bridgehubAddr = ethers.utils.getAddress(cmd.bridgehubAddr);
console.log("Using Bridgehub address: ", bridgehubAddr);

await transferAdmin1StepTo(deployWallet, stmAddr, ownerAddress, true);
await transferAdmin1StepTo(deployWallet, bridgehubAddr, ownerAddress, true);
});

program

Check failure on line 147 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`

Check failure on line 147 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`

Check failure on line 147 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
.command("accept-pending-admin")
.option("--stm-addr <stateTransitionManagerAddr>")
.option("--bridgehub-addr <bridgehubAddr>")
.action(async (cmd) => {

Check failure on line 151 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`

Check failure on line 151 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`

Check failure on line 151 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`


Check failure on line 153 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 153 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 153 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
const stmAddr = ethers.utils.getAddress(cmd.stmAddr);
console.log("Using STM address: ", stmAddr);
const bridgehubAddr = ethers.utils.getAddress(cmd.bridgehubAddr);
console.log("Using Bridgehub address: ", bridgehubAddr);

const addresses = [ stmAddr, bridgehubAddr];

Check failure on line 159 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`

Check failure on line 159 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`

Check failure on line 159 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`

const govCalls = addresses.map(acceptAdminCall);

const govOperation = {
calls: govCalls,
predecessor: ethers.constants.HashZero,
salt: ethers.constants.HashZero,
};

const scheduleData = governanceInterface.encodeFunctionData("scheduleTransparent", [govOperation, 0]);
const executeData = governanceInterface.encodeFunctionData("execute", [govOperation]);

console.log("Calldata for scheduling: ", scheduleData);
console.log("Calldata for execution: ", executeData);
});

Check failure on line 174 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `····`

Check failure on line 174 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `····`

Check failure on line 174 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `····`

await program.parseAsync(process.argv);

Check failure on line 176 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

Check failure on line 176 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

Check failure on line 176 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
}

Check failure on line 177 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

Check failure on line 177 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`

Check failure on line 177 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎`


Check failure on line 179 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 179 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed

Check failure on line 179 in l1-contracts/scripts/governance-accept-ownership.ts

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
main()
.then(() => process.exit(0))
.catch((err) => {
Expand Down Expand Up @@ -139,3 +209,32 @@ function acceptOwnershipCall(target: string) {
data,
};
}

async function transferAdmin1StepTo(
wallet: ethers.Wallet,
contractAddress: string,
newOwner: string,
printPendingOwner: boolean = true
) {
const l1Erc20ABI = ['function setPendingAdmin(address to)'];
const contract = new ethers.Contract(contractAddress, l1Erc20ABI, wallet);
console.log("Transferring admin of contract: ", contractAddress, " to: ", newOwner);
const tx = await contract.setPendingAdmin(newOwner);
console.log("Tx hash", tx.hash);
await tx.wait();
// if (printPendingOwner) {
// const newPendingOwner = await contract.pendingAdmin();
// console.log("New pending owner: ", newPendingOwner);
// }
}

function acceptAdminCall(target: string) {
const abi = ['function acceptAdmin()'];
const interf = new Interface(abi);
const data = interf.encodeFunctionData("acceptAdmin", []);
return {
target,
value: 0,
data,
};
}

0 comments on commit 40879dd

Please sign in to comment.