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

This commit is contained in:
Mohammad Amin Khashkhashi Moghaddam 2023-07-25 17:37:47 +02:00 committed by GitHub
parent fafb786015
commit ea37f6aab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 57 additions and 11 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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,

View File

@ -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 {