From eef8468a229d1cd22c7a1acec59f22edb24498cf Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Wed, 24 Jan 2024 14:36:10 +0100 Subject: [PATCH] Entropy support in contract manager (#1242) * Rename contracts to PriceFeedContracts * Initial version of EvmEntropyContract --- contract_manager/package.json | 1 + contract_manager/scripts/check_proposal.ts | 11 +- contract_manager/scripts/deploy_cosmwasm.ts | 4 +- contract_manager/scripts/fetch_fees.ts | 12 +- .../scripts/list_evm_contracts.ts | 9 +- contract_manager/scripts/upload_cosmwasm.ts | 4 +- contract_manager/src/base.ts | 2 +- contract_manager/src/contracts/aptos.ts | 21 ++- contract_manager/src/contracts/cosmwasm.ts | 22 +-- contract_manager/src/contracts/evm.ts | 81 ++++++++- contract_manager/src/contracts/sui.ts | 23 ++- contract_manager/src/shell.ts | 8 +- contract_manager/src/store.ts | 38 ++-- .../store/contracts/AptosContracts.yaml | 6 +- .../store/contracts/CosmWasmContracts.yaml | 28 +-- .../store/contracts/EvmContracts.yaml | 171 +++++++++--------- .../store/contracts/SuiContracts.yaml | 8 +- package-lock.json | 2 + .../deploy-scripts/src/instantiate-pyth.ts | 4 +- .../src/instantiate-wormhole.ts | 4 +- .../scripts/contractManagerConfig.js | 4 +- target_chains/sui/cli/src/cli.ts | 8 +- target_chains/sui/cli/src/upgrade_pyth.ts | 6 +- 23 files changed, 286 insertions(+), 191 deletions(-) diff --git a/contract_manager/package.json b/contract_manager/package.json index 7d1d712fb..b1901abb5 100644 --- a/contract_manager/package.json +++ b/contract_manager/package.json @@ -24,6 +24,7 @@ "@injectivelabs/networks": "1.0.68", "@mysten/sui.js": "^0.37.1", "@pythnetwork/cosmwasm-deploy-tools": "*", + "@pythnetwork/entropy-sdk-solidity": "*", "@pythnetwork/price-service-client": "*", "@pythnetwork/pyth-sui-js": "*", "aptos": "^1.5.0", diff --git a/contract_manager/scripts/check_proposal.ts b/contract_manager/scripts/check_proposal.ts index 1117b5f14..3dd2cb498 100644 --- a/contract_manager/scripts/check_proposal.ts +++ b/contract_manager/scripts/check_proposal.ts @@ -18,7 +18,10 @@ import { } from "@pythnetwork/client/lib/cluster"; import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; import { AccountMeta, Keypair, PublicKey } from "@solana/web3.js"; -import { EvmContract, WormholeEvmContract } from "../src/contracts/evm"; +import { + EvmPriceFeedContract, + WormholeEvmContract, +} from "../src/contracts/evm"; import Web3 from "web3"; const parser = yargs(hideBin(process.argv)) @@ -71,11 +74,11 @@ async function main() { const currentIndex = await contract.getCurrentGuardianSetIndex(); const guardianSet = await contract.getGuardianSet(); - const proxyContract = new EvmContract(chain, address); + const proxyContract = new EvmPriceFeedContract(chain, address); const proxyCode = await proxyContract.getCode(); const receiverImplementation = await proxyContract.getImplementationAddress(); - const implementationCode = await new EvmContract( + const implementationCode = await new EvmPriceFeedContract( chain, receiverImplementation ).getCode(); @@ -103,7 +106,7 @@ async function main() { instruction.governanceAction.targetChainId ) { const address = instruction.governanceAction.address; - const contract = new EvmContract(chain, address); + const contract = new EvmPriceFeedContract(chain, address); const code = await contract.getCodeDigestWithoutAddress(); // this should be the same keccak256 of the deployedCode property generated by truffle console.log(`${chain.getId()} Address:${address} digest:${code}`); diff --git a/contract_manager/scripts/deploy_cosmwasm.ts b/contract_manager/scripts/deploy_cosmwasm.ts index fa0eb2392..8212f109b 100644 --- a/contract_manager/scripts/deploy_cosmwasm.ts +++ b/contract_manager/scripts/deploy_cosmwasm.ts @@ -1,7 +1,7 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import { CosmWasmChain } from "../src/chains"; -import { CosmWasmContract } from "../src/contracts/cosmwasm"; +import { CosmWasmPriceFeedContract } from "../src/contracts/cosmwasm"; import { DefaultStore } from "../src/store"; const parser = yargs(hideBin(process.argv)) @@ -36,7 +36,7 @@ async function main() { const argv = await parser.argv; const { code, wormholeContract } = argv; console.log( - await CosmWasmContract.deploy( + await CosmWasmPriceFeedContract.deploy( DefaultStore.chains[argv.chain] as CosmWasmChain, wormholeContract, argv["private-key"], diff --git a/contract_manager/scripts/fetch_fees.ts b/contract_manager/scripts/fetch_fees.ts index 29e13cb3a..b5e0398be 100644 --- a/contract_manager/scripts/fetch_fees.ts +++ b/contract_manager/scripts/fetch_fees.ts @@ -1,10 +1,10 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import { - AptosContract, - CosmWasmContract, + AptosPriceFeedContract, + CosmWasmPriceFeedContract, DefaultStore, - EvmContract, + EvmPriceFeedContract, } from "../src"; const parser = yargs(hideBin(process.argv)) @@ -22,9 +22,9 @@ async function main() { for (const contract of Object.values(DefaultStore.contracts)) { if (contract.getChain().isMainnet() === argv.testnet) continue; if ( - contract instanceof AptosContract || - contract instanceof EvmContract || - contract instanceof CosmWasmContract + contract instanceof AptosPriceFeedContract || + contract instanceof EvmPriceFeedContract || + contract instanceof CosmWasmPriceFeedContract ) { try { console.log(`${contract.getId()} ${await contract.getTotalFee()}`); diff --git a/contract_manager/scripts/list_evm_contracts.ts b/contract_manager/scripts/list_evm_contracts.ts index 51794d4a9..7c36eea33 100644 --- a/contract_manager/scripts/list_evm_contracts.ts +++ b/contract_manager/scripts/list_evm_contracts.ts @@ -1,10 +1,10 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import { - AptosContract, - CosmWasmContract, + AptosPriceFeedContract, + CosmWasmPriceFeedContract, DefaultStore, - EvmContract, + EvmPriceFeedContract, } from "../src"; const parser = yargs(hideBin(process.argv)) @@ -22,7 +22,8 @@ async function main() { const entries = []; for (const contract of Object.values(DefaultStore.contracts)) { if (contract.getChain().isMainnet() === argv.testnet) continue; - if (contract instanceof EvmContract) { + if (contract instanceof EvmPriceFeedContract) { + let wormholeContract = await contract.getWormholeContract(); try { const version = await contract.getVersion(); entries.push({ diff --git a/contract_manager/scripts/upload_cosmwasm.ts b/contract_manager/scripts/upload_cosmwasm.ts index 9bf7501ae..2cbc0faf3 100644 --- a/contract_manager/scripts/upload_cosmwasm.ts +++ b/contract_manager/scripts/upload_cosmwasm.ts @@ -1,7 +1,7 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import { CosmWasmChain } from "../src/chains"; -import { CosmWasmContract } from "../src/contracts/cosmwasm"; +import { CosmWasmPriceFeedContract } from "../src/contracts/cosmwasm"; import { DefaultStore } from "../src/store"; import { toPrivateKey } from "../src"; @@ -30,7 +30,7 @@ const parser = yargs(hideBin(process.argv)) async function main() { const argv = await parser.argv; const { code } = argv; - const { codeId } = await CosmWasmContract.storeCode( + const { codeId } = await CosmWasmPriceFeedContract.storeCode( DefaultStore.chains[argv.chain] as CosmWasmChain, toPrivateKey(argv["private-key"]), code diff --git a/contract_manager/src/base.ts b/contract_manager/src/base.ts index c75370be6..bd2f4759f 100644 --- a/contract_manager/src/base.ts +++ b/contract_manager/src/base.ts @@ -50,7 +50,7 @@ export interface PriceFeed { emaPrice: Price; } -export abstract class Contract extends Storable { +export abstract class PriceFeedContract extends Storable { /** * Returns the time period in seconds that stale data is considered valid for. */ diff --git a/contract_manager/src/contracts/aptos.ts b/contract_manager/src/contracts/aptos.ts index 821779a5a..e21a15110 100644 --- a/contract_manager/src/contracts/aptos.ts +++ b/contract_manager/src/contracts/aptos.ts @@ -1,4 +1,4 @@ -import { Contract, PriceFeed, PrivateKey, TxResult } from "../base"; +import { PriceFeedContract, PriceFeed, PrivateKey, TxResult } from "../base"; import { ApiError, BCS, CoinClient, TxnBuilderTypes } from "aptos"; import { AptosChain, Chain } from "../chains"; import { DataSource } from "xc_admin_common"; @@ -70,8 +70,8 @@ export class WormholeAptosContract extends WormholeContract { } } -export class AptosContract extends Contract { - static type = "AptosContract"; +export class AptosPriceFeedContract extends PriceFeedContract { + static type = "AptosPriceFeedContract"; /** * Given the ids of the pyth state and wormhole state, create a new AptosContract @@ -92,11 +92,16 @@ export class AptosContract extends Contract { static fromJson( chain: Chain, parsed: { type: string; stateId: string; wormholeStateId: string } - ): AptosContract { - if (parsed.type !== AptosContract.type) throw new Error("Invalid type"); + ): AptosPriceFeedContract { + if (parsed.type !== AptosPriceFeedContract.type) + throw new Error("Invalid type"); if (!(chain instanceof AptosChain)) throw new Error(`Wrong chain type ${chain}`); - return new AptosContract(chain, parsed.stateId, parsed.wormholeStateId); + return new AptosPriceFeedContract( + chain, + parsed.stateId, + parsed.wormholeStateId + ); } async executeGovernanceInstruction( @@ -252,7 +257,7 @@ export class AptosContract extends Contract { } getType(): string { - return AptosContract.type; + return AptosPriceFeedContract.type; } async getTotalFee(): Promise { @@ -272,7 +277,7 @@ export class AptosContract extends Contract { chain: this.chain.getId(), stateId: this.stateId, wormholeStateId: this.wormholeStateId, - type: AptosContract.type, + type: AptosPriceFeedContract.type, }; } } diff --git a/contract_manager/src/contracts/cosmwasm.ts b/contract_manager/src/contracts/cosmwasm.ts index 4da3002ae..962593415 100644 --- a/contract_manager/src/contracts/cosmwasm.ts +++ b/contract_manager/src/contracts/cosmwasm.ts @@ -11,7 +11,7 @@ import { Coin } from "@cosmjs/stargate"; import { DataSource } from "xc_admin_common"; import { CosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { - Contract, + PriceFeedContract, getDefaultDeploymentConfig, PrivateKey, TxResult, @@ -89,7 +89,8 @@ export class WormholeCosmWasmContract extends WormholeContract { } } -export class CosmWasmContract extends Contract { +export class CosmWasmPriceFeedContract extends PriceFeedContract { + static type = "CosmWasmPriceFeedContract"; async getDataSources(): Promise { const config = await this.getConfig(); return config.config_v1.data_sources.map( @@ -112,8 +113,6 @@ export class CosmWasmContract extends Contract { }; } - static type = "CosmWasmContract"; - constructor(public chain: CosmWasmChain, public address: string) { super(); } @@ -121,15 +120,16 @@ export class CosmWasmContract extends Contract { static fromJson( chain: Chain, parsed: { type: string; address: string } - ): CosmWasmContract { - if (parsed.type !== CosmWasmContract.type) throw new Error("Invalid type"); + ): CosmWasmPriceFeedContract { + if (parsed.type !== CosmWasmPriceFeedContract.type) + throw new Error("Invalid type"); if (!(chain instanceof CosmWasmChain)) throw new Error(`Wrong chain type ${chain}`); - return new CosmWasmContract(chain, parsed.address); + return new CosmWasmPriceFeedContract(chain, parsed.address); } getType(): string { - return CosmWasmContract.type; + return CosmWasmPriceFeedContract.type; } /** @@ -161,7 +161,7 @@ export class CosmWasmContract extends Contract { codeId: number, config: DeploymentConfig, privateKey: PrivateKey - ): Promise { + ): Promise { const executor = await chain.getExecutor(privateKey); const result = await executor.instantiateContract({ codeId: codeId, @@ -172,7 +172,7 @@ export class CosmWasmContract extends Contract { newAdminAddr: result.contractAddr, contractAddr: result.contractAddr, }); - return new CosmWasmContract(chain, result.contractAddr); + return new CosmWasmPriceFeedContract(chain, result.contractAddr); } getId(): string { @@ -183,7 +183,7 @@ export class CosmWasmContract extends Contract { return { chain: this.chain.getId(), address: this.address, - type: CosmWasmContract.type, + type: CosmWasmPriceFeedContract.type, }; } diff --git a/contract_manager/src/contracts/evm.ts b/contract_manager/src/contracts/evm.ts index e1b808e4e..4013d4c79 100644 --- a/contract_manager/src/contracts/evm.ts +++ b/contract_manager/src/contracts/evm.ts @@ -1,6 +1,7 @@ import Web3 from "web3"; import PythInterfaceAbi from "@pythnetwork/pyth-sdk-solidity/abis/IPyth.json"; -import { Contract, PrivateKey } from "../base"; +import EntropyAbi from "@pythnetwork/entropy-sdk-solidity/abis/IEntropy.json"; +import { PriceFeedContract, PrivateKey, Storable } from "../base"; import { Chain, EvmChain } from "../chains"; import { DataSource } from "xc_admin_common"; import { WormholeContract } from "./wormhole"; @@ -281,8 +282,71 @@ export class WormholeEvmContract extends WormholeContract { } } -export class EvmContract extends Contract { - static type = "EvmContract"; +interface EntropyProviderInfo { + feeInWei: string; + accruedFeesInWei: string; + originalCommitment: string; + originalCommitmentSequenceNumber: string; + commitmentMetadata: string; + uri: string; + endSequenceNumber: string; + sequenceNumber: string; + currentCommitment: string; + currentCommitmentSequenceNumber: string; +} + +export class EvmEntropyContract extends Storable { + static type = "EvmEntropyContract"; + + constructor(public chain: EvmChain, public address: string) { + super(); + } + + getId(): string { + return `${this.chain.getId()}_${this.address}`; + } + + getType(): string { + return EvmEntropyContract.type; + } + + static fromJson( + chain: Chain, + parsed: { type: string; address: string } + ): EvmEntropyContract { + if (parsed.type !== EvmEntropyContract.type) + throw new Error("Invalid type"); + if (!(chain instanceof EvmChain)) + throw new Error(`Wrong chain type ${chain}`); + return new EvmEntropyContract(chain, parsed.address); + } + + toJson() { + return { + chain: this.chain.getId(), + address: this.address, + type: EvmPriceFeedContract.type, + }; + } + + getContract() { + const web3 = new Web3(this.chain.getRpcUrl()); + return new web3.eth.Contract(EntropyAbi as any, this.address); // eslint-disable-line @typescript-eslint/no-explicit-any + } + + async getDefaultProvider(): Promise { + const contract = this.getContract(); + return await contract.methods.getDefaultProvider().call(); + } + + async getProviderInfo(address: string): Promise { + const contract = this.getContract(); + return await contract.methods.getProviderInfo(address).call(); + } +} + +export class EvmPriceFeedContract extends PriceFeedContract { + static type = "EvmPriceFeedContract"; constructor(public chain: EvmChain, public address: string) { super(); @@ -291,11 +355,12 @@ export class EvmContract extends Contract { static fromJson( chain: Chain, parsed: { type: string; address: string } - ): EvmContract { - if (parsed.type !== EvmContract.type) throw new Error("Invalid type"); + ): EvmPriceFeedContract { + if (parsed.type !== EvmPriceFeedContract.type) + throw new Error("Invalid type"); if (!(chain instanceof EvmChain)) throw new Error(`Wrong chain type ${chain}`); - return new EvmContract(chain, parsed.address); + return new EvmPriceFeedContract(chain, parsed.address); } getId(): string { @@ -303,7 +368,7 @@ export class EvmContract extends Contract { } getType(): string { - return EvmContract.type; + return EvmPriceFeedContract.type; } async getVersion(): Promise { @@ -496,7 +561,7 @@ export class EvmContract extends Contract { return { chain: this.chain.getId(), address: this.address, - type: EvmContract.type, + type: EvmPriceFeedContract.type, }; } } diff --git a/contract_manager/src/contracts/sui.ts b/contract_manager/src/contracts/sui.ts index b4408c6d5..75247093e 100644 --- a/contract_manager/src/contracts/sui.ts +++ b/contract_manager/src/contracts/sui.ts @@ -7,15 +7,15 @@ import { } from "@mysten/sui.js"; import { Chain, SuiChain } from "../chains"; import { DataSource } from "xc_admin_common"; -import { Contract, PrivateKey, TxResult } from "../base"; +import { PriceFeedContract, PrivateKey, TxResult } from "../base"; import { SuiPythClient } from "@pythnetwork/pyth-sui-js"; -export class SuiContract extends Contract { - static type = "SuiContract"; +export class SuiPriceFeedContract extends PriceFeedContract { + static type = "SuiPriceFeedContract"; private client: SuiPythClient; /** - * Given the ids of the pyth state and wormhole state, create a new SuiContract + * Given the ids of the pyth state and wormhole state, create a new SuiPriceFeedContract * The package ids are derived based on the state ids * * @param chain the chain which this contract is deployed on @@ -38,15 +38,20 @@ export class SuiContract extends Contract { static fromJson( chain: Chain, parsed: { type: string; stateId: string; wormholeStateId: string } - ): SuiContract { - if (parsed.type !== SuiContract.type) throw new Error("Invalid type"); + ): SuiPriceFeedContract { + if (parsed.type !== SuiPriceFeedContract.type) + throw new Error("Invalid type"); if (!(chain instanceof SuiChain)) throw new Error(`Wrong chain type ${chain}`); - return new SuiContract(chain, parsed.stateId, parsed.wormholeStateId); + return new SuiPriceFeedContract( + chain, + parsed.stateId, + parsed.wormholeStateId + ); } getType(): string { - return SuiContract.type; + return SuiPriceFeedContract.type; } getChain(): SuiChain { @@ -58,7 +63,7 @@ export class SuiContract extends Contract { chain: this.chain.getId(), stateId: this.stateId, wormholeStateId: this.wormholeStateId, - type: SuiContract.type, + type: SuiPriceFeedContract.type, }; } diff --git a/contract_manager/src/shell.ts b/contract_manager/src/shell.ts index 6af377fca..47b30b093 100644 --- a/contract_manager/src/shell.ts +++ b/contract_manager/src/shell.ts @@ -7,10 +7,10 @@ repl.start(); repl.evalCode( "import { loadHotWallet, Vault } from './src/governance';" + "import { SuiChain, CosmWasmChain, AptosChain, EvmChain } from './src/chains';" + - "import { SuiContract } from './src/contracts/sui';" + - "import { WormholeCosmWasmContract, CosmWasmContract } from './src/contracts/cosmwasm';" + - "import { WormholeEvmContract, EvmContract } from './src/contracts/evm';" + - "import { WormholeAptosContract, AptosContract } from './src/contracts/aptos';" + + "import { SuiPriceFeedContract } from './src/contracts/sui';" + + "import { WormholeCosmWasmContract, CosmWasmPriceFeedContract } from './src/contracts/cosmwasm';" + + "import { WormholeEvmContract, EvmPriceFeedContract } from './src/contracts/evm';" + + "import { WormholeAptosContract, AptosPriceFeedContract } from './src/contracts/aptos';" + "import { DefaultStore } from './src/store';" + "import { toPrivateKey } from './src/base';" + "DefaultStore" diff --git a/contract_manager/src/store.ts b/contract_manager/src/store.ts index 3448433bb..37707abdd 100644 --- a/contract_manager/src/store.ts +++ b/contract_manager/src/store.ts @@ -7,19 +7,21 @@ import { SuiChain, } from "./chains"; import { - AptosContract, - CosmWasmContract, - EvmContract, - SuiContract, + AptosPriceFeedContract, + CosmWasmPriceFeedContract, + EvmEntropyContract, + EvmPriceFeedContract, + SuiPriceFeedContract, } from "./contracts"; -import { Contract } from "./base"; +import { PriceFeedContract } from "./base"; import { parse, stringify } from "yaml"; import { readdirSync, readFileSync, statSync, writeFileSync } from "fs"; import { Vault } from "./governance"; export class Store { public chains: Record = { global: new GlobalChain() }; - public contracts: Record = {}; + public contracts: Record = {}; + public entropy_contracts: Record = {}; public vaults: Record = {}; constructor(public path: string) { @@ -28,7 +30,7 @@ export class Store { this.loadAllVaults(); } - static serialize(obj: Contract | Chain | Vault) { + static serialize(obj: PriceFeedContract | Chain | Vault) { return stringify([obj.toJson()]); } @@ -73,7 +75,7 @@ export class Store { } saveAllContracts() { - const contractsByType: Record = {}; + const contractsByType: Record = {}; for (const contract of Object.values(this.contracts)) { if (!contractsByType[contract.getType()]) { contractsByType[contract.getType()] = []; @@ -106,10 +108,11 @@ export class Store { loadAllContracts() { const allContractClasses = { - [CosmWasmContract.type]: CosmWasmContract, - [SuiContract.type]: SuiContract, - [EvmContract.type]: EvmContract, - [AptosContract.type]: AptosContract, + [CosmWasmPriceFeedContract.type]: CosmWasmPriceFeedContract, + [SuiPriceFeedContract.type]: SuiPriceFeedContract, + [EvmPriceFeedContract.type]: EvmPriceFeedContract, + [AptosPriceFeedContract.type]: AptosPriceFeedContract, + [EvmEntropyContract.type]: EvmEntropyContract, }; this.getYamlFiles(`${this.path}/contracts/`).forEach((yamlFile) => { const parsedArray = parse(readFileSync(yamlFile, "utf-8")); @@ -122,11 +125,18 @@ export class Store { chain, parsed ); - if (this.contracts[chainContract.getId()]) + if ( + this.contracts[chainContract.getId()] || + this.entropy_contracts[chainContract.getId()] + ) throw new Error( `Multiple contracts with id ${chainContract.getId()} found` ); - this.contracts[chainContract.getId()] = chainContract; + if (chainContract instanceof EvmEntropyContract) { + this.entropy_contracts[chainContract.getId()] = chainContract; + } else { + this.contracts[chainContract.getId()] = chainContract; + } } }); } diff --git a/contract_manager/store/contracts/AptosContracts.yaml b/contract_manager/store/contracts/AptosContracts.yaml index 7ebe5d72c..6437cea1d 100644 --- a/contract_manager/store/contracts/AptosContracts.yaml +++ b/contract_manager/store/contracts/AptosContracts.yaml @@ -1,12 +1,12 @@ - chain: aptos_mainnet stateId: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387" wormholeStateId: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625" - type: AptosContract + type: AptosPriceFeedContract - chain: aptos_testnet stateId: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387" wormholeStateId: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625" - type: AptosContract + type: AptosPriceFeedContract - chain: movement_move_devnet stateId: "0x9357e76fe965c9956a76181ee49f66d51b7f9c3800182a944ed96be86301e49f" wormholeStateId: "0x9236893d6444b208b7e0b3e8d4be4ace90b6d17817ab7d1584e46a33ef5c50c9" - type: AptosContract + type: AptosPriceFeedContract diff --git a/contract_manager/store/contracts/CosmWasmContracts.yaml b/contract_manager/store/contracts/CosmWasmContracts.yaml index 3621c19e8..0887a689e 100644 --- a/contract_manager/store/contracts/CosmWasmContracts.yaml +++ b/contract_manager/store/contracts/CosmWasmContracts.yaml @@ -1,42 +1,42 @@ - chain: injective_testnet address: inj18rlflp3735h25jmjx97d22c72sxk260amdjxlu - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: juno_testnet address: juno1eacsrua27njc35pxz37y97gmcjs899t59f8pf0rkejjyvtmhws5q6lxsdd - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: sei_testnet_atlantic_2 address: sei1kpntez76v38yuxhhaaahdmvjxnr5tkr8tq077smefs7uw70rj5yqw2aewy - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: neutron_testnet_pion_1 address: neutron15ldst8t80982akgr8w8ekcytejzkmfpgdkeq4xgtge48qs7435jqp87u3t - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: osmosis address: osmo13ge29x4e2s63a8ytz2px8gurtyznmue4a69n5275692v3qn3ks8q7cwck7 - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: injective address: inj12j43nf2f0qumnt2zrrmpvnsqgzndxefujlvr08 - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: sei_testnet_atlantic_2 address: sei1w2rxq6eckak47s25crxlhmq96fzjwdtjgdwavn56ggc0qvxvw7rqczxyfy - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: sei_pacific_1 address: sei15d2tyq2jzxmpg32y3am3w62dts32qgzmds9qnr6c87r0gwwr7ynqal0x38 - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: osmosis_testnet_5 address: osmo1lltupx02sj99suakmuk4sr4ppqf34ajedaxut3ukjwkv6469erwqtpg9t3 - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: osmosis_testnet_5 address: osmo1hpdzqku55lmfmptpyj6wdlugqs5etr6teqf7r4yqjjrxjznjhtuqqu5kdh - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: neutron address: neutron1m2emc93m9gpwgsrsf2vylv9xvgqh654630v7dfrhrkmr5slly53spg85wv - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: injective_testnet address: inj18hckkzqf47mdhd734g6papk6wj20y24rm43sk9 - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: juno_testnet address: juno1h93q9kwlnfml2gum4zj54al9w4jdmuhtzrh6vhycnemsqlqv9l9snnznxs - type: CosmWasmContract + type: CosmWasmPriceFeedContract - chain: neutron_testnet_pion_1 address: neutron16zwrmx3zgggmxhzau86xfycm42cr4sj888hdvzsxya3qarp6zhhqzhlkvz - type: CosmWasmContract + type: CosmWasmPriceFeedContract diff --git a/contract_manager/store/contracts/EvmContracts.yaml b/contract_manager/store/contracts/EvmContracts.yaml index 4ab88df4a..d15cce113 100644 --- a/contract_manager/store/contracts/EvmContracts.yaml +++ b/contract_manager/store/contracts/EvmContracts.yaml @@ -1,252 +1,255 @@ - chain: evmos address: "0x354bF866A4B006C9AF9d9e06d9364217A8616E12" - type: EvmContract + type: EvmPriceFeedContract - chain: ethereum address: "0x4305FB66699C3B2702D4d05CF36551390A4c69C6" - type: EvmContract + type: EvmPriceFeedContract - chain: polygon address: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C" - type: EvmContract + type: EvmPriceFeedContract - chain: aurora address: "0xF89C7b475821EC3fDC2dC8099032c05c6c0c9AB9" - type: EvmContract + type: EvmPriceFeedContract - chain: fantom address: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C" - type: EvmContract + type: EvmPriceFeedContract - chain: optimism address: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C" - type: EvmContract + type: EvmPriceFeedContract - chain: arbitrum address: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C" - type: EvmContract + type: EvmPriceFeedContract - chain: gnosis address: "0x2880aB155794e7179c9eE2e38200202908C17B43" - type: EvmContract + type: EvmPriceFeedContract - chain: polygon_zkevm address: "0xC5E56d6b40F3e3B5fbfa266bCd35C37426537c65" - type: EvmContract + type: EvmPriceFeedContract - chain: conflux_espace address: "0xe9d69CdD6Fe41e7B621B4A688C5D1a68cB5c8ADc" - type: EvmContract + type: EvmPriceFeedContract - chain: bsc address: "0x4D7E825f80bDf85e913E0DD2A2D54927e9dE1594" - type: EvmContract + type: EvmPriceFeedContract - chain: kava address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: avalanche address: "0x4305FB66699C3B2702D4d05CF36551390A4c69C6" - type: EvmContract + type: EvmPriceFeedContract - chain: canto address: "0x98046Bd286715D3B0BC227Dd7a956b83D8978603" - type: EvmContract + type: EvmPriceFeedContract - chain: linea address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: neon address: "0x7f2dB085eFC3560AFF33865dD727225d91B4f9A5" - type: EvmContract + type: EvmPriceFeedContract - chain: mantle address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: meter address: "0xbFe3f445653f2136b2FD1e6DdDb5676392E3AF16" - type: EvmContract + type: EvmPriceFeedContract - chain: kcc address: "0xE0d0e68297772Dd5a1f1D99897c581E2082dbA5B" - type: EvmContract + type: EvmPriceFeedContract - chain: eos address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: celo address: "0xff1a0f4744e8582DF1aE09D5611b887B6a12925C" - type: EvmContract + type: EvmPriceFeedContract - chain: wemix address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: base address: "0x8250f4aF4B972684F7b336503E2D6dFeDeB1487a" - type: EvmContract + type: EvmPriceFeedContract - chain: cronos address: "0xE0d0e68297772Dd5a1f1D99897c581E2082dbA5B" - type: EvmContract + type: EvmPriceFeedContract - chain: zksync address: "0xf087c864AEccFb6A2Bf1Af6A0382B0d0f6c5D834" - type: EvmContract + type: EvmPriceFeedContract - chain: ronin address: "0x2880aB155794e7179c9eE2e38200202908C17B43" - type: EvmContract + type: EvmPriceFeedContract - chain: horizen_eon address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: shimmer address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: boba address: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF" - type: EvmContract + type: EvmPriceFeedContract - chain: manta address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: scroll address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: chiliz address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: coredao address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: tomochain address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: base_goerli address: "0xEbe57e8045F2F230872523bbff7374986E45C486" - type: EvmContract + type: EvmPriceFeedContract - chain: arbitrum_sepolia address: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF" - type: EvmContract + type: EvmPriceFeedContract - chain: fuji address: "0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509" - type: EvmContract + type: EvmPriceFeedContract - chain: canto_testnet address: "0x26DD80569a8B23768A1d80869Ed7339e07595E85" - type: EvmContract + type: EvmPriceFeedContract - chain: polygon_zkevm_testnet address: "0xFf255f800044225f54Af4510332Aa3D67CC77635" - type: EvmContract + type: EvmPriceFeedContract - chain: aurora_testnet address: "0x74f09cb3c7e2A01865f424FD14F6dc9A14E3e94E" - type: EvmContract + type: EvmPriceFeedContract - chain: mantle_testnet address: "0xDd24F84d36BF92C65F92307595335bdFab5Bbd21" - type: EvmContract + type: EvmPriceFeedContract - chain: chiado address: "0x98046Bd286715D3B0BC227Dd7a956b83D8978603" - type: EvmContract + type: EvmPriceFeedContract - chain: kava_testnet address: "0xfA25E653b44586dBbe27eE9d252192F0e4956683" - type: EvmContract + type: EvmPriceFeedContract - chain: conflux_espace_testnet address: "0xDd24F84d36BF92C65F92307595335bdFab5Bbd21" - type: EvmContract + type: EvmPriceFeedContract - chain: celo_alfajores_testnet address: "0x74f09cb3c7e2A01865f424FD14F6dc9A14E3e94E" - type: EvmContract + type: EvmPriceFeedContract - chain: bsc_testnet address: "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb" - type: EvmContract + type: EvmPriceFeedContract - chain: syndr_nitro_testnet address: "0xEbe57e8045F2F230872523bbff7374986E45C486" - type: EvmContract + type: EvmPriceFeedContract - chain: kcc_testnet address: "0x74f09cb3c7e2A01865f424FD14F6dc9A14E3e94E" - type: EvmContract + type: EvmPriceFeedContract - chain: eos_testnet address: "0x0708325268dF9F66270F1401206434524814508b" - type: EvmContract + type: EvmPriceFeedContract - chain: meter_testnet address: "0x5a71C07a0588074443545eE0c08fb0375564c3E4" - type: EvmContract + type: EvmPriceFeedContract - chain: optimism_goerli address: "0xDd24F84d36BF92C65F92307595335bdFab5Bbd21" - type: EvmContract + type: EvmPriceFeedContract - chain: shimmer_testnet address: "0x8D254a21b3C86D32F7179855531CE99164721933" - type: EvmContract + type: EvmPriceFeedContract - chain: scroll_sepolia address: "0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c" - type: EvmContract + type: EvmPriceFeedContract - chain: saigon address: "0xEbe57e8045F2F230872523bbff7374986E45C486" - type: EvmContract + type: EvmPriceFeedContract - chain: boba_goerli address: "0x8D254a21b3C86D32F7179855531CE99164721933" - type: EvmContract + type: EvmPriceFeedContract - chain: manta_testnet address: "0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c" - type: EvmContract + type: EvmPriceFeedContract - chain: chiliz_spicy address: "0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509" - type: EvmContract + type: EvmPriceFeedContract - chain: astar_testnet address: "0x8D254a21b3C86D32F7179855531CE99164721933" - type: EvmContract + type: EvmPriceFeedContract - chain: coredao_testnet address: "0x8D254a21b3C86D32F7179855531CE99164721933" - type: EvmContract + type: EvmPriceFeedContract - chain: tomochain_testnet address: "0x5D289Ad1CE59fCC25b6892e7A303dfFf3a9f7167" - type: EvmContract + type: EvmPriceFeedContract - chain: cronos_testnet address: "0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320" - type: EvmContract + type: EvmPriceFeedContract - chain: wemix_testnet address: "0x26DD80569a8B23768A1d80869Ed7339e07595E85" - type: EvmContract + type: EvmPriceFeedContract - chain: mumbai address: "0xFC6bd9F9f0c6481c6Af3A7Eb46b296A5B85ed379" - type: EvmContract + type: EvmPriceFeedContract - chain: fantom_testnet address: "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb" - type: EvmContract + type: EvmPriceFeedContract - chain: sepolia address: "0x26DD80569a8B23768A1d80869Ed7339e07595E85" - type: EvmContract + type: EvmPriceFeedContract - chain: sepolia address: "0xDd24F84d36BF92C65F92307595335bdFab5Bbd21" - type: EvmContract + type: EvmPriceFeedContract - chain: linea_goerli address: "0xdF21D137Aadc95588205586636710ca2890538d5" - type: EvmContract + type: EvmPriceFeedContract - chain: evmos_testnet address: "0x74f09cb3c7e2A01865f424FD14F6dc9A14E3e94E" - type: EvmContract + type: EvmPriceFeedContract - chain: zetachain_testnet address: "0x0708325268dF9F66270F1401206434524814508b" - type: EvmContract + type: EvmPriceFeedContract - chain: neon_devnet address: "0x0708325268dF9F66270F1401206434524814508b" - type: EvmContract + type: EvmPriceFeedContract - chain: zksync_goerli address: "0x8739d5024B5143278E2b15Bd9e7C26f6CEc658F1" - type: EvmContract + type: EvmPriceFeedContract - chain: optimism_sepolia address: "0x0708325268dF9F66270F1401206434524814508b" - type: EvmContract + type: EvmPriceFeedContract - chain: mode address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: mode_testnet address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: bttc_testnet address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: bttc address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: zksync_sepolia address: "0x056f829183Ec806A78c26C98961678c24faB71af" - type: EvmContract + type: EvmPriceFeedContract - chain: base_sepolia address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: movement_evm_devnet address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: zkfair_testnet address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: blast_s2_testnet address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: zkfair address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: filecoin_calibration address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract - chain: filecoin address: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729" - type: EvmContract + type: EvmPriceFeedContract +- chain: base_goerli + address: "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF" + type: EvmEntropyContract diff --git a/contract_manager/store/contracts/SuiContracts.yaml b/contract_manager/store/contracts/SuiContracts.yaml index 49ea44109..b995a3617 100644 --- a/contract_manager/store/contracts/SuiContracts.yaml +++ b/contract_manager/store/contracts/SuiContracts.yaml @@ -1,16 +1,16 @@ - chain: sui_mainnet stateId: "0xf9ff3ef935ef6cdfb659a203bf2754cebeb63346e29114a535ea6f41315e5a3f" wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c" - type: SuiContract + type: SuiPriceFeedContract - chain: sui_mainnet stateId: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8" wormholeStateId: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c" - type: SuiContract + type: SuiPriceFeedContract - chain: sui_testnet stateId: "0xb3142a723792001caafc601b7c6fe38f09f3684e360b56d8d90fc574e71e75f3" wormholeStateId: "0xebba4cc4d614f7a7cdbe883acc76d1cc767922bc96778e7b68be0d15fce27c02" - type: SuiContract + type: SuiPriceFeedContract - chain: sui_testnet stateId: "0x2d82612a354f0b7e52809fc2845642911c7190404620cec8688f68808f8800d8" wormholeStateId: "0xebba4cc4d614f7a7cdbe883acc76d1cc767922bc96778e7b68be0d15fce27c02" - type: SuiContract + type: SuiPriceFeedContract diff --git a/package-lock.json b/package-lock.json index 40082f4dd..dc50ce80e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "@injectivelabs/networks": "1.0.68", "@mysten/sui.js": "^0.37.1", "@pythnetwork/cosmwasm-deploy-tools": "*", + "@pythnetwork/entropy-sdk-solidity": "*", "@pythnetwork/price-service-client": "*", "@pythnetwork/pyth-sui-js": "*", "aptos": "^1.5.0", @@ -79727,6 +79728,7 @@ "@injectivelabs/networks": "1.0.68", "@mysten/sui.js": "^0.37.1", "@pythnetwork/cosmwasm-deploy-tools": "*", + "@pythnetwork/entropy-sdk-solidity": "*", "@pythnetwork/price-service-client": "*", "@pythnetwork/pyth-sui-js": "*", "aptos": "^1.5.0", diff --git a/target_chains/cosmwasm/deploy-scripts/src/instantiate-pyth.ts b/target_chains/cosmwasm/deploy-scripts/src/instantiate-pyth.ts index 01c13365f..9b8f33f2d 100644 --- a/target_chains/cosmwasm/deploy-scripts/src/instantiate-pyth.ts +++ b/target_chains/cosmwasm/deploy-scripts/src/instantiate-pyth.ts @@ -4,7 +4,7 @@ import { sha256 } from "@cosmjs/crypto"; import { getPythConfig } from "./configs"; import { CosmWasmChain, - CosmWasmContract, + CosmWasmPriceFeedContract, DefaultStore, Store, toPrivateKey, @@ -96,7 +96,7 @@ async function run() { }); console.log(`Contract admin set to ${address}`); - const contract = new CosmWasmContract(chain, address); + const contract = new CosmWasmPriceFeedContract(chain, address); DefaultStore.contracts[contract.getId()] = contract; DefaultStore.saveAllContracts(); console.log("Added the following to your CosmWasm contracts configs"); diff --git a/target_chains/cosmwasm/deploy-scripts/src/instantiate-wormhole.ts b/target_chains/cosmwasm/deploy-scripts/src/instantiate-wormhole.ts index 4ba5eb2bc..35b6335ab 100644 --- a/target_chains/cosmwasm/deploy-scripts/src/instantiate-wormhole.ts +++ b/target_chains/cosmwasm/deploy-scripts/src/instantiate-wormhole.ts @@ -3,7 +3,7 @@ import { hideBin } from "yargs/helpers"; import { getWormholeConfig } from "./configs"; import { CosmWasmChain, - CosmWasmContract, + CosmWasmPriceFeedContract, DefaultStore, toPrivateKey, WormholeCosmWasmContract, @@ -47,7 +47,7 @@ async function run() { throw new Error(`Chain ${argv.chain} not found or not a CosmWasmChain`); } const privateKey = toPrivateKey(argv["private-key"]); - const storeCodeRes = await CosmWasmContract.storeCode( + const storeCodeRes = await CosmWasmPriceFeedContract.storeCode( chain, privateKey, wasmFilePath diff --git a/target_chains/ethereum/contracts/scripts/contractManagerConfig.js b/target_chains/ethereum/contracts/scripts/contractManagerConfig.js index e794a0d79..67292a722 100644 --- a/target_chains/ethereum/contracts/scripts/contractManagerConfig.js +++ b/target_chains/ethereum/contracts/scripts/contractManagerConfig.js @@ -1,5 +1,5 @@ const { - EvmContract, + EvmPriceFeedContract, DefaultStore, Store, getDefaultDeploymentConfig, @@ -47,7 +47,7 @@ function getDefaultConfig(_chainName) { } function saveConfig(chainName, address) { const chain = DefaultStore.chains[chainName]; - const contract = new EvmContract(chain, address); + const contract = new EvmPriceFeedContract(chain, address); DefaultStore.contracts[contract.getId()] = contract; DefaultStore.saveAllContracts(); console.log("Added the following to your evm contract configs"); diff --git a/target_chains/sui/cli/src/cli.ts b/target_chains/sui/cli/src/cli.ts index 24ed8c95a..24cd952db 100644 --- a/target_chains/sui/cli/src/cli.ts +++ b/target_chains/sui/cli/src/cli.ts @@ -4,7 +4,7 @@ import { DefaultStore, getDefaultDeploymentConfig, SuiChain, - SuiContract, + SuiPriceFeedContract, } from "contract_manager"; import { PriceServiceConnection } from "@pythnetwork/price-service-client"; import { execSync } from "child_process"; @@ -49,8 +49,8 @@ const OPTIONS = { }, } as const; -function getContract(contractId: string): SuiContract { - const contract = DefaultStore.contracts[contractId] as SuiContract; +function getContract(contractId: string): SuiPriceFeedContract { + const contract = DefaultStore.contracts[contractId] as SuiPriceFeedContract; if (!contract) { throw new Error(`Contract ${contractId} not found`); } @@ -58,7 +58,7 @@ function getContract(contractId: string): SuiContract { } function getPriceService( - contract: SuiContract, + contract: SuiPriceFeedContract, endpointOverride: string | undefined ): PriceServiceConnection { const defaultEndpoint = contract.getChain().isMainnet() diff --git a/target_chains/sui/cli/src/upgrade_pyth.ts b/target_chains/sui/cli/src/upgrade_pyth.ts index c4d02678b..615215dda 100644 --- a/target_chains/sui/cli/src/upgrade_pyth.ts +++ b/target_chains/sui/cli/src/upgrade_pyth.ts @@ -6,7 +6,7 @@ import { TransactionBlock, } from "@mysten/sui.js"; import { execSync } from "child_process"; -import { SuiContract } from "contract_manager"; +import { SuiPriceFeedContract } from "contract_manager"; export function buildForBytecodeAndDigest(packagePath: string) { const buildOutput: { @@ -33,7 +33,7 @@ export async function upgradePyth( modules: number[][], dependencies: string[], signedVaa: Buffer, - contract: SuiContract + contract: SuiPriceFeedContract ) { const pythPackage = await contract.getPackageId(contract.stateId); @@ -78,7 +78,7 @@ export async function upgradePyth( export async function migratePyth( signer: RawSigner, signedUpgradeVaa: Buffer, - contract: SuiContract, + contract: SuiPriceFeedContract, pythPackageOld: string ) { const pythPackage = await contract.getPackageId(contract.stateId);