Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy injective (testnet) #4

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
13 changes: 8 additions & 5 deletions scripts/action/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// prevents "TypeError: Reflect.hasOwnMetadata is not a function"
import "reflect-metadata";

import { writeFileSync } from "fs";

import { loadContext } from "../src/load_context";
import { Client, HookType, config, getSigningClient } from "../src/config";
import { loadContext } from "../src/load_context";

import { ContractFetcher } from "./fetch";
import { Context } from "../src/types";
import { Contracts, deploy_ism } from "../src/deploy";
import { Context } from "../src/types";
import { ContractFetcher } from "./fetch";

const name = (c: any) => c.contractName;
const addr = (ctx: Context, c: any) => ctx.contracts[name(c)].address!;
Expand Down Expand Up @@ -97,6 +100,7 @@ const deploy_igp = async (
owner: client.signer,
gas_token: config.deploy.igp.token || config.network.gas.denom,
beneficiary: client.signer,
default_gas_usage: "250000" // must be string
});

// init igp oracle
Expand Down Expand Up @@ -154,7 +158,7 @@ const deploy_ism_hook = async (
type: "multisig",
owner: "<signer>",
validators: {
5: {
123: {
addrs: [client.signer_addr],
threshold: 1,
},
Expand Down Expand Up @@ -225,7 +229,6 @@ const deploy_hook = async (

case "merkle":
const merkle_hook_res = await hooks.merkle.instantiate({
owner: hook.owner === "<signer>" ? client.signer : hook.owner,
mailbox: addr(ctx, mailbox),
});

Expand Down
9 changes: 5 additions & 4 deletions scripts/action/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { Context } from "../src/types";
import { Client } from "../src/config";
import { Contracts } from "../src/deploy";
import {
HplMailbox,
HplValidatorAnnounce,
HplHookAggregate,
HplHookMerkle,
HplHookPausable,
Expand All @@ -15,11 +11,15 @@ import {
HplIsmAggregate,
HplIsmMultisig,
HplIsmRouting,
HplMailbox,
HplTestMockHook,
HplTestMockMsgReceiver,
HplValidatorAnnounce,
HplWarpCw20,
HplWarpNative,
} from "../src/contracts";
import { Contracts } from "../src/deploy";
import { Context } from "../src/types";

type Const<T> = new (
address: string | undefined,
Expand Down Expand Up @@ -70,6 +70,7 @@ export class ContractFetcher {
aggregate: this.get(HplIsmAggregate, "hpl_ism_aggregate"),
multisig: this.get(HplIsmMultisig, "hpl_ism_multisig"),
routing: this.get(HplIsmRouting, "hpl_ism_routing"),
pausable: this.get(HplHookPausable, "hpl_ism_pausable"),
},
mocks: {
hook: this.get(HplTestMockHook, "hpl_test_mock_hook"),
Expand Down
15 changes: 9 additions & 6 deletions scripts/action/mailbox.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// prevents "TypeError: Reflect.hasOwnMetadata is not a function"
import "reflect-metadata";

import { ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Command } from "commander";

import { version } from "../package.json";
import { config, getSigningClient } from "../src/config";
import {
HplHookMerkle,
HplIgp,
HplIgpOracle,
HplIsmAggregate,
HplMailbox,
HplHookMerkle,
HplIgp,
HplIgpOracle,
HplIsmAggregate,
HplMailbox,
} from "../src/contracts";
import { addPad } from "../src/conv";
import { loadContext } from "../src/load_context";
Expand Down Expand Up @@ -83,7 +86,7 @@ function makeHandler(
msg_body: Buffer.from(msg_body, "utf-8").toString("hex"),
},
},
[{ denom: "token", amount: "26000000" }]
[{ denom: "inj", amount: "2500" }]
);
console.log(parseWasmEventLog(res));
};
Expand Down
3 changes: 3 additions & 0 deletions scripts/action/warp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// prevents "TypeError: Reflect.hasOwnMetadata is not a function"
import "reflect-metadata";

import { version } from "../package.json";
import { loadContext } from "../src/load_context";
import { config, getSigningClient } from "../src/config";
Expand Down
102 changes: 102 additions & 0 deletions scripts/context/injective-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"contracts": {
"hpl_hook_aggregate": {
"codeId": 381,
"digest": "1d3c711db8ef6a536b94e72259361551343cee1645565f2ae88c9199fb1beef9"
},
"hpl_hook_fee": {
"codeId": 382,
"digest": "33b4e8ee59c4c5f6c95dde746d21666c7f81a49ce7391a5bd074a3104b703496"
},
"hpl_hook_merkle": {
"codeId": 383,
"digest": "c20c709a72769679ce1750927fe38107dfdbc5da2fa1c6da51bdf559aa5f652e"
},
"hpl_hook_pausable": {
"codeId": 384,
"digest": "454a4b99f7b3674c7fdc8e2c143bb2deb7fb66c9f94de98b893b56cd4fe2a0e7"
},
"hpl_hook_routing": {
"codeId": 385,
"digest": "d5cc55f7287d5ee0e59cf236e6211c8a68bd54bd773f4ee03ffb67df288b57ba"
},
"hpl_hook_routing_custom": {
"codeId": 386,
"digest": "55e9c6e12965617fd5dd19cac6c1d460009daeec66cc32a64ea8fe3432d7c854"
},
"hpl_hook_routing_fallback": {
"codeId": 387,
"digest": "89108d56675015c03cd266bd55bde577b57cfc946d1cea02f4d79dc31d037da5"
},
"hpl_igp": {
"address": "inj1y7h9y2vwtdfmxjm6ur9x8czcghp3u86e2wtcxr",
"codeId": 388,
"digest": "9fe334789058e7e236dc4bbea1c3becaa85b884ad762012b1a4753d7159e4c80"
},
"hpl_igp_oracle": {
"address": "inj1qkmy09d749jdl7p88slrxgzdfnt7u4wnfk7gxk",
"codeId": 389,
"digest": "e3b595296ce0638668bfe0e08dcfcf9717f0955c063d45f15c393dfedd0a309c"
},
"hpl_ism_aggregate": {
"codeId": 390,
"digest": "b425d0b79c1a51bf4c3e49adb00b389ca8fcccac12b355289c5f6daf27959a18"
},
"hpl_ism_multisig": {
"codeId": 391,
"digest": "ce34a65d380eb4ddb0e47a5e859c740f2f34675a026d8d123eaf548230e704a4"
},
"hpl_ism_pausable": {
"codeId": 392,
"digest": "8e5b96cd62378563267be930edb8c3dd9494ec13c6de7909172cdf0fe4edd4b2"
},
"hpl_ism_routing": {
"codeId": 393,
"digest": "8453cbfbaa0c68d0980689c734ff1f13c221e5a6e5c1938dea7645d1926a5e6e"
},
"hpl_mailbox": {
"address": "inj1palm2wtp6urg0c6j4f2ukv5u5ahdcrqek0sapt",
"codeId": 394,
"digest": "f21ec28636172a8d52602145b00f4cb56ba9d001dd6d4cbe6d5e38ace04ea3f3"
},
"hpl_test_mock_hook": {
"codeId": 395,
"digest": "b35975f8d3741d6fff93e262c2bd11ac582464c2adfc7ba95999952349a36395"
},
"hpl_test_mock_ism": {
"codeId": 396,
"digest": "b99645eab7b564218d184aaf8f840d5944c7bc6c4a55cef6aa36bbff0c44e078"
},
"hpl_test_mock_msg_receiver": {
"address": "inj1sy7sz0ek0353qym2q92l306m3h4tty24t5l9dt",
"codeId": 397,
"digest": "b073c3253a17ab2709e9eabc7c7010832632832ec24bdc6f4ff5ca87fcd26cba"
},
"hpl_validator_announce": {
"address": "inj1r7eztvhul0n4uc22r438m6tl7dezgthdw2cjjx",
"codeId": 398,
"digest": "768b0192d7b307dd6dbd26b8285f33b92530150186171d25b1831fe2fa16ce8a"
},
"hpl_warp_cw20": {
"codeId": 399,
"digest": "656725112ce2574d29ddcc7221a07c82de0bf3da5dc9ca22f70c256bdaa266e2"
},
"hpl_warp_native": {
"codeId": 400,
"digest": "1dc6d8e868dc606c04d2fcb075c8aa68c45416565ebefa60a5252362adcc05c4"
},
"hpl_default_ism": {
"codeId": 390,
"digest": "b425d0b79c1a51bf4c3e49adb00b389ca8fcccac12b355289c5f6daf27959a18",
"address": "inj1jkvdheut9sdzz492wagp2n3cxh9537w3v4786a"
},
"hpl_default_hook": {
"address": "inj1y7h9y2vwtdfmxjm6ur9x8czcghp3u86e2wtcxr"
},
"hpl_required_hook": {
"codeId": 383,
"digest": "c20c709a72769679ce1750927fe38107dfdbc5da2fa1c6da51bdf559aa5f652e",
"address": "inj1269dxcuyglc8mmecf95lf63elt3cq2tz57ka6h"
}
}
}
11 changes: 10 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@cosmjs/proto-signing": "^0.31.0",
"@cosmjs/stargate": "^0.31.0",
"@cosmjs/tendermint-rpc": "0.31.0",
"@injectivelabs/sdk-ts": "^1.14.5",
"axios": "^1.6.2",
"colors": "^1.4.0",
"commander": "^11.1.0",
Expand All @@ -33,5 +34,13 @@
"ts-yaml": "^1.0.0",
"tsx": "^3.13.0",
"typescript": "^5.1.6"
},
"resolutions": {
"@cosmjs/stargate": "0.31.0"
},
"pnpm": {
"patchedDependencies": {
"@cosmjs/cosmwasm-stargate@0.31.0": "patches/@cosmjs__cosmwasm-stargate@0.31.0.patch"
}
}
}
}
65 changes: 65 additions & 0 deletions scripts/patches/@cosmjs__cosmwasm-stargate@0.31.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/build/cosmwasmclient.js b/build/cosmwasmclient.js
index 8f6305b0263886c5c31fab661c9235723ba1e6e9..b2aac8730ae07b2e62fec2c0a5ee9e6808239a68 100644
--- a/build/cosmwasmclient.js
+++ b/build/cosmwasmclient.js
@@ -81,6 +81,10 @@ class CosmWasmClient {
async getAccount(searchAddress) {
try {
const account = await this.forceGetQueryClient().auth.account(searchAddress);
+ if (searchAddress.startsWith('inj')) {
+ const m = await require('@injectivelabs/sdk-ts');
+ return m.injectiveAccountParser(account);
+ }
return account ? (0, stargate_1.accountFromAny)(account) : null;
}
catch (error) {
diff --git a/build/signingcosmwasmclient.js b/build/signingcosmwasmclient.js
index 2780b8c5ff5ed95c1e3a2994266279d1d682d994..8493e0bd7140d67493bc10d7e6e033d860ef54bb 100644
--- a/build/signingcosmwasmclient.js
+++ b/build/signingcosmwasmclient.js
@@ -85,7 +85,12 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
if (!accountFromSigner) {
throw new Error("Failed to retrieve account from signer");
}
+
const pubkey = (0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey);
+ if (signerAddress.startsWith('inj')) {
+ pubkey['typeUrl'] = '/injective.crypto.v1beta1.ethsecp256k1.PubKey';
+ }
+
const { sequence } = await this.getSequence(signerAddress);
const { gasInfo } = await this.forceGetQueryClient().tx.simulate(anyMsgs, memo, pubkey, sequence);
(0, utils_1.assertDefined)(gasInfo);
@@ -107,7 +112,8 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
throw new Error(createDeliverTxResponseErrorMessage(result));
}
const parsedLogs = stargate_1.logs.parseRawLog(result.rawLog);
- const codeIdAttr = stargate_1.logs.findAttribute(parsedLogs, "store_code", "code_id");
+ const escapedCodeIdAttr = stargate_1.logs.findAttribute(parsedLogs, "cosmwasm.wasm.v1.EventCodeStored", "code_id");
+ const codeIdAttr = { value: escapedCodeIdAttr.value.replace(/\"/g, "") };
return {
checksum: (0, encoding_1.toHex)((0, crypto_1.sha256)(wasmCode)),
originalSize: wasmCode.length,
@@ -388,6 +394,10 @@ class SigningCosmWasmClient extends cosmwasmclient_1.CosmWasmClient {
throw new Error("Failed to retrieve account from signer");
}
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
+ if (signerAddress.startsWith('inj')) {
+ pubkey['typeUrl'] = '/injective.crypto.v1beta1.ethsecp256k1.PubKey';
+ }
+
const signMode = signing_1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
const signDoc = (0, amino_1.makeSignDoc)(msgs, fee, chainId, memo, accountNumber, sequence);
diff --git a/package.json b/package.json
index b073b4317319dbfd761befe3d163bfe6a00dbcef..293b53bdc5e9a62f624de27ee562ae9677f670d8 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,7 @@
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js"
},
"dependencies": {
+ "@injectivelabs/sdk-ts": "^1.14.4",
"@cosmjs/amino": "^0.31.0",
"@cosmjs/crypto": "^0.31.0",
"@cosmjs/encoding": "^0.31.0",
Loading
Loading