Skip to content

Commit

Permalink
feat(contract_manager): basic support for express relay contracts (#1755
Browse files Browse the repository at this point in the history
)
  • Loading branch information
m30m authored Jul 3, 2024
1 parent 3cb45ec commit 3762116
Show file tree
Hide file tree
Showing 9 changed files with 668 additions and 385 deletions.
5 changes: 4 additions & 1 deletion contract_manager/scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const COMMON_DEPLOY_OPTIONS = {
desc: "Save the contract to the store",
},
} as const;
export const COMMON_UPGRADE_OPTIONS = {
export const CHAIN_SELECTION_OPTIONS = {
testnet: {
type: "boolean",
default: false,
Expand All @@ -123,6 +123,9 @@ export const COMMON_UPGRADE_OPTIONS = {
string: true,
desc: "Chains to upgrade the contract on",
},
} as const;
export const COMMON_UPGRADE_OPTIONS = {
...CHAIN_SELECTION_OPTIONS,
"private-key": COMMON_DEPLOY_OPTIONS["private-key"],
"ops-key-path": {
type: "string",
Expand Down
22 changes: 22 additions & 0 deletions contract_manager/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DataSource,
EvmSetWormholeAddress,
UpgradeContract256Bit,
EvmExecute,
} from "@pythnetwork/xc-admin-common";
import { AptosClient, AptosAccount, CoinClient, TxnBuilderTypes } from "aptos";
import Web3 from "web3";
Expand Down Expand Up @@ -371,6 +372,27 @@ export class EvmChain extends Chain {
return new EvmUpgradeContract(this.wormholeChainName, address).encode();
}

/**
* Returns the payload for a governance action from the executor contract
* @param executor the address of the executor contract live on this chain
* @param callAddress the address of the contract to call
* @param calldata the calldata to pass to the contract
* @returns the payload for the governance action
*/
generateExecutorPayload(
executor: string,
callAddress: string,
calldata: string
): Buffer {
return new EvmExecute(
this.wormholeChainName,
executor.replace("0x", ""),
callAddress.replace("0x", ""),
0n,
Buffer.from(calldata.replace("0x", ""), "hex")
).encode();
}

generateGovernanceSetWormholeAddressPayload(address: string): Buffer {
return new EvmSetWormholeAddress(this.wormholeChainName, address).encode();
}
Expand Down
Loading

0 comments on commit 3762116

Please sign in to comment.