Update cosmjs injective patch to avoid sdk dep

injective-testnet
J M Rossy 9 months ago
parent 7ac7dcc127
commit 101a4aef80
  1. 146
      .yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch
  2. 11
      package.json
  3. 1
      public/logos/injective.svg
  4. 26
      src/consts/chains.ts
  5. 46
      src/consts/tokens.ts
  6. 106
      yarn.lock

@ -0,0 +1,146 @@
diff --git a/build/cosmwasmclient.js b/build/cosmwasmclient.js
index 8f6305b0263886c5c31fab661c9235723ba1e6e9..a3c7f20135babd6dd7774e4f2ac7e79cb0462db1 100644
--- a/build/cosmwasmclient.js
+++ b/build/cosmwasmclient.js
@@ -10,6 +10,112 @@ const utils_1 = require("@cosmjs/utils");
const abci_1 = require("cosmjs-types/cosmos/base/abci/v1beta1/abci");
const types_1 = require("cosmjs-types/cosmwasm/wasm/v1/types");
const modules_1 = require("./modules");
+
+/* Code copied in from injective SDK to avoid importing all 9Mb of the library */
+// node_modules/@injectivelabs/core-proto-ts/cjs/google/protobuf/any.js
+const minimal_1 = require("protobufjs/minimal");
+const Any = {
+ decode(input, length) {
+ const reader = input instanceof minimal_1.Reader ? input : minimal_1.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = { typeUrl: "", value: new Uint8Array(0) };
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+ message.typeUrl = reader.string();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+ message.value = reader.bytes();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+ };
+ // node_modules/@injectivelabs/core-proto-ts/cjs/cosmos/auth/v1beta1/auth.js
+const BaseAccount = {
+ decode(input, length) {
+ const reader = input instanceof minimal_1.Reader ? input : minimal_1.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = { address: "", pubKey: undefined, accountNumber: "0", sequence: "0" };
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+ message.address = reader.string();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+ message.pubKey = Any.decode(reader, reader.uint32());
+ continue;
+ case 3:
+ if (tag !== 24) {
+ break;
+ }
+ message.accountNumber = longToString(reader.uint64());
+ continue;
+ case 4:
+ if (tag !== 32) {
+ break;
+ }
+ message.sequence = longToString(reader.uint64());
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+};
+// node_modules/@injectivelabs/core-proto-ts/cjs/injective/types/v1beta1/account.js
+const EthAccount = {
+ decode(input, length) {
+ const reader = input instanceof minimal_1.Reader ? input : minimal_1.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = { baseAccount: undefined, codeHash: new Uint8Array(0) };
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+ message.baseAccount = BaseAccount.decode(reader, reader.uint32());
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+ message.codeHash = reader.bytes();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+};
+
class CosmWasmClient {
/**
* Creates an instance by connecting to the given Tendermint RPC endpoint.
@@ -78,9 +184,28 @@ class CosmWasmClient {
const status = await this.forceGetTmClient().status();
return status.syncInfo.latestBlockHeight;
}
+ decodeInjectiveAccount(injAccount){
+ const account = EthAccount.decode(injAccount.value);
+ const baseAccount = account.baseAccount;
+ const pubKey = baseAccount.pubKey;
+ return {
+ address: baseAccount.address,
+ pubkey: pubKey
+ ? {
+ type: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',
+ value: Buffer.from(pubKey.value).toString('base64'),
+ }
+ : null,
+ accountNumber: parseInt(baseAccount.accountNumber, 10),
+ sequence: parseInt(baseAccount.sequence, 10),
+ };
+ }
async getAccount(searchAddress) {
try {
const account = await this.forceGetQueryClient().auth.account(searchAddress);
+ if (searchAddress.startsWith('inj')) {
+ return this.decodeInjectiveAccount(account);
+ }
return account ? (0, stargate_1.accountFromAny)(account) : null;
}
catch (error) {

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"@chakra-ui/next-js": "^2.1.5", "@chakra-ui/next-js": "^2.1.5",
"@chakra-ui/react": "^2.8.1", "@chakra-ui/react": "^2.8.1",
"@cosmjs/cosmwasm-stargate": "^0.31.3", "@cosmjs/cosmwasm-stargate": "patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch",
"@cosmjs/stargate": "^0.31.3", "@cosmjs/stargate": "^0.31.3",
"@cosmos-kit/core": "^2.7.2", "@cosmos-kit/core": "^2.7.2",
"@cosmos-kit/cosmostation": "^2.4.4", "@cosmos-kit/cosmostation": "^2.4.4",
@ -88,10 +88,13 @@
}, },
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
"resolutions": { "resolutions": {
"ethers": "^5.7", "@cosmjs/cosmwasm-stargate@npm:^0.31.3": "patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch",
"zustand": "^4.4", "axios": "0.27.2",
"bn.js": "^5.2", "bn.js": "^5.2",
"cosmjs-types": "0.9",
"ethers": "^5.7",
"lit-html": "2.8.0",
"viem": "1.20.0", "viem": "1.20.0",
"lit-html": "2.8.0" "zustand": "^4.4"
} }
} }

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="w-32" data-icon="logo" data-prefix="fab" viewBox="0 0 33.36 33.36"><path fill="url(#a)" d="M4.04 5.76 4.7 5l.04-.03.08-.06.02-.03c.15-.14.31-.29.5-.42a6.73 6.73 0 0 1 9.04.47c2.84 2.66 2.59 6.95.32 9.8-2.86 4.25-7.8 10.18-.97 15.5 1.23.95 2.13 1.74 6 2.86-2.53.46-4.87.32-7.48-.35-1.84-1.04-4.74-3.27-5.73-6.28-1.5-4.57 2.63-11.39 4.61-14.02 2.74-3.64-1.69-7.57-4.94-3.18-1.7 2.3-4.68 8.78-3.64 13.59.6 2.73 1.4 4.71 4.6 7.44-.59-.35-1.16-.74-1.72-1.19A16.86 16.86 0 0 1 4.04 5.76Z"/><path fill="url(#b)" d="m29.32 27.6-.65.76-.04.02-.07.07-.02.02a7.52 7.52 0 0 1-2.59 1.57 6.73 6.73 0 0 1-6.96-1.6c-2.84-2.67-2.59-6.96-.32-9.81 2.87-4.25 7.8-10.18.97-15.5-1.23-.95-2.14-1.74-6-2.86 2.53-.46 4.87-.32 7.48.35 1.84 1.04 4.74 3.27 5.73 6.28 1.5 4.56-2.63 11.39-4.61 14.02-2.74 3.63 1.68 7.57 4.94 3.17 1.7-2.29 4.67-8.77 3.64-13.58-.6-2.73-1.4-4.72-4.6-7.45.59.35 1.16.75 1.72 1.2a16.86 16.86 0 0 1 1.38 23.34Z"/><defs><linearGradient id="a" x1="0" x2="33.36" y1="18.15" y2="18.15" gradientUnits="userSpaceOnUse"><stop stop-color="#0082FA"/><stop offset="1" stop-color="#00F2FE"/></linearGradient><linearGradient id="b" x1="0" x2="33.36" y1="15.21" y2="15.21" gradientUnits="userSpaceOnUse"><stop stop-color="#0082FA"/><stop offset="1" stop-color="#00F2FE"/></linearGradient></defs></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -1,4 +1,5 @@
import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk'; import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk';
import { ProtocolType } from '@hyperlane-xyz/utils';
// A map of chain names to ChainMetadata // A map of chain names to ChainMetadata
// Chains can be defined here, in chains.json, or in chains.yaml // Chains can be defined here, in chains.json, or in chains.yaml
@ -28,4 +29,29 @@ export const chains: ChainMap<ChainMetadata & { mailbox?: Address }> = {
// }, // },
// logoURI: '/logo.svg', // logoURI: '/logo.svg',
// }, // },
injectivetestnet: {
blockExplorers: [],
blocks: {
confirmations: 1,
estimateBlockTime: 3,
reorgPeriod: 1,
},
chainId: 'injective-888',
domainId: 6909546,
displayName: 'Injective Testnet',
displayNameShort: 'Inj. Testnet',
name: 'injectivetestnet',
nativeToken: {
decimals: 6,
name: 'Injective',
symbol: 'INJ',
},
bech32Prefix: 'inj',
slip44: 118,
protocol: ProtocolType.Cosmos,
rpcUrls: [{ http: 'https://k8s.testnet.tm.injective.network' }],
restUrls: [{ http: 'https://testnet.sentry.lcd.injective.network' }],
isTestnet: true,
},
}; };

@ -5,26 +5,36 @@ import { WarpTokenConfig } from '../features/tokens/types';
// The input here is typically the output of the Hyperlane CLI warp deploy command // The input here is typically the output of the Hyperlane CLI warp deploy command
export const tokenList: WarpTokenConfig = [ export const tokenList: WarpTokenConfig = [
// Example collateral token for an EVM chain // Example collateral token for an EVM chain
{ // {
type: 'collateral', // type: 'collateral',
chainId: 5, // chainId: 5,
address: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6', // address: '0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6',
hypCollateralAddress: '0x145de8760021c4ac6676376691b78038d3DE9097', // hypCollateralAddress: '0x145de8760021c4ac6676376691b78038d3DE9097',
name: 'Weth', // name: 'Weth',
symbol: 'WETH', // symbol: 'WETH',
decimals: 18, // decimals: 18,
logoURI: '/logos/weth.png', // See public/logos/ // logoURI: '/logos/weth.png', // See public/logos/
}, // },
// Example NFT (ERC721) token for an EVM chain // Example NFT (ERC721) token for an EVM chain
// {
// chainId: 5,
// name: 'Test721',
// symbol: 'TEST721',
// decimals: 0,
// type: 'collateral',
// address: '0x77566D540d1E207dFf8DA205ed78750F9a1e7c55',
// hypCollateralAddress: '0xDcbc0faAA269Cf649AC8950838664BB7B355BD6B',
// isNft: true,
// },
{ {
chainId: 5, type: 'native',
name: 'Test721', chainId: 'injective-888',
symbol: 'TEST721', name: 'Injective Coin',
decimals: 0, symbol: 'INJ',
type: 'collateral', decimals: 6,
address: '0x77566D540d1E207dFf8DA205ed78750F9a1e7c55', hypNativeAddress: 'inj1wn32e0e07yytd4m03n8mynnp6qzgg75qmhsq88',
hypCollateralAddress: '0xDcbc0faAA269Cf649AC8950838664BB7B355BD6B', logoURI: '/logos/injective.svg',
isNft: true,
}, },
]; ];

@ -1839,7 +1839,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@cosmjs/cosmwasm-stargate@npm:^0.31.3": "@cosmjs/cosmwasm-stargate@npm:0.31.3":
version: 0.31.3 version: 0.31.3
resolution: "@cosmjs/cosmwasm-stargate@npm:0.31.3" resolution: "@cosmjs/cosmwasm-stargate@npm:0.31.3"
dependencies: dependencies:
@ -1858,6 +1858,25 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@cosmjs/cosmwasm-stargate@patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch":
version: 0.31.3
resolution: "@cosmjs/cosmwasm-stargate@patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch::version=0.31.3&hash=1e2f10"
dependencies:
"@cosmjs/amino": "npm:^0.31.3"
"@cosmjs/crypto": "npm:^0.31.3"
"@cosmjs/encoding": "npm:^0.31.3"
"@cosmjs/math": "npm:^0.31.3"
"@cosmjs/proto-signing": "npm:^0.31.3"
"@cosmjs/stargate": "npm:^0.31.3"
"@cosmjs/tendermint-rpc": "npm:^0.31.3"
"@cosmjs/utils": "npm:^0.31.3"
cosmjs-types: "npm:^0.8.0"
long: "npm:^4.0.0"
pako: "npm:^2.0.2"
checksum: 9d5393554d40b5658a19768539660ddb96549de339274caee1cfad1784e5fa1f78cdb55ce161d755121e60493f172c8aa275ba448d865453b4771e04f8e8e079
languageName: node
linkType: hard
"@cosmjs/crypto@npm:^0.31.3": "@cosmjs/crypto@npm:^0.31.3":
version: 0.31.3 version: 0.31.3
resolution: "@cosmjs/crypto@npm:0.31.3" resolution: "@cosmjs/crypto@npm:0.31.3"
@ -3057,7 +3076,7 @@ __metadata:
dependencies: dependencies:
"@chakra-ui/next-js": "npm:^2.1.5" "@chakra-ui/next-js": "npm:^2.1.5"
"@chakra-ui/react": "npm:^2.8.1" "@chakra-ui/react": "npm:^2.8.1"
"@cosmjs/cosmwasm-stargate": "npm:^0.31.3" "@cosmjs/cosmwasm-stargate": "patch:@cosmjs/cosmwasm-stargate@npm%3A0.31.3#~/.yarn/patches/@cosmjs-cosmwasm-stargate-npm-0.31.3-4b3bafffd4.patch"
"@cosmjs/stargate": "npm:^0.31.3" "@cosmjs/stargate": "npm:^0.31.3"
"@cosmos-kit/core": "npm:^2.7.2" "@cosmos-kit/core": "npm:^2.7.2"
"@cosmos-kit/cosmostation": "npm:^2.4.4" "@cosmos-kit/cosmostation": "npm:^2.4.4"
@ -7913,6 +7932,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"asynckit@npm:^0.4.0":
version: 0.4.0
resolution: "asynckit@npm:0.4.0"
checksum: 3ce727cbc78f69d6a4722517a58ee926c8c21083633b1d3fdf66fd688f6c127a53a592141bd4866f9b63240a86e9d8e974b13919450bd17fa33c2d22c4558ad8
languageName: node
linkType: hard
"atomic-sleep@npm:^1.0.0": "atomic-sleep@npm:^1.0.0":
version: 1.0.0 version: 1.0.0
resolution: "atomic-sleep@npm:1.0.0" resolution: "atomic-sleep@npm:1.0.0"
@ -7952,12 +7978,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"axios@npm:^0.21.0, axios@npm:^0.21.2": "axios@npm:0.27.2":
version: 0.21.4 version: 0.27.2
resolution: "axios@npm:0.21.4" resolution: "axios@npm:0.27.2"
dependencies: dependencies:
follow-redirects: "npm:^1.14.0" follow-redirects: "npm:^1.14.9"
checksum: da644592cb6f8f9f8c64fdabd7e1396d6769d7a4c1ea5f8ae8beb5c2eb90a823e3a574352b0b934ac62edc762c0f52647753dc54f7d07279127a7e5c4cd20272 form-data: "npm:^4.0.0"
checksum: 2efaf18dd0805f7bc772882bc86f004abd92d51007b54c5081f74db0d08ce3593e2c010261896d25a14318eeaa2e966fd825e34f810e8a3339dc64b9d177cf70
languageName: node languageName: node
linkType: hard linkType: hard
@ -8780,6 +8807,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"combined-stream@npm:^1.0.8":
version: 1.0.8
resolution: "combined-stream@npm:1.0.8"
dependencies:
delayed-stream: "npm:~1.0.0"
checksum: 2e969e637d05d09fa50b02d74c83a1186f6914aae89e6653b62595cc75a221464f884f55f231b8f4df7a49537fba60bdc0427acd2bf324c09a1dbb84837e36e4
languageName: node
linkType: hard
"commander@npm:^2.20.3": "commander@npm:^2.20.3":
version: 2.20.3 version: 2.20.3
resolution: "commander@npm:2.20.3" resolution: "commander@npm:2.20.3"
@ -8893,17 +8929,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"cosmjs-types@npm:^0.8.0": "cosmjs-types@npm:0.9":
version: 0.8.0
resolution: "cosmjs-types@npm:0.8.0"
dependencies:
long: "npm:^4.0.0"
protobufjs: "npm:~6.11.2"
checksum: 9a6ac37a77349416bf5e3abab21b1084da4d293e76a77d11bb9fbaeef27c6f36b64b47b92ee587a0a5b66a543bfcd62078820dc0d14f9e39bd037a4801013dc1
languageName: node
linkType: hard
"cosmjs-types@npm:^0.9.0":
version: 0.9.0 version: 0.9.0
resolution: "cosmjs-types@npm:0.9.0" resolution: "cosmjs-types@npm:0.9.0"
checksum: c61137bf0aba5c4b73f5191590472e6de61203c3e3dc0081643ac388c9f27f65de052298a0c6b239543adaba7829f5ff9c9fb95ab44d7b4186b080b8478e3b27 checksum: c61137bf0aba5c4b73f5191590472e6de61203c3e3dc0081643ac388c9f27f65de052298a0c6b239543adaba7829f5ff9c9fb95ab44d7b4186b080b8478e3b27
@ -9186,6 +9212,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"delayed-stream@npm:~1.0.0":
version: 1.0.0
resolution: "delayed-stream@npm:1.0.0"
checksum: 46fe6e83e2cb1d85ba50bd52803c68be9bd953282fa7096f51fc29edd5d67ff84ff753c51966061e5ba7cb5e47ef6d36a91924eddb7f3f3483b1c560f77a0020
languageName: node
linkType: hard
"delegates@npm:^1.0.0": "delegates@npm:^1.0.0":
version: 1.0.0 version: 1.0.0
resolution: "delegates@npm:1.0.0" resolution: "delegates@npm:1.0.0"
@ -10240,13 +10273,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"follow-redirects@npm:^1.14.0": "follow-redirects@npm:^1.14.9":
version: 1.15.1 version: 1.15.5
resolution: "follow-redirects@npm:1.15.1" resolution: "follow-redirects@npm:1.15.5"
peerDependenciesMeta: peerDependenciesMeta:
debug: debug:
optional: true optional: true
checksum: a57f93ce566d4602fe7b2f6cef8f8d3d053891b3d8f2feae7e97eec18aa0003d23aeec8e857801d93887eee27e1617276a16f6a3d5c9d78e45882346612462d5 checksum: d467f13c1c6aa734599b8b369cd7a625b20081af358f6204ff515f6f4116eb440de9c4e0c49f10798eeb0df26c95dd05d5e0d9ddc5786ab1a8a8abefe92929b4
languageName: node languageName: node
linkType: hard linkType: hard
@ -10259,6 +10292,17 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"form-data@npm:^4.0.0":
version: 4.0.0
resolution: "form-data@npm:4.0.0"
dependencies:
asynckit: "npm:^0.4.0"
combined-stream: "npm:^1.0.8"
mime-types: "npm:^2.1.12"
checksum: 7264aa760a8cf09482816d8300f1b6e2423de1b02bba612a136857413fdc96d7178298ced106817655facc6b89036c6e12ae31c9eb5bdc16aabf502ae8a5d805
languageName: node
linkType: hard
"formik@npm:^2.4.5": "formik@npm:^2.4.5":
version: 2.4.5 version: 2.4.5
resolution: "formik@npm:2.4.5" resolution: "formik@npm:2.4.5"
@ -12557,6 +12601,22 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"mime-db@npm:1.52.0":
version: 1.52.0
resolution: "mime-db@npm:1.52.0"
checksum: 54bb60bf39e6f8689f6622784e668a3d7f8bed6b0d886f5c3c446cb3284be28b30bf707ed05d0fe44a036f8469976b2629bbea182684977b084de9da274694d7
languageName: node
linkType: hard
"mime-types@npm:^2.1.12":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
mime-db: "npm:1.52.0"
checksum: 89aa9651b67644035de2784a6e665fc685d79aba61857e02b9c8758da874a754aed4a9aced9265f5ed1171fd934331e5516b84a7f0218031b6fa0270eca1e51a
languageName: node
linkType: hard
"mime@npm:^3.0.0": "mime@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "mime@npm:3.0.0" resolution: "mime@npm:3.0.0"
@ -13735,7 +13795,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"protobufjs@npm:^6.11.2, protobufjs@npm:^6.8.8, protobufjs@npm:~6.11.2, protobufjs@npm:~6.11.3": "protobufjs@npm:^6.11.2, protobufjs@npm:^6.8.8, protobufjs@npm:~6.11.3":
version: 6.11.4 version: 6.11.4
resolution: "protobufjs@npm:6.11.4" resolution: "protobufjs@npm:6.11.4"
dependencies: dependencies:

Loading…
Cancel
Save