Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[contract_manager] Support for entropy and evm executor #1251

Merged
merged 11 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
0xfirefist marked this conversation as resolved.
Show resolved Hide resolved
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
Loading