Browse Source

refactor(cosmwasm/tools): update cosmjs dependencies (#1514)

* refactor(cosmwasm/tools): update cosmjs dependencies

We needed to update cosmjs dependencies to support Xion, which is based
on a new CometBFT-based variation of tendermint. This change also
includes the artifacts for the Xion testnet network.

* fix: pin a dependency to get nextjs to work

* fix: address review comments
Ali Behjati 1 year ago
parent
commit
a203808a44

+ 8 - 0
contract_manager/store/chains/CosmWasmChains.yaml

@@ -74,3 +74,11 @@
   prefix: rol
   feeDenom: urax
   type: CosmWasmChain
+- endpoint: https://testnet-burnt-rpc.lavenderfive.com
+  id: xion_testnet
+  wormholeChainName: xion_testnet
+  mainnet: false
+  gasPrice: "0.025"
+  prefix: xion
+  feeDenom: uxion
+  type: CosmWasmChain

+ 3 - 0
contract_manager/store/contracts/CosmWasmPriceFeedContracts.yaml

@@ -43,3 +43,6 @@
 - chain: rol_testnet
   address: rol1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucszdyfs8
   type: CosmWasmPriceFeedContract
+- chain: xion_testnet
+  address: xion1w39ctwxxhxxc2kxarycjxj9rndn65gf8daek7ggarwh3rq3zl0lqqllnmt
+  type: CosmWasmPriceFeedContract

+ 11 - 4
governance/xc_admin/packages/xc_admin_common/package.json

@@ -19,19 +19,26 @@
     "format": "prettier --write \"src/**/*.ts\"",
     "test": "jest"
   },
+  "//": [
+    "The injectivelabs/token-metadata package is pinned to a specific version to ensure that",
+    "wormhole-sdk can be built with the correct version of the package in nextjs (xc_admin_frontend).",
+    "Otherwise, the nextjs build will fail due to using a different version of the package."
+  ],
   "dependencies": {
-    "@certusone/wormhole-sdk": "^0.9.22",
+    "@certusone/wormhole-sdk": "^0.10.15",
     "@coral-xyz/anchor": "^0.29.0",
+    "@injectivelabs/sdk-ts": "^1.10.72",
+    "@injectivelabs/token-metadata": "~1.10.42",
     "@pythnetwork/client": "^2.17.0",
+    "@pythnetwork/pyth-solana-receiver": "*",
+    "@pythnetwork/solana-utils": "*",
     "@solana/buffer-layout": "^4.0.1",
     "@solana/web3.js": "^1.73.0",
     "@sqds/mesh": "^1.0.6",
     "bigint-buffer": "^1.1.5",
     "ethers": "^5.7.2",
     "lodash": "^4.17.21",
-    "typescript": "^4.9.4",
-    "@pythnetwork/solana-utils": "*",
-    "@pythnetwork/pyth-solana-receiver": "*"
+    "typescript": "^4.9.4"
   },
   "devDependencies": {
     "@types/bn.js": "^5.1.1",

+ 1 - 0
governance/xc_admin/packages/xc_admin_common/src/chains.ts

@@ -144,6 +144,7 @@ export const RECEIVER_CHAINS = {
   sei_evm_devnet: 50067,
   boba_sepolia: 50068,
   astar_zkyoto_testnet: 50069,
+  xion_testnet: 50070,
 };
 
 // If there is any overlapping value the receiver chain will replace the wormhole

File diff suppressed because it is too large
+ 492 - 225
package-lock.json


+ 9 - 9
target_chains/cosmwasm/tools/package.json

@@ -11,21 +11,21 @@
   "author": "",
   "license": "Apache-2.0",
   "dependencies": {
-    "@cosmjs/cosmwasm-stargate": "^0.29.5",
-    "@cosmjs/encoding": "^0.26.2",
-    "@cosmjs/proto-signing": "^0.30.1",
+    "@cosmjs/cosmwasm-stargate": "^0.32.3",
+    "@cosmjs/encoding": "^0.32.3",
+    "@cosmjs/proto-signing": "^0.32.3",
+    "@cosmjs/stargate": "^0.32.3",
     "@injectivelabs/networks": "^1.14.6",
-    "@injectivelabs/sdk-ts": "1.0.354",
+    "@injectivelabs/sdk-ts": "1.14.7",
     "@ltd/j-toml": "^1.38.0",
     "@pythnetwork/price-service-client": "*",
-    "@terra-money/terra.js": "^3.1.3",
+    "@terra-money/terra.js": "^3.1.10",
     "adm-zip": "^0.5.10",
-    "chain-registry": "^1.6.0",
-    "cosmjs-utils": "^0.1.0",
+    "chain-registry": "^1.45.1",
     "dotenv": "^16.0.0",
     "ethers": "^5.4.4",
     "node-downloader-helper": "^2.1.7",
-    "osmojs": "^13.0.0-rc.7-i-alpha",
+    "osmojs": "^16.12.1",
     "xc_admin_common": "*",
     "yargs": "^17.0.1"
   },
@@ -34,7 +34,7 @@
     "@types/yargs": "^17.0.18",
     "@typescript-eslint/eslint-plugin": "^5.43.0",
     "@typescript-eslint/parser": "^5.43.0",
-    "cosmjs-types": "^0.6.1",
+    "cosmjs-types": "^0.9.0",
     "eslint": "^8.27.0",
     "eslint-config-prettier": "^8.5.0",
     "ts-node": "^10.9.1",

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

@@ -119,7 +119,7 @@ export class CosmwasmQuerier implements ChainQuerier {
 
     return {
       ...contractInfo,
-      codeId: contractInfo.codeId.toNumber(),
+      codeId: Number(contractInfo.codeId),
       adminAddr: contractInfo.admin,
     };
   }

+ 3 - 3
target_chains/cosmwasm/tools/src/chains-manager/cosmwasm.ts

@@ -98,7 +98,7 @@ export class CosmwasmExecutor implements ChainExecutor {
       const txResponse = await cosmwasmClient.signAndBroadcast(
         address,
         [encodedMsgObject],
-        1.5
+        2
       );
 
       if (txResponse.code !== 0) {
@@ -154,7 +154,7 @@ export class CosmwasmExecutor implements ChainExecutor {
         value: {
           sender: accAddress,
           admin: accAddress,
-          codeId: Long.fromNumber(codeId),
+          codeId: BigInt(codeId),
           label,
           msg: Buffer.from(JSON.stringify(instMsg)),
           funds: [],
@@ -213,7 +213,7 @@ export class CosmwasmExecutor implements ChainExecutor {
       value: {
         sender: await this.getAddress(),
         contract: contractAddr,
-        codeId: Long.fromNumber(newCodeId),
+        codeId: BigInt(newCodeId),
         msg: Buffer.from(JSON.stringify(migrateMsg)),
       },
     };

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

@@ -118,7 +118,7 @@ export class InjectiveExecutor implements ChainExecutor {
     const sig = await this.wallet.sign(Buffer.from(signBytes));
 
     /** Append Signatures */
-    txRaw.setSignaturesList([sig]);
+    txRaw.signatures = txRaw.signatures.concat(sig);
 
     const txResponse = await txService.broadcast(txRaw);
 

+ 3 - 3
target_chains/cosmwasm/tools/src/ci/deployer/injective.ts

@@ -1,5 +1,5 @@
 import { readFileSync } from "fs";
-import { Bech32, toHex } from "@cosmjs/encoding";
+import { toHex, fromBech32 } from "@cosmjs/encoding";
 import { ethers } from "ethers";
 import assert from "assert";
 import { getNetworkInfo, Network } from "@injectivelabs/networks";
@@ -59,7 +59,7 @@ export class InjectiveDeployer implements Deployer {
     const sig = await this.wallet.sign(Buffer.from(signBytes));
 
     /** Append Signatures */
-    txRaw.setSignaturesList([sig]);
+    txRaw.signatures = txRaw.signatures.concat(sig);
 
     const txService = new TxGrpcClient(networkInfo.grpc);
     const txResponse = await txService.broadcast(txRaw);
@@ -216,7 +216,7 @@ export class InjectiveDeployer implements Deployer {
 // Injective addresses are "human-readable", but for cross-chain registrations, we
 // want the "canonical" version
 function convert_injective_address_to_hex(human_addr: string) {
-  return "0x" + toHex(ethers.utils.zeroPad(Bech32.decode(human_addr).data, 32));
+  return "0x" + toHex(ethers.utils.zeroPad(fromBech32(human_addr).data, 32));
 }
 
 // enter key of what to extract

+ 5 - 13
target_chains/cosmwasm/tools/src/ci/deployer/osmosis.ts

@@ -1,5 +1,4 @@
 import { getSigningOsmosisClient, cosmwasm, estimateOsmoFee } from "osmojs";
-import { getOfflineSignerProto as getOfflineSigner } from "cosmjs-utils";
 import { chains } from "chain-registry";
 import { Chain } from "@chain-registry/types";
 import { readFileSync } from "fs";
@@ -9,7 +8,7 @@ import assert from "assert";
 
 import { ContractInfo, Deployer } from ".";
 import { convert_terra_address_to_hex, extractFromRawLog } from "./terra";
-import { EncodeObject } from "@cosmjs/proto-signing";
+import { EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
 import Long from "long";
 
 export type OsmosisHost = {
@@ -26,11 +25,7 @@ export class OsmosisDeployer implements Deployer {
   }
 
   private async getAccountAddress(): Promise<string> {
-    const signer = await getOfflineSigner({
-      mnemonic: this.mnemonic,
-      chain: this.chain,
-    });
-
+    const signer = await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic);
     const accountData = await signer.getAccounts();
     return accountData[0].address;
   }
@@ -38,10 +33,7 @@ export class OsmosisDeployer implements Deployer {
   private async signAndBroadcast(
     msg: EncodeObject
   ): Promise<DeliverTxResponse> {
-    const signer = await getOfflineSigner({
-      mnemonic: this.mnemonic,
-      chain: this.chain,
-    });
+    const signer = await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic);
 
     const client = await getSigningOsmosisClient({
       rpcEndpoint: this.endpoint,
@@ -69,7 +61,7 @@ export class OsmosisDeployer implements Deployer {
     const rs = await client.signAndBroadcast(address, [msg], fee);
 
     if (rs.code !== 0) {
-      console.error(`Transaction failed: ${rs.rawLog}`);
+      console.error(`Transaction failed: ${rs.events}`);
     } else {
       console.log(
         `Broadcasted transaction hash: ${JSON.stringify(rs.transactionHash)}`
@@ -210,7 +202,7 @@ export class OsmosisDeployer implements Deployer {
     const { codeId, creator, admin } = contractInfo;
 
     return {
-      codeId: codeId.toNumber(),
+      codeId: Number(codeId),
       address: address,
       creator: creator,
       admin: admin,

+ 2 - 2
target_chains/cosmwasm/tools/src/ci/deployer/terra.ts

@@ -11,7 +11,7 @@ import {
   isTxError,
 } from "@terra-money/terra.js";
 import { readFileSync } from "fs";
-import { Bech32, toHex } from "@cosmjs/encoding";
+import { fromBech32, toHex } from "@cosmjs/encoding";
 import { ethers } from "ethers";
 import assert from "assert";
 import { ContractInfo, Deployer } from ".";
@@ -179,7 +179,7 @@ export class TerraDeployer implements Deployer {
 // Terra addresses are "human-readable", but for cross-chain registrations, we
 // want the "canonical" version
 export function convert_terra_address_to_hex(human_addr: string) {
-  return "0x" + toHex(ethers.utils.zeroPad(Bech32.decode(human_addr).data, 32));
+  return "0x" + toHex(ethers.utils.zeroPad(fromBech32(human_addr).data, 32));
 }
 
 // enter key of what to extract

Some files were not shown because too many files changed in this diff