Skip to content

Commit 31ad2b6

Browse files
authored
[contract-manager] Evm upgrades (#971)
* Add evm contract infos + minor improvements * Throw error if chainId is invalid instead of using 0 silently * Add wormholeChainName property for chains to use in governance actions * Return all signatures upon proposal execution * Unify privateKey schema for contract manager * Implement getLastExecutedGovernanceSequence for all contract types * Unify getPriceFeed interface between contracts * Add update price feed for evm * Adjust gasPrice on evm * Add setter for datasources + add global chain for universal governance instructions * Add utility function to execute arbitrary governance Vaa * Remove redundant contract * Better error message when gas is not enough on deployment * Add aptos mainnet config * Restore sui override of setFee governance message generation * Export executeVaa function * Address PR feedbacks * More documentation and cleanup * Remove INFURA_KEY logic and replace RPC endpoints with public ones * EVMContract -> EvmContract, EVMChain -> EvmChain * Make executeUpdatePriceFeed interface on cosmos similar to evm * Better error message and more comment regarding gas
1 parent db6bba9 commit 31ad2b6

File tree

133 files changed

+1461
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1461
-377
lines changed

contract_manager/examples/deploy_cosmwasm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import yargs from "yargs";
22
import { hideBin } from "yargs/helpers";
33
import { CosmWasmChain } from "../src/chains";
4-
import { CosmWasmContract } from "../src/cosmwasm";
4+
import { CosmWasmContract } from "../src/contracts/cosmwasm";
55
import { DefaultStore } from "../src/store";
66

77
const parser = yargs(hideBin(process.argv))

contract_manager/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"url": "git+https://github.com/pyth-network/pyth-crosschain.git"
1515
},
1616
"dependencies": {
17+
"@mysten/sui.js": "^0.37.1",
1718
"@certusone/wormhole-sdk": "^0.9.8",
1819
"@pythnetwork/cosmwasm-deploy-tools": "*",
1920
"@pythnetwork/price-service-client": "*",

contract_manager/src/base.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ export abstract class Storable {
2020
abstract toJson(): any;
2121
}
2222

23+
export interface Price {
24+
price: string;
25+
conf: string;
26+
publishTime: string;
27+
expo: string;
28+
}
29+
30+
export interface PriceFeed {
31+
price: Price;
32+
emaPrice: Price;
33+
}
34+
2335
export abstract class Contract extends Storable {
2436
/**
2537
* Returns the time period in seconds that stale data is considered valid for.
@@ -42,12 +54,30 @@ export abstract class Contract extends Storable {
4254
*/
4355
abstract getBaseUpdateFee(): Promise<{ amount: string; denom?: string }>;
4456

57+
/**
58+
* Returns the last governance sequence that was executed on this contract
59+
* this number increases based on the sequence number of the governance messages
60+
* that are executed on this contract
61+
*
62+
* This is used to determine which governance messages are stale and can not be executed
63+
*/
64+
abstract getLastExecutedGovernanceSequence(): Promise<number>;
65+
66+
/**
67+
* Returns the price feed for the given feed id or undefined if not found
68+
* @param feedId hex encoded feed id without 0x prefix
69+
*/
70+
abstract getPriceFeed(feedId: string): Promise<PriceFeed | undefined>;
71+
4572
/**
4673
* Executes the governance instruction contained in the VAA using the sender credentials
47-
* @param sender based on the contract type, this can be a private key, a mnemonic, a wallet, etc.
74+
* @param senderPrivateKey private key of the sender in hex format without 0x prefix
4875
* @param vaa the VAA to execute
4976
*/
50-
abstract executeGovernanceInstruction(sender: any, vaa: Buffer): Promise<any>;
77+
abstract executeGovernanceInstruction(
78+
senderPrivateKey: string,
79+
vaa: Buffer
80+
): Promise<any>;
5181

5282
/**
5383
* Returns the single data source that this contract accepts governance messages from

0 commit comments

Comments
 (0)