Selaa lähdekoodia

Add injective executor logic and contracts and getVersion utility function (#983)

Mohammad Amin Khashkhashi Moghaddam 2 vuotta sitten
vanhempi
sitoutus
ea37f6aab5
14 muutettua tiedostoa jossa 57 lisäystä ja 11 poistoa
  1. 9 1
      contract_manager/src/contracts/cosmwasm.ts
  2. 6 0
      contract_manager/store/chains/CosmWasmChain/injective.yaml
  3. 6 0
      contract_manager/store/chains/CosmWasmChain/injective_testnet.yaml
  4. 9 0
      contract_manager/store/chains/CosmWasmChain/osmosis.yaml
  5. 1 1
      contract_manager/store/chains/CosmWasmChain/sei_testnet_atlantic_2.yaml
  6. 3 0
      contract_manager/store/contracts/CosmWasmContract/injective_inj12j43nf2f0qumnt2zrrmpvnsqgzndxefujlvr08.yaml
  7. 3 0
      contract_manager/store/contracts/CosmWasmContract/injective_testnet_inj18rlflp3735h25jmjx97d22c72sxk260amdjxlu.yaml
  8. 3 0
      contract_manager/store/contracts/CosmWasmContract/osmosis_osmo1hpdzqku55lmfmptpyj6wdlugqs5etr6teqf7r4yqjjrxjznjhtuqqu5kdh.yaml
  9. 0 3
      contract_manager/store/contracts/CosmWasmContract/osmosis_testnet_5_osmo1q3pzdelxnh2yk66vux4s6ewrw59sx0uu2q6xd7navlsvc3vry92sk3pe7g.yaml
  10. 3 0
      contract_manager/store/contracts/CosmWasmContract/sei_pacific_1_sei15d2tyq2jzxmpg32y3am3w62dts32qgzmds9qnr6c87r0gwwr7ynqal0x38.yaml
  11. 3 0
      contract_manager/store/contracts/CosmWasmContract/sei_testnet_atlantic_2_sei1kpntez76v38yuxhhaaahdmvjxnr5tkr8tq077smefs7uw70rj5yqw2aewy.yaml
  12. 0 3
      contract_manager/store/contracts/CosmWasmContract/sei_testnet_atlantic_2_sei1w2rxq6eckak47s25crxlhmq96fzjwdtjgdwavn56ggc0qvxvw7rqczxyfy.yaml
  13. 4 1
      target_chains/cosmwasm/tools/src/chains-manager/chains.ts
  14. 7 2
      target_chains/cosmwasm/tools/src/chains-manager/injective.ts

+ 9 - 1
contract_manager/src/contracts/cosmwasm.ts

@@ -5,6 +5,7 @@ import { CHAINS, DataSource } from "xc_admin_common";
 import { DeploymentType } from "@pythnetwork/cosmwasm-deploy-tools/lib/helper";
 import {
   CosmwasmExecutor,
+  InjectiveExecutor,
   Price,
   PythWrapperExecutor,
   PythWrapperQuerier,
@@ -156,7 +157,9 @@ export class CosmWasmContract extends Contract {
   }
 
   private static async getExecutor(chain: CosmWasmChain, privateKey: string) {
-    // TODO: logic for injective
+    if (chain.getId().indexOf("injective") > -1) {
+      return new InjectiveExecutor(chain.executorEndpoint, privateKey);
+    }
     return new CosmwasmExecutor(
       chain.executorEndpoint,
       await CosmwasmExecutor.getSignerFromPrivateKey(privateKey, chain.prefix),
@@ -327,6 +330,11 @@ export class CosmWasmContract extends Contract {
     return config.config_v1.fee;
   }
 
+  async getVersion(): Promise<any> {
+    const config = await this.getConfig();
+    return config.contract_version;
+  }
+
   getChain(): CosmWasmChain {
     return this.chain;
   }

+ 6 - 0
contract_manager/store/chains/CosmWasmChain/injective.yaml

@@ -0,0 +1,6 @@
+querierEndpoint: https://injective-rpc.quickapi.com:443
+executorEndpoint: https://k8s.global.mainnet.chain.grpc-web.injective.network:443
+id: injective
+wormholeChainName: injective
+mainnet: true
+type: CosmWasmChain

+ 6 - 0
contract_manager/store/chains/CosmWasmChain/injective_testnet.yaml

@@ -0,0 +1,6 @@
+querierEndpoint: https://k8s.testnet.tm.injective.network:443
+executorEndpoint: https://k8s.testnet.chain.grpc-web.injective.network
+id: injective_testnet
+wormholeChainName: injective_testnet
+mainnet: false
+type: CosmWasmChain

+ 9 - 0
contract_manager/store/chains/CosmWasmChain/osmosis.yaml

@@ -0,0 +1,9 @@
+querierEndpoint: https://rpc.osmosis.zone:443
+executorEndpoint: https://rpc.osmosis.zone:443
+id: osmosis
+wormholeChainName: osmosis
+mainnet: true
+gasPrice: "0.025"
+prefix: osmo
+feeDenom: uosmo
+type: CosmWasmChain

+ 1 - 1
contract_manager/store/chains/CosmWasmChain/sei_testnet_atlantic_2.yaml

@@ -3,7 +3,7 @@ executorEndpoint: https://rpc.atlantic-2.seinetwork.io/
 id: sei_testnet_atlantic_2
 wormholeChainName: sei_testnet_atlantic_2
 mainnet: false
-gasPrice: "0.01"
+gasPrice: "0.10"
 prefix: sei
 feeDenom: usei
 type: CosmWasmChain

+ 3 - 0
contract_manager/store/contracts/CosmWasmContract/injective_inj12j43nf2f0qumnt2zrrmpvnsqgzndxefujlvr08.yaml

@@ -0,0 +1,3 @@
+chain: injective
+address: inj12j43nf2f0qumnt2zrrmpvnsqgzndxefujlvr08
+type: CosmWasmContract

+ 3 - 0
contract_manager/store/contracts/CosmWasmContract/injective_testnet_inj18rlflp3735h25jmjx97d22c72sxk260amdjxlu.yaml

@@ -0,0 +1,3 @@
+chain: injective_testnet
+address: inj18rlflp3735h25jmjx97d22c72sxk260amdjxlu
+type: CosmWasmContract

+ 3 - 0
contract_manager/store/contracts/CosmWasmContract/osmosis_osmo1hpdzqku55lmfmptpyj6wdlugqs5etr6teqf7r4yqjjrxjznjhtuqqu5kdh.yaml

@@ -0,0 +1,3 @@
+chain: osmosis
+address: osmo13ge29x4e2s63a8ytz2px8gurtyznmue4a69n5275692v3qn3ks8q7cwck7
+type: CosmWasmContract

+ 0 - 3
contract_manager/store/contracts/CosmWasmContract/osmosis_testnet_5_osmo1q3pzdelxnh2yk66vux4s6ewrw59sx0uu2q6xd7navlsvc3vry92sk3pe7g.yaml

@@ -1,3 +0,0 @@
-chain: osmosis_testnet_5
-address: osmo1q3pzdelxnh2yk66vux4s6ewrw59sx0uu2q6xd7navlsvc3vry92sk3pe7g
-type: CosmWasmContract

+ 3 - 0
contract_manager/store/contracts/CosmWasmContract/sei_pacific_1_sei15d2tyq2jzxmpg32y3am3w62dts32qgzmds9qnr6c87r0gwwr7ynqal0x38.yaml

@@ -0,0 +1,3 @@
+chain: sei_pacific_1
+address: sei15d2tyq2jzxmpg32y3am3w62dts32qgzmds9qnr6c87r0gwwr7ynqal0x38
+type: CosmWasmContract

+ 3 - 0
contract_manager/store/contracts/CosmWasmContract/sei_testnet_atlantic_2_sei1kpntez76v38yuxhhaaahdmvjxnr5tkr8tq077smefs7uw70rj5yqw2aewy.yaml

@@ -0,0 +1,3 @@
+chain: sei_testnet_atlantic_2
+address: sei1kpntez76v38yuxhhaaahdmvjxnr5tkr8tq077smefs7uw70rj5yqw2aewy
+type: CosmWasmContract

+ 0 - 3
contract_manager/store/contracts/CosmWasmContract/sei_testnet_atlantic_2_sei1w2rxq6eckak47s25crxlhmq96fzjwdtjgdwavn56ggc0qvxvw7rqczxyfy.yaml

@@ -1,3 +0,0 @@
-chain: sei_testnet_atlantic_2
-address: sei1w2rxq6eckak47s25crxlhmq96fzjwdtjgdwavn56ggc0qvxvw7rqczxyfy
-type: CosmWasmContract

+ 4 - 1
target_chains/cosmwasm/tools/src/chains-manager/chains.ts

@@ -141,7 +141,10 @@ export async function createExecutorForChain(
   const chainType = chainConfig.chainType;
 
   if (chainType === ChainType.INJECTIVE) {
-    return new InjectiveExecutor(chainConfig.executorEndpoint, mnemonic);
+    return InjectiveExecutor.fromMnemonic(
+      chainConfig.executorEndpoint,
+      mnemonic
+    );
   } else
     return new CosmwasmExecutor(
       chainConfig.executorEndpoint,

+ 7 - 2
target_chains/cosmwasm/tools/src/chains-manager/injective.ts

@@ -36,9 +36,14 @@ export class InjectiveExecutor implements ChainExecutor {
 
   constructor(
     private readonly grpcEndpoint: string,
-    readonly mnemonic: string
+    readonly privateKey: string
   ) {
-    this.wallet = PrivateKey.fromMnemonic(mnemonic);
+    this.wallet = PrivateKey.fromHex(privateKey);
+  }
+
+  static fromMnemonic(grpcEndpoint: string, mnemonic: string) {
+    const wallet = PrivateKey.fromMnemonic(mnemonic);
+    return new InjectiveExecutor(grpcEndpoint, wallet.toHex());
   }
 
   private getAddress(): string {