Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfirefist committed Jan 29, 2024
1 parent 39f14a9 commit 012472a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function main() {
for (const contract of Object.values(DefaultStore.entropy_contracts)) {
if (selectedChains.includes(contract.chain)) {
console.log("Creating payload for chain: ", contract.chain.getId());
const pendingOwner = (await contract.getPendingOwner()).replace("0x", "");
const pendingOwner = await contract.getPendingOwner();
const adminPayload = contract.generateAcceptAdminPayload(pendingOwner);
const ownerPayload =
contract.generateAcceptOwnershipPayload(pendingOwner);
Expand Down
31 changes: 15 additions & 16 deletions contract_manager/src/contracts/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,31 +364,30 @@ export class EvmEntropyContract extends Storable {
return new EvmEntropyContract(chain, parsed.address);
}

//TODO: document and move this to executor contract
generateAcceptAdminPayload(executor: string): Buffer {
const contract = this.getContract();
const data = contract.methods.acceptAdmin().encodeABI();
const payload = Buffer.from(data.slice(2), "hex");
// Generate a payload for the given executor address and calldata.
// `executor` and `calldata` should be hex strings.
generatePayload(executor: string, calldata: string) {
return new EvmExecute(
this.chain.wormholeChainName,
executor,
executor.replace("0x", ""),
this.address.replace("0x", ""),
0n,
payload
Buffer.from(calldata.replace("0x", ""), "hex")
).encode();
}

generateAcceptOwnershipPayload(executor: string): Buffer {
// Generates a payload for the newAdmin to call acceptAdmin on the entropy contracts
generateAcceptAdminPayload(newAdmin: string): Buffer {
const contract = this.getContract();
const data = contract.methods.acceptAdmin().encodeABI();
return this.generatePayload(newAdmin, data);
}

// Generates a payload for newOwner to call acceptOwnership on the entropy contracts
generateAcceptOwnershipPayload(newOwner: string): Buffer {
const contract = this.getContract();
const data = contract.methods.acceptOwnership().encodeABI();
const payload = Buffer.from(data.slice(2), "hex");
return new EvmExecute(
this.chain.wormholeChainName,
executor,
this.address.replace("0x", ""),
0n,
payload
).encode();
return this.generatePayload(newOwner, data);
}

getOwner(): string {
Expand Down

0 comments on commit 012472a

Please sign in to comment.