Skip to content

Commit 3762116

Browse files
authored
feat(contract_manager): basic support for express relay contracts (#1755)
1 parent 3cb45ec commit 3762116

File tree

9 files changed

+668
-385
lines changed

9 files changed

+668
-385
lines changed

contract_manager/scripts/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const COMMON_DEPLOY_OPTIONS = {
107107
desc: "Save the contract to the store",
108108
},
109109
} as const;
110-
export const COMMON_UPGRADE_OPTIONS = {
110+
export const CHAIN_SELECTION_OPTIONS = {
111111
testnet: {
112112
type: "boolean",
113113
default: false,
@@ -123,6 +123,9 @@ export const COMMON_UPGRADE_OPTIONS = {
123123
string: true,
124124
desc: "Chains to upgrade the contract on",
125125
},
126+
} as const;
127+
export const COMMON_UPGRADE_OPTIONS = {
128+
...CHAIN_SELECTION_OPTIONS,
126129
"private-key": COMMON_DEPLOY_OPTIONS["private-key"],
127130
"ops-key-path": {
128131
type: "string",

contract_manager/src/chains.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
DataSource,
1111
EvmSetWormholeAddress,
1212
UpgradeContract256Bit,
13+
EvmExecute,
1314
} from "@pythnetwork/xc-admin-common";
1415
import { AptosClient, AptosAccount, CoinClient, TxnBuilderTypes } from "aptos";
1516
import Web3 from "web3";
@@ -371,6 +372,27 @@ export class EvmChain extends Chain {
371372
return new EvmUpgradeContract(this.wormholeChainName, address).encode();
372373
}
373374

375+
/**
376+
* Returns the payload for a governance action from the executor contract
377+
* @param executor the address of the executor contract live on this chain
378+
* @param callAddress the address of the contract to call
379+
* @param calldata the calldata to pass to the contract
380+
* @returns the payload for the governance action
381+
*/
382+
generateExecutorPayload(
383+
executor: string,
384+
callAddress: string,
385+
calldata: string
386+
): Buffer {
387+
return new EvmExecute(
388+
this.wormholeChainName,
389+
executor.replace("0x", ""),
390+
callAddress.replace("0x", ""),
391+
0n,
392+
Buffer.from(calldata.replace("0x", ""), "hex")
393+
).encode();
394+
}
395+
374396
generateGovernanceSetWormholeAddressPayload(address: string): Buffer {
375397
return new EvmSetWormholeAddress(this.wormholeChainName, address).encode();
376398
}

0 commit comments

Comments
 (0)