diff --git a/.eslintignore b/.eslintignore index 7f55fc07..80dc185c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,5 @@ lib/**/codec/generated/codecimpl.* lib/dist docs +*/**/*.md +*/**/*.json diff --git a/README.md b/README.md index af3f54f3..b303ebe5 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,158 @@ const queryResult = await client.query().. // example client.query().bank.allBalances(
) ``` +### 1.6. Transaction Decoding/Encoding support +Our SDK supports transaction decoding from hex-encoded strings. -## 2. Cosmos Protobuf Definitions +```typescript +import { TxDecoder } from './txDecoder'; +const txDecoder = new TxDecoder(); +const decodedTx = txDecoder.fromHex('0a9b010a8c010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126c0a2b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a36383532717371733868783530122b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a363835327173717338687835301a100a08626173657463726f120431303030120a616d696e6f2074657374126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210223c9395d41013e6470c8d27da8b75850554faada3fe3e812660cbdf4534a85d712040a020801180112170a110a08626173657463726f1205313030303010a08d061a4031f4c489b98decb367972790747139c7706f54aafd9e5a3a5ada4f72c7b017646f1eb5cb1bdf518603d5d8991466a13c3f68844dcd9b168b5d4ca0cb5ea514bc'); + +//Prints decoded in Cosmos compatible JSON format +console.log(decodedTx.toCosmosJSON()) + +// Prints +// "{"tx":{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"basetcro","amount":"1000"}],"from_address":"tcro1fzcrza3j4f2677jfuxulkg33z6852qsqs8hx50","to_address":"tcro1fzcrza3j4f2677jfuxulkg33z6852qsqs8hx50"}],"memo":"amino test","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AiPJOV1BAT5kcMjSfai3WFBVT6raP+PoEmYMvfRTSoXX"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"1"}],"fee":{"amount":[{"denom":"basetcro","amount":"10000"}],"gas_limit":"100000","payer":"","granter":""}},"signatures":["MfTEibmN7LNnlyeQdHE5x3BvVKr9nlo6WtpPcsewF2RvHrXLG99RhgPV2JkUZqE8P2iETc2bFotdTKDLXqUUvA=="]}}" + +``` + +### 1.7. Offline Signing +Our SDK supports offline signing for secure external transaction management. + +#### Flow: +Machine 1 (Online): +1. Build a `RawTransactionV2` instance. +2. Export Cosmos compatible JSON by using `.toCosmosJSON()`. +3. Export Signer(s) list using `.exportSignerAccounts()`. + +Machine 2 (Offline/Online): +1. Create a `SignableTransactionV2` instance from a stringified cosmos compatible JSON string. +2. You can import Signer(s) list using two methods: + 1. call `importSignerAccounts()` on the instance above **OR** + 2. (Advance usage) call `setSignerAccountNumberAtIndex()` to manually set AccountNumber at a specified index. +3. You can choose to export the signed hex encoded transaction and broadcast it manually + +Eg: +```typescript +// import respective classes +// .... + +/* Machine 1: */ +const rawTx = new cro.v2.RawTransactionV2(); +// .... Do rest operations here +const exportUnsignedCosmosJSON = rawTx.toCosmosJSON(); +const exportSignerInfoToJSON = rawTx.exportSignerAccounts(); + +/* Machine 2: */ +const signerAccountsOptional: SignerAccount[] = cro + .v2 + .RawTransactionV2 + .parseSignerAccounts(exportSignerInfoToJSON); +/* SignerAccount[] has the structure of +[{ + publicKey: ; + accountNumber: new Big(0); + signMode: SIGN_MODE.DIRECT; +}]; +*/ + +const signableTx = new SignableTransactionV2({ + rawTxJSON: exportUnsignedCosmosJSON, + network: , + signerAccounts: signerAccountsOptional, +}); + +/* `Import SignerAccounts` starts */ + +// METHOD 1: using importSignerAccounts() +signableTx.importSignerAccounts([ + // SignerAccount 1 + { + publicKey: Bytes.fromHexString('hexString'); + accountNumber: new Big(0); + signMode: SIGN_MODE.DIRECT; + }, + // SignerAccount 2 + { + publicKey: Bytes.fromUint8Array(); + accountNumber: new Big(2); + signMode: SIGN_MODE.DIRECT; + } +]); + +// METHOD 2 (For Advance Users): using setSignerAccountNumberAtIndex() +const signerInfoListINDEX: number = 1; +const newAccountNumber: Big = new Big(1); +signableTx.setSignerAccountNumberAtIndex(signerInfoListINDEX, newAccountNumber); + +/* `Import SignerAccounts` ends */ + +// .... Do rest operations here on SignableTransaction + +const signedTx = signableTx.toSigned(); + +console.log(signedTx.getHexEncoded()); +// 0aa4010a8c010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126c0a2b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b6333122b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b63331a100a08626173657463726f120431323130120f48656c6c6f2054657374204d656d6f1896ef14126a0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c3d281a28592adce81bee3094f00eae26932cbc682fba239b90f47dac9fe703612040a020801180d12160a100a08626173657463726f12043635303010c08b111a40fe9b30f29bb9a83df3685f5bf8b7e6c34bae9ee8ba93115af4136289354c5bf947698ef3a3c0a1f6092ba7a2069616c436f4bcf6f3ecef11b92ad4d319ec0347 + +// Note that the result of signedTx.getHexEncoded() can be directly broadcasted to the network as a raw tx + +``` + + +### 1.8. Create a message from Cosmos compatible JSON +All **Cosmos message** types supported on our SDK can be instantiated using the function `.fromCosmosMsgJSON()` on respective classes. You need to pass a valid Msg `JSON` string and a `network` instance. +Eg. +```typescript +const msgSendJson ='{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + +const msgSend = cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(msgSendJson, CroNetwork.Testnet); +// `msgSend` is a valid instance of `MsgSendV2` and can be used for Transaction building + + +const msgFundCommunityPoolJson = '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","amount":[{ "denom": "basetcro", "amount": "3478499933290496" }],"depositor":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + +const msgFundCommPool = cro.v2.distribution.MsgFundCommunityPoolV2.fromCosmosMsgJSON(msgFundCommunityPoolJson, CroNetwork.Testnet); +// `msgFundCommPool`is a valid instance of `MsgFundCommunityPoolV2` and can be used for Transaction building + +``` + +## 2. Introducing `V2` message types +Our SDK has introduced `V2` message types in order to support: +- Custom `denom` +- Multiple `amount` in several Cosmos Message types +- Multiple `fee` amount in `SignerInfo` + +You can use the `v2` property on the `CroSDK` instance like in the example below: + +```typescript +// imports here + +const cro = CroSDK({ network: sdk.CroNetwork.Testnet }); + +// v2 methods below +const coin1 = new cro.Coin('88888888', Units.BASE); +const coin2 = new cro.Coin('99999999', Units.BASE); +const msgSendV2 = new cro.v2.bank.MsgSendV2({ + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin1, coin2], +}); +``` + +### 2.1 List of new `V2` methods + +* New classes for external transaction management: + - `RawTransactionV2` + - `.toCosmosJSON()` : Get a Cosmos-sdk compatible JSON string + - `.exportSignerAccounts()` : Exports a human readable JSON of `SignerAccount` + - `appendFeeAmount(...)` : Add multiple fee amount to `SignerInfo` list + - `CoinV2` : Supports custom denom support + - `SignableTransactionV2` : Load your Cosmos Tx JSON for transaction management. + +Please note new message types may be added under the `CroSDK` instance. + +## 3. Cosmos Protobuf Definitions ### Generate Cosmos Protobuf Definitions in JavaScript @@ -191,4 +341,4 @@ npm run docs:build The resulting generated documentation will be created in the `docs/dist` directory ## 4. License -[Apache 2.0](./LICENSE) \ No newline at end of file +[Apache 2.0](./LICENSE) diff --git a/lib/e2e/offline-signing/.gitignore b/lib/e2e/offline-signing/.gitignore new file mode 100644 index 00000000..027b6b45 --- /dev/null +++ b/lib/e2e/offline-signing/.gitignore @@ -0,0 +1,2 @@ +chain-maind +home/ diff --git a/lib/e2e/offline-signing/README.md b/lib/e2e/offline-signing/README.md new file mode 100644 index 00000000..7a526cc1 --- /dev/null +++ b/lib/e2e/offline-signing/README.md @@ -0,0 +1,23 @@ +# Offline Signing End-to-End Test + +This test will compare the offline signing results of chain-maind and the JSlib. + +## How to run + +### 1. Go to correct directory +```bash +cd ./lib/e2e/offling-signing +``` + +### 2. Download latest `chain-maind` release to the folder + +https://github.com/crypto-com/chain-main/releases + +### 3. Run compare tool +```bash +# Go to jslib root directory +cd ../../../ +npm run test:e2e:offline-signing +``` + +The test will take some time to complete. \ No newline at end of file diff --git a/lib/e2e/offline-signing/compare.ts b/lib/e2e/offline-signing/compare.ts new file mode 100644 index 00000000..56e94d3e --- /dev/null +++ b/lib/e2e/offline-signing/compare.ts @@ -0,0 +1,215 @@ +/* eslint-disable*/ +import 'mocha'; +import { expect } from 'chai'; +import { spawnSync, exec as childProcessExec } from 'child_process'; +import { writeFileSync } from 'fs'; +import { promisify } from 'util'; +import stringify = require('json-stable-stringify'); +import temp = require('temp'); + +/* eslint-disable import/first */ +import Big from 'big.js'; +import { CroNetwork, CroSDK } from '../../src/core/cro'; +import { Network } from '../../src/network/network'; +import { HDKey } from '../../src/hdkey/hdkey'; +import { Secp256k1KeyPair } from '../../src/keypair/secp256k1'; +import utils from '../../src/utils'; +import { SignableTransactionV2 } from '../../src/transaction/v2.signable'; +import { Bytes } from '../../src/utils/bytes/bytes'; + +const exec = promisify(childProcessExec); + +const CHAIN_MAIND_PATH = process.env.OFFLINE_SIGNING_CHAIN_MAIND_PATH || './lib/e2e/offline-signing/chain-maind'; +const CHAIN_MAIND_HOME_FOLDER = process.env.OFFLINE_SIGNING_CHAIN_MAIND_HOME_FOLDER || './lib/e2e/offline-signing/home'; + +const generateUnsignedTxWithChainMaind = async (command: string, network: Network): Promise => { + return ( + await exec( + `${CHAIN_MAIND_PATH} \ + --home=${CHAIN_MAIND_HOME_FOLDER} \ + tx ${command} \ + --chain-id=${network.chainId} \ + --generate-only`, + ) + ).stdout; +}; + +const restoreChainMaindKeySync = (name: string, mnemonics: string, hdPath: string): string => { + const result = spawnSync( + CHAIN_MAIND_PATH, + [ + `--home=${CHAIN_MAIND_HOME_FOLDER}`, + 'keys', + 'add', + name, + '--keyring-backend=test', + `--hd-path=${hdPath}`, + '--recover', + ], + { + input: `${mnemonics}\n`, + }, + ); + if (result.error) { + throw result.error; + } + if (result.status !== 0) { + throw new Error(result.stderr.toString('utf8')); + } + console.log(result.stdout.toString('utf8')); + return result.stdout.toString('utf8'); +}; + +const generateAccount = ( + network: Network, +): { + mnemonics: string; + hdPath: string; + keyPair: Secp256k1KeyPair; + address: string; +} => { + const cro = CroSDK({ network }); + + const mnemonics = HDKey.generateMnemonic(12); + const importedHDKey = HDKey.fromMnemonic(mnemonics); + const hdPath = "m/44'/1'/0'/0/0"; + const privateKey = importedHDKey.derivePrivKey(hdPath); + const keyPair = Secp256k1KeyPair.fromPrivKey(privateKey); + const address = new cro.Address(keyPair).account(); + return { + mnemonics, + hdPath, + keyPair, + address, + }; +}; + +const signUnsignedTxWithChainMaind = async ( + unsignedTx: string, + signer: { + name: string; + address: string; + accountNumber: Big; + accountSequence: Big; + }, + chainId: string, +): Promise => { + const unsignTxTmpFile = temp.openSync(); + writeFileSync(unsignTxTmpFile.path, unsignedTx); + const signedTx = ( + await exec( + `${CHAIN_MAIND_PATH} \ + --home=${CHAIN_MAIND_HOME_FOLDER} \ + tx sign ${unsignTxTmpFile.path} \ + --offline \ + --from=${signer.address} \ + --account-number=${signer.accountNumber} \ + --sequence=${signer.accountSequence} \ + --chain-id=${chainId} \ + --keyring-backend=test`, + ) + ).stdout; + + const signedTxTmpFile = temp.openSync(); + writeFileSync(signedTxTmpFile.path, signedTx); + const signedTxHex = ( + await exec( + `${CHAIN_MAIND_PATH} \ + --home=${CHAIN_MAIND_HOME_FOLDER} \ + tx encode ${signedTxTmpFile.path}`, + ) + ).stdout; + + return Bytes.fromBase64String(signedTxHex.trim()).toHexString(); +}; + +const unifyJSON = (anyContent: string): string => stringify(JSON.parse(anyContent)); + +describe('Offline Signing chain-maind vs JSlib', function () { + it('MsgSend should be consistent', async function () { + const network = CroNetwork.Mainnet; + const cro = CroSDK({ + network, + }); + const fromAccount = generateAccount(network); + const toAccount = generateAccount(network); + + const walletName = Date.now().toString(); + restoreChainMaindKeySync(walletName, fromAccount.mnemonics, fromAccount.hdPath); + + let amount = new utils.Big(1); + let timeoutHeight = new utils.Big(1); + let memo = 'random memo !@#$%^&*()_+'; + let accountNumber = new utils.Big(1); + let accountSequence = new utils.Big(1); + + // eslint-disable-next-line no-constant-condition + for (let i = 0; i < 1000; i += 1) { + console.log(` +Testing Parameters: +Amount: ${amount.toFixed(0)} +TimeoutHeight: ${timeoutHeight.toFixed(0)} +Memo: ${memo} +AccountNumber: ${accountNumber.toFixed(0)} +AccountSequence: ${accountSequence.toFixed(0)}`); + // eslint-disable-next-line no-await-in-loop + const unsignedTxWithChainMaind = await generateUnsignedTxWithChainMaind( + `bank send ${fromAccount.address} ${toAccount.address} ${amount.toFixed(0)}${ + network.coin.baseDenom + } --fees=${amount.toFixed(0)}${ + network.coin.baseDenom + } --memo="${memo}" --timeout-height=${timeoutHeight.toFixed(0)} --from=${walletName}`, + network, + ); + // eslint-disable-next-line no-await-in-loop + const signedTxWithChainMaind = await signUnsignedTxWithChainMaind( + unsignedTxWithChainMaind, + { + name: walletName, + address: fromAccount.address, + accountNumber, + accountSequence, + }, + network.chainId, + ); + + const rawTx = new cro.v2.RawTransactionV2() + .setFees([cro.v2.CoinV2.fromBaseUnit(amount.toFixed(0))]) + .setMemo(memo) + .setTimeOutHeight(timeoutHeight.toFixed(0)) + .appendMessage( + new cro.v2.bank.MsgSendV2({ + fromAddress: fromAccount.address, + toAddress: toAccount.address, + amount: [cro.v2.CoinV2.fromBaseUnit(amount.toFixed(0))], + }), + ); + const unsignedTxWithJSLib = rawTx.toCosmosJSON(); + expect(unifyJSON(unsignedTxWithJSLib)).to.deep.eq(unifyJSON(unsignedTxWithChainMaind)); + + rawTx.addSigner({ + publicKey: fromAccount.keyPair.getPubKey(), + accountNumber, + accountSequence, + }); + const unsignedTx = rawTx.toCosmosJSON(); + const signerInfo = rawTx.exportSignerAccounts(); + + const signableTx = new SignableTransactionV2({ + rawTxJSON: unsignedTx, + network, + signerAccounts: cro.v2.RawTransactionV2.parseSignerAccounts(signerInfo), + }); + const signedTxWithJSLib = signableTx + .setSignature(0, fromAccount.keyPair.sign(signableTx.toSignDoc(0))) + .toSigned(); + expect(signedTxWithJSLib.getHexEncoded()).to.eq(signedTxWithChainMaind); + + amount = amount.add('1000000000000'); + timeoutHeight = timeoutHeight.add('1000000000000'); + memo = 'random memo !@#$%^&*()_+'; + accountNumber = accountNumber.add('1000000000000'); + accountSequence = accountSequence.add('1000000000000'); + } + }); +}); diff --git a/lib/e2e/offline-signing/package-lock.json b/lib/e2e/offline-signing/package-lock.json new file mode 100644 index 00000000..dc22fd46 --- /dev/null +++ b/lib/e2e/offline-signing/package-lock.json @@ -0,0 +1,1911 @@ +{ + "name": "offline-signing", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "@types/json-stable-stringify": "1.0.33", + "@types/temp": "0.9.1", + "big.js": "6.1.1", + "chai": "4.3.4", + "json-stable-stringify": "1.0.1", + "mocha": "9.0.3", + "temp": "0.9.4" + } + }, + "node_modules/@types/json-stable-stringify": { + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify/-/json-stable-stringify-1.0.33.tgz", + "integrity": "sha512-qEWiQff6q2tA5gcJGWwzplQcXdJtm+0oy6IHGHzlOf3eFAkGE/FIPXZK9ofWgNSHVp8AFFI33PJJshS0ei3Gvw==" + }, + "node_modules/@types/node": { + "version": "16.4.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.4.2.tgz", + "integrity": "sha512-vxyhOzFCm+jC/T5KugbVsYy1DbQM0h3NCFUrVbu0+pYa/nr+heeucpqxpa8j4pUmIGLPYzboY9zIdOF0niFAjQ==" + }, + "node_modules/@types/temp": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@types/temp/-/temp-0.9.1.tgz", + "integrity": "sha512-yDQ8Y+oQi9V7VkexwE6NBSVyNuyNFeGI275yWXASc2DjmxNicMi9O50KxDpNlST1kBbV9jKYBHGXhgNYFMPqtA==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "engines": { + "node": ">=4" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/big.js": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.1.1.tgz", + "integrity": "sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg==", + "engines": { + "node": "*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/bigjs" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "node_modules/camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "engines": { + "node": ">=4" + } + }, + "node_modules/is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dependencies": { + "jsonify": "~0.0.0" + } + }, + "node_modules/jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "engines": { + "node": "*" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "node_modules/mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mocha": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", + "dependencies": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.2", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.23", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/temp": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", + "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", + "dependencies": { + "mkdirp": "^0.5.1", + "rimraf": "~2.6.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, + "dependencies": { + "@types/json-stable-stringify": { + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify/-/json-stable-stringify-1.0.33.tgz", + "integrity": "sha512-qEWiQff6q2tA5gcJGWwzplQcXdJtm+0oy6IHGHzlOf3eFAkGE/FIPXZK9ofWgNSHVp8AFFI33PJJshS0ei3Gvw==" + }, + "@types/node": { + "version": "16.4.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.4.2.tgz", + "integrity": "sha512-vxyhOzFCm+jC/T5KugbVsYy1DbQM0h3NCFUrVbu0+pYa/nr+heeucpqxpa8j4pUmIGLPYzboY9zIdOF0niFAjQ==" + }, + "@types/temp": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@types/temp/-/temp-0.9.1.tgz", + "integrity": "sha512-yDQ8Y+oQi9V7VkexwE6NBSVyNuyNFeGI275yWXASc2DjmxNicMi9O50KxDpNlST1kBbV9jKYBHGXhgNYFMPqtA==", + "requires": { + "@types/node": "*" + } + }, + "@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "big.js": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.1.1.tgz", + "integrity": "sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg==" + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==" + }, + "chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "requires": { + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==" + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "requires": { + "type-detect": "^4.0.0" + } + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==" + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==" + }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "~0.0.0" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "requires": { + "p-locate": "^5.0.0" + } + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "mocha": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", + "requires": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.2", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.23", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==" + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "requires": { + "p-limit": "^3.0.2" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" + }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "requires": { + "randombytes": "^2.1.0" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "temp": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", + "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", + "requires": { + "mkdirp": "^0.5.1", + "rimraf": "~2.6.2" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==" + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==" + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" + } + } +} diff --git a/lib/e2e/offline-signing/package.json b/lib/e2e/offline-signing/package.json new file mode 100644 index 00000000..b66ee43f --- /dev/null +++ b/lib/e2e/offline-signing/package.json @@ -0,0 +1,11 @@ +{ + "dependencies": { + "@types/json-stable-stringify": "1.0.33", + "@types/temp": "0.9.1", + "big.js": "6.1.1", + "chai": "4.3.4", + "json-stable-stringify": "1.0.1", + "mocha": "9.0.3", + "temp": "0.9.4" + } +} diff --git a/lib/e2e/transaction.spec.ts b/lib/e2e/transaction.spec.ts index 06034681..0751381e 100644 --- a/lib/e2e/transaction.spec.ts +++ b/lib/e2e/transaction.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable */ import 'mocha'; import Big from 'big.js'; import { expect } from 'chai'; @@ -57,6 +58,73 @@ const env = { }; describe('e2e test suite', function () { + describe('`v2` message types', function () { + it('[BANK] creates a MsgSend Type Transaction and Broadcasts it.', async function () { + const hdKey = HDKey.fromMnemonic(env.mnemonic.communityAccount); + const hdKey2 = HDKey.fromMnemonic(env.mnemonic.reserveAccount); + const hdKey3 = HDKey.fromMnemonic(env.mnemonic.randomEmptyAccount); + const privKey = hdKey.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const privKey2 = hdKey2.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const randomPrivKey = hdKey3.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + const keyPair2 = Secp256k1KeyPair.fromPrivKey(privKey2); + const randomKeyPair = Secp256k1KeyPair.fromPrivKey(randomPrivKey); + + const cro = CroSDK({ network: customNetwork }); + const rawTx = new cro.v2.RawTransactionV2(); + const address1 = new cro.Address(keyPair.getPubKey()); + const address2 = new cro.Address(keyPair2.getPubKey()); + const randomAddress = new cro.Address(randomKeyPair.getPubKey()); + const client = await cro.CroClient.connect(); + + const msgSend1 = new cro.v2.bank.MsgSendV2({ + fromAddress: address1.account(), + toAddress: randomAddress.account(), + amount: [new cro.Coin('100000', Units.BASE)], + }); + + const msgSend2 = new cro.v2.bank.MsgSendV2({ + fromAddress: address2.account(), + toAddress: address1.account(), + amount: [new cro.Coin('20000', Units.BASE)], + }); + + const account1 = await client.getAccount(address1.account()); + const account2 = await client.getAccount(address2.account()); + + expect(account1).to.be.not.null; + expect(account2).to.be.not.null; + + const signableTx = rawTx + .appendMessage(msgSend1) + .appendMessage(msgSend2) + .addSigner({ + publicKey: keyPair.getPubKey(), + accountNumber: new Big(account1!.accountNumber), + accountSequence: new Big(account1!.sequence), + }) + .addSigner({ + publicKey: keyPair2.getPubKey(), + accountNumber: new Big(account2!.accountNumber), + accountSequence: new Big(account2!.sequence), + }) + .toSignable(); + + const signedTx = signableTx + .setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))) + .setSignature(1, keyPair2.sign(signableTx.toSignDocumentHash(1))) + .toSigned(); + + expect(msgSend1.fromAddress).to.eq(account1!.address); + expect(msgSend1.toAddress).to.eq(randomAddress.account()); + const broadcastResult = await client.broadcastTx(signedTx.encode().toUint8Array()); + assertIsBroadcastTxSuccess(broadcastResult); + + const { transactionHash } = broadcastResult; + expect(transactionHash).to.match(/^[0-9A-F]{64}$/); + }); + }) + it('[BANK] creates a MsgSend type Transaction Signed by Legacy Amino JSON mode and Broadcasts it', async function () { const hdKey = HDKey.fromMnemonic(env.mnemonic.communityAccount); const hdKey2 = HDKey.fromMnemonic(env.mnemonic.reserveAccount); @@ -188,6 +256,58 @@ describe('e2e test suite', function () { const { transactionHash } = broadcastResult; expect(transactionHash).to.match(/^[0-9A-F]{64}$/); }); + it('[BANK] creates a MsgSend Type Transaction with `Fee` amount and Broadcasts it.', async function () { + const hdKey = HDKey.fromMnemonic(env.mnemonic.communityAccount); + const hdKey2 = HDKey.fromMnemonic(env.mnemonic.reserveAccount); + const hdKey3 = HDKey.fromMnemonic(env.mnemonic.randomEmptyAccount); + const privKey = hdKey.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const privKey2 = hdKey2.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const randomPrivKey = hdKey3.derivePrivKey(`m/44'/${customNetwork.bip44Path.coinType}'/0'/0/0`); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + const keyPair2 = Secp256k1KeyPair.fromPrivKey(privKey2); + const randomKeyPair = Secp256k1KeyPair.fromPrivKey(randomPrivKey); + + const cro = CroSDK({ network: customNetwork }); + const rawTx = new cro.RawTransaction(); + const address1 = new cro.Address(keyPair.getPubKey()); + const address2 = new cro.Address(keyPair2.getPubKey()); + const randomAddress = new cro.Address(randomKeyPair.getPubKey()); + const client = await cro.CroClient.connect(); + + const msgSend1 = new cro.bank.MsgSend({ + fromAddress: address1.account(), + toAddress: randomAddress.account(), + amount: new cro.Coin('100000', Units.BASE), + }); + + const account1 = await client.getAccount(address1.account()); + const account2 = await client.getAccount(address2.account()); + + expect(account1).to.be.not.null; + expect(account2).to.be.not.null; + + const signableTx = rawTx + .appendMessage(msgSend1) + .addSigner({ + publicKey: keyPair.getPubKey(), + accountNumber: new Big(account1!.accountNumber), + accountSequence: new Big(account1!.sequence), + }) + .setFee(cro.Coin.fromCRO("0.002")) + .toSignable(); + + const signedTx = signableTx + .setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))) + .toSigned(); + + expect(msgSend1.fromAddress).to.eq(account1!.address); + expect(msgSend1.toAddress).to.eq(randomAddress.account()); + const broadcastResult = await client.broadcastTx(signedTx.encode().toUint8Array()); + assertIsBroadcastTxSuccess(broadcastResult); + + const { transactionHash } = broadcastResult; + expect(transactionHash).to.match(/^[0-9A-F]{64}$/); + }); it('[STAKING] Creates, signs and broadcasts a `MsgDelegate` Tx', async function () { const hdKey = HDKey.fromMnemonic(env.mnemonic.ecosystemAccount); diff --git a/lib/e2e/tx-decoder/.gitignore b/lib/e2e/tx-decoder/.gitignore new file mode 100644 index 00000000..e2764db4 --- /dev/null +++ b/lib/e2e/tx-decoder/.gitignore @@ -0,0 +1,2 @@ +diff/ +decode-cosmosbase64tx \ No newline at end of file diff --git a/lib/e2e/tx-decoder/README.md b/lib/e2e/tx-decoder/README.md new file mode 100644 index 00000000..d03b0de3 --- /dev/null +++ b/lib/e2e/tx-decoder/README.md @@ -0,0 +1,30 @@ +# TxDecoder End-to-End Test + +This test will compare the decoding results of CosmosSDK based TxDecoder and the JSlib. Inconsistencies will be reported categorized by message type. + +## How to run + +### 1. Go to correct directory +```bash +cd ./lib/e2e/tx-decoder +``` + +### 2. Build Golang cosmos transaction decoder +```bash +git clone https://github.com/calvinlauyh/cosmosutils +cd cosmosutils && make && cd .. +cp ./cosmosutils/build/decode-cosmosbase64tx . +``` + +### 3. Run compare tool +```bash +# Go to jslib root directory +cd ../../../ +npm run test:e2e:tx-decoder +``` + +### 4. Read report +```bash +cd ./lib/e2e/tx-decoder/diff +ls +``` \ No newline at end of file diff --git a/lib/e2e/tx-decoder/compare.ts b/lib/e2e/tx-decoder/compare.ts new file mode 100644 index 00000000..fa5da74b --- /dev/null +++ b/lib/e2e/tx-decoder/compare.ts @@ -0,0 +1,122 @@ +/* eslint-disable*/ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; +import axios from 'axios'; +import { exec as childProcessExec } from 'child_process'; +import { inspect, promisify } from 'util'; +import { writeFileSync, existsSync, mkdirSync } from 'fs'; +import { detailedDiff } from 'deep-object-diff'; + +import { TxDecoder } from '../../src/utils/txDecoder'; +import { Bytes } from '../../src/utils/bytes/bytes'; + +const exec = promisify(childProcessExec); + +const README = ` + Environment: + TXDECODER_STARTING_HEIGHT: The starting height to scan for transactions + TXDECODER_ENDING_HEIGHT: (Optional) The ending height to scan for transactions + TXDECODER_TENDERMINT_RPC: (Optional) The base URL to Crypto.org Chain Tendermint RPC + TXDECODER_DIFF_OUTPUT_FOLDER: (Optional) Folder to output the differences. Default ./lib/e2e/tx-decoder/diff +`; +const TENDERMINT_RPC_BASEURL = process.env.TXDECODER_TENDERMINT_RPC || 'https://mainnet.crypto.org:26657'; +const GO_DECODER_PATH = './lib/e2e/tx-decoder/decode-cosmosbase64tx'; +const DIFF_OUTPUT_FOLDER = process.env.TXDECODER_DIFF_OUTPUT_FOLDER || './lib/e2e/tx-decoder/diff'; + +if (!process.env.TXDECODER_STARTING_HEIGHT) { + console.error('Missing argument'); + console.log(README); + process.exit(1); +} + +const STARTING_HEIGHT = process.env.TXDECODER_STARTING_HEIGHT; + +const getRawTxsAtBlockHeight = async (rpcUrl: string, height: string): Promise => { + // eslint-disable-next-line no-constant-condition + while (true) { + try { + // eslint-disable-next-line no-await-in-loop + const block: any = await axios.get(`${rpcUrl}/block?height=${height}`); + + if (block.error) { + return Promise.reject(new Error('Exceeded chain latest height')); + } + + return block.data.result.block.data.txs; + } catch (err) { + console.error(`error when requesting Tenderint RPC: ${err.toString()}. Retry in 1 minute`); + /* eslint-disable-next-line no-await-in-loop */ + await new Promise((resolve) => setTimeout(resolve, 60000)); + /* eslint-disable-next-line no-continue */ + continue; + } + } +}; + +const decodeRawTxWithGo = async (rawTx: string): Promise => { + const decoded = await exec(`${GO_DECODER_PATH} ${rawTx}`); + return JSON.parse(decoded.stdout); +}; + +const writeReport = async (height: string, index: number, report: Report) => { + const messageTypes = report.jslib.body.messages.map((message: any) => { + return message['@type']; + }); + + /* eslint-disable-next-line no-restricted-syntax */ + for (const messageType of messageTypes) { + const basePath = `${DIFF_OUTPUT_FOLDER}/${messageType}`; + if (!existsSync(basePath)) { + mkdirSync(basePath); + } + + writeFileSync(`${basePath}/${height}-${index}.json`, JSON.stringify(report, null, 2)); + } +}; + +interface Report { + diff: object; + go: any; + jslib: any; +} + +describe('TxDecoder Golang vs JSlib', function () { + it('should decode to the same result', async function () { + const txDecoder = new TxDecoder(); + + const isEnded = (height: string) => + process.env.TXDECODER_ENDING_HEIGHT ? height === process.env.TXDECODER_ENDING_HEIGHT : true; + for (let height = STARTING_HEIGHT; isEnded(height); ) { + console.log(`Comparing transactions at height ${height}`); + /* eslint-disable-next-line no-await-in-loop */ + const txs = await getRawTxsAtBlockHeight(TENDERMINT_RPC_BASEURL, height); + + for (let i = 0; i < txs.length; i += 1) { + const tx = txs[i]; + + /* eslint-disable-next-line no-await-in-loop */ + const decodeByGo = await decodeRawTxWithGo(tx); + const decodeByJsLib = JSON.parse( + txDecoder.fromHex(Bytes.fromBase64String(tx).toHexString()).toCosmosJSON(), + ); + + try { + expect(decodeByJsLib).to.deep.eq(decodeByGo); + } catch (err) { + const diff = detailedDiff(decodeByJsLib, decodeByGo); + const report: Report = { + diff, + go: decodeByGo, + jslib: decodeByJsLib, + }; + console.log(inspect(report, false, null, true)); + // eslint-disable-next-line + await writeReport(height, i, report); + } + } + + height = new Big(height).add(1).toFixed(0); + } + }); +}); diff --git a/lib/e2e/tx-decoder/package-lock.json b/lib/e2e/tx-decoder/package-lock.json new file mode 100644 index 00000000..9ac8cba3 --- /dev/null +++ b/lib/e2e/tx-decoder/package-lock.json @@ -0,0 +1,1826 @@ +{ + "name": "tx-decoder", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "0.21.1", + "big.js": "6.1.1", + "chai": "4.3.4", + "deep-object-diff": "1.1.0", + "mocha": "9.0.3" + } + }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "engines": { + "node": ">=4" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "engines": { + "node": "*" + } + }, + "node_modules/axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "dependencies": { + "follow-redirects": "^1.10.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/big.js": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.1.1.tgz", + "integrity": "sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg==", + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/bigjs" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "node_modules/camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/deep-object-diff": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/deep-object-diff/-/deep-object-diff-1.1.0.tgz", + "integrity": "sha512-b+QLs5vHgS+IoSNcUE4n9HP2NwcHj7aqnJWsjPtuG75Rh5TOaGt0OjAYInh77d5T16V5cRDC+Pw/6ZZZiETBGw==" + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/follow-redirects": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", + "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "engines": { + "node": ">=4" + } + }, + "node_modules/is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", + "dependencies": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.2", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.23", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "engines": { + "node": ">=4" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, + "dependencies": { + "@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==" + }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "big.js": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-6.1.1.tgz", + "integrity": "sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg==" + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, + "camelcase": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", + "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==" + }, + "chai": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + } + }, + "chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" + }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "requires": { + "ms": "2.1.2" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==" + }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "requires": { + "type-detect": "^4.0.0" + } + }, + "deep-object-diff": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/deep-object-diff/-/deep-object-diff-1.1.0.tgz", + "integrity": "sha512-b+QLs5vHgS+IoSNcUE4n9HP2NwcHj7aqnJWsjPtuG75Rh5TOaGt0OjAYInh77d5T16V5cRDC+Pw/6ZZZiETBGw==" + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==" + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==" + }, + "follow-redirects": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", + "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==" + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==" + }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "requires": { + "p-locate": "^5.0.0" + } + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "mocha": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.3.tgz", + "integrity": "sha512-hnYFrSefHxYS2XFGtN01x8un0EwNu2bzKvhpRFhgoybIvMaOkkL60IVPmkb5h6XDmUl4IMSB+rT5cIO4/4bJgg==", + "requires": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.2", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.7", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.23", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.1.5", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "nanoid": { + "version": "3.1.23", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", + "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==" + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "requires": { + "p-limit": "^3.0.2" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==" + }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "requires": { + "randombytes": "^2.1.0" + } + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==" + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "workerpool": { + "version": "6.1.5", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", + "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==" + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + } + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==" + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + } + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" + } + } +} diff --git a/lib/e2e/tx-decoder/package.json b/lib/e2e/tx-decoder/package.json new file mode 100644 index 00000000..ddb82f0e --- /dev/null +++ b/lib/e2e/tx-decoder/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "axios": "0.21.1", + "big.js": "6.1.1", + "chai": "4.3.4", + "deep-object-diff": "1.1.0", + "mocha": "9.0.3" + } +} diff --git a/lib/src/client/client.ts b/lib/src/client/client.ts index 90b03366..d9b94695 100644 --- a/lib/src/client/client.ts +++ b/lib/src/client/client.ts @@ -10,6 +10,8 @@ import { setupBankExtension, setupDistributionExtension, setupStakingExtension, + IbcExtension, + setupIbcExtension, } from '@cosmjs/stargate'; import { Account } from '@cosmjs/stargate/build/accounts'; import { Coin } from '@cosmjs/stargate/build/codec/cosmos/base/v1beta1/coin'; @@ -20,7 +22,9 @@ import { InitConfigurations } from '../core/cro'; import { owUrl } from './ow.types'; export interface ICroClient { - query(): (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension) | undefined; + query(): + | (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & IbcExtension) + | undefined; getChainId(): Promise; getHeight(): Promise; getAccount(searchAddress: string): Promise; @@ -43,7 +47,7 @@ export const croClient = function (config: InitConfigurations) { readonly txClient: StargateClient; readonly queryClient: - | (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension) + | (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & IbcExtension) | undefined; private constructor(tmClient: Tendermint34Client, txClient: StargateClient) { @@ -55,6 +59,7 @@ export const croClient = function (config: InitConfigurations) { setupBankExtension, setupStakingExtension, setupDistributionExtension, + setupIbcExtension, ); this.baseDenom = config.network.coin.baseDenom; @@ -73,7 +78,7 @@ export const croClient = function (config: InitConfigurations) { } public query(): - | (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension) + | (QueryClient & AuthExtension & BankExtension & DistributionExtension & StakingExtension & IbcExtension) | undefined { return this.queryClient; } diff --git a/lib/src/coin/v2.coin/v2.coin.spec.ts b/lib/src/coin/v2.coin/v2.coin.spec.ts new file mode 100644 index 00000000..6357772c --- /dev/null +++ b/lib/src/coin/v2.coin/v2.coin.spec.ts @@ -0,0 +1,321 @@ +/* eslint-disable */ + +import { expect } from 'chai'; +import { fuzzyDescribe } from '../../test/mocha-fuzzy/suite'; + +import { CroNetwork, CroSDK } from '../../core/cro'; + +const cro = CroSDK({ network: CroNetwork.Testnet }); + +describe('Coin', function () { + describe('constructor', function () { + fuzzyDescribe('should throw Error when the provided argument is not (string, Unit)', function (fuzzy) { + const testRunner = fuzzy(fuzzy.StringArg('1000'), fuzzy.StringArg(cro.v2.CoinV2.UNIT_BASE)); + testRunner( + function (args0, args1) { + if (!args0.valid) { + expect(() => new cro.v2.CoinV2(args0.value, args1.value)).to.throw( + 'Expected `amount` to be of type `string`', + ); + } else if (!args1.valid) { + expect(() => new cro.v2.CoinV2(args0.value, args1.value)).to.throw( + 'Expected `unit` to be of type `string`', + ); + } + }, + { invalidArgsOnly: true }, + ); + }); + + context('When unit is base unit', function () { + it('should throw Error when the provided string is not a valid number', function () { + expect(() => new cro.v2.CoinV2('invalid', cro.v2.CoinV2.UNIT_BASE)).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is a floating number', function () { + expect(() => new cro.v2.CoinV2('1234.5678', cro.v2.CoinV2.UNIT_BASE)).to.throw( + 'Expected base amount to be an integer', + ); + }); + + it('should throw Error when the provided string is not a base10 number', function () { + expect(() => new cro.v2.CoinV2('0xff', cro.v2.CoinV2.UNIT_BASE)).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is a negative integer', function () { + expect(() => new cro.v2.CoinV2('-1000', cro.v2.CoinV2.UNIT_BASE)).to.throw('Expected base amount to be positive'); + }); + + it('should throw Error if the value exceed total supply', function () { + expect(() => new cro.v2.CoinV2('10000000000000000001', cro.v2.CoinV2.UNIT_BASE)).to.throw( + 'Expected base amount to be within total supply', + ); + }); + + it('should return a coins object of the provided string', function () { + const anyBaseValue = '1000'; + const coins = new cro.v2.CoinV2(anyBaseValue, cro.v2.CoinV2.UNIT_BASE); + + expect(coins.toString()).to.eq(anyBaseValue); + }); + }); + + context('When unit is CRO', function () { + it('should throw Error when the provided string is not a valid number', function () { + expect(() => new cro.v2.CoinV2('invalid', cro.v2.CoinV2.UNIT_CRO)).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is not a base10 number', function () { + expect(() => new cro.v2.CoinV2('0xff', cro.v2.CoinV2.UNIT_CRO)).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is a negative integer', function () { + expect(() => new cro.v2.CoinV2('-1000', cro.v2.CoinV2.UNIT_CRO)).to.throw('Expected CRO amount to be positive'); + }); + + it('should throw Error when the provided string exceed 8 decimal places', function () { + expect(() => new cro.v2.CoinV2('1000.123456789', cro.v2.CoinV2.UNIT_CRO)).to.throw( + 'Expected CRO amount to have at most 8 decimal places', + ); + }); + + it('should throw Error if the value exceed total supply', function () { + expect(() => new cro.v2.CoinV2('100000000001', cro.v2.CoinV2.UNIT_CRO)).to.throw( + 'Expected CRO amount to be within total supply', + ); + }); + + it('should return a coins object of the provided string', function () { + const anyCROValue = '0.00001'; + const coins = new cro.v2.CoinV2(anyCROValue, cro.v2.CoinV2.UNIT_CRO); + + const expectedBaseValue = '1000'; + expect(coins.toString()).to.eq(expectedBaseValue); + }); + }); + + context('When `denom` is passed along other params', function () { + it('should throw Error when the provided `units` and `denom` do not belong to same network', function () { + expect(() => new cro.v2.CoinV2('1000000', cro.v2.CoinV2.UNIT_CRO, 'cosmos')).to.throw( + 'Provided Units and Denom do not belong to the same network.', + ); + }); + it('should set the `denom` correctly', function () { + expect(() => new cro.v2.CoinV2('1000000', cro.v2.CoinV2.UNIT_BASE, 'cosmos')).to.not.throw(); + + const coin = new cro.v2.CoinV2('1000000', cro.v2.CoinV2.UNIT_BASE, 'cosmos'); + expect(coin.denom).to.equal('cosmos'); + expect(coin.baseAmount.toString()).to.equal('1000000'); + }); + it('should return `baseAmount` correctly on same network `unit` & `denom`', function () { + expect(() => new cro.v2.CoinV2('1000000', cro.v2.CoinV2.UNIT_CRO, 'cro')).to.not.throw(); + expect(() => new cro.v2.CoinV2('1000000', cro.v2.CoinV2.UNIT_CRO, 'tcro')).to.not.throw(); + + const CROcoin = new cro.v2.CoinV2('11111111', cro.v2.CoinV2.UNIT_CRO, 'cro'); + const TCROcoin = new cro.v2.CoinV2('22222222', cro.v2.CoinV2.UNIT_CRO, 'tcro'); + + expect(CROcoin.denom).to.equal('cro'); + expect(TCROcoin.denom).to.equal('tcro'); + + expect(TCROcoin.baseAmount.toString()).to.equal('2222222200000000'); + expect(TCROcoin.toString()).to.equal('2222222200000000'); + expect(TCROcoin.toString(cro.v2.CoinV2.UNIT_CRO)).to.equal('22222222'); + + expect(CROcoin.baseAmount.toString()).to.equal('1111111100000000'); + expect(CROcoin.toString()).to.equal('1111111100000000'); + expect(CROcoin.toString(cro.v2.CoinV2.UNIT_CRO)).to.equal('11111111'); + }); + }); + }); + + describe('fromCustomAmountDenom', function () { + fuzzyDescribe('should throw Error when the provided value is not a string', function (fuzzy) { + const testRunner = fuzzy(fuzzy.StringArg('1000')); + testRunner( + function (arg) { + expect(() => cro.v2.CoinV2.fromCustomAmountDenom(arg.value, arg.value)).to.throw( + 'Expected `amount` to be of type `string`', + ); + }, + { invalidArgsOnly: true }, + ); + }); + + it('should throw Error when the provided string is not a valid number', function () { + expect(() => cro.v2.CoinV2.fromCustomAmountDenom('invalid', 'invalid')).to.throw( + 'Expected amount to be a base10 number represented as string,', + ); + }); + + it('should return `coin` instance on correct params', function () { + const coin = cro.v2.CoinV2.fromCustomAmountDenom('1000', 'uatom'); + expect(coin.denom).to.equal('uatom'); + expect(coin.baseAmount.toString()).to.equal('1000'); + expect(coin.toCosmosCoin().amount).to.equal('1000'); + expect(coin.toCosmosCoin().denom).to.equal('uatom'); + }); + }); + + describe('fromBaseUnit', function () { + fuzzyDescribe('should throw Error when the provided value is not a string', function (fuzzy) { + const testRunner = fuzzy(fuzzy.StringArg('1000')); + testRunner( + function (arg) { + expect(() => cro.v2.CoinV2.fromBaseUnit(arg.value)).to.throw('Expected `amount` to be of type `string`'); + }, + { invalidArgsOnly: true }, + ); + }); + + it('should throw Error when the provided string is not a valid number', function () { + expect(() => cro.v2.CoinV2.fromBaseUnit('invalid')).to.throw( + 'Expected amount to be a base10 number represented as string,', + ); + }); + + it('should throw Error when the provided string is a floating number', function () { + expect(() => cro.v2.CoinV2.fromBaseUnit('1234.5678')).to.throw('Expected base amount to be an integer'); + expect(() => cro.v2.CoinV2.fromBaseUnit('-1234.5678')).to.throw('Expected base amount to be an integer'); + }); + + it('should throw Error when the provided string is not a base10 number', function () { + expect(() => cro.v2.CoinV2.fromBaseUnit('0xff')).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is a negative integer', function () { + expect(() => cro.v2.CoinV2.fromBaseUnit('-1000')).to.throw('Expected base amount to be positive'); + }); + + it('should throw Error if the value exceed total supply', function () { + expect(() => cro.v2.CoinV2.fromBaseUnit('10000000000000000001')).to.throw( + 'Expected base amount to be within total supply', + ); + }); + + it('should return a coins object of the provided base unit string', function () { + const anyBaseValue = '1000'; + const coins = cro.v2.CoinV2.fromBaseUnit(anyBaseValue); + expect(coins.toString()).to.eq(anyBaseValue); + }); + }); + + describe('fromCRO', function () { + fuzzyDescribe('should throw Error when the provided value is not a string', function (fuzzy) { + const testRunner = fuzzy(fuzzy.StringArg('0.1')); + testRunner( + function (arg) { + expect(() => cro.v2.CoinV2.fromCRO(arg.value)).to.throw('Expected `amount` to be of type `string`'); + }, + { invalidArgsOnly: true }, + ); + }); + + it('should throw Error when the provided string is not a valid number', function () { + expect(() => cro.v2.CoinV2.fromCRO('invalid')).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string exceeds 8 decimal places', function () { + expect(() => cro.v2.CoinV2.fromCRO('1000.123456789')).to.throw( + 'Expected CRO amount to have at most 8 decimal places', + ); + expect(() => cro.v2.CoinV2.fromCRO('-1000.123456789')).to.throw( + 'Expected CRO amount to have at most 8 decimal places', + ); + }); + + it('should throw Error when the provided string is not a base10 number', function () { + expect(() => cro.v2.CoinV2.fromCRO('0xff')).to.throw( + 'Expected amount to be a base10 number represented as string', + ); + }); + + it('should throw Error when the provided string is a negative integer', function () { + expect(() => cro.v2.CoinV2.fromCRO('-1000')).to.throw('Expected CRO amount to be positive'); + }); + + it('should throw Error if the value exceed total supply', function () { + expect(() => cro.v2.CoinV2.fromCRO('10000000000000000001')).to.throw( + 'Expected CRO amount to be within total supply', + ); + }); + + it('should return a coins object of the provided CRO unit string', function () { + const anyCROValue = '0.00001'; + const coins = cro.v2.CoinV2.fromCRO(anyCROValue); + + const expectedBaseValue = '1000'; + expect(coins.toString()).to.eq(expectedBaseValue); + }); + }); + + describe('toCosmosCoin', function () { + it('should return the Cosmos Coin object', function () { + const anyCoin = cro.v2.CoinV2.fromBaseUnit('1000'); + expect(anyCoin.toCosmosCoin()).to.deep.eq({ + amount: '1000', + denom: CroNetwork.Testnet.coin.baseDenom, + }); + }); + }); + + describe('toString', function () { + fuzzyDescribe('should throw Error when the provided unit is not a string', function (fuzzy) { + const testRunner = fuzzy(fuzzy.optional(fuzzy.String)(cro.v2.CoinV2.UNIT_BASE)); + testRunner( + function (arg) { + const anyCoin = cro.v2.CoinV2.fromBaseUnit('1000'); + expect(() => anyCoin.toString(arg.value)).to.throw('Expected argument to be of type `string`'); + }, + { invalidArgsOnly: true }, + ); + }); + + it('should throw Error when the provided unit is invalid', function () { + const anyCoin = cro.v2.CoinV2.fromBaseUnit('1000'); + + expect(() => anyCoin.toString('invalid' as any)).to.throw('Expected string to be one of the Coin units'); + }); + + it('should return the base unit when no unit is provided', function () { + const anyBaseValue = '1000'; + const coins = cro.v2.CoinV2.fromBaseUnit(anyBaseValue); + + expect(coins.toString()).to.eq(anyBaseValue); + }); + + it('should return the base unit when unit is base', function () { + const anyBaseValue = '1000'; + const coins = cro.v2.CoinV2.fromBaseUnit(anyBaseValue); + + expect(coins.toString(cro.v2.CoinV2.UNIT_BASE)).to.eq(anyBaseValue); + }); + + it('should return the CRO value when unit is CRO', function () { + const anyBaseValue = '1000'; + const coins = cro.v2.CoinV2.fromBaseUnit(anyBaseValue); + + const expectedCROValue = '0.00001'; + expect(coins.toString(cro.v2.CoinV2.UNIT_CRO)).to.eq(expectedCROValue); + }); + + it('should return the CRO value when unit is CRO and has 8 decimal places', function () { + const anyBaseValue = '12345678'; + const coins = cro.v2.CoinV2.fromBaseUnit(anyBaseValue); + + const expectedCROValue = '0.12345678'; + expect(coins.toString(cro.v2.CoinV2.UNIT_CRO)).to.eq(expectedCROValue); + }); + }); +}); diff --git a/lib/src/coin/v2.coin/v2.coin.ts b/lib/src/coin/v2.coin/v2.coin.ts new file mode 100644 index 00000000..409419b9 --- /dev/null +++ b/lib/src/coin/v2.coin/v2.coin.ts @@ -0,0 +1,235 @@ +import Big from 'big.js'; +import ow from 'ow'; + +import { owCoinUnit } from '../ow.types'; +import { InitConfigurations, CroNetwork } from '../../core/cro'; +import { Network } from '../../network/network'; +import { Coin as CosmosCoin, coin as cosmosCoin, coins as cosmosCoins } from '../../cosmos/coins'; + +export enum Units { + BASE = 'base', + CRO = 'cro', +} + +// Duck type check due to limitations of non exportable type for proper instance of checks +export function isCoin(object: Object): boolean { + // eslint-disable-next-line no-prototype-builtins + return object.hasOwnProperty('baseAmount'); +} + +// Mainly used to export Coin type +export interface ICoin { + toCosmosCoin(): CosmosCoin; + + toCosmosCoins(): CosmosCoin[]; + + getNetwork(): Network; +} + +export const coinv2 = function (config: InitConfigurations) { + return class CoinV2 implements ICoin { + public static croAllDenoms = [ + ...Object.values(CroNetwork.Mainnet.coin), + ...Object.values(CroNetwork.Testnet.coin), + ]; + + /** + * Total supply in base unit represented as string + * @type {string} + * @static + * @memberof Coin + */ + public static TOTAL_SUPPLY_STRING = '10000000000000000000'; + + public static TOTAL_SUPPLY = new CoinV2(CoinV2.TOTAL_SUPPLY_STRING, Units.BASE); + + /** + * One CRO in base unit represented as Big object + * @type {Big} + * @static + * @memberof Coin + */ + public static ONE_CRO_IN_BASE_UNIT = new Big('100000000'); + + /** + * Denote base unit + * @type {string} + * @static + * @memberof Coin + */ + public static UNIT_BASE = Units.BASE; + + /** + * Denote CRO unit + * @type {string} + * @static + * @memberof Coin + */ + public static UNIT_CRO = Units.CRO; + + /** + * Coin value stored in basic unit as Big + */ + public readonly baseAmount: Big; + + public readonly network: Network; + + public readonly denom: string; + + public readonly receivedAmount: Big; + + /** + * Constructor to create a Coin + * @param {string} amount coins amount represented as string + * @param {Units} unit unit of the coins + * @param {string} denom chain compatible denom value (Optional) + * @throws {Error} amount or unit is invalid + * @returns {CoinV2} + */ + constructor(amount: string, unit: Units, denom?: string) { + ow(amount, 'amount', ow.string); + ow(denom, 'denom', ow.optional.string); + ow(unit, 'unit', owCoinUnit); + + let coins: Big; + try { + coins = new Big(amount); + } catch (err) { + throw new TypeError(`Expected amount to be a base10 number represented as string, got \`${amount}\``); + } + this.network = config.network; + + this.baseAmount = coins; + + if (unit === Units.BASE) { + this.baseAmount = CoinV2.parseBaseAmount(coins); + } else if (unit === Units.CRO) { + if (typeof denom === 'undefined') { + this.baseAmount = CoinV2.parseCROAmount(coins); + } else if (['cro', 'tcro'].includes(denom.toLowerCase())) { + this.baseAmount = CoinV2.parseCROAmount(coins); + } else if (!['cro', 'tcro'].includes(denom.toLowerCase())) { + throw new Error('Provided Units and Denom do not belong to the same network.'); + } + } + this.denom = denom || this.network.coin.baseDenom; + this.receivedAmount = coins; + } + + /** + * + * @param {string} amount amount in base unit + * @param {string} denom chain compatible denom value + */ + public static fromCustomAmountDenom = (amount: string, denom: string): CoinV2 => { + return new CoinV2(amount, Units.BASE, denom); + }; + + getNetwork(): Network { + return this.network; + } + + /** + * Parse and validate a amount in base unit represented as Big + * @param {Big} baseAmount amount in base unit + * @returns {Big} the parsed coins in base unit + * @throws {TypeError} coins amount is invalid + */ + static parseBaseAmount(baseAmount: Big): Big { + if (baseAmount.cmp(baseAmount.toFixed(0)) !== 0) { + throw new TypeError(`Expected base amount to be an integer, got \`${baseAmount}\``); + } + if (baseAmount.lt(0)) { + throw new TypeError(`Expected base amount to be positive, got \`${baseAmount}\``); + } + + if (baseAmount.gt(CoinV2.TOTAL_SUPPLY_STRING)) { + throw new TypeError(`Expected base amount to be within total supply, got \`${baseAmount}\``); + } + + return baseAmount; + } + + /** + * Parse and validate a amount in CRO unit represented as Big to base unit + * @param {Big} croAmount amount in CRO unit + * @returns {Big} the parsed coins in base unit + * @throws {TypeError} coins amount is invalid + */ + static parseCROAmount(croAmount: Big): Big { + const baseAmount = croAmount.mul(CoinV2.ONE_CRO_IN_BASE_UNIT); + if (baseAmount.cmp(baseAmount.toFixed(0)) !== 0) { + throw new TypeError(`Expected CRO amount to have at most 8 decimal places, got \`${croAmount}\``); + } + + if (baseAmount.lt(0)) { + throw new TypeError(`Expected CRO amount to be positive, got \`${croAmount}\``); + } + + if (baseAmount.gt(CoinV2.TOTAL_SUPPLY_STRING)) { + throw new TypeError(`Expected CRO amount to be within total supply, got \`${croAmount}\``); + } + + return baseAmount; + } + + /** + * Create a Coin from the base unit + * @param {string} baseValue coins value in base unit + * @returns {CoinV2} + * @throws {Error} base value is invalid + * @memberof Coin + */ + public static fromBaseUnit(baseValue: string): CoinV2 { + return new CoinV2(baseValue, Units.BASE); + } + + /** + * Create a Coin from CRO unit + * @param {string} croValue coins value in CRO unit + * @returns {CoinV2} + * @throws {Error} cro value is invalid + * @memberof Coin + */ + public static fromCRO(croValue: string): CoinV2 { + return new CoinV2(croValue, Units.CRO); + } + + /** + * Returns the Cosmos-compatible Coin object representation + * @returns {CosmosCoin} + * @memberof Coin + * */ + public toCosmosCoin(): CosmosCoin { + return cosmosCoin(this.toString(Units.BASE), this.denom); + } + + /** + * Returns the Cosmos-compatible Coin object representation + * @returns {CosmosCoin[]} + * @memberof Coin + * */ + public toCosmosCoins(): CosmosCoin[] { + return cosmosCoins(this.toString(Units.BASE), this.denom); + } + + /** + * Returns a string representation of the Coin in the specified unit. Default unit is base. + * @param {Units} [unit=Unit.Base] coins unit + * @returns {string} + * @throws {Error} unit is invalid + * @memberof Coin + */ + public toString(unit: Units = Units.BASE): string { + ow(unit, owCoinUnit); + + if (!CoinV2.croAllDenoms.includes(this.denom)) { + return this.receivedAmount.toString(); + } + if (unit === Units.BASE) { + return this.baseAmount.toString(); + } + return this.baseAmount.div(CoinV2.ONE_CRO_IN_BASE_UNIT).toString(); + } + }; +}; diff --git a/lib/src/core/cro.ts b/lib/src/core/cro.ts index cce4233a..d7acdd0e 100644 --- a/lib/src/core/cro.ts +++ b/lib/src/core/cro.ts @@ -17,8 +17,8 @@ import { msgWithdrawValidatorCommission } from '../transaction/msg/distribution/ import { msgDeposit } from '../transaction/msg/gov/MsgDeposit'; import { msgVote } from '../transaction/msg/gov/MsgVote'; import { msgSubmitProposal } from '../transaction/msg/gov/MsgSubmitProposal'; -import { communityPoolSpendProposal } from '../transaction/msg/gov/CommunityPoolSpendProposal'; -import { paramChangeProposal } from '../transaction/msg/gov/ParamChangeProposal'; +import { communityPoolSpendProposal } from '../transaction/msg/gov/proposal/CommunityPoolSpendProposal'; +import { paramChangeProposal } from '../transaction/msg/gov/proposal/ParamChangeProposal'; import { cancelSoftwareUpgradeProposal } from '../transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal'; import { softwareUpgradeProposal } from '../transaction/msg/gov/proposal/SoftwareUpgradeProposal'; import { msgSetWithdrawAddress } from '../transaction/msg/distribution/MsgSetWithdrawAddress'; @@ -29,6 +29,23 @@ import { msgMintNFT } from '../transaction/msg/nft/MsgMintNFT'; import { msgEditNFT } from '../transaction/msg/nft/MsgEditNFT'; import { msgTransferNFT } from '../transaction/msg/nft/MsgTransferNFT'; import { msgBurnNFT } from '../transaction/msg/nft/MsgBurnNFT'; +import { msgTransferIBC } from '../transaction/msg/ibc/applications/MsgTransfer'; +import { msgCreateClientIBC } from '../transaction/msg/ibc/core/MsgCreateClient'; +import { msgSendV2 } from '../transaction/msg/v2/bank/v2.msgsend'; +import { msgFundCommunityPoolV2 } from '../transaction/msg/v2/distribution/v2.MsgFundCommunityPool'; +import { msgDepositV2 } from '../transaction/msg/v2/gov/v2.MsgDeposit'; +import { communityPoolSpendProposalV2 } from '../transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal'; +import { msgSubmitProposalV2 } from '../transaction/msg/v2/gov/v2.MsgSubmitProposal'; +import { msgUpdateClientIBC } from '../transaction/msg/ibc/core/MsgUpdateClient'; +import { msgUpgradeClientIBC } from '../transaction/msg/ibc/core/MsgUpgradeClient'; +import { msgSubmitMisbehaviourIBC } from '../transaction/msg/ibc/core/MsgSubmitMisbehaviour'; +import { rawTransactionV2 } from '../transaction/v2.raw'; +import { coinv2 } from '../coin/v2.coin/v2.coin'; +import { msgClientState } from '../transaction/msg/ibc/lightclients/ClientState'; +import { msgConsensusState } from '../transaction/msg/ibc/lightclients/ConsensusState'; +import { msgHeader } from '../transaction/msg/ibc/lightclients/Header'; +import { MsgConnectionOpenConfirmIBC } from '../transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm'; +import { MsgConnectionOpenTryIBC } from '../transaction/msg/ibc/core/connection/MsgConnectionOpenTry'; export const CroSDK = function (configs: InitConfigurations) { ow(configs, 'configs', owCroSDKInitParams); @@ -48,7 +65,6 @@ export const CroSDK = function (configs: InitConfigurations) { CancelSoftwareUpgradeProposal: cancelSoftwareUpgradeProposal(), SoftwareUpgradeProposal: softwareUpgradeProposal(), TextProposal: textProposal(), - // TODO : More type of proposals to be added here }, }, bank: { @@ -74,6 +90,39 @@ export const CroSDK = function (configs: InitConfigurations) { MsgTransferNFT: msgTransferNFT(configs), MsgBurnNFT: msgBurnNFT(configs), }, + ibc: { + MsgTransfer: msgTransferIBC(configs), + MsgCreateClient: msgCreateClientIBC(configs), + MsgUpdateClient: msgUpdateClientIBC(configs), + MsgUpgradeClient: msgUpgradeClientIBC(configs), + MsgSubmitMisbehaviour: msgSubmitMisbehaviourIBC(configs), + lightclient: { + ClientState: msgClientState(), + ConsensusState: msgConsensusState(), + Header: msgHeader(), + }, + connection: { + MsgConnectionOpenConfirm: MsgConnectionOpenConfirmIBC(configs), + MsgConnectionOpenTry: MsgConnectionOpenTryIBC(configs), + }, + }, + v2: { + bank: { + MsgSendV2: msgSendV2(configs), + }, + distribution: { + MsgFundCommunityPoolV2: msgFundCommunityPoolV2(configs), + }, + gov: { + MsgDepositV2: msgDepositV2(configs), + MsgSubmitProposalV2: msgSubmitProposalV2(configs), + proposal: { + CommunityPoolSpendProposalV2: communityPoolSpendProposalV2(configs), + }, + }, + RawTransactionV2: rawTransactionV2(configs), + CoinV2: coinv2(configs), + }, Options: configs, }; }; diff --git a/lib/src/cosmos/v1beta1/codec/generated/codecimpl.d.ts b/lib/src/cosmos/v1beta1/codec/generated/codecimpl.d.ts index 0678ec60..c412159d 100644 --- a/lib/src/cosmos/v1beta1/codec/generated/codecimpl.d.ts +++ b/lib/src/cosmos/v1beta1/codec/generated/codecimpl.d.ts @@ -1882,7 +1882,7 @@ export namespace cosmos { /** Properties of a HistoricalInfo. */ interface IHistoricalInfo { /** HistoricalInfo header */ - header?: tendermint.types.IHeader | null; + header?: tendermintV2.types.IHeader | null; /** HistoricalInfo valset */ valset?: cosmos.staking.v1beta1.IValidator[] | null; @@ -1897,7 +1897,7 @@ export namespace cosmos { constructor(p?: cosmos.staking.v1beta1.IHistoricalInfo); /** HistoricalInfo header. */ - public header?: tendermint.types.IHeader | null; + public header?: tendermintV2.types.IHeader | null; /** HistoricalInfo valset. */ public valset: cosmos.staking.v1beta1.IValidator[]; @@ -3826,6 +3826,157 @@ export namespace cosmos { } } + /** Namespace slashing. */ + namespace slashing { + /** Namespace v1beta1. */ + namespace v1beta1 { + /** Represents a Msg */ + class Msg extends $protobuf.rpc.Service { + /** + * Constructs a new Msg service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Msg service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create( + rpcImpl: $protobuf.RPCImpl, + requestDelimited?: boolean, + responseDelimited?: boolean, + ): Msg; + + /** + * Calls Unjail. + * @param request MsgUnjail message or plain object + * @param callback Node-style callback called with the error, if any, and MsgUnjailResponse + */ + public unjail( + request: cosmos.slashing.v1beta1.IMsgUnjail, + callback: cosmos.slashing.v1beta1.Msg.UnjailCallback, + ): void; + + /** + * Calls Unjail. + * @param request MsgUnjail message or plain object + * @returns Promise + */ + public unjail( + request: cosmos.slashing.v1beta1.IMsgUnjail, + ): Promise; + } + + namespace Msg { + /** + * Callback as used by {@link cosmos.slashing.v1beta1.Msg#unjail}. + * @param error Error, if any + * @param [response] MsgUnjailResponse + */ + type UnjailCallback = ( + error: Error | null, + response?: cosmos.slashing.v1beta1.MsgUnjailResponse, + ) => void; + } + + /** Properties of a MsgUnjail. */ + interface IMsgUnjail { + /** MsgUnjail validatorAddr */ + validatorAddr?: string | null; + } + + /** Represents a MsgUnjail. */ + class MsgUnjail implements IMsgUnjail { + /** + * Constructs a new MsgUnjail. + * @param [p] Properties to set + */ + constructor(p?: cosmos.slashing.v1beta1.IMsgUnjail); + + /** MsgUnjail validatorAddr. */ + public validatorAddr: string; + + /** + * Creates a new MsgUnjail instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUnjail instance + */ + public static create( + properties?: cosmos.slashing.v1beta1.IMsgUnjail, + ): cosmos.slashing.v1beta1.MsgUnjail; + + /** + * Encodes the specified MsgUnjail message. Does not implicitly {@link cosmos.slashing.v1beta1.MsgUnjail.verify|verify} messages. + * @param m MsgUnjail message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: cosmos.slashing.v1beta1.IMsgUnjail, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MsgUnjail message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUnjail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): cosmos.slashing.v1beta1.MsgUnjail; + } + + /** Properties of a MsgUnjailResponse. */ + interface IMsgUnjailResponse {} + + /** Represents a MsgUnjailResponse. */ + class MsgUnjailResponse implements IMsgUnjailResponse { + /** + * Constructs a new MsgUnjailResponse. + * @param [p] Properties to set + */ + constructor(p?: cosmos.slashing.v1beta1.IMsgUnjailResponse); + + /** + * Creates a new MsgUnjailResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUnjailResponse instance + */ + public static create( + properties?: cosmos.slashing.v1beta1.IMsgUnjailResponse, + ): cosmos.slashing.v1beta1.MsgUnjailResponse; + + /** + * Encodes the specified MsgUnjailResponse message. Does not implicitly {@link cosmos.slashing.v1beta1.MsgUnjailResponse.verify|verify} messages. + * @param m MsgUnjailResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: cosmos.slashing.v1beta1.IMsgUnjailResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgUnjailResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUnjailResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): cosmos.slashing.v1beta1.MsgUnjailResponse; + } + } + } + /** Namespace base. */ namespace base { /** Namespace v1beta1. */ @@ -4130,6 +4281,63 @@ export namespace cosmos { ): cosmos.crypto.multisig.v1beta1.CompactBitArray; } } + + /** Properties of a LegacyAminoPubKey. */ + interface ILegacyAminoPubKey { + /** LegacyAminoPubKey threshold */ + threshold?: number | null; + + /** LegacyAminoPubKey publicKeys */ + publicKeys?: google.protobuf.IAny[] | null; + } + + /** Represents a LegacyAminoPubKey. */ + class LegacyAminoPubKey implements ILegacyAminoPubKey { + /** + * Constructs a new LegacyAminoPubKey. + * @param [p] Properties to set + */ + constructor(p?: cosmos.crypto.multisig.ILegacyAminoPubKey); + + /** LegacyAminoPubKey threshold. */ + public threshold: number; + + /** LegacyAminoPubKey publicKeys. */ + public publicKeys: google.protobuf.IAny[]; + + /** + * Creates a new LegacyAminoPubKey instance using the specified properties. + * @param [properties] Properties to set + * @returns LegacyAminoPubKey instance + */ + public static create( + properties?: cosmos.crypto.multisig.ILegacyAminoPubKey, + ): cosmos.crypto.multisig.LegacyAminoPubKey; + + /** + * Encodes the specified LegacyAminoPubKey message. Does not implicitly {@link cosmos.crypto.multisig.LegacyAminoPubKey.verify|verify} messages. + * @param m LegacyAminoPubKey message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: cosmos.crypto.multisig.ILegacyAminoPubKey, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a LegacyAminoPubKey message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns LegacyAminoPubKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): cosmos.crypto.multisig.LegacyAminoPubKey; + } } /** Namespace secp256k1. */ @@ -6540,208 +6748,5353 @@ export namespace google { } } -/** Namespace ibc. */ -export namespace ibc { - /** Namespace applications. */ - namespace applications { - /** Namespace transfer. */ - namespace transfer { - /** Namespace v1. */ - namespace v1 { - /** Represents a Msg */ - class Msg extends $protobuf.rpc.Service { - /** - * Constructs a new Msg service. - * @param rpcImpl RPC implementation - * @param [requestDelimited=false] Whether requests are length-delimited - * @param [responseDelimited=false] Whether responses are length-delimited - */ - constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); +/** Namespace ics23. */ +export namespace ics23 { + /** HashOp enum. */ + enum HashOp { + NO_HASH = 0, + SHA256 = 1, + SHA512 = 2, + KECCAK = 3, + RIPEMD160 = 4, + BITCOIN = 5, + } - /** - * Creates new Msg service using the specified rpc implementation. - * @param rpcImpl RPC implementation - * @param [requestDelimited=false] Whether requests are length-delimited - * @param [responseDelimited=false] Whether responses are length-delimited - * @returns RPC service. Useful where requests and/or responses are streamed. - */ - public static create( - rpcImpl: $protobuf.RPCImpl, - requestDelimited?: boolean, - responseDelimited?: boolean, - ): Msg; + /** + * LengthOp defines how to process the key and value of the LeafOp + * to include length information. After encoding the length with the given + * algorithm, the length will be prepended to the key and value bytes. + * (Each one with it's own encoded length) + */ + enum LengthOp { + NO_PREFIX = 0, + VAR_PROTO = 1, + VAR_RLP = 2, + FIXED32_BIG = 3, + FIXED32_LITTLE = 4, + FIXED64_BIG = 5, + FIXED64_LITTLE = 6, + REQUIRE_32_BYTES = 7, + REQUIRE_64_BYTES = 8, + } - /** - * Calls Transfer. - * @param request MsgTransfer message or plain object - * @param callback Node-style callback called with the error, if any, and MsgTransferResponse - */ - public transfer( - request: ibc.applications.transfer.v1.IMsgTransfer, - callback: ibc.applications.transfer.v1.Msg.TransferCallback, - ): void; + /** Properties of an ExistenceProof. */ + interface IExistenceProof { + /** ExistenceProof key */ + key?: Uint8Array | null; - /** - * Calls Transfer. - * @param request MsgTransfer message or plain object - * @returns Promise - */ - public transfer( - request: ibc.applications.transfer.v1.IMsgTransfer, - ): Promise; - } + /** ExistenceProof value */ + value?: Uint8Array | null; - namespace Msg { - /** - * Callback as used by {@link ibc.applications.transfer.v1.Msg#transfer}. - * @param error Error, if any - * @param [response] MsgTransferResponse - */ - type TransferCallback = ( - error: Error | null, - response?: ibc.applications.transfer.v1.MsgTransferResponse, - ) => void; - } + /** ExistenceProof leaf */ + leaf?: ics23.ILeafOp | null; - /** Properties of a MsgTransfer. */ - interface IMsgTransfer { - /** MsgTransfer sourcePort */ - sourcePort?: string | null; + /** ExistenceProof path */ + path?: ics23.IInnerOp[] | null; + } - /** MsgTransfer sourceChannel */ - sourceChannel?: string | null; + /** + * ExistenceProof takes a key and a value and a set of steps to perform on it. + * The result of peforming all these steps will provide a "root hash", which can + * be compared to the value in a header. + * + * Since it is computationally infeasible to produce a hash collission for any of the used + * cryptographic hash functions, if someone can provide a series of operations to transform + * a given key and value into a root hash that matches some trusted root, these key and values + * must be in the referenced merkle tree. + * + * The only possible issue is maliablity in LeafOp, such as providing extra prefix data, + * which should be controlled by a spec. Eg. with lengthOp as NONE, + * prefix = FOO, key = BAR, value = CHOICE + * and + * prefix = F, key = OOBAR, value = CHOICE + * would produce the same value. + * + * With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field + * in the ProofSpec is valuable to prevent this mutability. And why all trees should + * length-prefix the data before hashing it. + */ + class ExistenceProof implements IExistenceProof { + /** + * Constructs a new ExistenceProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.IExistenceProof); + + /** ExistenceProof key. */ + public key: Uint8Array; + + /** ExistenceProof value. */ + public value: Uint8Array; + + /** ExistenceProof leaf. */ + public leaf?: ics23.ILeafOp | null; + + /** ExistenceProof path. */ + public path: ics23.IInnerOp[]; + + /** + * Creates a new ExistenceProof instance using the specified properties. + * @param [properties] Properties to set + * @returns ExistenceProof instance + */ + public static create(properties?: ics23.IExistenceProof): ics23.ExistenceProof; + + /** + * Encodes the specified ExistenceProof message. Does not implicitly {@link ics23.ExistenceProof.verify|verify} messages. + * @param m ExistenceProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IExistenceProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExistenceProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ExistenceProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.ExistenceProof; + } - /** MsgTransfer token */ - token?: cosmos.base.v1beta1.ICoin | null; + /** Properties of a NonExistenceProof. */ + interface INonExistenceProof { + /** NonExistenceProof key */ + key?: Uint8Array | null; - /** MsgTransfer sender */ - sender?: string | null; + /** NonExistenceProof left */ + left?: ics23.IExistenceProof | null; - /** MsgTransfer receiver */ - receiver?: string | null; + /** NonExistenceProof right */ + right?: ics23.IExistenceProof | null; + } - /** MsgTransfer timeoutHeight */ - timeoutHeight?: ibc.core.client.v1.IHeight | null; + /** Represents a NonExistenceProof. */ + class NonExistenceProof implements INonExistenceProof { + /** + * Constructs a new NonExistenceProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.INonExistenceProof); + + /** NonExistenceProof key. */ + public key: Uint8Array; + + /** NonExistenceProof left. */ + public left?: ics23.IExistenceProof | null; + + /** NonExistenceProof right. */ + public right?: ics23.IExistenceProof | null; + + /** + * Creates a new NonExistenceProof instance using the specified properties. + * @param [properties] Properties to set + * @returns NonExistenceProof instance + */ + public static create(properties?: ics23.INonExistenceProof): ics23.NonExistenceProof; + + /** + * Encodes the specified NonExistenceProof message. Does not implicitly {@link ics23.NonExistenceProof.verify|verify} messages. + * @param m NonExistenceProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.INonExistenceProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a NonExistenceProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns NonExistenceProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.NonExistenceProof; + } - /** MsgTransfer timeoutTimestamp */ - timeoutTimestamp?: Long | null; - } + /** Properties of a CommitmentProof. */ + interface ICommitmentProof { + /** CommitmentProof exist */ + exist?: ics23.IExistenceProof | null; - /** Represents a MsgTransfer. */ - class MsgTransfer implements IMsgTransfer { - /** - * Constructs a new MsgTransfer. - * @param [p] Properties to set - */ - constructor(p?: ibc.applications.transfer.v1.IMsgTransfer); + /** CommitmentProof nonexist */ + nonexist?: ics23.INonExistenceProof | null; - /** MsgTransfer sourcePort. */ - public sourcePort: string; + /** CommitmentProof batch */ + batch?: ics23.IBatchProof | null; - /** MsgTransfer sourceChannel. */ - public sourceChannel: string; + /** CommitmentProof compressed */ + compressed?: ics23.ICompressedBatchProof | null; + } - /** MsgTransfer token. */ - public token?: cosmos.base.v1beta1.ICoin | null; + /** Represents a CommitmentProof. */ + class CommitmentProof implements ICommitmentProof { + /** + * Constructs a new CommitmentProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.ICommitmentProof); + + /** CommitmentProof exist. */ + public exist?: ics23.IExistenceProof | null; + + /** CommitmentProof nonexist. */ + public nonexist?: ics23.INonExistenceProof | null; + + /** CommitmentProof batch. */ + public batch?: ics23.IBatchProof | null; + + /** CommitmentProof compressed. */ + public compressed?: ics23.ICompressedBatchProof | null; + + /** CommitmentProof proof. */ + public proof?: 'exist' | 'nonexist' | 'batch' | 'compressed'; + + /** + * Creates a new CommitmentProof instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitmentProof instance + */ + public static create(properties?: ics23.ICommitmentProof): ics23.CommitmentProof; + + /** + * Encodes the specified CommitmentProof message. Does not implicitly {@link ics23.CommitmentProof.verify|verify} messages. + * @param m CommitmentProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ICommitmentProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitmentProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CommitmentProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.CommitmentProof; + } - /** MsgTransfer sender. */ - public sender: string; + /** Properties of a LeafOp. */ + interface ILeafOp { + /** LeafOp hash */ + hash?: ics23.HashOp | null; - /** MsgTransfer receiver. */ - public receiver: string; + /** LeafOp prehashKey */ + prehashKey?: ics23.HashOp | null; - /** MsgTransfer timeoutHeight. */ - public timeoutHeight?: ibc.core.client.v1.IHeight | null; + /** LeafOp prehashValue */ + prehashValue?: ics23.HashOp | null; - /** MsgTransfer timeoutTimestamp. */ - public timeoutTimestamp: Long; + /** LeafOp length */ + length?: ics23.LengthOp | null; - /** - * Creates a new MsgTransfer instance using the specified properties. - * @param [properties] Properties to set - * @returns MsgTransfer instance - */ - public static create( - properties?: ibc.applications.transfer.v1.IMsgTransfer, - ): ibc.applications.transfer.v1.MsgTransfer; + /** LeafOp prefix */ + prefix?: Uint8Array | null; + } - /** - * Encodes the specified MsgTransfer message. Does not implicitly {@link ibc.applications.transfer.v1.MsgTransfer.verify|verify} messages. - * @param m MsgTransfer message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode( - m: ibc.applications.transfer.v1.IMsgTransfer, - w?: $protobuf.Writer, - ): $protobuf.Writer; + /** + * LeafOp represents the raw key-value data we wish to prove, and + * must be flexible to represent the internal transformation from + * the original key-value pairs into the basis hash, for many existing + * merkle trees. + * + * key and value are passed in. So that the signature of this operation is: + * leafOp(key, value) -> output + * + * To process this, first prehash the keys and values if needed (ANY means no hash in this case): + * hkey = prehashKey(key) + * hvalue = prehashValue(value) + * + * Then combine the bytes, and hash it + * output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) + */ + class LeafOp implements ILeafOp { + /** + * Constructs a new LeafOp. + * @param [p] Properties to set + */ + constructor(p?: ics23.ILeafOp); + + /** LeafOp hash. */ + public hash: ics23.HashOp; + + /** LeafOp prehashKey. */ + public prehashKey: ics23.HashOp; + + /** LeafOp prehashValue. */ + public prehashValue: ics23.HashOp; + + /** LeafOp length. */ + public length: ics23.LengthOp; + + /** LeafOp prefix. */ + public prefix: Uint8Array; + + /** + * Creates a new LeafOp instance using the specified properties. + * @param [properties] Properties to set + * @returns LeafOp instance + */ + public static create(properties?: ics23.ILeafOp): ics23.LeafOp; + + /** + * Encodes the specified LeafOp message. Does not implicitly {@link ics23.LeafOp.verify|verify} messages. + * @param m LeafOp message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ILeafOp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LeafOp message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns LeafOp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.LeafOp; + } - /** - * Decodes a MsgTransfer message from the specified reader or buffer. + /** Properties of an InnerOp. */ + interface IInnerOp { + /** InnerOp hash */ + hash?: ics23.HashOp | null; + + /** InnerOp prefix */ + prefix?: Uint8Array | null; + + /** InnerOp suffix */ + suffix?: Uint8Array | null; + } + + /** + * InnerOp represents a merkle-proof step that is not a leaf. + * It represents concatenating two children and hashing them to provide the next result. + * + * The result of the previous step is passed in, so the signature of this op is: + * innerOp(child) -> output + * + * The result of applying InnerOp should be: + * output = op.hash(op.prefix || child || op.suffix) + * + * where the || operator is concatenation of binary data, + * and child is the result of hashing all the tree below this step. + * + * Any special data, like prepending child with the length, or prepending the entire operation with + * some value to differentiate from leaf nodes, should be included in prefix and suffix. + * If either of prefix or suffix is empty, we just treat it as an empty string + */ + class InnerOp implements IInnerOp { + /** + * Constructs a new InnerOp. + * @param [p] Properties to set + */ + constructor(p?: ics23.IInnerOp); + + /** InnerOp hash. */ + public hash: ics23.HashOp; + + /** InnerOp prefix. */ + public prefix: Uint8Array; + + /** InnerOp suffix. */ + public suffix: Uint8Array; + + /** + * Creates a new InnerOp instance using the specified properties. + * @param [properties] Properties to set + * @returns InnerOp instance + */ + public static create(properties?: ics23.IInnerOp): ics23.InnerOp; + + /** + * Encodes the specified InnerOp message. Does not implicitly {@link ics23.InnerOp.verify|verify} messages. + * @param m InnerOp message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IInnerOp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InnerOp message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns InnerOp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.InnerOp; + } + + /** Properties of a ProofSpec. */ + interface IProofSpec { + /** ProofSpec leafSpec */ + leafSpec?: ics23.ILeafOp | null; + + /** ProofSpec innerSpec */ + innerSpec?: ics23.IInnerSpec | null; + + /** ProofSpec maxDepth */ + maxDepth?: number | null; + + /** ProofSpec minDepth */ + minDepth?: number | null; + } + + /** + * ProofSpec defines what the expected parameters are for a given proof type. + * This can be stored in the client and used to validate any incoming proofs. + * + * verify(ProofSpec, Proof) -> Proof | Error + * + * As demonstrated in tests, if we don't fix the algorithm used to calculate the + * LeafHash for a given tree, there are many possible key-value pairs that can + * generate a given hash (by interpretting the preimage differently). + * We need this for proper security, requires client knows a priori what + * tree format server uses. But not in code, rather a configuration object. + */ + class ProofSpec implements IProofSpec { + /** + * Constructs a new ProofSpec. + * @param [p] Properties to set + */ + constructor(p?: ics23.IProofSpec); + + /** ProofSpec leafSpec. */ + public leafSpec?: ics23.ILeafOp | null; + + /** ProofSpec innerSpec. */ + public innerSpec?: ics23.IInnerSpec | null; + + /** ProofSpec maxDepth. */ + public maxDepth: number; + + /** ProofSpec minDepth. */ + public minDepth: number; + + /** + * Creates a new ProofSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns ProofSpec instance + */ + public static create(properties?: ics23.IProofSpec): ics23.ProofSpec; + + /** + * Encodes the specified ProofSpec message. Does not implicitly {@link ics23.ProofSpec.verify|verify} messages. + * @param m ProofSpec message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IProofSpec, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProofSpec message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ProofSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.ProofSpec; + } + + /** Properties of an InnerSpec. */ + interface IInnerSpec { + /** InnerSpec childOrder */ + childOrder?: number[] | null; + + /** InnerSpec childSize */ + childSize?: number | null; + + /** InnerSpec minPrefixLength */ + minPrefixLength?: number | null; + + /** InnerSpec maxPrefixLength */ + maxPrefixLength?: number | null; + + /** InnerSpec emptyChild */ + emptyChild?: Uint8Array | null; + + /** InnerSpec hash */ + hash?: ics23.HashOp | null; + } + + /** Represents an InnerSpec. */ + class InnerSpec implements IInnerSpec { + /** + * Constructs a new InnerSpec. + * @param [p] Properties to set + */ + constructor(p?: ics23.IInnerSpec); + + /** InnerSpec childOrder. */ + public childOrder: number[]; + + /** InnerSpec childSize. */ + public childSize: number; + + /** InnerSpec minPrefixLength. */ + public minPrefixLength: number; + + /** InnerSpec maxPrefixLength. */ + public maxPrefixLength: number; + + /** InnerSpec emptyChild. */ + public emptyChild: Uint8Array; + + /** InnerSpec hash. */ + public hash: ics23.HashOp; + + /** + * Creates a new InnerSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns InnerSpec instance + */ + public static create(properties?: ics23.IInnerSpec): ics23.InnerSpec; + + /** + * Encodes the specified InnerSpec message. Does not implicitly {@link ics23.InnerSpec.verify|verify} messages. + * @param m InnerSpec message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IInnerSpec, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InnerSpec message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns InnerSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.InnerSpec; + } + + /** Properties of a BatchProof. */ + interface IBatchProof { + /** BatchProof entries */ + entries?: ics23.IBatchEntry[] | null; + } + + /** Represents a BatchProof. */ + class BatchProof implements IBatchProof { + /** + * Constructs a new BatchProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.IBatchProof); + + /** BatchProof entries. */ + public entries: ics23.IBatchEntry[]; + + /** + * Creates a new BatchProof instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchProof instance + */ + public static create(properties?: ics23.IBatchProof): ics23.BatchProof; + + /** + * Encodes the specified BatchProof message. Does not implicitly {@link ics23.BatchProof.verify|verify} messages. + * @param m BatchProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IBatchProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns BatchProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.BatchProof; + } + + /** Properties of a BatchEntry. */ + interface IBatchEntry { + /** BatchEntry exist */ + exist?: ics23.IExistenceProof | null; + + /** BatchEntry nonexist */ + nonexist?: ics23.INonExistenceProof | null; + } + + /** Represents a BatchEntry. */ + class BatchEntry implements IBatchEntry { + /** + * Constructs a new BatchEntry. + * @param [p] Properties to set + */ + constructor(p?: ics23.IBatchEntry); + + /** BatchEntry exist. */ + public exist?: ics23.IExistenceProof | null; + + /** BatchEntry nonexist. */ + public nonexist?: ics23.INonExistenceProof | null; + + /** BatchEntry proof. */ + public proof?: 'exist' | 'nonexist'; + + /** + * Creates a new BatchEntry instance using the specified properties. + * @param [properties] Properties to set + * @returns BatchEntry instance + */ + public static create(properties?: ics23.IBatchEntry): ics23.BatchEntry; + + /** + * Encodes the specified BatchEntry message. Does not implicitly {@link ics23.BatchEntry.verify|verify} messages. + * @param m BatchEntry message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.IBatchEntry, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BatchEntry message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns BatchEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.BatchEntry; + } + + /** Properties of a CompressedBatchProof. */ + interface ICompressedBatchProof { + /** CompressedBatchProof entries */ + entries?: ics23.ICompressedBatchEntry[] | null; + + /** CompressedBatchProof lookupInners */ + lookupInners?: ics23.IInnerOp[] | null; + } + + /** Represents a CompressedBatchProof. */ + class CompressedBatchProof implements ICompressedBatchProof { + /** + * Constructs a new CompressedBatchProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.ICompressedBatchProof); + + /** CompressedBatchProof entries. */ + public entries: ics23.ICompressedBatchEntry[]; + + /** CompressedBatchProof lookupInners. */ + public lookupInners: ics23.IInnerOp[]; + + /** + * Creates a new CompressedBatchProof instance using the specified properties. + * @param [properties] Properties to set + * @returns CompressedBatchProof instance + */ + public static create(properties?: ics23.ICompressedBatchProof): ics23.CompressedBatchProof; + + /** + * Encodes the specified CompressedBatchProof message. Does not implicitly {@link ics23.CompressedBatchProof.verify|verify} messages. + * @param m CompressedBatchProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ICompressedBatchProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompressedBatchProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CompressedBatchProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.CompressedBatchProof; + } + + /** Properties of a CompressedBatchEntry. */ + interface ICompressedBatchEntry { + /** CompressedBatchEntry exist */ + exist?: ics23.ICompressedExistenceProof | null; + + /** CompressedBatchEntry nonexist */ + nonexist?: ics23.ICompressedNonExistenceProof | null; + } + + /** Represents a CompressedBatchEntry. */ + class CompressedBatchEntry implements ICompressedBatchEntry { + /** + * Constructs a new CompressedBatchEntry. + * @param [p] Properties to set + */ + constructor(p?: ics23.ICompressedBatchEntry); + + /** CompressedBatchEntry exist. */ + public exist?: ics23.ICompressedExistenceProof | null; + + /** CompressedBatchEntry nonexist. */ + public nonexist?: ics23.ICompressedNonExistenceProof | null; + + /** CompressedBatchEntry proof. */ + public proof?: 'exist' | 'nonexist'; + + /** + * Creates a new CompressedBatchEntry instance using the specified properties. + * @param [properties] Properties to set + * @returns CompressedBatchEntry instance + */ + public static create(properties?: ics23.ICompressedBatchEntry): ics23.CompressedBatchEntry; + + /** + * Encodes the specified CompressedBatchEntry message. Does not implicitly {@link ics23.CompressedBatchEntry.verify|verify} messages. + * @param m CompressedBatchEntry message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ICompressedBatchEntry, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompressedBatchEntry message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CompressedBatchEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.CompressedBatchEntry; + } + + /** Properties of a CompressedExistenceProof. */ + interface ICompressedExistenceProof { + /** CompressedExistenceProof key */ + key?: Uint8Array | null; + + /** CompressedExistenceProof value */ + value?: Uint8Array | null; + + /** CompressedExistenceProof leaf */ + leaf?: ics23.ILeafOp | null; + + /** CompressedExistenceProof path */ + path?: number[] | null; + } + + /** Represents a CompressedExistenceProof. */ + class CompressedExistenceProof implements ICompressedExistenceProof { + /** + * Constructs a new CompressedExistenceProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.ICompressedExistenceProof); + + /** CompressedExistenceProof key. */ + public key: Uint8Array; + + /** CompressedExistenceProof value. */ + public value: Uint8Array; + + /** CompressedExistenceProof leaf. */ + public leaf?: ics23.ILeafOp | null; + + /** CompressedExistenceProof path. */ + public path: number[]; + + /** + * Creates a new CompressedExistenceProof instance using the specified properties. + * @param [properties] Properties to set + * @returns CompressedExistenceProof instance + */ + public static create(properties?: ics23.ICompressedExistenceProof): ics23.CompressedExistenceProof; + + /** + * Encodes the specified CompressedExistenceProof message. Does not implicitly {@link ics23.CompressedExistenceProof.verify|verify} messages. + * @param m CompressedExistenceProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ICompressedExistenceProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompressedExistenceProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CompressedExistenceProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.CompressedExistenceProof; + } + + /** Properties of a CompressedNonExistenceProof. */ + interface ICompressedNonExistenceProof { + /** CompressedNonExistenceProof key */ + key?: Uint8Array | null; + + /** CompressedNonExistenceProof left */ + left?: ics23.ICompressedExistenceProof | null; + + /** CompressedNonExistenceProof right */ + right?: ics23.ICompressedExistenceProof | null; + } + + /** Represents a CompressedNonExistenceProof. */ + class CompressedNonExistenceProof implements ICompressedNonExistenceProof { + /** + * Constructs a new CompressedNonExistenceProof. + * @param [p] Properties to set + */ + constructor(p?: ics23.ICompressedNonExistenceProof); + + /** CompressedNonExistenceProof key. */ + public key: Uint8Array; + + /** CompressedNonExistenceProof left. */ + public left?: ics23.ICompressedExistenceProof | null; + + /** CompressedNonExistenceProof right. */ + public right?: ics23.ICompressedExistenceProof | null; + + /** + * Creates a new CompressedNonExistenceProof instance using the specified properties. + * @param [properties] Properties to set + * @returns CompressedNonExistenceProof instance + */ + public static create(properties?: ics23.ICompressedNonExistenceProof): ics23.CompressedNonExistenceProof; + + /** + * Encodes the specified CompressedNonExistenceProof message. Does not implicitly {@link ics23.CompressedNonExistenceProof.verify|verify} messages. + * @param m CompressedNonExistenceProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ics23.ICompressedNonExistenceProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompressedNonExistenceProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CompressedNonExistenceProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ics23.CompressedNonExistenceProof; + } +} + +/** Namespace tendermint. */ +export namespace tendermintV2 { + /** Namespace types. */ + namespace types { + /** BlockIDFlag enum. */ + enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + } + + /** SignedMsgType enum. */ + enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + SIGNED_MSG_TYPE_PROPOSAL = 32, + } + + /** Properties of a PartSetHeader. */ + interface IPartSetHeader { + /** PartSetHeader total */ + total?: number | null; + + /** PartSetHeader hash */ + hash?: Uint8Array | null; + } + + /** Represents a PartSetHeader. */ + class PartSetHeader implements IPartSetHeader { + /** + * Constructs a new PartSetHeader. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IPartSetHeader); + + /** PartSetHeader total. */ + public total: number; + + /** PartSetHeader hash. */ + public hash: Uint8Array; + + /** + * Creates a new PartSetHeader instance using the specified properties. + * @param [properties] Properties to set + * @returns PartSetHeader instance + */ + public static create(properties?: tendermintV2.types.IPartSetHeader): tendermintV2.types.PartSetHeader; + + /** + * Encodes the specified PartSetHeader message. Does not implicitly {@link tendermint.types.PartSetHeader.verify|verify} messages. + * @param m PartSetHeader message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IPartSetHeader, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PartSetHeader message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PartSetHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.PartSetHeader; + } + + /** Properties of a Part. */ + interface IPart { + /** Part index */ + index?: number | null; + + /** Part bytes */ + bytes?: Uint8Array | null; + + /** Part proof */ + proof?: tendermintV2.crypto.IProof | null; + } + + /** Represents a Part. */ + class Part implements IPart { + /** + * Constructs a new Part. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IPart); + + /** Part index. */ + public index: number; + + /** Part bytes. */ + public bytes: Uint8Array; + + /** Part proof. */ + public proof?: tendermintV2.crypto.IProof | null; + + /** + * Creates a new Part instance using the specified properties. + * @param [properties] Properties to set + * @returns Part instance + */ + public static create(properties?: tendermintV2.types.IPart): tendermintV2.types.Part; + + /** + * Encodes the specified Part message. Does not implicitly {@link tendermint.types.Part.verify|verify} messages. + * @param m Part message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IPart, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Part message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Part + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Part; + } + + /** Properties of a BlockID. */ + interface IBlockID { + /** BlockID hash */ + hash?: Uint8Array | null; + + /** BlockID partSetHeader */ + partSetHeader?: tendermintV2.types.IPartSetHeader | null; + } + + /** Represents a BlockID. */ + class BlockID implements IBlockID { + /** + * Constructs a new BlockID. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IBlockID); + + /** BlockID hash. */ + public hash: Uint8Array; + + /** BlockID partSetHeader. */ + public partSetHeader?: tendermintV2.types.IPartSetHeader | null; + + /** + * Creates a new BlockID instance using the specified properties. + * @param [properties] Properties to set + * @returns BlockID instance + */ + public static create(properties?: tendermintV2.types.IBlockID): tendermintV2.types.BlockID; + + /** + * Encodes the specified BlockID message. Does not implicitly {@link tendermint.types.BlockID.verify|verify} messages. + * @param m BlockID message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IBlockID, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BlockID message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns BlockID + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.BlockID; + } + + /** Properties of a Header. */ + interface IHeader { + /** Header version */ + version?: tendermintV2.version.IConsensus | null; + + /** Header chainId */ + chainId?: string | null; + + /** Header height */ + height?: Long | null; + + /** Header time */ + time?: google.protobuf.ITimestamp | null; + + /** Header lastBlockId */ + lastBlockId?: tendermintV2.types.IBlockID | null; + + /** Header lastCommitHash */ + lastCommitHash?: Uint8Array | null; + + /** Header dataHash */ + dataHash?: Uint8Array | null; + + /** Header validatorsHash */ + validatorsHash?: Uint8Array | null; + + /** Header nextValidatorsHash */ + nextValidatorsHash?: Uint8Array | null; + + /** Header consensusHash */ + consensusHash?: Uint8Array | null; + + /** Header appHash */ + appHash?: Uint8Array | null; + + /** Header lastResultsHash */ + lastResultsHash?: Uint8Array | null; + + /** Header evidenceHash */ + evidenceHash?: Uint8Array | null; + + /** Header proposerAddress */ + proposerAddress?: Uint8Array | null; + } + + /** Represents a Header. */ + class Header implements IHeader { + /** + * Constructs a new Header. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IHeader); + + /** Header version. */ + public version?: tendermintV2.version.IConsensus | null; + + /** Header chainId. */ + public chainId: string; + + /** Header height. */ + public height: Long; + + /** Header time. */ + public time?: google.protobuf.ITimestamp | null; + + /** Header lastBlockId. */ + public lastBlockId?: tendermintV2.types.IBlockID | null; + + /** Header lastCommitHash. */ + public lastCommitHash: Uint8Array; + + /** Header dataHash. */ + public dataHash: Uint8Array; + + /** Header validatorsHash. */ + public validatorsHash: Uint8Array; + + /** Header nextValidatorsHash. */ + public nextValidatorsHash: Uint8Array; + + /** Header consensusHash. */ + public consensusHash: Uint8Array; + + /** Header appHash. */ + public appHash: Uint8Array; + + /** Header lastResultsHash. */ + public lastResultsHash: Uint8Array; + + /** Header evidenceHash. */ + public evidenceHash: Uint8Array; + + /** Header proposerAddress. */ + public proposerAddress: Uint8Array; + + /** + * Creates a new Header instance using the specified properties. + * @param [properties] Properties to set + * @returns Header instance + */ + public static create(properties?: tendermintV2.types.IHeader): tendermintV2.types.Header; + + /** + * Encodes the specified Header message. Does not implicitly {@link tendermint.types.Header.verify|verify} messages. + * @param m Header message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IHeader, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Header message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Header + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Header; + } + + /** Properties of a Data. */ + interface IData { + /** Data txs */ + txs?: Uint8Array[] | null; + } + + /** Represents a Data. */ + class Data implements IData { + /** + * Constructs a new Data. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IData); + + /** Data txs. */ + public txs: Uint8Array[]; + + /** + * Creates a new Data instance using the specified properties. + * @param [properties] Properties to set + * @returns Data instance + */ + public static create(properties?: tendermintV2.types.IData): tendermintV2.types.Data; + + /** + * Encodes the specified Data message. Does not implicitly {@link tendermint.types.Data.verify|verify} messages. + * @param m Data message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IData, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Data message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Data + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Data; + } + + /** Properties of a Vote. */ + interface IVote { + /** Vote type */ + type?: tendermintV2.types.SignedMsgType | null; + + /** Vote height */ + height?: Long | null; + + /** Vote round */ + round?: number | null; + + /** Vote blockId */ + blockId?: tendermintV2.types.IBlockID | null; + + /** Vote timestamp */ + timestamp?: google.protobuf.ITimestamp | null; + + /** Vote validatorAddress */ + validatorAddress?: Uint8Array | null; + + /** Vote validatorIndex */ + validatorIndex?: number | null; + + /** Vote signature */ + signature?: Uint8Array | null; + } + + /** Represents a Vote. */ + class Vote implements IVote { + /** + * Constructs a new Vote. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IVote); + + /** Vote type. */ + public type: tendermintV2.types.SignedMsgType; + + /** Vote height. */ + public height: Long; + + /** Vote round. */ + public round: number; + + /** Vote blockId. */ + public blockId?: tendermintV2.types.IBlockID | null; + + /** Vote timestamp. */ + public timestamp?: google.protobuf.ITimestamp | null; + + /** Vote validatorAddress. */ + public validatorAddress: Uint8Array; + + /** Vote validatorIndex. */ + public validatorIndex: number; + + /** Vote signature. */ + public signature: Uint8Array; + + /** + * Creates a new Vote instance using the specified properties. + * @param [properties] Properties to set + * @returns Vote instance + */ + public static create(properties?: tendermintV2.types.IVote): tendermintV2.types.Vote; + + /** + * Encodes the specified Vote message. Does not implicitly {@link tendermint.types.Vote.verify|verify} messages. + * @param m Vote message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IVote, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Vote message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Vote + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Vote; + } + + /** Properties of a Commit. */ + interface ICommit { + /** Commit height */ + height?: Long | null; + + /** Commit round */ + round?: number | null; + + /** Commit blockId */ + blockId?: tendermintV2.types.IBlockID | null; + + /** Commit signatures */ + signatures?: tendermintV2.types.ICommitSig[] | null; + } + + /** Represents a Commit. */ + class Commit implements ICommit { + /** + * Constructs a new Commit. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ICommit); + + /** Commit height. */ + public height: Long; + + /** Commit round. */ + public round: number; + + /** Commit blockId. */ + public blockId?: tendermintV2.types.IBlockID | null; + + /** Commit signatures. */ + public signatures: tendermintV2.types.ICommitSig[]; + + /** + * Creates a new Commit instance using the specified properties. + * @param [properties] Properties to set + * @returns Commit instance + */ + public static create(properties?: tendermintV2.types.ICommit): tendermintV2.types.Commit; + + /** + * Encodes the specified Commit message. Does not implicitly {@link tendermint.types.Commit.verify|verify} messages. + * @param m Commit message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ICommit, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Commit message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Commit + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Commit; + } + + /** Properties of a CommitSig. */ + interface ICommitSig { + /** CommitSig blockIdFlag */ + blockIdFlag?: tendermintV2.types.BlockIDFlag | null; + + /** CommitSig validatorAddress */ + validatorAddress?: Uint8Array | null; + + /** CommitSig timestamp */ + timestamp?: google.protobuf.ITimestamp | null; + + /** CommitSig signature */ + signature?: Uint8Array | null; + } + + /** Represents a CommitSig. */ + class CommitSig implements ICommitSig { + /** + * Constructs a new CommitSig. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ICommitSig); + + /** CommitSig blockIdFlag. */ + public blockIdFlag: tendermintV2.types.BlockIDFlag; + + /** CommitSig validatorAddress. */ + public validatorAddress: Uint8Array; + + /** CommitSig timestamp. */ + public timestamp?: google.protobuf.ITimestamp | null; + + /** CommitSig signature. */ + public signature: Uint8Array; + + /** + * Creates a new CommitSig instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitSig instance + */ + public static create(properties?: tendermintV2.types.ICommitSig): tendermintV2.types.CommitSig; + + /** + * Encodes the specified CommitSig message. Does not implicitly {@link tendermint.types.CommitSig.verify|verify} messages. + * @param m CommitSig message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ICommitSig, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitSig message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns CommitSig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.CommitSig; + } + + /** Properties of a Proposal. */ + interface IProposal { + /** Proposal type */ + type?: tendermintV2.types.SignedMsgType | null; + + /** Proposal height */ + height?: Long | null; + + /** Proposal round */ + round?: number | null; + + /** Proposal polRound */ + polRound?: number | null; + + /** Proposal blockId */ + blockId?: tendermintV2.types.IBlockID | null; + + /** Proposal timestamp */ + timestamp?: google.protobuf.ITimestamp | null; + + /** Proposal signature */ + signature?: Uint8Array | null; + } + + /** Represents a Proposal. */ + class Proposal implements IProposal { + /** + * Constructs a new Proposal. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IProposal); + + /** Proposal type. */ + public type: tendermintV2.types.SignedMsgType; + + /** Proposal height. */ + public height: Long; + + /** Proposal round. */ + public round: number; + + /** Proposal polRound. */ + public polRound: number; + + /** Proposal blockId. */ + public blockId?: tendermintV2.types.IBlockID | null; + + /** Proposal timestamp. */ + public timestamp?: google.protobuf.ITimestamp | null; + + /** Proposal signature. */ + public signature: Uint8Array; + + /** + * Creates a new Proposal instance using the specified properties. + * @param [properties] Properties to set + * @returns Proposal instance + */ + public static create(properties?: tendermintV2.types.IProposal): tendermintV2.types.Proposal; + + /** + * Encodes the specified Proposal message. Does not implicitly {@link tendermint.types.Proposal.verify|verify} messages. + * @param m Proposal message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IProposal, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Proposal message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Proposal + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Proposal; + } + + /** Properties of a SignedHeader. */ + interface ISignedHeader { + /** SignedHeader header */ + header?: tendermintV2.types.IHeader | null; + + /** SignedHeader commit */ + commit?: tendermintV2.types.ICommit | null; + } + + /** Represents a SignedHeader. */ + class SignedHeader implements ISignedHeader { + /** + * Constructs a new SignedHeader. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ISignedHeader); + + /** SignedHeader header. */ + public header?: tendermintV2.types.IHeader | null; + + /** SignedHeader commit. */ + public commit?: tendermintV2.types.ICommit | null; + + /** + * Creates a new SignedHeader instance using the specified properties. + * @param [properties] Properties to set + * @returns SignedHeader instance + */ + public static create(properties?: tendermintV2.types.ISignedHeader): tendermintV2.types.SignedHeader; + + /** + * Encodes the specified SignedHeader message. Does not implicitly {@link tendermint.types.SignedHeader.verify|verify} messages. + * @param m SignedHeader message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ISignedHeader, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SignedHeader message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns SignedHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.SignedHeader; + } + + /** Properties of a LightBlock. */ + interface ILightBlock { + /** LightBlock signedHeader */ + signedHeader?: tendermintV2.types.ISignedHeader | null; + + /** LightBlock validatorSet */ + validatorSet?: tendermintV2.types.IValidatorSet | null; + } + + /** Represents a LightBlock. */ + class LightBlock implements ILightBlock { + /** + * Constructs a new LightBlock. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ILightBlock); + + /** LightBlock signedHeader. */ + public signedHeader?: tendermintV2.types.ISignedHeader | null; + + /** LightBlock validatorSet. */ + public validatorSet?: tendermintV2.types.IValidatorSet | null; + + /** + * Creates a new LightBlock instance using the specified properties. + * @param [properties] Properties to set + * @returns LightBlock instance + */ + public static create(properties?: tendermintV2.types.ILightBlock): tendermintV2.types.LightBlock; + + /** + * Encodes the specified LightBlock message. Does not implicitly {@link tendermint.types.LightBlock.verify|verify} messages. + * @param m LightBlock message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ILightBlock, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LightBlock message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns LightBlock + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.LightBlock; + } + + /** Properties of a BlockMeta. */ + interface IBlockMeta { + /** BlockMeta blockId */ + blockId?: tendermintV2.types.IBlockID | null; + + /** BlockMeta blockSize */ + blockSize?: Long | null; + + /** BlockMeta header */ + header?: tendermintV2.types.IHeader | null; + + /** BlockMeta numTxs */ + numTxs?: Long | null; + } + + /** Represents a BlockMeta. */ + class BlockMeta implements IBlockMeta { + /** + * Constructs a new BlockMeta. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IBlockMeta); + + /** BlockMeta blockId. */ + public blockId?: tendermintV2.types.IBlockID | null; + + /** BlockMeta blockSize. */ + public blockSize: Long; + + /** BlockMeta header. */ + public header?: tendermintV2.types.IHeader | null; + + /** BlockMeta numTxs. */ + public numTxs: Long; + + /** + * Creates a new BlockMeta instance using the specified properties. + * @param [properties] Properties to set + * @returns BlockMeta instance + */ + public static create(properties?: tendermintV2.types.IBlockMeta): tendermintV2.types.BlockMeta; + + /** + * Encodes the specified BlockMeta message. Does not implicitly {@link tendermint.types.BlockMeta.verify|verify} messages. + * @param m BlockMeta message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IBlockMeta, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BlockMeta message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns BlockMeta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.BlockMeta; + } + + /** Properties of a TxProof. */ + interface ITxProof { + /** TxProof rootHash */ + rootHash?: Uint8Array | null; + + /** TxProof data */ + data?: Uint8Array | null; + + /** TxProof proof */ + proof?: tendermintV2.crypto.IProof | null; + } + + /** Represents a TxProof. */ + class TxProof implements ITxProof { + /** + * Constructs a new TxProof. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ITxProof); + + /** TxProof rootHash. */ + public rootHash: Uint8Array; + + /** TxProof data. */ + public data: Uint8Array; + + /** TxProof proof. */ + public proof?: tendermintV2.crypto.IProof | null; + + /** + * Creates a new TxProof instance using the specified properties. + * @param [properties] Properties to set + * @returns TxProof instance + */ + public static create(properties?: tendermintV2.types.ITxProof): tendermintV2.types.TxProof; + + /** + * Encodes the specified TxProof message. Does not implicitly {@link tendermint.types.TxProof.verify|verify} messages. + * @param m TxProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ITxProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TxProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns TxProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.TxProof; + } + + /** Properties of a ValidatorSet. */ + interface IValidatorSet { + /** ValidatorSet validators */ + validators?: tendermintV2.types.IValidator[] | null; + + /** ValidatorSet proposer */ + proposer?: tendermintV2.types.IValidator | null; + + /** ValidatorSet totalVotingPower */ + totalVotingPower?: Long | null; + } + + /** Represents a ValidatorSet. */ + class ValidatorSet implements IValidatorSet { + /** + * Constructs a new ValidatorSet. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IValidatorSet); + + /** ValidatorSet validators. */ + public validators: tendermintV2.types.IValidator[]; + + /** ValidatorSet proposer. */ + public proposer?: tendermintV2.types.IValidator | null; + + /** ValidatorSet totalVotingPower. */ + public totalVotingPower: Long; + + /** + * Creates a new ValidatorSet instance using the specified properties. + * @param [properties] Properties to set + * @returns ValidatorSet instance + */ + public static create(properties?: tendermintV2.types.IValidatorSet): tendermintV2.types.ValidatorSet; + + /** + * Encodes the specified ValidatorSet message. Does not implicitly {@link tendermint.types.ValidatorSet.verify|verify} messages. + * @param m ValidatorSet message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IValidatorSet, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValidatorSet message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ValidatorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.ValidatorSet; + } + + /** Properties of a Validator. */ + interface IValidator { + /** Validator address */ + address?: Uint8Array | null; + + /** Validator pubKey */ + pubKey?: tendermintV2.crypto.IPublicKey | null; + + /** Validator votingPower */ + votingPower?: Long | null; + + /** Validator proposerPriority */ + proposerPriority?: Long | null; + } + + /** Represents a Validator. */ + class Validator implements IValidator { + /** + * Constructs a new Validator. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.IValidator); + + /** Validator address. */ + public address: Uint8Array; + + /** Validator pubKey. */ + public pubKey?: tendermintV2.crypto.IPublicKey | null; + + /** Validator votingPower. */ + public votingPower: Long; + + /** Validator proposerPriority. */ + public proposerPriority: Long; + + /** + * Creates a new Validator instance using the specified properties. + * @param [properties] Properties to set + * @returns Validator instance + */ + public static create(properties?: tendermintV2.types.IValidator): tendermintV2.types.Validator; + + /** + * Encodes the specified Validator message. Does not implicitly {@link tendermint.types.Validator.verify|verify} messages. + * @param m Validator message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.IValidator, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Validator message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Validator + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.Validator; + } + + /** Properties of a SimpleValidator. */ + interface ISimpleValidator { + /** SimpleValidator pubKey */ + pubKey?: tendermintV2.crypto.IPublicKey | null; + + /** SimpleValidator votingPower */ + votingPower?: Long | null; + } + + /** Represents a SimpleValidator. */ + class SimpleValidator implements ISimpleValidator { + /** + * Constructs a new SimpleValidator. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.types.ISimpleValidator); + + /** SimpleValidator pubKey. */ + public pubKey?: tendermintV2.crypto.IPublicKey | null; + + /** SimpleValidator votingPower. */ + public votingPower: Long; + + /** + * Creates a new SimpleValidator instance using the specified properties. + * @param [properties] Properties to set + * @returns SimpleValidator instance + */ + public static create(properties?: tendermintV2.types.ISimpleValidator): tendermintV2.types.SimpleValidator; + + /** + * Encodes the specified SimpleValidator message. Does not implicitly {@link tendermint.types.SimpleValidator.verify|verify} messages. + * @param m SimpleValidator message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.types.ISimpleValidator, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SimpleValidator message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns SimpleValidator + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.types.SimpleValidator; + } + } + + /** Namespace crypto. */ + namespace crypto { + /** Properties of a Proof. */ + interface IProof { + /** Proof total */ + total?: Long | null; + + /** Proof index */ + index?: Long | null; + + /** Proof leafHash */ + leafHash?: Uint8Array | null; + + /** Proof aunts */ + aunts?: Uint8Array[] | null; + } + + /** Represents a Proof. */ + class Proof implements IProof { + /** + * Constructs a new Proof. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IProof); + + /** Proof total. */ + public total: Long; + + /** Proof index. */ + public index: Long; + + /** Proof leafHash. */ + public leafHash: Uint8Array; + + /** Proof aunts. */ + public aunts: Uint8Array[]; + + /** + * Creates a new Proof instance using the specified properties. + * @param [properties] Properties to set + * @returns Proof instance + */ + public static create(properties?: tendermintV2.crypto.IProof): tendermintV2.crypto.Proof; + + /** + * Encodes the specified Proof message. Does not implicitly {@link tendermint.crypto.Proof.verify|verify} messages. + * @param m Proof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IProof, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Proof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Proof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.Proof; + } + + /** Properties of a ValueOp. */ + interface IValueOp { + /** ValueOp key */ + key?: Uint8Array | null; + + /** ValueOp proof */ + proof?: tendermintV2.crypto.IProof | null; + } + + /** Represents a ValueOp. */ + class ValueOp implements IValueOp { + /** + * Constructs a new ValueOp. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IValueOp); + + /** ValueOp key. */ + public key: Uint8Array; + + /** ValueOp proof. */ + public proof?: tendermintV2.crypto.IProof | null; + + /** + * Creates a new ValueOp instance using the specified properties. + * @param [properties] Properties to set + * @returns ValueOp instance + */ + public static create(properties?: tendermintV2.crypto.IValueOp): tendermintV2.crypto.ValueOp; + + /** + * Encodes the specified ValueOp message. Does not implicitly {@link tendermint.crypto.ValueOp.verify|verify} messages. + * @param m ValueOp message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IValueOp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ValueOp message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ValueOp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.ValueOp; + } + + /** Properties of a DominoOp. */ + interface IDominoOp { + /** DominoOp key */ + key?: string | null; + + /** DominoOp input */ + input?: string | null; + + /** DominoOp output */ + output?: string | null; + } + + /** Represents a DominoOp. */ + class DominoOp implements IDominoOp { + /** + * Constructs a new DominoOp. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IDominoOp); + + /** DominoOp key. */ + public key: string; + + /** DominoOp input. */ + public input: string; + + /** DominoOp output. */ + public output: string; + + /** + * Creates a new DominoOp instance using the specified properties. + * @param [properties] Properties to set + * @returns DominoOp instance + */ + public static create(properties?: tendermintV2.crypto.IDominoOp): tendermintV2.crypto.DominoOp; + + /** + * Encodes the specified DominoOp message. Does not implicitly {@link tendermint.crypto.DominoOp.verify|verify} messages. + * @param m DominoOp message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IDominoOp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DominoOp message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns DominoOp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.DominoOp; + } + + /** Properties of a ProofOp. */ + interface IProofOp { + /** ProofOp type */ + type?: string | null; + + /** ProofOp key */ + key?: Uint8Array | null; + + /** ProofOp data */ + data?: Uint8Array | null; + } + + /** Represents a ProofOp. */ + class ProofOp implements IProofOp { + /** + * Constructs a new ProofOp. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IProofOp); + + /** ProofOp type. */ + public type: string; + + /** ProofOp key. */ + public key: Uint8Array; + + /** ProofOp data. */ + public data: Uint8Array; + + /** + * Creates a new ProofOp instance using the specified properties. + * @param [properties] Properties to set + * @returns ProofOp instance + */ + public static create(properties?: tendermintV2.crypto.IProofOp): tendermintV2.crypto.ProofOp; + + /** + * Encodes the specified ProofOp message. Does not implicitly {@link tendermint.crypto.ProofOp.verify|verify} messages. + * @param m ProofOp message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IProofOp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProofOp message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ProofOp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.ProofOp; + } + + /** Properties of a ProofOps. */ + interface IProofOps { + /** ProofOps ops */ + ops?: tendermintV2.crypto.IProofOp[] | null; + } + + /** Represents a ProofOps. */ + class ProofOps implements IProofOps { + /** + * Constructs a new ProofOps. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IProofOps); + + /** ProofOps ops. */ + public ops: tendermintV2.crypto.IProofOp[]; + + /** + * Creates a new ProofOps instance using the specified properties. + * @param [properties] Properties to set + * @returns ProofOps instance + */ + public static create(properties?: tendermintV2.crypto.IProofOps): tendermintV2.crypto.ProofOps; + + /** + * Encodes the specified ProofOps message. Does not implicitly {@link tendermint.crypto.ProofOps.verify|verify} messages. + * @param m ProofOps message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IProofOps, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ProofOps message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ProofOps + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.ProofOps; + } + + /** Properties of a PublicKey. */ + interface IPublicKey { + /** PublicKey ed25519 */ + ed25519?: Uint8Array | null; + + /** PublicKey secp256k1 */ + secp256k1?: Uint8Array | null; + } + + /** Represents a PublicKey. */ + class PublicKey implements IPublicKey { + /** + * Constructs a new PublicKey. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.crypto.IPublicKey); + + /** PublicKey ed25519. */ + public ed25519: Uint8Array; + + /** PublicKey secp256k1. */ + public secp256k1: Uint8Array; + + /** PublicKey sum. */ + public sum?: 'ed25519' | 'secp256k1'; + + /** + * Creates a new PublicKey instance using the specified properties. + * @param [properties] Properties to set + * @returns PublicKey instance + */ + public static create(properties?: tendermintV2.crypto.IPublicKey): tendermintV2.crypto.PublicKey; + + /** + * Encodes the specified PublicKey message. Does not implicitly {@link tendermint.crypto.PublicKey.verify|verify} messages. + * @param m PublicKey message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.crypto.IPublicKey, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PublicKey message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PublicKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.crypto.PublicKey; + } + } + + /** Namespace version. */ + namespace version { + /** Properties of an App. */ + interface IApp { + /** App protocol */ + protocol?: Long | null; + + /** App software */ + software?: string | null; + } + + /** Represents an App. */ + class App implements IApp { + /** + * Constructs a new App. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.version.IApp); + + /** App protocol. */ + public protocol: Long; + + /** App software. */ + public software: string; + + /** + * Creates a new App instance using the specified properties. + * @param [properties] Properties to set + * @returns App instance + */ + public static create(properties?: tendermintV2.version.IApp): tendermintV2.version.App; + + /** + * Encodes the specified App message. Does not implicitly {@link tendermint.version.App.verify|verify} messages. + * @param m App message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.version.IApp, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an App message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns App + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.version.App; + } + + /** Properties of a Consensus. */ + interface IConsensus { + /** Consensus block */ + block?: Long | null; + + /** Consensus app */ + app?: Long | null; + } + + /** Represents a Consensus. */ + class Consensus implements IConsensus { + /** + * Constructs a new Consensus. + * @param [p] Properties to set + */ + constructor(p?: tendermintV2.version.IConsensus); + + /** Consensus block. */ + public block: Long; + + /** Consensus app. */ + public app: Long; + + /** + * Creates a new Consensus instance using the specified properties. + * @param [properties] Properties to set + * @returns Consensus instance + */ + public static create(properties?: tendermintV2.version.IConsensus): tendermintV2.version.Consensus; + + /** + * Encodes the specified Consensus message. Does not implicitly {@link tendermint.version.Consensus.verify|verify} messages. + * @param m Consensus message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: tendermintV2.version.IConsensus, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Consensus message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Consensus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermintV2.version.Consensus; + } + } +} + +/** Namespace ibc. */ +export namespace ibc { + /** Namespace core. */ + namespace core { + /** Namespace commitment. */ + namespace commitment { + /** Namespace v1. */ + namespace v1 { + /** Properties of a MerkleRoot. */ + interface IMerkleRoot { + /** MerkleRoot hash */ + hash?: Uint8Array | null; + } + + /** Represents a MerkleRoot. */ + class MerkleRoot implements IMerkleRoot { + /** + * Constructs a new MerkleRoot. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.commitment.v1.IMerkleRoot); + + /** MerkleRoot hash. */ + public hash: Uint8Array; + + /** + * Creates a new MerkleRoot instance using the specified properties. + * @param [properties] Properties to set + * @returns MerkleRoot instance + */ + public static create( + properties?: ibc.core.commitment.v1.IMerkleRoot, + ): ibc.core.commitment.v1.MerkleRoot; + + /** + * Encodes the specified MerkleRoot message. Does not implicitly {@link ibc.core.commitment.v1.MerkleRoot.verify|verify} messages. + * @param m MerkleRoot message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.commitment.v1.IMerkleRoot, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerkleRoot message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MerkleRoot + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.commitment.v1.MerkleRoot; + } + + /** Properties of a MerklePrefix. */ + interface IMerklePrefix { + /** MerklePrefix keyPrefix */ + keyPrefix?: Uint8Array | null; + } + + /** Represents a MerklePrefix. */ + class MerklePrefix implements IMerklePrefix { + /** + * Constructs a new MerklePrefix. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.commitment.v1.IMerklePrefix); + + /** MerklePrefix keyPrefix. */ + public keyPrefix: Uint8Array; + + /** + * Creates a new MerklePrefix instance using the specified properties. + * @param [properties] Properties to set + * @returns MerklePrefix instance + */ + public static create( + properties?: ibc.core.commitment.v1.IMerklePrefix, + ): ibc.core.commitment.v1.MerklePrefix; + + /** + * Encodes the specified MerklePrefix message. Does not implicitly {@link ibc.core.commitment.v1.MerklePrefix.verify|verify} messages. + * @param m MerklePrefix message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.commitment.v1.IMerklePrefix, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MerklePrefix message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MerklePrefix + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.commitment.v1.MerklePrefix; + } + + /** Properties of a MerklePath. */ + interface IMerklePath { + /** MerklePath keyPath */ + keyPath?: string[] | null; + } + + /** Represents a MerklePath. */ + class MerklePath implements IMerklePath { + /** + * Constructs a new MerklePath. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.commitment.v1.IMerklePath); + + /** MerklePath keyPath. */ + public keyPath: string[]; + + /** + * Creates a new MerklePath instance using the specified properties. + * @param [properties] Properties to set + * @returns MerklePath instance + */ + public static create( + properties?: ibc.core.commitment.v1.IMerklePath, + ): ibc.core.commitment.v1.MerklePath; + + /** + * Encodes the specified MerklePath message. Does not implicitly {@link ibc.core.commitment.v1.MerklePath.verify|verify} messages. + * @param m MerklePath message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.commitment.v1.IMerklePath, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MerklePath message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MerklePath + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.commitment.v1.MerklePath; + } + + /** Properties of a MerkleProof. */ + interface IMerkleProof { + /** MerkleProof proofs */ + proofs?: ics23.ICommitmentProof[] | null; + } + + /** Represents a MerkleProof. */ + class MerkleProof implements IMerkleProof { + /** + * Constructs a new MerkleProof. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.commitment.v1.IMerkleProof); + + /** MerkleProof proofs. */ + public proofs: ics23.ICommitmentProof[]; + + /** + * Creates a new MerkleProof instance using the specified properties. + * @param [properties] Properties to set + * @returns MerkleProof instance + */ + public static create( + properties?: ibc.core.commitment.v1.IMerkleProof, + ): ibc.core.commitment.v1.MerkleProof; + + /** + * Encodes the specified MerkleProof message. Does not implicitly {@link ibc.core.commitment.v1.MerkleProof.verify|verify} messages. + * @param m MerkleProof message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.commitment.v1.IMerkleProof, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MerkleProof message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MerkleProof + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.commitment.v1.MerkleProof; + } + } + } + + /** Namespace channel. */ + namespace channel { + /** Namespace v1. */ + namespace v1 { + /** Represents a Msg */ + class Msg extends $protobuf.rpc.Service { + /** + * Constructs a new Msg service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Msg service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create( + rpcImpl: $protobuf.RPCImpl, + requestDelimited?: boolean, + responseDelimited?: boolean, + ): Msg; + + /** + * Calls ChannelOpenInit. + * @param request MsgChannelOpenInit message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelOpenInitResponse + */ + public channelOpenInit( + request: ibc.core.channel.v1.IMsgChannelOpenInit, + callback: ibc.core.channel.v1.Msg.ChannelOpenInitCallback, + ): void; + + /** + * Calls ChannelOpenInit. + * @param request MsgChannelOpenInit message or plain object + * @returns Promise + */ + public channelOpenInit( + request: ibc.core.channel.v1.IMsgChannelOpenInit, + ): Promise; + + /** + * Calls ChannelOpenTry. + * @param request MsgChannelOpenTry message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelOpenTryResponse + */ + public channelOpenTry( + request: ibc.core.channel.v1.IMsgChannelOpenTry, + callback: ibc.core.channel.v1.Msg.ChannelOpenTryCallback, + ): void; + + /** + * Calls ChannelOpenTry. + * @param request MsgChannelOpenTry message or plain object + * @returns Promise + */ + public channelOpenTry( + request: ibc.core.channel.v1.IMsgChannelOpenTry, + ): Promise; + + /** + * Calls ChannelOpenAck. + * @param request MsgChannelOpenAck message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelOpenAckResponse + */ + public channelOpenAck( + request: ibc.core.channel.v1.IMsgChannelOpenAck, + callback: ibc.core.channel.v1.Msg.ChannelOpenAckCallback, + ): void; + + /** + * Calls ChannelOpenAck. + * @param request MsgChannelOpenAck message or plain object + * @returns Promise + */ + public channelOpenAck( + request: ibc.core.channel.v1.IMsgChannelOpenAck, + ): Promise; + + /** + * Calls ChannelOpenConfirm. + * @param request MsgChannelOpenConfirm message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelOpenConfirmResponse + */ + public channelOpenConfirm( + request: ibc.core.channel.v1.IMsgChannelOpenConfirm, + callback: ibc.core.channel.v1.Msg.ChannelOpenConfirmCallback, + ): void; + + /** + * Calls ChannelOpenConfirm. + * @param request MsgChannelOpenConfirm message or plain object + * @returns Promise + */ + public channelOpenConfirm( + request: ibc.core.channel.v1.IMsgChannelOpenConfirm, + ): Promise; + + /** + * Calls ChannelCloseInit. + * @param request MsgChannelCloseInit message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelCloseInitResponse + */ + public channelCloseInit( + request: ibc.core.channel.v1.IMsgChannelCloseInit, + callback: ibc.core.channel.v1.Msg.ChannelCloseInitCallback, + ): void; + + /** + * Calls ChannelCloseInit. + * @param request MsgChannelCloseInit message or plain object + * @returns Promise + */ + public channelCloseInit( + request: ibc.core.channel.v1.IMsgChannelCloseInit, + ): Promise; + + /** + * Calls ChannelCloseConfirm. + * @param request MsgChannelCloseConfirm message or plain object + * @param callback Node-style callback called with the error, if any, and MsgChannelCloseConfirmResponse + */ + public channelCloseConfirm( + request: ibc.core.channel.v1.IMsgChannelCloseConfirm, + callback: ibc.core.channel.v1.Msg.ChannelCloseConfirmCallback, + ): void; + + /** + * Calls ChannelCloseConfirm. + * @param request MsgChannelCloseConfirm message or plain object + * @returns Promise + */ + public channelCloseConfirm( + request: ibc.core.channel.v1.IMsgChannelCloseConfirm, + ): Promise; + + /** + * Calls RecvPacket. + * @param request MsgRecvPacket message or plain object + * @param callback Node-style callback called with the error, if any, and MsgRecvPacketResponse + */ + public recvPacket( + request: ibc.core.channel.v1.IMsgRecvPacket, + callback: ibc.core.channel.v1.Msg.RecvPacketCallback, + ): void; + + /** + * Calls RecvPacket. + * @param request MsgRecvPacket message or plain object + * @returns Promise + */ + public recvPacket( + request: ibc.core.channel.v1.IMsgRecvPacket, + ): Promise; + + /** + * Calls Timeout. + * @param request MsgTimeout message or plain object + * @param callback Node-style callback called with the error, if any, and MsgTimeoutResponse + */ + public timeout( + request: ibc.core.channel.v1.IMsgTimeout, + callback: ibc.core.channel.v1.Msg.TimeoutCallback, + ): void; + + /** + * Calls Timeout. + * @param request MsgTimeout message or plain object + * @returns Promise + */ + public timeout( + request: ibc.core.channel.v1.IMsgTimeout, + ): Promise; + + /** + * Calls TimeoutOnClose. + * @param request MsgTimeoutOnClose message or plain object + * @param callback Node-style callback called with the error, if any, and MsgTimeoutOnCloseResponse + */ + public timeoutOnClose( + request: ibc.core.channel.v1.IMsgTimeoutOnClose, + callback: ibc.core.channel.v1.Msg.TimeoutOnCloseCallback, + ): void; + + /** + * Calls TimeoutOnClose. + * @param request MsgTimeoutOnClose message or plain object + * @returns Promise + */ + public timeoutOnClose( + request: ibc.core.channel.v1.IMsgTimeoutOnClose, + ): Promise; + + /** + * Calls Acknowledgement. + * @param request MsgAcknowledgement message or plain object + * @param callback Node-style callback called with the error, if any, and MsgAcknowledgementResponse + */ + public acknowledgement( + request: ibc.core.channel.v1.IMsgAcknowledgement, + callback: ibc.core.channel.v1.Msg.AcknowledgementCallback, + ): void; + + /** + * Calls Acknowledgement. + * @param request MsgAcknowledgement message or plain object + * @returns Promise + */ + public acknowledgement( + request: ibc.core.channel.v1.IMsgAcknowledgement, + ): Promise; + } + + namespace Msg { + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelOpenInit}. + * @param error Error, if any + * @param [response] MsgChannelOpenInitResponse + */ + type ChannelOpenInitCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelOpenInitResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelOpenTry}. + * @param error Error, if any + * @param [response] MsgChannelOpenTryResponse + */ + type ChannelOpenTryCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelOpenTryResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelOpenAck}. + * @param error Error, if any + * @param [response] MsgChannelOpenAckResponse + */ + type ChannelOpenAckCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelOpenAckResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelOpenConfirm}. + * @param error Error, if any + * @param [response] MsgChannelOpenConfirmResponse + */ + type ChannelOpenConfirmCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelOpenConfirmResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelCloseInit}. + * @param error Error, if any + * @param [response] MsgChannelCloseInitResponse + */ + type ChannelCloseInitCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelCloseInitResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#channelCloseConfirm}. + * @param error Error, if any + * @param [response] MsgChannelCloseConfirmResponse + */ + type ChannelCloseConfirmCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgChannelCloseConfirmResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#recvPacket}. + * @param error Error, if any + * @param [response] MsgRecvPacketResponse + */ + type RecvPacketCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgRecvPacketResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#timeout}. + * @param error Error, if any + * @param [response] MsgTimeoutResponse + */ + type TimeoutCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgTimeoutResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#timeoutOnClose}. + * @param error Error, if any + * @param [response] MsgTimeoutOnCloseResponse + */ + type TimeoutOnCloseCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgTimeoutOnCloseResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.channel.v1.Msg#acknowledgement}. + * @param error Error, if any + * @param [response] MsgAcknowledgementResponse + */ + type AcknowledgementCallback = ( + error: Error | null, + response?: ibc.core.channel.v1.MsgAcknowledgementResponse, + ) => void; + } + + /** Properties of a MsgChannelOpenInit. */ + interface IMsgChannelOpenInit { + /** MsgChannelOpenInit portId */ + portId?: string | null; + + /** MsgChannelOpenInit channel */ + channel?: ibc.core.channel.v1.IChannel | null; + + /** MsgChannelOpenInit signer */ + signer?: string | null; + } + + /** Represents a MsgChannelOpenInit. */ + class MsgChannelOpenInit implements IMsgChannelOpenInit { + /** + * Constructs a new MsgChannelOpenInit. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenInit); + + /** MsgChannelOpenInit portId. */ + public portId: string; + + /** MsgChannelOpenInit channel. */ + public channel?: ibc.core.channel.v1.IChannel | null; + + /** MsgChannelOpenInit signer. */ + public signer: string; + + /** + * Creates a new MsgChannelOpenInit instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenInit instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenInit, + ): ibc.core.channel.v1.MsgChannelOpenInit; + + /** + * Encodes the specified MsgChannelOpenInit message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenInit.verify|verify} messages. + * @param m MsgChannelOpenInit message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenInit, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenInit message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenInit + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenInit; + } + + /** Properties of a MsgChannelOpenInitResponse. */ + interface IMsgChannelOpenInitResponse {} + + /** Represents a MsgChannelOpenInitResponse. */ + class MsgChannelOpenInitResponse implements IMsgChannelOpenInitResponse { + /** + * Constructs a new MsgChannelOpenInitResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenInitResponse); + + /** + * Creates a new MsgChannelOpenInitResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenInitResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenInitResponse, + ): ibc.core.channel.v1.MsgChannelOpenInitResponse; + + /** + * Encodes the specified MsgChannelOpenInitResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenInitResponse.verify|verify} messages. + * @param m MsgChannelOpenInitResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenInitResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenInitResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenInitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenInitResponse; + } + + /** Properties of a MsgChannelOpenTry. */ + interface IMsgChannelOpenTry { + /** MsgChannelOpenTry portId */ + portId?: string | null; + + /** MsgChannelOpenTry previousChannelId */ + previousChannelId?: string | null; + + /** MsgChannelOpenTry channel */ + channel?: ibc.core.channel.v1.IChannel | null; + + /** MsgChannelOpenTry counterpartyVersion */ + counterpartyVersion?: string | null; + + /** MsgChannelOpenTry proofInit */ + proofInit?: Uint8Array | null; + + /** MsgChannelOpenTry proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenTry signer */ + signer?: string | null; + } + + /** Represents a MsgChannelOpenTry. */ + class MsgChannelOpenTry implements IMsgChannelOpenTry { + /** + * Constructs a new MsgChannelOpenTry. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenTry); + + /** MsgChannelOpenTry portId. */ + public portId: string; + + /** MsgChannelOpenTry previousChannelId. */ + public previousChannelId: string; + + /** MsgChannelOpenTry channel. */ + public channel?: ibc.core.channel.v1.IChannel | null; + + /** MsgChannelOpenTry counterpartyVersion. */ + public counterpartyVersion: string; + + /** MsgChannelOpenTry proofInit. */ + public proofInit: Uint8Array; + + /** MsgChannelOpenTry proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenTry signer. */ + public signer: string; + + /** + * Creates a new MsgChannelOpenTry instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenTry instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenTry, + ): ibc.core.channel.v1.MsgChannelOpenTry; + + /** + * Encodes the specified MsgChannelOpenTry message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenTry.verify|verify} messages. + * @param m MsgChannelOpenTry message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenTry, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenTry message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenTry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenTry; + } + + /** Properties of a MsgChannelOpenTryResponse. */ + interface IMsgChannelOpenTryResponse {} + + /** Represents a MsgChannelOpenTryResponse. */ + class MsgChannelOpenTryResponse implements IMsgChannelOpenTryResponse { + /** + * Constructs a new MsgChannelOpenTryResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenTryResponse); + + /** + * Creates a new MsgChannelOpenTryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenTryResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenTryResponse, + ): ibc.core.channel.v1.MsgChannelOpenTryResponse; + + /** + * Encodes the specified MsgChannelOpenTryResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenTryResponse.verify|verify} messages. + * @param m MsgChannelOpenTryResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenTryResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenTryResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenTryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenTryResponse; + } + + /** Properties of a MsgChannelOpenAck. */ + interface IMsgChannelOpenAck { + /** MsgChannelOpenAck portId */ + portId?: string | null; + + /** MsgChannelOpenAck channelId */ + channelId?: string | null; + + /** MsgChannelOpenAck counterpartyChannelId */ + counterpartyChannelId?: string | null; + + /** MsgChannelOpenAck counterpartyVersion */ + counterpartyVersion?: string | null; + + /** MsgChannelOpenAck proofTry */ + proofTry?: Uint8Array | null; + + /** MsgChannelOpenAck proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenAck signer */ + signer?: string | null; + } + + /** Represents a MsgChannelOpenAck. */ + class MsgChannelOpenAck implements IMsgChannelOpenAck { + /** + * Constructs a new MsgChannelOpenAck. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenAck); + + /** MsgChannelOpenAck portId. */ + public portId: string; + + /** MsgChannelOpenAck channelId. */ + public channelId: string; + + /** MsgChannelOpenAck counterpartyChannelId. */ + public counterpartyChannelId: string; + + /** MsgChannelOpenAck counterpartyVersion. */ + public counterpartyVersion: string; + + /** MsgChannelOpenAck proofTry. */ + public proofTry: Uint8Array; + + /** MsgChannelOpenAck proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenAck signer. */ + public signer: string; + + /** + * Creates a new MsgChannelOpenAck instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenAck instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenAck, + ): ibc.core.channel.v1.MsgChannelOpenAck; + + /** + * Encodes the specified MsgChannelOpenAck message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenAck.verify|verify} messages. + * @param m MsgChannelOpenAck message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenAck, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenAck message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenAck + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenAck; + } + + /** Properties of a MsgChannelOpenAckResponse. */ + interface IMsgChannelOpenAckResponse {} + + /** Represents a MsgChannelOpenAckResponse. */ + class MsgChannelOpenAckResponse implements IMsgChannelOpenAckResponse { + /** + * Constructs a new MsgChannelOpenAckResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenAckResponse); + + /** + * Creates a new MsgChannelOpenAckResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenAckResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenAckResponse, + ): ibc.core.channel.v1.MsgChannelOpenAckResponse; + + /** + * Encodes the specified MsgChannelOpenAckResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenAckResponse.verify|verify} messages. + * @param m MsgChannelOpenAckResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenAckResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenAckResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenAckResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenAckResponse; + } + + /** Properties of a MsgChannelOpenConfirm. */ + interface IMsgChannelOpenConfirm { + /** MsgChannelOpenConfirm portId */ + portId?: string | null; + + /** MsgChannelOpenConfirm channelId */ + channelId?: string | null; + + /** MsgChannelOpenConfirm proofAck */ + proofAck?: Uint8Array | null; + + /** MsgChannelOpenConfirm proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenConfirm signer */ + signer?: string | null; + } + + /** Represents a MsgChannelOpenConfirm. */ + class MsgChannelOpenConfirm implements IMsgChannelOpenConfirm { + /** + * Constructs a new MsgChannelOpenConfirm. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenConfirm); + + /** MsgChannelOpenConfirm portId. */ + public portId: string; + + /** MsgChannelOpenConfirm channelId. */ + public channelId: string; + + /** MsgChannelOpenConfirm proofAck. */ + public proofAck: Uint8Array; + + /** MsgChannelOpenConfirm proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelOpenConfirm signer. */ + public signer: string; + + /** + * Creates a new MsgChannelOpenConfirm instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenConfirm instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenConfirm, + ): ibc.core.channel.v1.MsgChannelOpenConfirm; + + /** + * Encodes the specified MsgChannelOpenConfirm message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenConfirm.verify|verify} messages. + * @param m MsgChannelOpenConfirm message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenConfirm, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenConfirm message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenConfirm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenConfirm; + } + + /** Properties of a MsgChannelOpenConfirmResponse. */ + interface IMsgChannelOpenConfirmResponse {} + + /** Represents a MsgChannelOpenConfirmResponse. */ + class MsgChannelOpenConfirmResponse implements IMsgChannelOpenConfirmResponse { + /** + * Constructs a new MsgChannelOpenConfirmResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelOpenConfirmResponse); + + /** + * Creates a new MsgChannelOpenConfirmResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelOpenConfirmResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelOpenConfirmResponse, + ): ibc.core.channel.v1.MsgChannelOpenConfirmResponse; + + /** + * Encodes the specified MsgChannelOpenConfirmResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelOpenConfirmResponse.verify|verify} messages. + * @param m MsgChannelOpenConfirmResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelOpenConfirmResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelOpenConfirmResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelOpenConfirmResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelOpenConfirmResponse; + } + + /** Properties of a MsgChannelCloseInit. */ + interface IMsgChannelCloseInit { + /** MsgChannelCloseInit portId */ + portId?: string | null; + + /** MsgChannelCloseInit channelId */ + channelId?: string | null; + + /** MsgChannelCloseInit signer */ + signer?: string | null; + } + + /** Represents a MsgChannelCloseInit. */ + class MsgChannelCloseInit implements IMsgChannelCloseInit { + /** + * Constructs a new MsgChannelCloseInit. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelCloseInit); + + /** MsgChannelCloseInit portId. */ + public portId: string; + + /** MsgChannelCloseInit channelId. */ + public channelId: string; + + /** MsgChannelCloseInit signer. */ + public signer: string; + + /** + * Creates a new MsgChannelCloseInit instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelCloseInit instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelCloseInit, + ): ibc.core.channel.v1.MsgChannelCloseInit; + + /** + * Encodes the specified MsgChannelCloseInit message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelCloseInit.verify|verify} messages. + * @param m MsgChannelCloseInit message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelCloseInit, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelCloseInit message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelCloseInit + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelCloseInit; + } + + /** Properties of a MsgChannelCloseInitResponse. */ + interface IMsgChannelCloseInitResponse {} + + /** Represents a MsgChannelCloseInitResponse. */ + class MsgChannelCloseInitResponse implements IMsgChannelCloseInitResponse { + /** + * Constructs a new MsgChannelCloseInitResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelCloseInitResponse); + + /** + * Creates a new MsgChannelCloseInitResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelCloseInitResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelCloseInitResponse, + ): ibc.core.channel.v1.MsgChannelCloseInitResponse; + + /** + * Encodes the specified MsgChannelCloseInitResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelCloseInitResponse.verify|verify} messages. + * @param m MsgChannelCloseInitResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelCloseInitResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelCloseInitResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelCloseInitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelCloseInitResponse; + } + + /** Properties of a MsgChannelCloseConfirm. */ + interface IMsgChannelCloseConfirm { + /** MsgChannelCloseConfirm portId */ + portId?: string | null; + + /** MsgChannelCloseConfirm channelId */ + channelId?: string | null; + + /** MsgChannelCloseConfirm proofInit */ + proofInit?: Uint8Array | null; + + /** MsgChannelCloseConfirm proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelCloseConfirm signer */ + signer?: string | null; + } + + /** Represents a MsgChannelCloseConfirm. */ + class MsgChannelCloseConfirm implements IMsgChannelCloseConfirm { + /** + * Constructs a new MsgChannelCloseConfirm. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelCloseConfirm); + + /** MsgChannelCloseConfirm portId. */ + public portId: string; + + /** MsgChannelCloseConfirm channelId. */ + public channelId: string; + + /** MsgChannelCloseConfirm proofInit. */ + public proofInit: Uint8Array; + + /** MsgChannelCloseConfirm proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgChannelCloseConfirm signer. */ + public signer: string; + + /** + * Creates a new MsgChannelCloseConfirm instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelCloseConfirm instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelCloseConfirm, + ): ibc.core.channel.v1.MsgChannelCloseConfirm; + + /** + * Encodes the specified MsgChannelCloseConfirm message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelCloseConfirm.verify|verify} messages. + * @param m MsgChannelCloseConfirm message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelCloseConfirm, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelCloseConfirm message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelCloseConfirm + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelCloseConfirm; + } + + /** Properties of a MsgChannelCloseConfirmResponse. */ + interface IMsgChannelCloseConfirmResponse {} + + /** Represents a MsgChannelCloseConfirmResponse. */ + class MsgChannelCloseConfirmResponse implements IMsgChannelCloseConfirmResponse { + /** + * Constructs a new MsgChannelCloseConfirmResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgChannelCloseConfirmResponse); + + /** + * Creates a new MsgChannelCloseConfirmResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgChannelCloseConfirmResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgChannelCloseConfirmResponse, + ): ibc.core.channel.v1.MsgChannelCloseConfirmResponse; + + /** + * Encodes the specified MsgChannelCloseConfirmResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgChannelCloseConfirmResponse.verify|verify} messages. + * @param m MsgChannelCloseConfirmResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgChannelCloseConfirmResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgChannelCloseConfirmResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgChannelCloseConfirmResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgChannelCloseConfirmResponse; + } + + /** Properties of a MsgRecvPacket. */ + interface IMsgRecvPacket { + /** MsgRecvPacket packet */ + packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgRecvPacket proofCommitment */ + proofCommitment?: Uint8Array | null; + + /** MsgRecvPacket proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgRecvPacket signer */ + signer?: string | null; + } + + /** Represents a MsgRecvPacket. */ + class MsgRecvPacket implements IMsgRecvPacket { + /** + * Constructs a new MsgRecvPacket. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgRecvPacket); + + /** MsgRecvPacket packet. */ + public packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgRecvPacket proofCommitment. */ + public proofCommitment: Uint8Array; + + /** MsgRecvPacket proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgRecvPacket signer. */ + public signer: string; + + /** + * Creates a new MsgRecvPacket instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgRecvPacket instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgRecvPacket, + ): ibc.core.channel.v1.MsgRecvPacket; + + /** + * Encodes the specified MsgRecvPacket message. Does not implicitly {@link ibc.core.channel.v1.MsgRecvPacket.verify|verify} messages. + * @param m MsgRecvPacket message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.IMsgRecvPacket, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MsgRecvPacket message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgRecvPacket + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgRecvPacket; + } + + /** Properties of a MsgRecvPacketResponse. */ + interface IMsgRecvPacketResponse {} + + /** Represents a MsgRecvPacketResponse. */ + class MsgRecvPacketResponse implements IMsgRecvPacketResponse { + /** + * Constructs a new MsgRecvPacketResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgRecvPacketResponse); + + /** + * Creates a new MsgRecvPacketResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgRecvPacketResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgRecvPacketResponse, + ): ibc.core.channel.v1.MsgRecvPacketResponse; + + /** + * Encodes the specified MsgRecvPacketResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgRecvPacketResponse.verify|verify} messages. + * @param m MsgRecvPacketResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgRecvPacketResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgRecvPacketResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgRecvPacketResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgRecvPacketResponse; + } + + /** Properties of a MsgTimeout. */ + interface IMsgTimeout { + /** MsgTimeout packet */ + packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgTimeout proofUnreceived */ + proofUnreceived?: Uint8Array | null; + + /** MsgTimeout proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgTimeout nextSequenceRecv */ + nextSequenceRecv?: Long | null; + + /** MsgTimeout signer */ + signer?: string | null; + } + + /** Represents a MsgTimeout. */ + class MsgTimeout implements IMsgTimeout { + /** + * Constructs a new MsgTimeout. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgTimeout); + + /** MsgTimeout packet. */ + public packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgTimeout proofUnreceived. */ + public proofUnreceived: Uint8Array; + + /** MsgTimeout proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgTimeout nextSequenceRecv. */ + public nextSequenceRecv: Long; + + /** MsgTimeout signer. */ + public signer: string; + + /** + * Creates a new MsgTimeout instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTimeout instance + */ + public static create(properties?: ibc.core.channel.v1.IMsgTimeout): ibc.core.channel.v1.MsgTimeout; + + /** + * Encodes the specified MsgTimeout message. Does not implicitly {@link ibc.core.channel.v1.MsgTimeout.verify|verify} messages. + * @param m MsgTimeout message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.IMsgTimeout, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MsgTimeout message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTimeout + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.channel.v1.MsgTimeout; + } + + /** Properties of a MsgTimeoutResponse. */ + interface IMsgTimeoutResponse {} + + /** Represents a MsgTimeoutResponse. */ + class MsgTimeoutResponse implements IMsgTimeoutResponse { + /** + * Constructs a new MsgTimeoutResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgTimeoutResponse); + + /** + * Creates a new MsgTimeoutResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTimeoutResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgTimeoutResponse, + ): ibc.core.channel.v1.MsgTimeoutResponse; + + /** + * Encodes the specified MsgTimeoutResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgTimeoutResponse.verify|verify} messages. + * @param m MsgTimeoutResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgTimeoutResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgTimeoutResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTimeoutResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgTimeoutResponse; + } + + /** Properties of a MsgTimeoutOnClose. */ + interface IMsgTimeoutOnClose { + /** MsgTimeoutOnClose packet */ + packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgTimeoutOnClose proofUnreceived */ + proofUnreceived?: Uint8Array | null; + + /** MsgTimeoutOnClose proofClose */ + proofClose?: Uint8Array | null; + + /** MsgTimeoutOnClose proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgTimeoutOnClose nextSequenceRecv */ + nextSequenceRecv?: Long | null; + + /** MsgTimeoutOnClose signer */ + signer?: string | null; + } + + /** Represents a MsgTimeoutOnClose. */ + class MsgTimeoutOnClose implements IMsgTimeoutOnClose { + /** + * Constructs a new MsgTimeoutOnClose. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgTimeoutOnClose); + + /** MsgTimeoutOnClose packet. */ + public packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgTimeoutOnClose proofUnreceived. */ + public proofUnreceived: Uint8Array; + + /** MsgTimeoutOnClose proofClose. */ + public proofClose: Uint8Array; + + /** MsgTimeoutOnClose proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgTimeoutOnClose nextSequenceRecv. */ + public nextSequenceRecv: Long; + + /** MsgTimeoutOnClose signer. */ + public signer: string; + + /** + * Creates a new MsgTimeoutOnClose instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTimeoutOnClose instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgTimeoutOnClose, + ): ibc.core.channel.v1.MsgTimeoutOnClose; + + /** + * Encodes the specified MsgTimeoutOnClose message. Does not implicitly {@link ibc.core.channel.v1.MsgTimeoutOnClose.verify|verify} messages. + * @param m MsgTimeoutOnClose message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgTimeoutOnClose, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgTimeoutOnClose message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTimeoutOnClose + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgTimeoutOnClose; + } + + /** Properties of a MsgTimeoutOnCloseResponse. */ + interface IMsgTimeoutOnCloseResponse {} + + /** Represents a MsgTimeoutOnCloseResponse. */ + class MsgTimeoutOnCloseResponse implements IMsgTimeoutOnCloseResponse { + /** + * Constructs a new MsgTimeoutOnCloseResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgTimeoutOnCloseResponse); + + /** + * Creates a new MsgTimeoutOnCloseResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTimeoutOnCloseResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgTimeoutOnCloseResponse, + ): ibc.core.channel.v1.MsgTimeoutOnCloseResponse; + + /** + * Encodes the specified MsgTimeoutOnCloseResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgTimeoutOnCloseResponse.verify|verify} messages. + * @param m MsgTimeoutOnCloseResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgTimeoutOnCloseResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgTimeoutOnCloseResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTimeoutOnCloseResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgTimeoutOnCloseResponse; + } + + /** Properties of a MsgAcknowledgement. */ + interface IMsgAcknowledgement { + /** MsgAcknowledgement packet */ + packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgAcknowledgement acknowledgement */ + acknowledgement?: Uint8Array | null; + + /** MsgAcknowledgement proofAcked */ + proofAcked?: Uint8Array | null; + + /** MsgAcknowledgement proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgAcknowledgement signer */ + signer?: string | null; + } + + /** Represents a MsgAcknowledgement. */ + class MsgAcknowledgement implements IMsgAcknowledgement { + /** + * Constructs a new MsgAcknowledgement. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgAcknowledgement); + + /** MsgAcknowledgement packet. */ + public packet?: ibc.core.channel.v1.IPacket | null; + + /** MsgAcknowledgement acknowledgement. */ + public acknowledgement: Uint8Array; + + /** MsgAcknowledgement proofAcked. */ + public proofAcked: Uint8Array; + + /** MsgAcknowledgement proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgAcknowledgement signer. */ + public signer: string; + + /** + * Creates a new MsgAcknowledgement instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgAcknowledgement instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgAcknowledgement, + ): ibc.core.channel.v1.MsgAcknowledgement; + + /** + * Encodes the specified MsgAcknowledgement message. Does not implicitly {@link ibc.core.channel.v1.MsgAcknowledgement.verify|verify} messages. + * @param m MsgAcknowledgement message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgAcknowledgement, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgAcknowledgement message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgAcknowledgement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgAcknowledgement; + } + + /** Properties of a MsgAcknowledgementResponse. */ + interface IMsgAcknowledgementResponse {} + + /** Represents a MsgAcknowledgementResponse. */ + class MsgAcknowledgementResponse implements IMsgAcknowledgementResponse { + /** + * Constructs a new MsgAcknowledgementResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IMsgAcknowledgementResponse); + + /** + * Creates a new MsgAcknowledgementResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgAcknowledgementResponse instance + */ + public static create( + properties?: ibc.core.channel.v1.IMsgAcknowledgementResponse, + ): ibc.core.channel.v1.MsgAcknowledgementResponse; + + /** + * Encodes the specified MsgAcknowledgementResponse message. Does not implicitly {@link ibc.core.channel.v1.MsgAcknowledgementResponse.verify|verify} messages. + * @param m MsgAcknowledgementResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IMsgAcknowledgementResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgAcknowledgementResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgAcknowledgementResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.MsgAcknowledgementResponse; + } + + /** Properties of a Channel. */ + interface IChannel { + /** Channel state */ + state?: ibc.core.channel.v1.State | null; + + /** Channel ordering */ + ordering?: ibc.core.channel.v1.Order | null; + + /** Channel counterparty */ + counterparty?: ibc.core.channel.v1.ICounterparty | null; + + /** Channel connectionHops */ + connectionHops?: string[] | null; + + /** Channel version */ + version?: string | null; + } + + /** Represents a Channel. */ + class Channel implements IChannel { + /** + * Constructs a new Channel. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IChannel); + + /** Channel state. */ + public state: ibc.core.channel.v1.State; + + /** Channel ordering. */ + public ordering: ibc.core.channel.v1.Order; + + /** Channel counterparty. */ + public counterparty?: ibc.core.channel.v1.ICounterparty | null; + + /** Channel connectionHops. */ + public connectionHops: string[]; + + /** Channel version. */ + public version: string; + + /** + * Creates a new Channel instance using the specified properties. + * @param [properties] Properties to set + * @returns Channel instance + */ + public static create(properties?: ibc.core.channel.v1.IChannel): ibc.core.channel.v1.Channel; + + /** + * Encodes the specified Channel message. Does not implicitly {@link ibc.core.channel.v1.Channel.verify|verify} messages. + * @param m Channel message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.IChannel, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Channel message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Channel + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.channel.v1.Channel; + } + + /** Properties of an IdentifiedChannel. */ + interface IIdentifiedChannel { + /** IdentifiedChannel state */ + state?: ibc.core.channel.v1.State | null; + + /** IdentifiedChannel ordering */ + ordering?: ibc.core.channel.v1.Order | null; + + /** IdentifiedChannel counterparty */ + counterparty?: ibc.core.channel.v1.ICounterparty | null; + + /** IdentifiedChannel connectionHops */ + connectionHops?: string[] | null; + + /** IdentifiedChannel version */ + version?: string | null; + + /** IdentifiedChannel portId */ + portId?: string | null; + + /** IdentifiedChannel channelId */ + channelId?: string | null; + } + + /** Represents an IdentifiedChannel. */ + class IdentifiedChannel implements IIdentifiedChannel { + /** + * Constructs a new IdentifiedChannel. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IIdentifiedChannel); + + /** IdentifiedChannel state. */ + public state: ibc.core.channel.v1.State; + + /** IdentifiedChannel ordering. */ + public ordering: ibc.core.channel.v1.Order; + + /** IdentifiedChannel counterparty. */ + public counterparty?: ibc.core.channel.v1.ICounterparty | null; + + /** IdentifiedChannel connectionHops. */ + public connectionHops: string[]; + + /** IdentifiedChannel version. */ + public version: string; + + /** IdentifiedChannel portId. */ + public portId: string; + + /** IdentifiedChannel channelId. */ + public channelId: string; + + /** + * Creates a new IdentifiedChannel instance using the specified properties. + * @param [properties] Properties to set + * @returns IdentifiedChannel instance + */ + public static create( + properties?: ibc.core.channel.v1.IIdentifiedChannel, + ): ibc.core.channel.v1.IdentifiedChannel; + + /** + * Encodes the specified IdentifiedChannel message. Does not implicitly {@link ibc.core.channel.v1.IdentifiedChannel.verify|verify} messages. + * @param m IdentifiedChannel message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IIdentifiedChannel, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes an IdentifiedChannel message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns IdentifiedChannel + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.IdentifiedChannel; + } + + /** State enum. */ + enum State { + STATE_UNINITIALIZED_UNSPECIFIED = 0, + STATE_INIT = 1, + STATE_TRYOPEN = 2, + STATE_OPEN = 3, + STATE_CLOSED = 4, + } + + /** Order enum. */ + enum Order { + ORDER_NONE_UNSPECIFIED = 0, + ORDER_UNORDERED = 1, + ORDER_ORDERED = 2, + } + + /** Properties of a Counterparty. */ + interface ICounterparty { + /** Counterparty portId */ + portId?: string | null; + + /** Counterparty channelId */ + channelId?: string | null; + } + + /** Represents a Counterparty. */ + class Counterparty implements ICounterparty { + /** + * Constructs a new Counterparty. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.ICounterparty); + + /** Counterparty portId. */ + public portId: string; + + /** Counterparty channelId. */ + public channelId: string; + + /** + * Creates a new Counterparty instance using the specified properties. + * @param [properties] Properties to set + * @returns Counterparty instance + */ + public static create( + properties?: ibc.core.channel.v1.ICounterparty, + ): ibc.core.channel.v1.Counterparty; + + /** + * Encodes the specified Counterparty message. Does not implicitly {@link ibc.core.channel.v1.Counterparty.verify|verify} messages. + * @param m Counterparty message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.ICounterparty, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Counterparty message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Counterparty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.Counterparty; + } + + /** Properties of a Packet. */ + interface IPacket { + /** Packet sequence */ + sequence?: Long | null; + + /** Packet sourcePort */ + sourcePort?: string | null; + + /** Packet sourceChannel */ + sourceChannel?: string | null; + + /** Packet destinationPort */ + destinationPort?: string | null; + + /** Packet destinationChannel */ + destinationChannel?: string | null; + + /** Packet data */ + data?: Uint8Array | null; + + /** Packet timeoutHeight */ + timeoutHeight?: ibc.core.client.v1.IHeight | null; + + /** Packet timeoutTimestamp */ + timeoutTimestamp?: Long | null; + } + + /** Represents a Packet. */ + class Packet implements IPacket { + /** + * Constructs a new Packet. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IPacket); + + /** Packet sequence. */ + public sequence: Long; + + /** Packet sourcePort. */ + public sourcePort: string; + + /** Packet sourceChannel. */ + public sourceChannel: string; + + /** Packet destinationPort. */ + public destinationPort: string; + + /** Packet destinationChannel. */ + public destinationChannel: string; + + /** Packet data. */ + public data: Uint8Array; + + /** Packet timeoutHeight. */ + public timeoutHeight?: ibc.core.client.v1.IHeight | null; + + /** Packet timeoutTimestamp. */ + public timeoutTimestamp: Long; + + /** + * Creates a new Packet instance using the specified properties. + * @param [properties] Properties to set + * @returns Packet instance + */ + public static create(properties?: ibc.core.channel.v1.IPacket): ibc.core.channel.v1.Packet; + + /** + * Encodes the specified Packet message. Does not implicitly {@link ibc.core.channel.v1.Packet.verify|verify} messages. + * @param m Packet message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.IPacket, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Packet message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Packet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.channel.v1.Packet; + } + + /** Properties of a PacketState. */ + interface IPacketState { + /** PacketState portId */ + portId?: string | null; + + /** PacketState channelId */ + channelId?: string | null; + + /** PacketState sequence */ + sequence?: Long | null; + + /** PacketState data */ + data?: Uint8Array | null; + } + + /** Represents a PacketState. */ + class PacketState implements IPacketState { + /** + * Constructs a new PacketState. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IPacketState); + + /** PacketState portId. */ + public portId: string; + + /** PacketState channelId. */ + public channelId: string; + + /** PacketState sequence. */ + public sequence: Long; + + /** PacketState data. */ + public data: Uint8Array; + + /** + * Creates a new PacketState instance using the specified properties. + * @param [properties] Properties to set + * @returns PacketState instance + */ + public static create( + properties?: ibc.core.channel.v1.IPacketState, + ): ibc.core.channel.v1.PacketState; + + /** + * Encodes the specified PacketState message. Does not implicitly {@link ibc.core.channel.v1.PacketState.verify|verify} messages. + * @param m PacketState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.channel.v1.IPacketState, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PacketState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PacketState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.channel.v1.PacketState; + } + + /** Properties of an Acknowledgement. */ + interface IAcknowledgement { + /** Acknowledgement result */ + result?: Uint8Array | null; + + /** Acknowledgement error */ + error?: string | null; + } + + /** Represents an Acknowledgement. */ + class Acknowledgement implements IAcknowledgement { + /** + * Constructs a new Acknowledgement. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.channel.v1.IAcknowledgement); + + /** Acknowledgement result. */ + public result: Uint8Array; + + /** Acknowledgement error. */ + public error: string; + + /** Acknowledgement response. */ + public response?: 'result' | 'error'; + + /** + * Creates a new Acknowledgement instance using the specified properties. + * @param [properties] Properties to set + * @returns Acknowledgement instance + */ + public static create( + properties?: ibc.core.channel.v1.IAcknowledgement, + ): ibc.core.channel.v1.Acknowledgement; + + /** + * Encodes the specified Acknowledgement message. Does not implicitly {@link ibc.core.channel.v1.Acknowledgement.verify|verify} messages. + * @param m Acknowledgement message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.channel.v1.IAcknowledgement, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes an Acknowledgement message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Acknowledgement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.channel.v1.Acknowledgement; + } + } + } + + /** Namespace client. */ + namespace client { + /** Namespace v1. */ + namespace v1 { + /** Represents a Msg */ + class Msg extends $protobuf.rpc.Service { + /** + * Constructs a new Msg service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Msg service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create( + rpcImpl: $protobuf.RPCImpl, + requestDelimited?: boolean, + responseDelimited?: boolean, + ): Msg; + + /** + * Calls CreateClient. + * @param request MsgCreateClient message or plain object + * @param callback Node-style callback called with the error, if any, and MsgCreateClientResponse + */ + public createClient( + request: ibc.core.client.v1.IMsgCreateClient, + callback: ibc.core.client.v1.Msg.CreateClientCallback, + ): void; + + /** + * Calls CreateClient. + * @param request MsgCreateClient message or plain object + * @returns Promise + */ + public createClient( + request: ibc.core.client.v1.IMsgCreateClient, + ): Promise; + + /** + * Calls UpdateClient. + * @param request MsgUpdateClient message or plain object + * @param callback Node-style callback called with the error, if any, and MsgUpdateClientResponse + */ + public updateClient( + request: ibc.core.client.v1.IMsgUpdateClient, + callback: ibc.core.client.v1.Msg.UpdateClientCallback, + ): void; + + /** + * Calls UpdateClient. + * @param request MsgUpdateClient message or plain object + * @returns Promise + */ + public updateClient( + request: ibc.core.client.v1.IMsgUpdateClient, + ): Promise; + + /** + * Calls UpgradeClient. + * @param request MsgUpgradeClient message or plain object + * @param callback Node-style callback called with the error, if any, and MsgUpgradeClientResponse + */ + public upgradeClient( + request: ibc.core.client.v1.IMsgUpgradeClient, + callback: ibc.core.client.v1.Msg.UpgradeClientCallback, + ): void; + + /** + * Calls UpgradeClient. + * @param request MsgUpgradeClient message or plain object + * @returns Promise + */ + public upgradeClient( + request: ibc.core.client.v1.IMsgUpgradeClient, + ): Promise; + + /** + * Calls SubmitMisbehaviour. + * @param request MsgSubmitMisbehaviour message or plain object + * @param callback Node-style callback called with the error, if any, and MsgSubmitMisbehaviourResponse + */ + public submitMisbehaviour( + request: ibc.core.client.v1.IMsgSubmitMisbehaviour, + callback: ibc.core.client.v1.Msg.SubmitMisbehaviourCallback, + ): void; + + /** + * Calls SubmitMisbehaviour. + * @param request MsgSubmitMisbehaviour message or plain object + * @returns Promise + */ + public submitMisbehaviour( + request: ibc.core.client.v1.IMsgSubmitMisbehaviour, + ): Promise; + } + + namespace Msg { + /** + * Callback as used by {@link ibc.core.client.v1.Msg#createClient}. + * @param error Error, if any + * @param [response] MsgCreateClientResponse + */ + type CreateClientCallback = ( + error: Error | null, + response?: ibc.core.client.v1.MsgCreateClientResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.client.v1.Msg#updateClient}. + * @param error Error, if any + * @param [response] MsgUpdateClientResponse + */ + type UpdateClientCallback = ( + error: Error | null, + response?: ibc.core.client.v1.MsgUpdateClientResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.client.v1.Msg#upgradeClient}. + * @param error Error, if any + * @param [response] MsgUpgradeClientResponse + */ + type UpgradeClientCallback = ( + error: Error | null, + response?: ibc.core.client.v1.MsgUpgradeClientResponse, + ) => void; + + /** + * Callback as used by {@link ibc.core.client.v1.Msg#submitMisbehaviour}. + * @param error Error, if any + * @param [response] MsgSubmitMisbehaviourResponse + */ + type SubmitMisbehaviourCallback = ( + error: Error | null, + response?: ibc.core.client.v1.MsgSubmitMisbehaviourResponse, + ) => void; + } + + /** Properties of a MsgCreateClient. */ + interface IMsgCreateClient { + /** MsgCreateClient clientState */ + clientState?: google.protobuf.IAny | null; + + /** MsgCreateClient consensusState */ + consensusState?: google.protobuf.IAny | null; + + /** MsgCreateClient signer */ + signer?: string | null; + } + + /** Represents a MsgCreateClient. */ + class MsgCreateClient implements IMsgCreateClient { + /** + * Constructs a new MsgCreateClient. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgCreateClient); + + /** MsgCreateClient clientState. */ + public clientState?: google.protobuf.IAny | null; + + /** MsgCreateClient consensusState. */ + public consensusState?: google.protobuf.IAny | null; + + /** MsgCreateClient signer. */ + public signer: string; + + /** + * Creates a new MsgCreateClient instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgCreateClient instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgCreateClient, + ): ibc.core.client.v1.MsgCreateClient; + + /** + * Encodes the specified MsgCreateClient message. Does not implicitly {@link ibc.core.client.v1.MsgCreateClient.verify|verify} messages. + * @param m MsgCreateClient message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgCreateClient, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgCreateClient message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgCreateClient + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgCreateClient; + } + + /** Properties of a MsgCreateClientResponse. */ + interface IMsgCreateClientResponse {} + + /** Represents a MsgCreateClientResponse. */ + class MsgCreateClientResponse implements IMsgCreateClientResponse { + /** + * Constructs a new MsgCreateClientResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgCreateClientResponse); + + /** + * Creates a new MsgCreateClientResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgCreateClientResponse instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgCreateClientResponse, + ): ibc.core.client.v1.MsgCreateClientResponse; + + /** + * Encodes the specified MsgCreateClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgCreateClientResponse.verify|verify} messages. + * @param m MsgCreateClientResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgCreateClientResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgCreateClientResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgCreateClientResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgCreateClientResponse; + } + + /** Properties of a MsgUpdateClient. */ + interface IMsgUpdateClient { + /** MsgUpdateClient clientId */ + clientId?: string | null; + + /** MsgUpdateClient header */ + header?: google.protobuf.IAny | null; + + /** MsgUpdateClient signer */ + signer?: string | null; + } + + /** Represents a MsgUpdateClient. */ + class MsgUpdateClient implements IMsgUpdateClient { + /** + * Constructs a new MsgUpdateClient. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgUpdateClient); + + /** MsgUpdateClient clientId. */ + public clientId: string; + + /** MsgUpdateClient header. */ + public header?: google.protobuf.IAny | null; + + /** MsgUpdateClient signer. */ + public signer: string; + + /** + * Creates a new MsgUpdateClient instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUpdateClient instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgUpdateClient, + ): ibc.core.client.v1.MsgUpdateClient; + + /** + * Encodes the specified MsgUpdateClient message. Does not implicitly {@link ibc.core.client.v1.MsgUpdateClient.verify|verify} messages. + * @param m MsgUpdateClient message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgUpdateClient, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgUpdateClient message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUpdateClient + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgUpdateClient; + } + + /** Properties of a MsgUpdateClientResponse. */ + interface IMsgUpdateClientResponse {} + + /** Represents a MsgUpdateClientResponse. */ + class MsgUpdateClientResponse implements IMsgUpdateClientResponse { + /** + * Constructs a new MsgUpdateClientResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgUpdateClientResponse); + + /** + * Creates a new MsgUpdateClientResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUpdateClientResponse instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgUpdateClientResponse, + ): ibc.core.client.v1.MsgUpdateClientResponse; + + /** + * Encodes the specified MsgUpdateClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgUpdateClientResponse.verify|verify} messages. + * @param m MsgUpdateClientResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgUpdateClientResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgUpdateClientResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUpdateClientResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgUpdateClientResponse; + } + + /** Properties of a MsgUpgradeClient. */ + interface IMsgUpgradeClient { + /** MsgUpgradeClient clientId */ + clientId?: string | null; + + /** MsgUpgradeClient clientState */ + clientState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient consensusState */ + consensusState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient proofUpgradeClient */ + proofUpgradeClient?: Uint8Array | null; + + /** MsgUpgradeClient proofUpgradeConsensusState */ + proofUpgradeConsensusState?: Uint8Array | null; + + /** MsgUpgradeClient signer */ + signer?: string | null; + } + + /** Represents a MsgUpgradeClient. */ + class MsgUpgradeClient implements IMsgUpgradeClient { + /** + * Constructs a new MsgUpgradeClient. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgUpgradeClient); + + /** MsgUpgradeClient clientId. */ + public clientId: string; + + /** MsgUpgradeClient clientState. */ + public clientState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient consensusState. */ + public consensusState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient proofUpgradeClient. */ + public proofUpgradeClient: Uint8Array; + + /** MsgUpgradeClient proofUpgradeConsensusState. */ + public proofUpgradeConsensusState: Uint8Array; + + /** MsgUpgradeClient signer. */ + public signer: string; + + /** + * Creates a new MsgUpgradeClient instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUpgradeClient instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgUpgradeClient, + ): ibc.core.client.v1.MsgUpgradeClient; + + /** + * Encodes the specified MsgUpgradeClient message. Does not implicitly {@link ibc.core.client.v1.MsgUpgradeClient.verify|verify} messages. + * @param m MsgUpgradeClient message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgUpgradeClient, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgUpgradeClient message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUpgradeClient + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgUpgradeClient; + } + + /** Properties of a MsgUpgradeClientResponse. */ + interface IMsgUpgradeClientResponse {} + + /** Represents a MsgUpgradeClientResponse. */ + class MsgUpgradeClientResponse implements IMsgUpgradeClientResponse { + /** + * Constructs a new MsgUpgradeClientResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgUpgradeClientResponse); + + /** + * Creates a new MsgUpgradeClientResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgUpgradeClientResponse instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgUpgradeClientResponse, + ): ibc.core.client.v1.MsgUpgradeClientResponse; + + /** + * Encodes the specified MsgUpgradeClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgUpgradeClientResponse.verify|verify} messages. + * @param m MsgUpgradeClientResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgUpgradeClientResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgUpgradeClientResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgUpgradeClientResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgUpgradeClientResponse; + } + + /** Properties of a MsgSubmitMisbehaviour. */ + interface IMsgSubmitMisbehaviour { + /** MsgSubmitMisbehaviour clientId */ + clientId?: string | null; + + /** MsgSubmitMisbehaviour misbehaviour */ + misbehaviour?: google.protobuf.IAny | null; + + /** MsgSubmitMisbehaviour signer */ + signer?: string | null; + } + + /** Represents a MsgSubmitMisbehaviour. */ + class MsgSubmitMisbehaviour implements IMsgSubmitMisbehaviour { + /** + * Constructs a new MsgSubmitMisbehaviour. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgSubmitMisbehaviour); + + /** MsgSubmitMisbehaviour clientId. */ + public clientId: string; + + /** MsgSubmitMisbehaviour misbehaviour. */ + public misbehaviour?: google.protobuf.IAny | null; + + /** MsgSubmitMisbehaviour signer. */ + public signer: string; + + /** + * Creates a new MsgSubmitMisbehaviour instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgSubmitMisbehaviour instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgSubmitMisbehaviour, + ): ibc.core.client.v1.MsgSubmitMisbehaviour; + + /** + * Encodes the specified MsgSubmitMisbehaviour message. Does not implicitly {@link ibc.core.client.v1.MsgSubmitMisbehaviour.verify|verify} messages. + * @param m MsgSubmitMisbehaviour message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgSubmitMisbehaviour, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgSubmitMisbehaviour message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgSubmitMisbehaviour + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgSubmitMisbehaviour; + } + + /** Properties of a MsgSubmitMisbehaviourResponse. */ + interface IMsgSubmitMisbehaviourResponse {} + + /** Represents a MsgSubmitMisbehaviourResponse. */ + class MsgSubmitMisbehaviourResponse implements IMsgSubmitMisbehaviourResponse { + /** + * Constructs a new MsgSubmitMisbehaviourResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse); + + /** + * Creates a new MsgSubmitMisbehaviourResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgSubmitMisbehaviourResponse instance + */ + public static create( + properties?: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse, + ): ibc.core.client.v1.MsgSubmitMisbehaviourResponse; + + /** + * Encodes the specified MsgSubmitMisbehaviourResponse message. Does not implicitly {@link ibc.core.client.v1.MsgSubmitMisbehaviourResponse.verify|verify} messages. + * @param m MsgSubmitMisbehaviourResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a MsgSubmitMisbehaviourResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgSubmitMisbehaviourResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.MsgSubmitMisbehaviourResponse; + } + + /** Properties of an IdentifiedClientState. */ + interface IIdentifiedClientState { + /** IdentifiedClientState clientId */ + clientId?: string | null; + + /** IdentifiedClientState clientState */ + clientState?: google.protobuf.IAny | null; + } + + /** Represents an IdentifiedClientState. */ + class IdentifiedClientState implements IIdentifiedClientState { + /** + * Constructs a new IdentifiedClientState. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IIdentifiedClientState); + + /** IdentifiedClientState clientId. */ + public clientId: string; + + /** IdentifiedClientState clientState. */ + public clientState?: google.protobuf.IAny | null; + + /** + * Creates a new IdentifiedClientState instance using the specified properties. + * @param [properties] Properties to set + * @returns IdentifiedClientState instance + */ + public static create( + properties?: ibc.core.client.v1.IIdentifiedClientState, + ): ibc.core.client.v1.IdentifiedClientState; + + /** + * Encodes the specified IdentifiedClientState message. Does not implicitly {@link ibc.core.client.v1.IdentifiedClientState.verify|verify} messages. + * @param m IdentifiedClientState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IIdentifiedClientState, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes an IdentifiedClientState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns IdentifiedClientState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.IdentifiedClientState; + } + + /** Properties of a ConsensusStateWithHeight. */ + interface IConsensusStateWithHeight { + /** ConsensusStateWithHeight height */ + height?: ibc.core.client.v1.IHeight | null; + + /** ConsensusStateWithHeight consensusState */ + consensusState?: google.protobuf.IAny | null; + } + + /** Represents a ConsensusStateWithHeight. */ + class ConsensusStateWithHeight implements IConsensusStateWithHeight { + /** + * Constructs a new ConsensusStateWithHeight. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IConsensusStateWithHeight); + + /** ConsensusStateWithHeight height. */ + public height?: ibc.core.client.v1.IHeight | null; + + /** ConsensusStateWithHeight consensusState. */ + public consensusState?: google.protobuf.IAny | null; + + /** + * Creates a new ConsensusStateWithHeight instance using the specified properties. + * @param [properties] Properties to set + * @returns ConsensusStateWithHeight instance + */ + public static create( + properties?: ibc.core.client.v1.IConsensusStateWithHeight, + ): ibc.core.client.v1.ConsensusStateWithHeight; + + /** + * Encodes the specified ConsensusStateWithHeight message. Does not implicitly {@link ibc.core.client.v1.ConsensusStateWithHeight.verify|verify} messages. + * @param m ConsensusStateWithHeight message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IConsensusStateWithHeight, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a ConsensusStateWithHeight message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ConsensusStateWithHeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.ConsensusStateWithHeight; + } + + /** Properties of a ClientConsensusStates. */ + interface IClientConsensusStates { + /** ClientConsensusStates clientId */ + clientId?: string | null; + + /** ClientConsensusStates consensusStates */ + consensusStates?: ibc.core.client.v1.IConsensusStateWithHeight[] | null; + } + + /** Represents a ClientConsensusStates. */ + class ClientConsensusStates implements IClientConsensusStates { + /** + * Constructs a new ClientConsensusStates. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IClientConsensusStates); + + /** ClientConsensusStates clientId. */ + public clientId: string; + + /** ClientConsensusStates consensusStates. */ + public consensusStates: ibc.core.client.v1.IConsensusStateWithHeight[]; + + /** + * Creates a new ClientConsensusStates instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientConsensusStates instance + */ + public static create( + properties?: ibc.core.client.v1.IClientConsensusStates, + ): ibc.core.client.v1.ClientConsensusStates; + + /** + * Encodes the specified ClientConsensusStates message. Does not implicitly {@link ibc.core.client.v1.ClientConsensusStates.verify|verify} messages. + * @param m ClientConsensusStates message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IClientConsensusStates, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a ClientConsensusStates message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientConsensusStates + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.ClientConsensusStates; + } + + /** Properties of a ClientUpdateProposal. */ + interface IClientUpdateProposal { + /** ClientUpdateProposal title */ + title?: string | null; + + /** ClientUpdateProposal description */ + description?: string | null; + + /** ClientUpdateProposal clientId */ + clientId?: string | null; + + /** ClientUpdateProposal header */ + header?: google.protobuf.IAny | null; + } + + /** Represents a ClientUpdateProposal. */ + class ClientUpdateProposal implements IClientUpdateProposal { + /** + * Constructs a new ClientUpdateProposal. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IClientUpdateProposal); + + /** ClientUpdateProposal title. */ + public title: string; + + /** ClientUpdateProposal description. */ + public description: string; + + /** ClientUpdateProposal clientId. */ + public clientId: string; + + /** ClientUpdateProposal header. */ + public header?: google.protobuf.IAny | null; + + /** + * Creates a new ClientUpdateProposal instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientUpdateProposal instance + */ + public static create( + properties?: ibc.core.client.v1.IClientUpdateProposal, + ): ibc.core.client.v1.ClientUpdateProposal; + + /** + * Encodes the specified ClientUpdateProposal message. Does not implicitly {@link ibc.core.client.v1.ClientUpdateProposal.verify|verify} messages. + * @param m ClientUpdateProposal message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.core.client.v1.IClientUpdateProposal, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a ClientUpdateProposal message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientUpdateProposal + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.client.v1.ClientUpdateProposal; + } + + /** Properties of an Height. */ + interface IHeight { + /** Height revisionNumber */ + revisionNumber?: Long | null; + + /** Height revisionHeight */ + revisionHeight?: Long | null; + } + + /** Represents an Height. */ + class Height implements IHeight { + /** + * Constructs a new Height. + * @param [p] Properties to set + */ + constructor(p?: ibc.core.client.v1.IHeight); + + /** Height revisionNumber. */ + public revisionNumber: Long; + + /** Height revisionHeight. */ + public revisionHeight: Long; + + /** + * Creates a new Height instance using the specified properties. + * @param [properties] Properties to set + * @returns Height instance + */ + public static create(properties?: ibc.core.client.v1.IHeight): ibc.core.client.v1.Height; + + /** + * Encodes the specified Height message. Does not implicitly {@link ibc.core.client.v1.Height.verify|verify} messages. + * @param m Height message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode(m: ibc.core.client.v1.IHeight, w?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Height message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgTransfer + * @returns Height * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode( - r: $protobuf.Reader | Uint8Array, - l?: number, - ): ibc.applications.transfer.v1.MsgTransfer; + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.client.v1.Height; } - /** Properties of a MsgTransferResponse. */ - interface IMsgTransferResponse {} + /** Properties of a Params. */ + interface IParams { + /** Params allowedClients */ + allowedClients?: string[] | null; + } - /** Represents a MsgTransferResponse. */ - class MsgTransferResponse implements IMsgTransferResponse { + /** Represents a Params. */ + class Params implements IParams { /** - * Constructs a new MsgTransferResponse. + * Constructs a new Params. * @param [p] Properties to set */ - constructor(p?: ibc.applications.transfer.v1.IMsgTransferResponse); + constructor(p?: ibc.core.client.v1.IParams); + + /** Params allowedClients. */ + public allowedClients: string[]; /** - * Creates a new MsgTransferResponse instance using the specified properties. + * Creates a new Params instance using the specified properties. * @param [properties] Properties to set - * @returns MsgTransferResponse instance + * @returns Params instance */ - public static create( - properties?: ibc.applications.transfer.v1.IMsgTransferResponse, - ): ibc.applications.transfer.v1.MsgTransferResponse; + public static create(properties?: ibc.core.client.v1.IParams): ibc.core.client.v1.Params; /** - * Encodes the specified MsgTransferResponse message. Does not implicitly {@link ibc.applications.transfer.v1.MsgTransferResponse.verify|verify} messages. - * @param m MsgTransferResponse message or plain object to encode + * Encodes the specified Params message. Does not implicitly {@link ibc.core.client.v1.Params.verify|verify} messages. + * @param m Params message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ - public static encode( - m: ibc.applications.transfer.v1.IMsgTransferResponse, - w?: $protobuf.Writer, - ): $protobuf.Writer; + public static encode(m: ibc.core.client.v1.IParams, w?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a MsgTransferResponse message from the specified reader or buffer. + * Decodes a Params message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgTransferResponse + * @returns Params * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode( - r: $protobuf.Reader | Uint8Array, - l?: number, - ): ibc.applications.transfer.v1.MsgTransferResponse; + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.client.v1.Params; } } } - } - /** Namespace core. */ - namespace core { - /** Namespace client. */ - namespace client { + /** Namespace connection. */ + namespace connection { /** Namespace v1. */ namespace v1 { /** Represents a Msg */ @@ -6768,2329 +12121,2689 @@ export namespace ibc { ): Msg; /** - * Calls CreateClient. - * @param request MsgCreateClient message or plain object - * @param callback Node-style callback called with the error, if any, and MsgCreateClientResponse + * Calls ConnectionOpenInit. + * @param request MsgConnectionOpenInit message or plain object + * @param callback Node-style callback called with the error, if any, and MsgConnectionOpenInitResponse */ - public createClient( - request: ibc.core.client.v1.IMsgCreateClient, - callback: ibc.core.client.v1.Msg.CreateClientCallback, + public connectionOpenInit( + request: ibc.core.connection.v1.IMsgConnectionOpenInit, + callback: ibc.core.connection.v1.Msg.ConnectionOpenInitCallback, ): void; /** - * Calls CreateClient. - * @param request MsgCreateClient message or plain object + * Calls ConnectionOpenInit. + * @param request MsgConnectionOpenInit message or plain object * @returns Promise */ - public createClient( - request: ibc.core.client.v1.IMsgCreateClient, - ): Promise; + public connectionOpenInit( + request: ibc.core.connection.v1.IMsgConnectionOpenInit, + ): Promise; /** - * Calls UpdateClient. - * @param request MsgUpdateClient message or plain object - * @param callback Node-style callback called with the error, if any, and MsgUpdateClientResponse + * Calls ConnectionOpenTry. + * @param request MsgConnectionOpenTry message or plain object + * @param callback Node-style callback called with the error, if any, and MsgConnectionOpenTryResponse */ - public updateClient( - request: ibc.core.client.v1.IMsgUpdateClient, - callback: ibc.core.client.v1.Msg.UpdateClientCallback, + public connectionOpenTry( + request: ibc.core.connection.v1.IMsgConnectionOpenTry, + callback: ibc.core.connection.v1.Msg.ConnectionOpenTryCallback, ): void; /** - * Calls UpdateClient. - * @param request MsgUpdateClient message or plain object + * Calls ConnectionOpenTry. + * @param request MsgConnectionOpenTry message or plain object * @returns Promise */ - public updateClient( - request: ibc.core.client.v1.IMsgUpdateClient, - ): Promise; + public connectionOpenTry( + request: ibc.core.connection.v1.IMsgConnectionOpenTry, + ): Promise; /** - * Calls UpgradeClient. - * @param request MsgUpgradeClient message or plain object - * @param callback Node-style callback called with the error, if any, and MsgUpgradeClientResponse + * Calls ConnectionOpenAck. + * @param request MsgConnectionOpenAck message or plain object + * @param callback Node-style callback called with the error, if any, and MsgConnectionOpenAckResponse */ - public upgradeClient( - request: ibc.core.client.v1.IMsgUpgradeClient, - callback: ibc.core.client.v1.Msg.UpgradeClientCallback, + public connectionOpenAck( + request: ibc.core.connection.v1.IMsgConnectionOpenAck, + callback: ibc.core.connection.v1.Msg.ConnectionOpenAckCallback, ): void; /** - * Calls UpgradeClient. - * @param request MsgUpgradeClient message or plain object + * Calls ConnectionOpenAck. + * @param request MsgConnectionOpenAck message or plain object * @returns Promise */ - public upgradeClient( - request: ibc.core.client.v1.IMsgUpgradeClient, - ): Promise; + public connectionOpenAck( + request: ibc.core.connection.v1.IMsgConnectionOpenAck, + ): Promise; /** - * Calls SubmitMisbehaviour. - * @param request MsgSubmitMisbehaviour message or plain object - * @param callback Node-style callback called with the error, if any, and MsgSubmitMisbehaviourResponse + * Calls ConnectionOpenConfirm. + * @param request MsgConnectionOpenConfirm message or plain object + * @param callback Node-style callback called with the error, if any, and MsgConnectionOpenConfirmResponse */ - public submitMisbehaviour( - request: ibc.core.client.v1.IMsgSubmitMisbehaviour, - callback: ibc.core.client.v1.Msg.SubmitMisbehaviourCallback, + public connectionOpenConfirm( + request: ibc.core.connection.v1.IMsgConnectionOpenConfirm, + callback: ibc.core.connection.v1.Msg.ConnectionOpenConfirmCallback, ): void; /** - * Calls SubmitMisbehaviour. - * @param request MsgSubmitMisbehaviour message or plain object + * Calls ConnectionOpenConfirm. + * @param request MsgConnectionOpenConfirm message or plain object * @returns Promise */ - public submitMisbehaviour( - request: ibc.core.client.v1.IMsgSubmitMisbehaviour, - ): Promise; + public connectionOpenConfirm( + request: ibc.core.connection.v1.IMsgConnectionOpenConfirm, + ): Promise; } namespace Msg { /** - * Callback as used by {@link ibc.core.client.v1.Msg#createClient}. + * Callback as used by {@link ibc.core.connection.v1.Msg#connectionOpenInit}. * @param error Error, if any - * @param [response] MsgCreateClientResponse + * @param [response] MsgConnectionOpenInitResponse */ - type CreateClientCallback = ( + type ConnectionOpenInitCallback = ( error: Error | null, - response?: ibc.core.client.v1.MsgCreateClientResponse, + response?: ibc.core.connection.v1.MsgConnectionOpenInitResponse, ) => void; /** - * Callback as used by {@link ibc.core.client.v1.Msg#updateClient}. + * Callback as used by {@link ibc.core.connection.v1.Msg#connectionOpenTry}. * @param error Error, if any - * @param [response] MsgUpdateClientResponse + * @param [response] MsgConnectionOpenTryResponse */ - type UpdateClientCallback = ( + type ConnectionOpenTryCallback = ( error: Error | null, - response?: ibc.core.client.v1.MsgUpdateClientResponse, + response?: ibc.core.connection.v1.MsgConnectionOpenTryResponse, ) => void; /** - * Callback as used by {@link ibc.core.client.v1.Msg#upgradeClient}. + * Callback as used by {@link ibc.core.connection.v1.Msg#connectionOpenAck}. * @param error Error, if any - * @param [response] MsgUpgradeClientResponse + * @param [response] MsgConnectionOpenAckResponse */ - type UpgradeClientCallback = ( + type ConnectionOpenAckCallback = ( error: Error | null, - response?: ibc.core.client.v1.MsgUpgradeClientResponse, + response?: ibc.core.connection.v1.MsgConnectionOpenAckResponse, ) => void; /** - * Callback as used by {@link ibc.core.client.v1.Msg#submitMisbehaviour}. + * Callback as used by {@link ibc.core.connection.v1.Msg#connectionOpenConfirm}. * @param error Error, if any - * @param [response] MsgSubmitMisbehaviourResponse + * @param [response] MsgConnectionOpenConfirmResponse */ - type SubmitMisbehaviourCallback = ( + type ConnectionOpenConfirmCallback = ( error: Error | null, - response?: ibc.core.client.v1.MsgSubmitMisbehaviourResponse, + response?: ibc.core.connection.v1.MsgConnectionOpenConfirmResponse, ) => void; } - /** Properties of a MsgCreateClient. */ - interface IMsgCreateClient { - /** MsgCreateClient clientState */ - clientState?: google.protobuf.IAny | null; + /** Properties of a MsgConnectionOpenInit. */ + interface IMsgConnectionOpenInit { + /** MsgConnectionOpenInit clientId */ + clientId?: string | null; - /** MsgCreateClient consensusState */ - consensusState?: google.protobuf.IAny | null; + /** MsgConnectionOpenInit counterparty */ + counterparty?: ibc.core.connection.v1.ICounterparty | null; - /** MsgCreateClient signer */ + /** MsgConnectionOpenInit version */ + version?: ibc.core.connection.v1.IVersion | null; + + /** MsgConnectionOpenInit delayPeriod */ + delayPeriod?: Long | null; + + /** MsgConnectionOpenInit signer */ signer?: string | null; } - /** Represents a MsgCreateClient. */ - class MsgCreateClient implements IMsgCreateClient { + /** Represents a MsgConnectionOpenInit. */ + class MsgConnectionOpenInit implements IMsgConnectionOpenInit { /** - * Constructs a new MsgCreateClient. + * Constructs a new MsgConnectionOpenInit. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgCreateClient); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenInit); - /** MsgCreateClient clientState. */ - public clientState?: google.protobuf.IAny | null; + /** MsgConnectionOpenInit clientId. */ + public clientId: string; - /** MsgCreateClient consensusState. */ - public consensusState?: google.protobuf.IAny | null; + /** MsgConnectionOpenInit counterparty. */ + public counterparty?: ibc.core.connection.v1.ICounterparty | null; - /** MsgCreateClient signer. */ + /** MsgConnectionOpenInit version. */ + public version?: ibc.core.connection.v1.IVersion | null; + + /** MsgConnectionOpenInit delayPeriod. */ + public delayPeriod: Long; + + /** MsgConnectionOpenInit signer. */ public signer: string; /** - * Creates a new MsgCreateClient instance using the specified properties. + * Creates a new MsgConnectionOpenInit instance using the specified properties. * @param [properties] Properties to set - * @returns MsgCreateClient instance + * @returns MsgConnectionOpenInit instance */ public static create( - properties?: ibc.core.client.v1.IMsgCreateClient, - ): ibc.core.client.v1.MsgCreateClient; + properties?: ibc.core.connection.v1.IMsgConnectionOpenInit, + ): ibc.core.connection.v1.MsgConnectionOpenInit; /** - * Encodes the specified MsgCreateClient message. Does not implicitly {@link ibc.core.client.v1.MsgCreateClient.verify|verify} messages. - * @param m MsgCreateClient message or plain object to encode + * Encodes the specified MsgConnectionOpenInit message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenInit.verify|verify} messages. + * @param m MsgConnectionOpenInit message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgCreateClient, + m: ibc.core.connection.v1.IMsgConnectionOpenInit, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgCreateClient message from the specified reader or buffer. + * Decodes a MsgConnectionOpenInit message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgCreateClient + * @returns MsgConnectionOpenInit * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgCreateClient; + ): ibc.core.connection.v1.MsgConnectionOpenInit; } - /** Properties of a MsgCreateClientResponse. */ - interface IMsgCreateClientResponse {} + /** Properties of a MsgConnectionOpenInitResponse. */ + interface IMsgConnectionOpenInitResponse {} - /** Represents a MsgCreateClientResponse. */ - class MsgCreateClientResponse implements IMsgCreateClientResponse { + /** Represents a MsgConnectionOpenInitResponse. */ + class MsgConnectionOpenInitResponse implements IMsgConnectionOpenInitResponse { /** - * Constructs a new MsgCreateClientResponse. + * Constructs a new MsgConnectionOpenInitResponse. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgCreateClientResponse); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenInitResponse); /** - * Creates a new MsgCreateClientResponse instance using the specified properties. + * Creates a new MsgConnectionOpenInitResponse instance using the specified properties. * @param [properties] Properties to set - * @returns MsgCreateClientResponse instance + * @returns MsgConnectionOpenInitResponse instance */ public static create( - properties?: ibc.core.client.v1.IMsgCreateClientResponse, - ): ibc.core.client.v1.MsgCreateClientResponse; + properties?: ibc.core.connection.v1.IMsgConnectionOpenInitResponse, + ): ibc.core.connection.v1.MsgConnectionOpenInitResponse; /** - * Encodes the specified MsgCreateClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgCreateClientResponse.verify|verify} messages. - * @param m MsgCreateClientResponse message or plain object to encode + * Encodes the specified MsgConnectionOpenInitResponse message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenInitResponse.verify|verify} messages. + * @param m MsgConnectionOpenInitResponse message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgCreateClientResponse, + m: ibc.core.connection.v1.IMsgConnectionOpenInitResponse, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgCreateClientResponse message from the specified reader or buffer. + * Decodes a MsgConnectionOpenInitResponse message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgCreateClientResponse + * @returns MsgConnectionOpenInitResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgCreateClientResponse; + ): ibc.core.connection.v1.MsgConnectionOpenInitResponse; } - /** Properties of a MsgUpdateClient. */ - interface IMsgUpdateClient { - /** MsgUpdateClient clientId */ + /** Properties of a MsgConnectionOpenTry. */ + interface IMsgConnectionOpenTry { + /** MsgConnectionOpenTry clientId */ clientId?: string | null; - /** MsgUpdateClient header */ - header?: google.protobuf.IAny | null; + /** MsgConnectionOpenTry previousConnectionId */ + previousConnectionId?: string | null; - /** MsgUpdateClient signer */ + /** MsgConnectionOpenTry clientState */ + clientState?: google.protobuf.IAny | null; + + /** MsgConnectionOpenTry counterparty */ + counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** MsgConnectionOpenTry delayPeriod */ + delayPeriod?: Long | null; + + /** MsgConnectionOpenTry counterpartyVersions */ + counterpartyVersions?: ibc.core.connection.v1.IVersion[] | null; + + /** MsgConnectionOpenTry proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenTry proofInit */ + proofInit?: Uint8Array | null; + + /** MsgConnectionOpenTry proofClient */ + proofClient?: Uint8Array | null; + + /** MsgConnectionOpenTry proofConsensus */ + proofConsensus?: Uint8Array | null; + + /** MsgConnectionOpenTry consensusHeight */ + consensusHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenTry signer */ signer?: string | null; } - /** Represents a MsgUpdateClient. */ - class MsgUpdateClient implements IMsgUpdateClient { + /** Represents a MsgConnectionOpenTry. */ + class MsgConnectionOpenTry implements IMsgConnectionOpenTry { /** - * Constructs a new MsgUpdateClient. + * Constructs a new MsgConnectionOpenTry. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgUpdateClient); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenTry); - /** MsgUpdateClient clientId. */ + /** MsgConnectionOpenTry clientId. */ public clientId: string; - /** MsgUpdateClient header. */ - public header?: google.protobuf.IAny | null; + /** MsgConnectionOpenTry previousConnectionId. */ + public previousConnectionId: string; - /** MsgUpdateClient signer. */ + /** MsgConnectionOpenTry clientState. */ + public clientState?: google.protobuf.IAny | null; + + /** MsgConnectionOpenTry counterparty. */ + public counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** MsgConnectionOpenTry delayPeriod. */ + public delayPeriod: Long; + + /** MsgConnectionOpenTry counterpartyVersions. */ + public counterpartyVersions: ibc.core.connection.v1.IVersion[]; + + /** MsgConnectionOpenTry proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenTry proofInit. */ + public proofInit: Uint8Array; + + /** MsgConnectionOpenTry proofClient. */ + public proofClient: Uint8Array; + + /** MsgConnectionOpenTry proofConsensus. */ + public proofConsensus: Uint8Array; + + /** MsgConnectionOpenTry consensusHeight. */ + public consensusHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenTry signer. */ public signer: string; /** - * Creates a new MsgUpdateClient instance using the specified properties. + * Creates a new MsgConnectionOpenTry instance using the specified properties. * @param [properties] Properties to set - * @returns MsgUpdateClient instance + * @returns MsgConnectionOpenTry instance */ public static create( - properties?: ibc.core.client.v1.IMsgUpdateClient, - ): ibc.core.client.v1.MsgUpdateClient; + properties?: ibc.core.connection.v1.IMsgConnectionOpenTry, + ): ibc.core.connection.v1.MsgConnectionOpenTry; /** - * Encodes the specified MsgUpdateClient message. Does not implicitly {@link ibc.core.client.v1.MsgUpdateClient.verify|verify} messages. - * @param m MsgUpdateClient message or plain object to encode + * Encodes the specified MsgConnectionOpenTry message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenTry.verify|verify} messages. + * @param m MsgConnectionOpenTry message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgUpdateClient, + m: ibc.core.connection.v1.IMsgConnectionOpenTry, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgUpdateClient message from the specified reader or buffer. + * Decodes a MsgConnectionOpenTry message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgUpdateClient + * @returns MsgConnectionOpenTry * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgUpdateClient; + ): ibc.core.connection.v1.MsgConnectionOpenTry; } - /** Properties of a MsgUpdateClientResponse. */ - interface IMsgUpdateClientResponse {} + /** Properties of a MsgConnectionOpenTryResponse. */ + interface IMsgConnectionOpenTryResponse {} - /** Represents a MsgUpdateClientResponse. */ - class MsgUpdateClientResponse implements IMsgUpdateClientResponse { + /** Represents a MsgConnectionOpenTryResponse. */ + class MsgConnectionOpenTryResponse implements IMsgConnectionOpenTryResponse { /** - * Constructs a new MsgUpdateClientResponse. + * Constructs a new MsgConnectionOpenTryResponse. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgUpdateClientResponse); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenTryResponse); /** - * Creates a new MsgUpdateClientResponse instance using the specified properties. + * Creates a new MsgConnectionOpenTryResponse instance using the specified properties. * @param [properties] Properties to set - * @returns MsgUpdateClientResponse instance + * @returns MsgConnectionOpenTryResponse instance */ public static create( - properties?: ibc.core.client.v1.IMsgUpdateClientResponse, - ): ibc.core.client.v1.MsgUpdateClientResponse; + properties?: ibc.core.connection.v1.IMsgConnectionOpenTryResponse, + ): ibc.core.connection.v1.MsgConnectionOpenTryResponse; /** - * Encodes the specified MsgUpdateClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgUpdateClientResponse.verify|verify} messages. - * @param m MsgUpdateClientResponse message or plain object to encode + * Encodes the specified MsgConnectionOpenTryResponse message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenTryResponse.verify|verify} messages. + * @param m MsgConnectionOpenTryResponse message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgUpdateClientResponse, + m: ibc.core.connection.v1.IMsgConnectionOpenTryResponse, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgUpdateClientResponse message from the specified reader or buffer. + * Decodes a MsgConnectionOpenTryResponse message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgUpdateClientResponse + * @returns MsgConnectionOpenTryResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgUpdateClientResponse; + ): ibc.core.connection.v1.MsgConnectionOpenTryResponse; } - /** Properties of a MsgUpgradeClient. */ - interface IMsgUpgradeClient { - /** MsgUpgradeClient clientId */ - clientId?: string | null; + /** Properties of a MsgConnectionOpenAck. */ + interface IMsgConnectionOpenAck { + /** MsgConnectionOpenAck connectionId */ + connectionId?: string | null; - /** MsgUpgradeClient clientState */ + /** MsgConnectionOpenAck counterpartyConnectionId */ + counterpartyConnectionId?: string | null; + + /** MsgConnectionOpenAck version */ + version?: ibc.core.connection.v1.IVersion | null; + + /** MsgConnectionOpenAck clientState */ clientState?: google.protobuf.IAny | null; - /** MsgUpgradeClient consensusState */ - consensusState?: google.protobuf.IAny | null; + /** MsgConnectionOpenAck proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenAck proofTry */ + proofTry?: Uint8Array | null; - /** MsgUpgradeClient proofUpgradeClient */ - proofUpgradeClient?: Uint8Array | null; + /** MsgConnectionOpenAck proofClient */ + proofClient?: Uint8Array | null; - /** MsgUpgradeClient proofUpgradeConsensusState */ - proofUpgradeConsensusState?: Uint8Array | null; + /** MsgConnectionOpenAck proofConsensus */ + proofConsensus?: Uint8Array | null; - /** MsgUpgradeClient signer */ + /** MsgConnectionOpenAck consensusHeight */ + consensusHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenAck signer */ signer?: string | null; } - /** Represents a MsgUpgradeClient. */ - class MsgUpgradeClient implements IMsgUpgradeClient { + /** Represents a MsgConnectionOpenAck. */ + class MsgConnectionOpenAck implements IMsgConnectionOpenAck { /** - * Constructs a new MsgUpgradeClient. + * Constructs a new MsgConnectionOpenAck. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgUpgradeClient); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenAck); - /** MsgUpgradeClient clientId. */ - public clientId: string; + /** MsgConnectionOpenAck connectionId. */ + public connectionId: string; - /** MsgUpgradeClient clientState. */ + /** MsgConnectionOpenAck counterpartyConnectionId. */ + public counterpartyConnectionId: string; + + /** MsgConnectionOpenAck version. */ + public version?: ibc.core.connection.v1.IVersion | null; + + /** MsgConnectionOpenAck clientState. */ public clientState?: google.protobuf.IAny | null; - /** MsgUpgradeClient consensusState. */ - public consensusState?: google.protobuf.IAny | null; + /** MsgConnectionOpenAck proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; - /** MsgUpgradeClient proofUpgradeClient. */ - public proofUpgradeClient: Uint8Array; + /** MsgConnectionOpenAck proofTry. */ + public proofTry: Uint8Array; - /** MsgUpgradeClient proofUpgradeConsensusState. */ - public proofUpgradeConsensusState: Uint8Array; + /** MsgConnectionOpenAck proofClient. */ + public proofClient: Uint8Array; - /** MsgUpgradeClient signer. */ + /** MsgConnectionOpenAck proofConsensus. */ + public proofConsensus: Uint8Array; + + /** MsgConnectionOpenAck consensusHeight. */ + public consensusHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenAck signer. */ public signer: string; /** - * Creates a new MsgUpgradeClient instance using the specified properties. + * Creates a new MsgConnectionOpenAck instance using the specified properties. * @param [properties] Properties to set - * @returns MsgUpgradeClient instance + * @returns MsgConnectionOpenAck instance */ public static create( - properties?: ibc.core.client.v1.IMsgUpgradeClient, - ): ibc.core.client.v1.MsgUpgradeClient; + properties?: ibc.core.connection.v1.IMsgConnectionOpenAck, + ): ibc.core.connection.v1.MsgConnectionOpenAck; /** - * Encodes the specified MsgUpgradeClient message. Does not implicitly {@link ibc.core.client.v1.MsgUpgradeClient.verify|verify} messages. - * @param m MsgUpgradeClient message or plain object to encode + * Encodes the specified MsgConnectionOpenAck message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenAck.verify|verify} messages. + * @param m MsgConnectionOpenAck message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgUpgradeClient, + m: ibc.core.connection.v1.IMsgConnectionOpenAck, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgUpgradeClient message from the specified reader or buffer. + * Decodes a MsgConnectionOpenAck message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgUpgradeClient + * @returns MsgConnectionOpenAck * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgUpgradeClient; + ): ibc.core.connection.v1.MsgConnectionOpenAck; } - /** Properties of a MsgUpgradeClientResponse. */ - interface IMsgUpgradeClientResponse {} + /** Properties of a MsgConnectionOpenAckResponse. */ + interface IMsgConnectionOpenAckResponse {} - /** Represents a MsgUpgradeClientResponse. */ - class MsgUpgradeClientResponse implements IMsgUpgradeClientResponse { + /** Represents a MsgConnectionOpenAckResponse. */ + class MsgConnectionOpenAckResponse implements IMsgConnectionOpenAckResponse { /** - * Constructs a new MsgUpgradeClientResponse. + * Constructs a new MsgConnectionOpenAckResponse. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgUpgradeClientResponse); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenAckResponse); /** - * Creates a new MsgUpgradeClientResponse instance using the specified properties. + * Creates a new MsgConnectionOpenAckResponse instance using the specified properties. * @param [properties] Properties to set - * @returns MsgUpgradeClientResponse instance + * @returns MsgConnectionOpenAckResponse instance */ public static create( - properties?: ibc.core.client.v1.IMsgUpgradeClientResponse, - ): ibc.core.client.v1.MsgUpgradeClientResponse; + properties?: ibc.core.connection.v1.IMsgConnectionOpenAckResponse, + ): ibc.core.connection.v1.MsgConnectionOpenAckResponse; /** - * Encodes the specified MsgUpgradeClientResponse message. Does not implicitly {@link ibc.core.client.v1.MsgUpgradeClientResponse.verify|verify} messages. - * @param m MsgUpgradeClientResponse message or plain object to encode + * Encodes the specified MsgConnectionOpenAckResponse message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenAckResponse.verify|verify} messages. + * @param m MsgConnectionOpenAckResponse message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgUpgradeClientResponse, + m: ibc.core.connection.v1.IMsgConnectionOpenAckResponse, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgUpgradeClientResponse message from the specified reader or buffer. + * Decodes a MsgConnectionOpenAckResponse message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgUpgradeClientResponse + * @returns MsgConnectionOpenAckResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgUpgradeClientResponse; + ): ibc.core.connection.v1.MsgConnectionOpenAckResponse; } - /** Properties of a MsgSubmitMisbehaviour. */ - interface IMsgSubmitMisbehaviour { - /** MsgSubmitMisbehaviour clientId */ - clientId?: string | null; + /** Properties of a MsgConnectionOpenConfirm. */ + interface IMsgConnectionOpenConfirm { + /** MsgConnectionOpenConfirm connectionId */ + connectionId?: string | null; - /** MsgSubmitMisbehaviour misbehaviour */ - misbehaviour?: google.protobuf.IAny | null; + /** MsgConnectionOpenConfirm proofAck */ + proofAck?: Uint8Array | null; - /** MsgSubmitMisbehaviour signer */ + /** MsgConnectionOpenConfirm proofHeight */ + proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenConfirm signer */ signer?: string | null; } - /** Represents a MsgSubmitMisbehaviour. */ - class MsgSubmitMisbehaviour implements IMsgSubmitMisbehaviour { + /** Represents a MsgConnectionOpenConfirm. */ + class MsgConnectionOpenConfirm implements IMsgConnectionOpenConfirm { /** - * Constructs a new MsgSubmitMisbehaviour. + * Constructs a new MsgConnectionOpenConfirm. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgSubmitMisbehaviour); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenConfirm); - /** MsgSubmitMisbehaviour clientId. */ - public clientId: string; + /** MsgConnectionOpenConfirm connectionId. */ + public connectionId: string; - /** MsgSubmitMisbehaviour misbehaviour. */ - public misbehaviour?: google.protobuf.IAny | null; + /** MsgConnectionOpenConfirm proofAck. */ + public proofAck: Uint8Array; - /** MsgSubmitMisbehaviour signer. */ + /** MsgConnectionOpenConfirm proofHeight. */ + public proofHeight?: ibc.core.client.v1.IHeight | null; + + /** MsgConnectionOpenConfirm signer. */ public signer: string; /** - * Creates a new MsgSubmitMisbehaviour instance using the specified properties. + * Creates a new MsgConnectionOpenConfirm instance using the specified properties. * @param [properties] Properties to set - * @returns MsgSubmitMisbehaviour instance + * @returns MsgConnectionOpenConfirm instance */ public static create( - properties?: ibc.core.client.v1.IMsgSubmitMisbehaviour, - ): ibc.core.client.v1.MsgSubmitMisbehaviour; + properties?: ibc.core.connection.v1.IMsgConnectionOpenConfirm, + ): ibc.core.connection.v1.MsgConnectionOpenConfirm; /** - * Encodes the specified MsgSubmitMisbehaviour message. Does not implicitly {@link ibc.core.client.v1.MsgSubmitMisbehaviour.verify|verify} messages. - * @param m MsgSubmitMisbehaviour message or plain object to encode + * Encodes the specified MsgConnectionOpenConfirm message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenConfirm.verify|verify} messages. + * @param m MsgConnectionOpenConfirm message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgSubmitMisbehaviour, + m: ibc.core.connection.v1.IMsgConnectionOpenConfirm, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgSubmitMisbehaviour message from the specified reader or buffer. + * Decodes a MsgConnectionOpenConfirm message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgSubmitMisbehaviour + * @returns MsgConnectionOpenConfirm * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgSubmitMisbehaviour; + ): ibc.core.connection.v1.MsgConnectionOpenConfirm; } - /** Properties of a MsgSubmitMisbehaviourResponse. */ - interface IMsgSubmitMisbehaviourResponse {} + /** Properties of a MsgConnectionOpenConfirmResponse. */ + interface IMsgConnectionOpenConfirmResponse {} - /** Represents a MsgSubmitMisbehaviourResponse. */ - class MsgSubmitMisbehaviourResponse implements IMsgSubmitMisbehaviourResponse { + /** Represents a MsgConnectionOpenConfirmResponse. */ + class MsgConnectionOpenConfirmResponse implements IMsgConnectionOpenConfirmResponse { /** - * Constructs a new MsgSubmitMisbehaviourResponse. + * Constructs a new MsgConnectionOpenConfirmResponse. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse); + constructor(p?: ibc.core.connection.v1.IMsgConnectionOpenConfirmResponse); /** - * Creates a new MsgSubmitMisbehaviourResponse instance using the specified properties. + * Creates a new MsgConnectionOpenConfirmResponse instance using the specified properties. * @param [properties] Properties to set - * @returns MsgSubmitMisbehaviourResponse instance + * @returns MsgConnectionOpenConfirmResponse instance */ public static create( - properties?: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse, - ): ibc.core.client.v1.MsgSubmitMisbehaviourResponse; + properties?: ibc.core.connection.v1.IMsgConnectionOpenConfirmResponse, + ): ibc.core.connection.v1.MsgConnectionOpenConfirmResponse; /** - * Encodes the specified MsgSubmitMisbehaviourResponse message. Does not implicitly {@link ibc.core.client.v1.MsgSubmitMisbehaviourResponse.verify|verify} messages. - * @param m MsgSubmitMisbehaviourResponse message or plain object to encode + * Encodes the specified MsgConnectionOpenConfirmResponse message. Does not implicitly {@link ibc.core.connection.v1.MsgConnectionOpenConfirmResponse.verify|verify} messages. + * @param m MsgConnectionOpenConfirmResponse message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IMsgSubmitMisbehaviourResponse, + m: ibc.core.connection.v1.IMsgConnectionOpenConfirmResponse, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a MsgSubmitMisbehaviourResponse message from the specified reader or buffer. + * Decodes a MsgConnectionOpenConfirmResponse message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns MsgSubmitMisbehaviourResponse + * @returns MsgConnectionOpenConfirmResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.MsgSubmitMisbehaviourResponse; + ): ibc.core.connection.v1.MsgConnectionOpenConfirmResponse; } - /** Properties of an IdentifiedClientState. */ - interface IIdentifiedClientState { - /** IdentifiedClientState clientId */ + /** Properties of a ConnectionEnd. */ + interface IConnectionEnd { + /** ConnectionEnd clientId */ clientId?: string | null; - /** IdentifiedClientState clientState */ - clientState?: google.protobuf.IAny | null; + /** ConnectionEnd versions */ + versions?: ibc.core.connection.v1.IVersion[] | null; + + /** ConnectionEnd state */ + state?: ibc.core.connection.v1.State | null; + + /** ConnectionEnd counterparty */ + counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** ConnectionEnd delayPeriod */ + delayPeriod?: Long | null; } - /** Represents an IdentifiedClientState. */ - class IdentifiedClientState implements IIdentifiedClientState { + /** Represents a ConnectionEnd. */ + class ConnectionEnd implements IConnectionEnd { /** - * Constructs a new IdentifiedClientState. + * Constructs a new ConnectionEnd. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IIdentifiedClientState); + constructor(p?: ibc.core.connection.v1.IConnectionEnd); - /** IdentifiedClientState clientId. */ + /** ConnectionEnd clientId. */ public clientId: string; - /** IdentifiedClientState clientState. */ - public clientState?: google.protobuf.IAny | null; + /** ConnectionEnd versions. */ + public versions: ibc.core.connection.v1.IVersion[]; + + /** ConnectionEnd state. */ + public state: ibc.core.connection.v1.State; + + /** ConnectionEnd counterparty. */ + public counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** ConnectionEnd delayPeriod. */ + public delayPeriod: Long; /** - * Creates a new IdentifiedClientState instance using the specified properties. + * Creates a new ConnectionEnd instance using the specified properties. * @param [properties] Properties to set - * @returns IdentifiedClientState instance + * @returns ConnectionEnd instance */ public static create( - properties?: ibc.core.client.v1.IIdentifiedClientState, - ): ibc.core.client.v1.IdentifiedClientState; + properties?: ibc.core.connection.v1.IConnectionEnd, + ): ibc.core.connection.v1.ConnectionEnd; /** - * Encodes the specified IdentifiedClientState message. Does not implicitly {@link ibc.core.client.v1.IdentifiedClientState.verify|verify} messages. - * @param m IdentifiedClientState message or plain object to encode + * Encodes the specified ConnectionEnd message. Does not implicitly {@link ibc.core.connection.v1.ConnectionEnd.verify|verify} messages. + * @param m ConnectionEnd message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IIdentifiedClientState, + m: ibc.core.connection.v1.IConnectionEnd, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes an IdentifiedClientState message from the specified reader or buffer. + * Decodes a ConnectionEnd message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns IdentifiedClientState + * @returns ConnectionEnd * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.IdentifiedClientState; + ): ibc.core.connection.v1.ConnectionEnd; } - /** Properties of a ConsensusStateWithHeight. */ - interface IConsensusStateWithHeight { - /** ConsensusStateWithHeight height */ - height?: ibc.core.client.v1.IHeight | null; + /** Properties of an IdentifiedConnection. */ + interface IIdentifiedConnection { + /** IdentifiedConnection id */ + id?: string | null; - /** ConsensusStateWithHeight consensusState */ - consensusState?: google.protobuf.IAny | null; + /** IdentifiedConnection clientId */ + clientId?: string | null; + + /** IdentifiedConnection versions */ + versions?: ibc.core.connection.v1.IVersion[] | null; + + /** IdentifiedConnection state */ + state?: ibc.core.connection.v1.State | null; + + /** IdentifiedConnection counterparty */ + counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** IdentifiedConnection delayPeriod */ + delayPeriod?: Long | null; } - /** Represents a ConsensusStateWithHeight. */ - class ConsensusStateWithHeight implements IConsensusStateWithHeight { + /** Represents an IdentifiedConnection. */ + class IdentifiedConnection implements IIdentifiedConnection { /** - * Constructs a new ConsensusStateWithHeight. + * Constructs a new IdentifiedConnection. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IConsensusStateWithHeight); + constructor(p?: ibc.core.connection.v1.IIdentifiedConnection); - /** ConsensusStateWithHeight height. */ - public height?: ibc.core.client.v1.IHeight | null; + /** IdentifiedConnection id. */ + public id: string; - /** ConsensusStateWithHeight consensusState. */ - public consensusState?: google.protobuf.IAny | null; + /** IdentifiedConnection clientId. */ + public clientId: string; + + /** IdentifiedConnection versions. */ + public versions: ibc.core.connection.v1.IVersion[]; + + /** IdentifiedConnection state. */ + public state: ibc.core.connection.v1.State; + + /** IdentifiedConnection counterparty. */ + public counterparty?: ibc.core.connection.v1.ICounterparty | null; + + /** IdentifiedConnection delayPeriod. */ + public delayPeriod: Long; /** - * Creates a new ConsensusStateWithHeight instance using the specified properties. + * Creates a new IdentifiedConnection instance using the specified properties. * @param [properties] Properties to set - * @returns ConsensusStateWithHeight instance + * @returns IdentifiedConnection instance */ public static create( - properties?: ibc.core.client.v1.IConsensusStateWithHeight, - ): ibc.core.client.v1.ConsensusStateWithHeight; + properties?: ibc.core.connection.v1.IIdentifiedConnection, + ): ibc.core.connection.v1.IdentifiedConnection; /** - * Encodes the specified ConsensusStateWithHeight message. Does not implicitly {@link ibc.core.client.v1.ConsensusStateWithHeight.verify|verify} messages. - * @param m ConsensusStateWithHeight message or plain object to encode + * Encodes the specified IdentifiedConnection message. Does not implicitly {@link ibc.core.connection.v1.IdentifiedConnection.verify|verify} messages. + * @param m IdentifiedConnection message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IConsensusStateWithHeight, + m: ibc.core.connection.v1.IIdentifiedConnection, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a ConsensusStateWithHeight message from the specified reader or buffer. + * Decodes an IdentifiedConnection message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns ConsensusStateWithHeight + * @returns IdentifiedConnection * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.ConsensusStateWithHeight; + ): ibc.core.connection.v1.IdentifiedConnection; } - /** Properties of a ClientConsensusStates. */ - interface IClientConsensusStates { - /** ClientConsensusStates clientId */ + /** State enum. */ + enum State { + STATE_UNINITIALIZED_UNSPECIFIED = 0, + STATE_INIT = 1, + STATE_TRYOPEN = 2, + STATE_OPEN = 3, + } + + /** Properties of a Counterparty. */ + interface ICounterparty { + /** Counterparty clientId */ clientId?: string | null; - /** ClientConsensusStates consensusStates */ - consensusStates?: ibc.core.client.v1.IConsensusStateWithHeight[] | null; + /** Counterparty connectionId */ + connectionId?: string | null; + + /** Counterparty prefix */ + prefix?: ibc.core.commitment.v1.IMerklePrefix | null; } - /** Represents a ClientConsensusStates. */ - class ClientConsensusStates implements IClientConsensusStates { + /** Represents a Counterparty. */ + class Counterparty implements ICounterparty { /** - * Constructs a new ClientConsensusStates. + * Constructs a new Counterparty. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IClientConsensusStates); + constructor(p?: ibc.core.connection.v1.ICounterparty); - /** ClientConsensusStates clientId. */ + /** Counterparty clientId. */ public clientId: string; - /** ClientConsensusStates consensusStates. */ - public consensusStates: ibc.core.client.v1.IConsensusStateWithHeight[]; + /** Counterparty connectionId. */ + public connectionId: string; + + /** Counterparty prefix. */ + public prefix?: ibc.core.commitment.v1.IMerklePrefix | null; /** - * Creates a new ClientConsensusStates instance using the specified properties. + * Creates a new Counterparty instance using the specified properties. * @param [properties] Properties to set - * @returns ClientConsensusStates instance + * @returns Counterparty instance */ public static create( - properties?: ibc.core.client.v1.IClientConsensusStates, - ): ibc.core.client.v1.ClientConsensusStates; + properties?: ibc.core.connection.v1.ICounterparty, + ): ibc.core.connection.v1.Counterparty; /** - * Encodes the specified ClientConsensusStates message. Does not implicitly {@link ibc.core.client.v1.ClientConsensusStates.verify|verify} messages. - * @param m ClientConsensusStates message or plain object to encode + * Encodes the specified Counterparty message. Does not implicitly {@link ibc.core.connection.v1.Counterparty.verify|verify} messages. + * @param m Counterparty message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IClientConsensusStates, + m: ibc.core.connection.v1.ICounterparty, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a ClientConsensusStates message from the specified reader or buffer. + * Decodes a Counterparty message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns ClientConsensusStates + * @returns Counterparty * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.ClientConsensusStates; + ): ibc.core.connection.v1.Counterparty; } - /** Properties of a ClientUpdateProposal. */ - interface IClientUpdateProposal { - /** ClientUpdateProposal title */ - title?: string | null; - - /** ClientUpdateProposal description */ - description?: string | null; - - /** ClientUpdateProposal clientId */ - clientId?: string | null; - - /** ClientUpdateProposal header */ - header?: google.protobuf.IAny | null; + /** Properties of a ClientPaths. */ + interface IClientPaths { + /** ClientPaths paths */ + paths?: string[] | null; } - /** Represents a ClientUpdateProposal. */ - class ClientUpdateProposal implements IClientUpdateProposal { + /** Represents a ClientPaths. */ + class ClientPaths implements IClientPaths { /** - * Constructs a new ClientUpdateProposal. + * Constructs a new ClientPaths. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IClientUpdateProposal); - - /** ClientUpdateProposal title. */ - public title: string; - - /** ClientUpdateProposal description. */ - public description: string; - - /** ClientUpdateProposal clientId. */ - public clientId: string; + constructor(p?: ibc.core.connection.v1.IClientPaths); - /** ClientUpdateProposal header. */ - public header?: google.protobuf.IAny | null; + /** ClientPaths paths. */ + public paths: string[]; /** - * Creates a new ClientUpdateProposal instance using the specified properties. + * Creates a new ClientPaths instance using the specified properties. * @param [properties] Properties to set - * @returns ClientUpdateProposal instance + * @returns ClientPaths instance */ public static create( - properties?: ibc.core.client.v1.IClientUpdateProposal, - ): ibc.core.client.v1.ClientUpdateProposal; + properties?: ibc.core.connection.v1.IClientPaths, + ): ibc.core.connection.v1.ClientPaths; /** - * Encodes the specified ClientUpdateProposal message. Does not implicitly {@link ibc.core.client.v1.ClientUpdateProposal.verify|verify} messages. - * @param m ClientUpdateProposal message or plain object to encode + * Encodes the specified ClientPaths message. Does not implicitly {@link ibc.core.connection.v1.ClientPaths.verify|verify} messages. + * @param m ClientPaths message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ public static encode( - m: ibc.core.client.v1.IClientUpdateProposal, + m: ibc.core.connection.v1.IClientPaths, w?: $protobuf.Writer, ): $protobuf.Writer; /** - * Decodes a ClientUpdateProposal message from the specified reader or buffer. + * Decodes a ClientPaths message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns ClientUpdateProposal + * @returns ClientPaths * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ public static decode( r: $protobuf.Reader | Uint8Array, l?: number, - ): ibc.core.client.v1.ClientUpdateProposal; + ): ibc.core.connection.v1.ClientPaths; } - /** Properties of an Height. */ - interface IHeight { - /** Height revisionNumber */ - revisionNumber?: Long | null; + /** Properties of a ConnectionPaths. */ + interface IConnectionPaths { + /** ConnectionPaths clientId */ + clientId?: string | null; - /** Height revisionHeight */ - revisionHeight?: Long | null; + /** ConnectionPaths paths */ + paths?: string[] | null; } - /** Represents an Height. */ - class Height implements IHeight { + /** Represents a ConnectionPaths. */ + class ConnectionPaths implements IConnectionPaths { /** - * Constructs a new Height. + * Constructs a new ConnectionPaths. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IHeight); + constructor(p?: ibc.core.connection.v1.IConnectionPaths); - /** Height revisionNumber. */ - public revisionNumber: Long; + /** ConnectionPaths clientId. */ + public clientId: string; - /** Height revisionHeight. */ - public revisionHeight: Long; + /** ConnectionPaths paths. */ + public paths: string[]; /** - * Creates a new Height instance using the specified properties. + * Creates a new ConnectionPaths instance using the specified properties. * @param [properties] Properties to set - * @returns Height instance + * @returns ConnectionPaths instance */ - public static create(properties?: ibc.core.client.v1.IHeight): ibc.core.client.v1.Height; + public static create( + properties?: ibc.core.connection.v1.IConnectionPaths, + ): ibc.core.connection.v1.ConnectionPaths; /** - * Encodes the specified Height message. Does not implicitly {@link ibc.core.client.v1.Height.verify|verify} messages. - * @param m Height message or plain object to encode + * Encodes the specified ConnectionPaths message. Does not implicitly {@link ibc.core.connection.v1.ConnectionPaths.verify|verify} messages. + * @param m ConnectionPaths message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ - public static encode(m: ibc.core.client.v1.IHeight, w?: $protobuf.Writer): $protobuf.Writer; + public static encode( + m: ibc.core.connection.v1.IConnectionPaths, + w?: $protobuf.Writer, + ): $protobuf.Writer; /** - * Decodes an Height message from the specified reader or buffer. + * Decodes a ConnectionPaths message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns Height + * @returns ConnectionPaths * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.client.v1.Height; + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.core.connection.v1.ConnectionPaths; } - /** Properties of a Params. */ - interface IParams { - /** Params allowedClients */ - allowedClients?: string[] | null; + /** Properties of a Version. */ + interface IVersion { + /** Version identifier */ + identifier?: string | null; + + /** Version features */ + features?: string[] | null; } - /** Represents a Params. */ - class Params implements IParams { + /** Represents a Version. */ + class Version implements IVersion { /** - * Constructs a new Params. + * Constructs a new Version. * @param [p] Properties to set */ - constructor(p?: ibc.core.client.v1.IParams); + constructor(p?: ibc.core.connection.v1.IVersion); - /** Params allowedClients. */ - public allowedClients: string[]; + /** Version identifier. */ + public identifier: string; + + /** Version features. */ + public features: string[]; /** - * Creates a new Params instance using the specified properties. + * Creates a new Version instance using the specified properties. * @param [properties] Properties to set - * @returns Params instance + * @returns Version instance */ - public static create(properties?: ibc.core.client.v1.IParams): ibc.core.client.v1.Params; + public static create(properties?: ibc.core.connection.v1.IVersion): ibc.core.connection.v1.Version; /** - * Encodes the specified Params message. Does not implicitly {@link ibc.core.client.v1.Params.verify|verify} messages. - * @param m Params message or plain object to encode + * Encodes the specified Version message. Does not implicitly {@link ibc.core.connection.v1.Version.verify|verify} messages. + * @param m Version message or plain object to encode * @param [w] Writer to encode to * @returns Writer */ - public static encode(m: ibc.core.client.v1.IParams, w?: $protobuf.Writer): $protobuf.Writer; + public static encode(m: ibc.core.connection.v1.IVersion, w?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a Params message from the specified reader or buffer. + * Decodes a Version message from the specified reader or buffer. * @param r Reader or buffer to decode from * @param [l] Message length if known beforehand - * @returns Params + * @returns Version * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.client.v1.Params; + public static decode(r: $protobuf.Reader | Uint8Array, l?: number): ibc.core.connection.v1.Version; } } } } -} - -/** Namespace tendermint. */ -export namespace tendermint { - /** Namespace types. */ - namespace types { - /** BlockIDFlag enum. */ - enum BlockIDFlag { - BLOCK_ID_FLAG_UNKNOWN = 0, - BLOCK_ID_FLAG_ABSENT = 1, - BLOCK_ID_FLAG_COMMIT = 2, - BLOCK_ID_FLAG_NIL = 3, - } - - /** SignedMsgType enum. */ - enum SignedMsgType { - SIGNED_MSG_TYPE_UNKNOWN = 0, - SIGNED_MSG_TYPE_PREVOTE = 1, - SIGNED_MSG_TYPE_PRECOMMIT = 2, - SIGNED_MSG_TYPE_PROPOSAL = 32, - } - - /** Properties of a PartSetHeader. */ - interface IPartSetHeader { - /** PartSetHeader total */ - total?: number | null; - - /** PartSetHeader hash */ - hash?: Uint8Array | null; - } - - /** Represents a PartSetHeader. */ - class PartSetHeader implements IPartSetHeader { - /** - * Constructs a new PartSetHeader. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IPartSetHeader); - - /** PartSetHeader total. */ - public total: number; - - /** PartSetHeader hash. */ - public hash: Uint8Array; - - /** - * Creates a new PartSetHeader instance using the specified properties. - * @param [properties] Properties to set - * @returns PartSetHeader instance - */ - public static create(properties?: tendermint.types.IPartSetHeader): tendermint.types.PartSetHeader; - - /** - * Encodes the specified PartSetHeader message. Does not implicitly {@link tendermint.types.PartSetHeader.verify|verify} messages. - * @param m PartSetHeader message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IPartSetHeader, w?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a PartSetHeader message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns PartSetHeader - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.PartSetHeader; - } - - /** Properties of a Part. */ - interface IPart { - /** Part index */ - index?: number | null; - - /** Part bytes */ - bytes?: Uint8Array | null; - - /** Part proof */ - proof?: tendermint.crypto.IProof | null; - } - - /** Represents a Part. */ - class Part implements IPart { - /** - * Constructs a new Part. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IPart); - - /** Part index. */ - public index: number; - - /** Part bytes. */ - public bytes: Uint8Array; - /** Part proof. */ - public proof?: tendermint.crypto.IProof | null; + /** Namespace applications. */ + namespace applications { + /** Namespace transfer. */ + namespace transfer { + /** Namespace v1. */ + namespace v1 { + /** Represents a Msg */ + class Msg extends $protobuf.rpc.Service { + /** + * Constructs a new Msg service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); - /** - * Creates a new Part instance using the specified properties. - * @param [properties] Properties to set - * @returns Part instance - */ - public static create(properties?: tendermint.types.IPart): tendermint.types.Part; + /** + * Creates new Msg service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create( + rpcImpl: $protobuf.RPCImpl, + requestDelimited?: boolean, + responseDelimited?: boolean, + ): Msg; - /** - * Encodes the specified Part message. Does not implicitly {@link tendermint.types.Part.verify|verify} messages. - * @param m Part message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IPart, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Calls Transfer. + * @param request MsgTransfer message or plain object + * @param callback Node-style callback called with the error, if any, and MsgTransferResponse + */ + public transfer( + request: ibc.applications.transfer.v1.IMsgTransfer, + callback: ibc.applications.transfer.v1.Msg.TransferCallback, + ): void; - /** - * Decodes a Part message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Part - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Part; - } + /** + * Calls Transfer. + * @param request MsgTransfer message or plain object + * @returns Promise + */ + public transfer( + request: ibc.applications.transfer.v1.IMsgTransfer, + ): Promise; + } - /** Properties of a BlockID. */ - interface IBlockID { - /** BlockID hash */ - hash?: Uint8Array | null; + namespace Msg { + /** + * Callback as used by {@link ibc.applications.transfer.v1.Msg#transfer}. + * @param error Error, if any + * @param [response] MsgTransferResponse + */ + type TransferCallback = ( + error: Error | null, + response?: ibc.applications.transfer.v1.MsgTransferResponse, + ) => void; + } - /** BlockID partSetHeader */ - partSetHeader?: tendermint.types.IPartSetHeader | null; - } + /** Properties of a MsgTransfer. */ + interface IMsgTransfer { + /** MsgTransfer sourcePort */ + sourcePort?: string | null; - /** Represents a BlockID. */ - class BlockID implements IBlockID { - /** - * Constructs a new BlockID. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IBlockID); + /** MsgTransfer sourceChannel */ + sourceChannel?: string | null; - /** BlockID hash. */ - public hash: Uint8Array; + /** MsgTransfer token */ + token?: cosmos.base.v1beta1.ICoin | null; - /** BlockID partSetHeader. */ - public partSetHeader?: tendermint.types.IPartSetHeader | null; + /** MsgTransfer sender */ + sender?: string | null; - /** - * Creates a new BlockID instance using the specified properties. - * @param [properties] Properties to set - * @returns BlockID instance - */ - public static create(properties?: tendermint.types.IBlockID): tendermint.types.BlockID; + /** MsgTransfer receiver */ + receiver?: string | null; - /** - * Encodes the specified BlockID message. Does not implicitly {@link tendermint.types.BlockID.verify|verify} messages. - * @param m BlockID message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IBlockID, w?: $protobuf.Writer): $protobuf.Writer; + /** MsgTransfer timeoutHeight */ + timeoutHeight?: ibc.core.client.v1.IHeight | null; - /** - * Decodes a BlockID message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns BlockID - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.BlockID; - } + /** MsgTransfer timeoutTimestamp */ + timeoutTimestamp?: Long | null; + } - /** Properties of a Header. */ - interface IHeader { - /** Header version */ - version?: tendermint.version.IConsensus | null; + /** Represents a MsgTransfer. */ + class MsgTransfer implements IMsgTransfer { + /** + * Constructs a new MsgTransfer. + * @param [p] Properties to set + */ + constructor(p?: ibc.applications.transfer.v1.IMsgTransfer); - /** Header chainId */ - chainId?: string | null; + /** MsgTransfer sourcePort. */ + public sourcePort: string; - /** Header height */ - height?: Long | null; + /** MsgTransfer sourceChannel. */ + public sourceChannel: string; - /** Header time */ - time?: google.protobuf.ITimestamp | null; + /** MsgTransfer token. */ + public token?: cosmos.base.v1beta1.ICoin | null; - /** Header lastBlockId */ - lastBlockId?: tendermint.types.IBlockID | null; + /** MsgTransfer sender. */ + public sender: string; - /** Header lastCommitHash */ - lastCommitHash?: Uint8Array | null; + /** MsgTransfer receiver. */ + public receiver: string; - /** Header dataHash */ - dataHash?: Uint8Array | null; + /** MsgTransfer timeoutHeight. */ + public timeoutHeight?: ibc.core.client.v1.IHeight | null; - /** Header validatorsHash */ - validatorsHash?: Uint8Array | null; + /** MsgTransfer timeoutTimestamp. */ + public timeoutTimestamp: Long; - /** Header nextValidatorsHash */ - nextValidatorsHash?: Uint8Array | null; + /** + * Creates a new MsgTransfer instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTransfer instance + */ + public static create( + properties?: ibc.applications.transfer.v1.IMsgTransfer, + ): ibc.applications.transfer.v1.MsgTransfer; - /** Header consensusHash */ - consensusHash?: Uint8Array | null; + /** + * Encodes the specified MsgTransfer message. Does not implicitly {@link ibc.applications.transfer.v1.MsgTransfer.verify|verify} messages. + * @param m MsgTransfer message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.applications.transfer.v1.IMsgTransfer, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Header appHash */ - appHash?: Uint8Array | null; + /** + * Decodes a MsgTransfer message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTransfer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.applications.transfer.v1.MsgTransfer; + } - /** Header lastResultsHash */ - lastResultsHash?: Uint8Array | null; + /** Properties of a MsgTransferResponse. */ + interface IMsgTransferResponse {} - /** Header evidenceHash */ - evidenceHash?: Uint8Array | null; + /** Represents a MsgTransferResponse. */ + class MsgTransferResponse implements IMsgTransferResponse { + /** + * Constructs a new MsgTransferResponse. + * @param [p] Properties to set + */ + constructor(p?: ibc.applications.transfer.v1.IMsgTransferResponse); - /** Header proposerAddress */ - proposerAddress?: Uint8Array | null; - } + /** + * Creates a new MsgTransferResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgTransferResponse instance + */ + public static create( + properties?: ibc.applications.transfer.v1.IMsgTransferResponse, + ): ibc.applications.transfer.v1.MsgTransferResponse; - /** Represents a Header. */ - class Header implements IHeader { - /** - * Constructs a new Header. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IHeader); + /** + * Encodes the specified MsgTransferResponse message. Does not implicitly {@link ibc.applications.transfer.v1.MsgTransferResponse.verify|verify} messages. + * @param m MsgTransferResponse message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.applications.transfer.v1.IMsgTransferResponse, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Header version. */ - public version?: tendermint.version.IConsensus | null; + /** + * Decodes a MsgTransferResponse message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns MsgTransferResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.applications.transfer.v1.MsgTransferResponse; + } + } + } + } - /** Header chainId. */ - public chainId: string; + /** Namespace lightclients. */ + namespace lightclients { + /** Namespace tendermint. */ + namespace tendermint { + /** Namespace v1. */ + namespace v1 { + /** Properties of a ClientState. */ + interface IClientState { + /** ClientState chainId */ + chainId?: string | null; - /** Header height. */ - public height: Long; + /** ClientState trustLevel */ + trustLevel?: ibc.lightclients.tendermint.v1.IFraction | null; - /** Header time. */ - public time?: google.protobuf.ITimestamp | null; + /** ClientState trustingPeriod */ + trustingPeriod?: google.protobuf.IDuration | null; - /** Header lastBlockId. */ - public lastBlockId?: tendermint.types.IBlockID | null; + /** ClientState unbondingPeriod */ + unbondingPeriod?: google.protobuf.IDuration | null; - /** Header lastCommitHash. */ - public lastCommitHash: Uint8Array; + /** ClientState maxClockDrift */ + maxClockDrift?: google.protobuf.IDuration | null; - /** Header dataHash. */ - public dataHash: Uint8Array; + /** ClientState frozenHeight */ + frozenHeight?: ibc.core.client.v1.IHeight | null; - /** Header validatorsHash. */ - public validatorsHash: Uint8Array; + /** ClientState latestHeight */ + latestHeight?: ibc.core.client.v1.IHeight | null; - /** Header nextValidatorsHash. */ - public nextValidatorsHash: Uint8Array; + /** ClientState proofSpecs */ + proofSpecs?: ics23.IProofSpec[] | null; - /** Header consensusHash. */ - public consensusHash: Uint8Array; + /** ClientState upgradePath */ + upgradePath?: string[] | null; - /** Header appHash. */ - public appHash: Uint8Array; + /** ClientState allowUpdateAfterExpiry */ + allowUpdateAfterExpiry?: boolean | null; - /** Header lastResultsHash. */ - public lastResultsHash: Uint8Array; + /** ClientState allowUpdateAfterMisbehaviour */ + allowUpdateAfterMisbehaviour?: boolean | null; + } - /** Header evidenceHash. */ - public evidenceHash: Uint8Array; + /** Represents a ClientState. */ + class ClientState implements IClientState { + /** + * Constructs a new ClientState. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.tendermint.v1.IClientState); - /** Header proposerAddress. */ - public proposerAddress: Uint8Array; + /** ClientState chainId. */ + public chainId: string; - /** - * Creates a new Header instance using the specified properties. - * @param [properties] Properties to set - * @returns Header instance - */ - public static create(properties?: tendermint.types.IHeader): tendermint.types.Header; + /** ClientState trustLevel. */ + public trustLevel?: ibc.lightclients.tendermint.v1.IFraction | null; - /** - * Encodes the specified Header message. Does not implicitly {@link tendermint.types.Header.verify|verify} messages. - * @param m Header message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IHeader, w?: $protobuf.Writer): $protobuf.Writer; + /** ClientState trustingPeriod. */ + public trustingPeriod?: google.protobuf.IDuration | null; - /** - * Decodes a Header message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Header; - } + /** ClientState unbondingPeriod. */ + public unbondingPeriod?: google.protobuf.IDuration | null; - /** Properties of a Data. */ - interface IData { - /** Data txs */ - txs?: Uint8Array[] | null; - } + /** ClientState maxClockDrift. */ + public maxClockDrift?: google.protobuf.IDuration | null; - /** Represents a Data. */ - class Data implements IData { - /** - * Constructs a new Data. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IData); + /** ClientState frozenHeight. */ + public frozenHeight?: ibc.core.client.v1.IHeight | null; - /** Data txs. */ - public txs: Uint8Array[]; + /** ClientState latestHeight. */ + public latestHeight?: ibc.core.client.v1.IHeight | null; - /** - * Creates a new Data instance using the specified properties. - * @param [properties] Properties to set - * @returns Data instance - */ - public static create(properties?: tendermint.types.IData): tendermint.types.Data; + /** ClientState proofSpecs. */ + public proofSpecs: ics23.IProofSpec[]; - /** - * Encodes the specified Data message. Does not implicitly {@link tendermint.types.Data.verify|verify} messages. - * @param m Data message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IData, w?: $protobuf.Writer): $protobuf.Writer; + /** ClientState upgradePath. */ + public upgradePath: string[]; - /** - * Decodes a Data message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Data - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Data; - } + /** ClientState allowUpdateAfterExpiry. */ + public allowUpdateAfterExpiry: boolean; - /** Properties of a Vote. */ - interface IVote { - /** Vote type */ - type?: tendermint.types.SignedMsgType | null; + /** ClientState allowUpdateAfterMisbehaviour. */ + public allowUpdateAfterMisbehaviour: boolean; - /** Vote height */ - height?: Long | null; + /** + * Creates a new ClientState instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientState instance + */ + public static create( + properties?: ibc.lightclients.tendermint.v1.IClientState, + ): ibc.lightclients.tendermint.v1.ClientState; - /** Vote round */ - round?: number | null; + /** + * Encodes the specified ClientState message. Does not implicitly {@link ibc.lightclients.tendermint.v1.ClientState.verify|verify} messages. + * @param m ClientState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.tendermint.v1.IClientState, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Vote blockId */ - blockId?: tendermint.types.IBlockID | null; + /** + * Decodes a ClientState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.tendermint.v1.ClientState; + } - /** Vote timestamp */ - timestamp?: google.protobuf.ITimestamp | null; + /** Properties of a ConsensusState. */ + interface IConsensusState { + /** ConsensusState timestamp */ + timestamp?: google.protobuf.ITimestamp | null; - /** Vote validatorAddress */ - validatorAddress?: Uint8Array | null; + /** ConsensusState root */ + root?: ibc.core.commitment.v1.IMerkleRoot | null; - /** Vote validatorIndex */ - validatorIndex?: number | null; + /** ConsensusState nextValidatorsHash */ + nextValidatorsHash?: Uint8Array | null; + } - /** Vote signature */ - signature?: Uint8Array | null; - } + /** Represents a ConsensusState. */ + class ConsensusState implements IConsensusState { + /** + * Constructs a new ConsensusState. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.tendermint.v1.IConsensusState); - /** Represents a Vote. */ - class Vote implements IVote { - /** - * Constructs a new Vote. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IVote); + /** ConsensusState timestamp. */ + public timestamp?: google.protobuf.ITimestamp | null; - /** Vote type. */ - public type: tendermint.types.SignedMsgType; + /** ConsensusState root. */ + public root?: ibc.core.commitment.v1.IMerkleRoot | null; - /** Vote height. */ - public height: Long; + /** ConsensusState nextValidatorsHash. */ + public nextValidatorsHash: Uint8Array; - /** Vote round. */ - public round: number; + /** + * Creates a new ConsensusState instance using the specified properties. + * @param [properties] Properties to set + * @returns ConsensusState instance + */ + public static create( + properties?: ibc.lightclients.tendermint.v1.IConsensusState, + ): ibc.lightclients.tendermint.v1.ConsensusState; - /** Vote blockId. */ - public blockId?: tendermint.types.IBlockID | null; + /** + * Encodes the specified ConsensusState message. Does not implicitly {@link ibc.lightclients.tendermint.v1.ConsensusState.verify|verify} messages. + * @param m ConsensusState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.tendermint.v1.IConsensusState, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Vote timestamp. */ - public timestamp?: google.protobuf.ITimestamp | null; + /** + * Decodes a ConsensusState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ConsensusState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.tendermint.v1.ConsensusState; + } - /** Vote validatorAddress. */ - public validatorAddress: Uint8Array; + /** Properties of a Misbehaviour. */ + interface IMisbehaviour { + /** Misbehaviour clientId */ + clientId?: string | null; - /** Vote validatorIndex. */ - public validatorIndex: number; + /** Misbehaviour header_1 */ + header_1?: ibc.lightclients.tendermint.v1.IHeader | null; - /** Vote signature. */ - public signature: Uint8Array; + /** Misbehaviour header_2 */ + header_2?: ibc.lightclients.tendermint.v1.IHeader | null; + } - /** - * Creates a new Vote instance using the specified properties. - * @param [properties] Properties to set - * @returns Vote instance - */ - public static create(properties?: tendermint.types.IVote): tendermint.types.Vote; + /** Represents a Misbehaviour. */ + class Misbehaviour implements IMisbehaviour { + /** + * Constructs a new Misbehaviour. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.tendermint.v1.IMisbehaviour); - /** - * Encodes the specified Vote message. Does not implicitly {@link tendermint.types.Vote.verify|verify} messages. - * @param m Vote message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IVote, w?: $protobuf.Writer): $protobuf.Writer; + /** Misbehaviour clientId. */ + public clientId: string; - /** - * Decodes a Vote message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Vote - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Vote; - } + /** Misbehaviour header_1. */ + public header_1?: ibc.lightclients.tendermint.v1.IHeader | null; - /** Properties of a Commit. */ - interface ICommit { - /** Commit height */ - height?: Long | null; + /** Misbehaviour header_2. */ + public header_2?: ibc.lightclients.tendermint.v1.IHeader | null; - /** Commit round */ - round?: number | null; + /** + * Creates a new Misbehaviour instance using the specified properties. + * @param [properties] Properties to set + * @returns Misbehaviour instance + */ + public static create( + properties?: ibc.lightclients.tendermint.v1.IMisbehaviour, + ): ibc.lightclients.tendermint.v1.Misbehaviour; - /** Commit blockId */ - blockId?: tendermint.types.IBlockID | null; + /** + * Encodes the specified Misbehaviour message. Does not implicitly {@link ibc.lightclients.tendermint.v1.Misbehaviour.verify|verify} messages. + * @param m Misbehaviour message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.tendermint.v1.IMisbehaviour, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Commit signatures */ - signatures?: tendermint.types.ICommitSig[] | null; - } + /** + * Decodes a Misbehaviour message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Misbehaviour + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.tendermint.v1.Misbehaviour; + } - /** Represents a Commit. */ - class Commit implements ICommit { - /** - * Constructs a new Commit. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ICommit); + /** Properties of a Header. */ + interface IHeader { + /** Header signedHeader */ + signedHeader?: tendermintV2.types.ISignedHeader | null; - /** Commit height. */ - public height: Long; + /** Header validatorSet */ + validatorSet?: tendermintV2.types.IValidatorSet | null; - /** Commit round. */ - public round: number; + /** Header trustedHeight */ + trustedHeight?: ibc.core.client.v1.IHeight | null; - /** Commit blockId. */ - public blockId?: tendermint.types.IBlockID | null; + /** Header trustedValidators */ + trustedValidators?: tendermintV2.types.IValidatorSet | null; + } - /** Commit signatures. */ - public signatures: tendermint.types.ICommitSig[]; + /** Represents a Header. */ + class Header implements IHeader { + /** + * Constructs a new Header. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.tendermint.v1.IHeader); - /** - * Creates a new Commit instance using the specified properties. - * @param [properties] Properties to set - * @returns Commit instance - */ - public static create(properties?: tendermint.types.ICommit): tendermint.types.Commit; + /** Header signedHeader. */ + public signedHeader?: tendermintV2.types.ISignedHeader | null; - /** - * Encodes the specified Commit message. Does not implicitly {@link tendermint.types.Commit.verify|verify} messages. - * @param m Commit message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ICommit, w?: $protobuf.Writer): $protobuf.Writer; + /** Header validatorSet. */ + public validatorSet?: tendermintV2.types.IValidatorSet | null; - /** - * Decodes a Commit message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Commit - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Commit; - } + /** Header trustedHeight. */ + public trustedHeight?: ibc.core.client.v1.IHeight | null; - /** Properties of a CommitSig. */ - interface ICommitSig { - /** CommitSig blockIdFlag */ - blockIdFlag?: tendermint.types.BlockIDFlag | null; + /** Header trustedValidators. */ + public trustedValidators?: tendermintV2.types.IValidatorSet | null; - /** CommitSig validatorAddress */ - validatorAddress?: Uint8Array | null; + /** + * Creates a new Header instance using the specified properties. + * @param [properties] Properties to set + * @returns Header instance + */ + public static create( + properties?: ibc.lightclients.tendermint.v1.IHeader, + ): ibc.lightclients.tendermint.v1.Header; - /** CommitSig timestamp */ - timestamp?: google.protobuf.ITimestamp | null; + /** + * Encodes the specified Header message. Does not implicitly {@link ibc.lightclients.tendermint.v1.Header.verify|verify} messages. + * @param m Header message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.tendermint.v1.IHeader, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** CommitSig signature */ - signature?: Uint8Array | null; - } + /** + * Decodes a Header message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Header + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.tendermint.v1.Header; + } - /** Represents a CommitSig. */ - class CommitSig implements ICommitSig { - /** - * Constructs a new CommitSig. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ICommitSig); + /** Properties of a Fraction. */ + interface IFraction { + /** Fraction numerator */ + numerator?: Long | null; - /** CommitSig blockIdFlag. */ - public blockIdFlag: tendermint.types.BlockIDFlag; + /** Fraction denominator */ + denominator?: Long | null; + } - /** CommitSig validatorAddress. */ - public validatorAddress: Uint8Array; + /** Represents a Fraction. */ + class Fraction implements IFraction { + /** + * Constructs a new Fraction. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.tendermint.v1.IFraction); - /** CommitSig timestamp. */ - public timestamp?: google.protobuf.ITimestamp | null; + /** Fraction numerator. */ + public numerator: Long; - /** CommitSig signature. */ - public signature: Uint8Array; + /** Fraction denominator. */ + public denominator: Long; - /** - * Creates a new CommitSig instance using the specified properties. - * @param [properties] Properties to set - * @returns CommitSig instance - */ - public static create(properties?: tendermint.types.ICommitSig): tendermint.types.CommitSig; + /** + * Creates a new Fraction instance using the specified properties. + * @param [properties] Properties to set + * @returns Fraction instance + */ + public static create( + properties?: ibc.lightclients.tendermint.v1.IFraction, + ): ibc.lightclients.tendermint.v1.Fraction; - /** - * Encodes the specified CommitSig message. Does not implicitly {@link tendermint.types.CommitSig.verify|verify} messages. - * @param m CommitSig message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ICommitSig, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Encodes the specified Fraction message. Does not implicitly {@link ibc.lightclients.tendermint.v1.Fraction.verify|verify} messages. + * @param m Fraction message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.tendermint.v1.IFraction, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** - * Decodes a CommitSig message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns CommitSig - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.CommitSig; + /** + * Decodes a Fraction message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Fraction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.tendermint.v1.Fraction; + } + } } - /** Properties of a Proposal. */ - interface IProposal { - /** Proposal type */ - type?: tendermint.types.SignedMsgType | null; + /** Namespace localhost. */ + namespace localhost { + /** Namespace v1. */ + namespace v1 { + /** Properties of a ClientState. */ + interface IClientState { + /** ClientState chainId */ + chainId?: string | null; - /** Proposal height */ - height?: Long | null; + /** ClientState height */ + height?: ibc.core.client.v1.IHeight | null; + } - /** Proposal round */ - round?: number | null; + /** Represents a ClientState. */ + class ClientState implements IClientState { + /** + * Constructs a new ClientState. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.localhost.v1.IClientState); - /** Proposal polRound */ - polRound?: number | null; + /** ClientState chainId. */ + public chainId: string; - /** Proposal blockId */ - blockId?: tendermint.types.IBlockID | null; + /** ClientState height. */ + public height?: ibc.core.client.v1.IHeight | null; - /** Proposal timestamp */ - timestamp?: google.protobuf.ITimestamp | null; + /** + * Creates a new ClientState instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientState instance + */ + public static create( + properties?: ibc.lightclients.localhost.v1.IClientState, + ): ibc.lightclients.localhost.v1.ClientState; - /** Proposal signature */ - signature?: Uint8Array | null; + /** + * Encodes the specified ClientState message. Does not implicitly {@link ibc.lightclients.localhost.v1.ClientState.verify|verify} messages. + * @param m ClientState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.localhost.v1.IClientState, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a ClientState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.localhost.v1.ClientState; + } + } } - /** Represents a Proposal. */ - class Proposal implements IProposal { - /** - * Constructs a new Proposal. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IProposal); + /** Namespace solomachine. */ + namespace solomachine { + /** Namespace v1. */ + namespace v1 { + /** Properties of a ClientState. */ + interface IClientState { + /** ClientState sequence */ + sequence?: Long | null; - /** Proposal type. */ - public type: tendermint.types.SignedMsgType; + /** ClientState frozenSequence */ + frozenSequence?: Long | null; - /** Proposal height. */ - public height: Long; + /** ClientState consensusState */ + consensusState?: ibc.lightclients.solomachine.v1.IConsensusState | null; - /** Proposal round. */ - public round: number; + /** ClientState allowUpdateAfterProposal */ + allowUpdateAfterProposal?: boolean | null; + } - /** Proposal polRound. */ - public polRound: number; + /** Represents a ClientState. */ + class ClientState implements IClientState { + /** + * Constructs a new ClientState. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IClientState); - /** Proposal blockId. */ - public blockId?: tendermint.types.IBlockID | null; + /** ClientState sequence. */ + public sequence: Long; - /** Proposal timestamp. */ - public timestamp?: google.protobuf.ITimestamp | null; + /** ClientState frozenSequence. */ + public frozenSequence: Long; - /** Proposal signature. */ - public signature: Uint8Array; + /** ClientState consensusState. */ + public consensusState?: ibc.lightclients.solomachine.v1.IConsensusState | null; - /** - * Creates a new Proposal instance using the specified properties. - * @param [properties] Properties to set - * @returns Proposal instance - */ - public static create(properties?: tendermint.types.IProposal): tendermint.types.Proposal; + /** ClientState allowUpdateAfterProposal. */ + public allowUpdateAfterProposal: boolean; - /** - * Encodes the specified Proposal message. Does not implicitly {@link tendermint.types.Proposal.verify|verify} messages. - * @param m Proposal message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IProposal, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Creates a new ClientState instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientState instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IClientState, + ): ibc.lightclients.solomachine.v1.ClientState; - /** - * Decodes a Proposal message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Proposal - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Proposal; - } + /** + * Encodes the specified ClientState message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ClientState.verify|verify} messages. + * @param m ClientState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IClientState, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Properties of a SignedHeader. */ - interface ISignedHeader { - /** SignedHeader header */ - header?: tendermint.types.IHeader | null; + /** + * Decodes a ClientState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ClientState; + } - /** SignedHeader commit */ - commit?: tendermint.types.ICommit | null; - } + /** Properties of a ConsensusState. */ + interface IConsensusState { + /** ConsensusState publicKey */ + publicKey?: google.protobuf.IAny | null; - /** Represents a SignedHeader. */ - class SignedHeader implements ISignedHeader { - /** - * Constructs a new SignedHeader. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ISignedHeader); + /** ConsensusState diversifier */ + diversifier?: string | null; - /** SignedHeader header. */ - public header?: tendermint.types.IHeader | null; + /** ConsensusState timestamp */ + timestamp?: Long | null; + } - /** SignedHeader commit. */ - public commit?: tendermint.types.ICommit | null; + /** Represents a ConsensusState. */ + class ConsensusState implements IConsensusState { + /** + * Constructs a new ConsensusState. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IConsensusState); - /** - * Creates a new SignedHeader instance using the specified properties. - * @param [properties] Properties to set - * @returns SignedHeader instance - */ - public static create(properties?: tendermint.types.ISignedHeader): tendermint.types.SignedHeader; + /** ConsensusState publicKey. */ + public publicKey?: google.protobuf.IAny | null; - /** - * Encodes the specified SignedHeader message. Does not implicitly {@link tendermint.types.SignedHeader.verify|verify} messages. - * @param m SignedHeader message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ISignedHeader, w?: $protobuf.Writer): $protobuf.Writer; + /** ConsensusState diversifier. */ + public diversifier: string; - /** - * Decodes a SignedHeader message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns SignedHeader - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.SignedHeader; - } + /** ConsensusState timestamp. */ + public timestamp: Long; - /** Properties of a LightBlock. */ - interface ILightBlock { - /** LightBlock signedHeader */ - signedHeader?: tendermint.types.ISignedHeader | null; + /** + * Creates a new ConsensusState instance using the specified properties. + * @param [properties] Properties to set + * @returns ConsensusState instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IConsensusState, + ): ibc.lightclients.solomachine.v1.ConsensusState; - /** LightBlock validatorSet */ - validatorSet?: tendermint.types.IValidatorSet | null; - } + /** + * Encodes the specified ConsensusState message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ConsensusState.verify|verify} messages. + * @param m ConsensusState message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IConsensusState, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Represents a LightBlock. */ - class LightBlock implements ILightBlock { - /** - * Constructs a new LightBlock. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ILightBlock); + /** + * Decodes a ConsensusState message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ConsensusState + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ConsensusState; + } - /** LightBlock signedHeader. */ - public signedHeader?: tendermint.types.ISignedHeader | null; + /** Properties of a Header. */ + interface IHeader { + /** Header sequence */ + sequence?: Long | null; - /** LightBlock validatorSet. */ - public validatorSet?: tendermint.types.IValidatorSet | null; + /** Header timestamp */ + timestamp?: Long | null; - /** - * Creates a new LightBlock instance using the specified properties. - * @param [properties] Properties to set - * @returns LightBlock instance - */ - public static create(properties?: tendermint.types.ILightBlock): tendermint.types.LightBlock; + /** Header signature */ + signature?: Uint8Array | null; - /** - * Encodes the specified LightBlock message. Does not implicitly {@link tendermint.types.LightBlock.verify|verify} messages. - * @param m LightBlock message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ILightBlock, w?: $protobuf.Writer): $protobuf.Writer; + /** Header newPublicKey */ + newPublicKey?: google.protobuf.IAny | null; - /** - * Decodes a LightBlock message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns LightBlock - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.LightBlock; - } + /** Header newDiversifier */ + newDiversifier?: string | null; + } - /** Properties of a BlockMeta. */ - interface IBlockMeta { - /** BlockMeta blockId */ - blockId?: tendermint.types.IBlockID | null; + /** Represents a Header. */ + class Header implements IHeader { + /** + * Constructs a new Header. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IHeader); - /** BlockMeta blockSize */ - blockSize?: Long | null; + /** Header sequence. */ + public sequence: Long; - /** BlockMeta header */ - header?: tendermint.types.IHeader | null; + /** Header timestamp. */ + public timestamp: Long; - /** BlockMeta numTxs */ - numTxs?: Long | null; - } + /** Header signature. */ + public signature: Uint8Array; - /** Represents a BlockMeta. */ - class BlockMeta implements IBlockMeta { - /** - * Constructs a new BlockMeta. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IBlockMeta); + /** Header newPublicKey. */ + public newPublicKey?: google.protobuf.IAny | null; - /** BlockMeta blockId. */ - public blockId?: tendermint.types.IBlockID | null; + /** Header newDiversifier. */ + public newDiversifier: string; - /** BlockMeta blockSize. */ - public blockSize: Long; + /** + * Creates a new Header instance using the specified properties. + * @param [properties] Properties to set + * @returns Header instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IHeader, + ): ibc.lightclients.solomachine.v1.Header; - /** BlockMeta header. */ - public header?: tendermint.types.IHeader | null; + /** + * Encodes the specified Header message. Does not implicitly {@link ibc.lightclients.solomachine.v1.Header.verify|verify} messages. + * @param m Header message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IHeader, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** BlockMeta numTxs. */ - public numTxs: Long; + /** + * Decodes a Header message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Header + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.Header; + } - /** - * Creates a new BlockMeta instance using the specified properties. - * @param [properties] Properties to set - * @returns BlockMeta instance - */ - public static create(properties?: tendermint.types.IBlockMeta): tendermint.types.BlockMeta; + /** Properties of a Misbehaviour. */ + interface IMisbehaviour { + /** Misbehaviour clientId */ + clientId?: string | null; - /** - * Encodes the specified BlockMeta message. Does not implicitly {@link tendermint.types.BlockMeta.verify|verify} messages. - * @param m BlockMeta message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IBlockMeta, w?: $protobuf.Writer): $protobuf.Writer; + /** Misbehaviour sequence */ + sequence?: Long | null; - /** - * Decodes a BlockMeta message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns BlockMeta - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.BlockMeta; - } + /** Misbehaviour signatureOne */ + signatureOne?: ibc.lightclients.solomachine.v1.ISignatureAndData | null; - /** Properties of a TxProof. */ - interface ITxProof { - /** TxProof rootHash */ - rootHash?: Uint8Array | null; + /** Misbehaviour signatureTwo */ + signatureTwo?: ibc.lightclients.solomachine.v1.ISignatureAndData | null; + } - /** TxProof data */ - data?: Uint8Array | null; + /** Represents a Misbehaviour. */ + class Misbehaviour implements IMisbehaviour { + /** + * Constructs a new Misbehaviour. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IMisbehaviour); - /** TxProof proof */ - proof?: tendermint.crypto.IProof | null; - } + /** Misbehaviour clientId. */ + public clientId: string; - /** Represents a TxProof. */ - class TxProof implements ITxProof { - /** - * Constructs a new TxProof. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ITxProof); + /** Misbehaviour sequence. */ + public sequence: Long; - /** TxProof rootHash. */ - public rootHash: Uint8Array; + /** Misbehaviour signatureOne. */ + public signatureOne?: ibc.lightclients.solomachine.v1.ISignatureAndData | null; - /** TxProof data. */ - public data: Uint8Array; + /** Misbehaviour signatureTwo. */ + public signatureTwo?: ibc.lightclients.solomachine.v1.ISignatureAndData | null; + + /** + * Creates a new Misbehaviour instance using the specified properties. + * @param [properties] Properties to set + * @returns Misbehaviour instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IMisbehaviour, + ): ibc.lightclients.solomachine.v1.Misbehaviour; + + /** + * Encodes the specified Misbehaviour message. Does not implicitly {@link ibc.lightclients.solomachine.v1.Misbehaviour.verify|verify} messages. + * @param m Misbehaviour message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IMisbehaviour, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** TxProof proof. */ - public proof?: tendermint.crypto.IProof | null; + /** + * Decodes a Misbehaviour message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns Misbehaviour + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.Misbehaviour; + } - /** - * Creates a new TxProof instance using the specified properties. - * @param [properties] Properties to set - * @returns TxProof instance - */ - public static create(properties?: tendermint.types.ITxProof): tendermint.types.TxProof; + /** Properties of a SignatureAndData. */ + interface ISignatureAndData { + /** SignatureAndData signature */ + signature?: Uint8Array | null; - /** - * Encodes the specified TxProof message. Does not implicitly {@link tendermint.types.TxProof.verify|verify} messages. - * @param m TxProof message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ITxProof, w?: $protobuf.Writer): $protobuf.Writer; + /** SignatureAndData dataType */ + dataType?: ibc.lightclients.solomachine.v1.DataType | null; - /** - * Decodes a TxProof message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns TxProof - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.TxProof; - } + /** SignatureAndData data */ + data?: Uint8Array | null; - /** Properties of a ValidatorSet. */ - interface IValidatorSet { - /** ValidatorSet validators */ - validators?: tendermint.types.IValidator[] | null; + /** SignatureAndData timestamp */ + timestamp?: Long | null; + } - /** ValidatorSet proposer */ - proposer?: tendermint.types.IValidator | null; + /** Represents a SignatureAndData. */ + class SignatureAndData implements ISignatureAndData { + /** + * Constructs a new SignatureAndData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.ISignatureAndData); - /** ValidatorSet totalVotingPower */ - totalVotingPower?: Long | null; - } + /** SignatureAndData signature. */ + public signature: Uint8Array; - /** Represents a ValidatorSet. */ - class ValidatorSet implements IValidatorSet { - /** - * Constructs a new ValidatorSet. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IValidatorSet); + /** SignatureAndData dataType. */ + public dataType: ibc.lightclients.solomachine.v1.DataType; - /** ValidatorSet validators. */ - public validators: tendermint.types.IValidator[]; + /** SignatureAndData data. */ + public data: Uint8Array; - /** ValidatorSet proposer. */ - public proposer?: tendermint.types.IValidator | null; + /** SignatureAndData timestamp. */ + public timestamp: Long; - /** ValidatorSet totalVotingPower. */ - public totalVotingPower: Long; + /** + * Creates a new SignatureAndData instance using the specified properties. + * @param [properties] Properties to set + * @returns SignatureAndData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.ISignatureAndData, + ): ibc.lightclients.solomachine.v1.SignatureAndData; - /** - * Creates a new ValidatorSet instance using the specified properties. - * @param [properties] Properties to set - * @returns ValidatorSet instance - */ - public static create(properties?: tendermint.types.IValidatorSet): tendermint.types.ValidatorSet; + /** + * Encodes the specified SignatureAndData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.SignatureAndData.verify|verify} messages. + * @param m SignatureAndData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.ISignatureAndData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** - * Encodes the specified ValidatorSet message. Does not implicitly {@link tendermint.types.ValidatorSet.verify|verify} messages. - * @param m ValidatorSet message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IValidatorSet, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Decodes a SignatureAndData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns SignatureAndData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.SignatureAndData; + } - /** - * Decodes a ValidatorSet message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ValidatorSet - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.ValidatorSet; - } + /** Properties of a TimestampedSignatureData. */ + interface ITimestampedSignatureData { + /** TimestampedSignatureData signatureData */ + signatureData?: Uint8Array | null; - /** Properties of a Validator. */ - interface IValidator { - /** Validator address */ - address?: Uint8Array | null; + /** TimestampedSignatureData timestamp */ + timestamp?: Long | null; + } - /** Validator pubKey */ - pubKey?: tendermint.crypto.IPublicKey | null; + /** Represents a TimestampedSignatureData. */ + class TimestampedSignatureData implements ITimestampedSignatureData { + /** + * Constructs a new TimestampedSignatureData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.ITimestampedSignatureData); - /** Validator votingPower */ - votingPower?: Long | null; + /** TimestampedSignatureData signatureData. */ + public signatureData: Uint8Array; - /** Validator proposerPriority */ - proposerPriority?: Long | null; - } + /** TimestampedSignatureData timestamp. */ + public timestamp: Long; - /** Represents a Validator. */ - class Validator implements IValidator { - /** - * Constructs a new Validator. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.IValidator); + /** + * Creates a new TimestampedSignatureData instance using the specified properties. + * @param [properties] Properties to set + * @returns TimestampedSignatureData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.ITimestampedSignatureData, + ): ibc.lightclients.solomachine.v1.TimestampedSignatureData; - /** Validator address. */ - public address: Uint8Array; + /** + * Encodes the specified TimestampedSignatureData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.TimestampedSignatureData.verify|verify} messages. + * @param m TimestampedSignatureData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.ITimestampedSignatureData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Validator pubKey. */ - public pubKey?: tendermint.crypto.IPublicKey | null; + /** + * Decodes a TimestampedSignatureData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns TimestampedSignatureData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.TimestampedSignatureData; + } - /** Validator votingPower. */ - public votingPower: Long; + /** Properties of a SignBytes. */ + interface ISignBytes { + /** SignBytes sequence */ + sequence?: Long | null; - /** Validator proposerPriority. */ - public proposerPriority: Long; + /** SignBytes timestamp */ + timestamp?: Long | null; - /** - * Creates a new Validator instance using the specified properties. - * @param [properties] Properties to set - * @returns Validator instance - */ - public static create(properties?: tendermint.types.IValidator): tendermint.types.Validator; + /** SignBytes diversifier */ + diversifier?: string | null; - /** - * Encodes the specified Validator message. Does not implicitly {@link tendermint.types.Validator.verify|verify} messages. - * @param m Validator message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.IValidator, w?: $protobuf.Writer): $protobuf.Writer; + /** SignBytes dataType */ + dataType?: ibc.lightclients.solomachine.v1.DataType | null; - /** - * Decodes a Validator message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Validator - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.Validator; - } + /** SignBytes data */ + data?: Uint8Array | null; + } - /** Properties of a SimpleValidator. */ - interface ISimpleValidator { - /** SimpleValidator pubKey */ - pubKey?: tendermint.crypto.IPublicKey | null; + /** Represents a SignBytes. */ + class SignBytes implements ISignBytes { + /** + * Constructs a new SignBytes. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.ISignBytes); - /** SimpleValidator votingPower */ - votingPower?: Long | null; - } + /** SignBytes sequence. */ + public sequence: Long; - /** Represents a SimpleValidator. */ - class SimpleValidator implements ISimpleValidator { - /** - * Constructs a new SimpleValidator. - * @param [p] Properties to set - */ - constructor(p?: tendermint.types.ISimpleValidator); + /** SignBytes timestamp. */ + public timestamp: Long; - /** SimpleValidator pubKey. */ - public pubKey?: tendermint.crypto.IPublicKey | null; + /** SignBytes diversifier. */ + public diversifier: string; - /** SimpleValidator votingPower. */ - public votingPower: Long; + /** SignBytes dataType. */ + public dataType: ibc.lightclients.solomachine.v1.DataType; - /** - * Creates a new SimpleValidator instance using the specified properties. - * @param [properties] Properties to set - * @returns SimpleValidator instance - */ - public static create(properties?: tendermint.types.ISimpleValidator): tendermint.types.SimpleValidator; + /** SignBytes data. */ + public data: Uint8Array; - /** - * Encodes the specified SimpleValidator message. Does not implicitly {@link tendermint.types.SimpleValidator.verify|verify} messages. - * @param m SimpleValidator message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.types.ISimpleValidator, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Creates a new SignBytes instance using the specified properties. + * @param [properties] Properties to set + * @returns SignBytes instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.ISignBytes, + ): ibc.lightclients.solomachine.v1.SignBytes; - /** - * Decodes a SimpleValidator message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns SimpleValidator - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.types.SimpleValidator; - } - } + /** + * Encodes the specified SignBytes message. Does not implicitly {@link ibc.lightclients.solomachine.v1.SignBytes.verify|verify} messages. + * @param m SignBytes message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.ISignBytes, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Namespace crypto. */ - namespace crypto { - /** Properties of a Proof. */ - interface IProof { - /** Proof total */ - total?: Long | null; + /** + * Decodes a SignBytes message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns SignBytes + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.SignBytes; + } - /** Proof index */ - index?: Long | null; + /** DataType enum. */ + enum DataType { + DATA_TYPE_UNINITIALIZED_UNSPECIFIED = 0, + DATA_TYPE_CLIENT_STATE = 1, + DATA_TYPE_CONSENSUS_STATE = 2, + DATA_TYPE_CONNECTION_STATE = 3, + DATA_TYPE_CHANNEL_STATE = 4, + DATA_TYPE_PACKET_COMMITMENT = 5, + DATA_TYPE_PACKET_ACKNOWLEDGEMENT = 6, + DATA_TYPE_PACKET_RECEIPT_ABSENCE = 7, + DATA_TYPE_NEXT_SEQUENCE_RECV = 8, + DATA_TYPE_HEADER = 9, + } - /** Proof leafHash */ - leafHash?: Uint8Array | null; + /** Properties of a HeaderData. */ + interface IHeaderData { + /** HeaderData newPubKey */ + newPubKey?: google.protobuf.IAny | null; - /** Proof aunts */ - aunts?: Uint8Array[] | null; - } + /** HeaderData newDiversifier */ + newDiversifier?: string | null; + } - /** Represents a Proof. */ - class Proof implements IProof { - /** - * Constructs a new Proof. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IProof); + /** Represents a HeaderData. */ + class HeaderData implements IHeaderData { + /** + * Constructs a new HeaderData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IHeaderData); - /** Proof total. */ - public total: Long; + /** HeaderData newPubKey. */ + public newPubKey?: google.protobuf.IAny | null; - /** Proof index. */ - public index: Long; + /** HeaderData newDiversifier. */ + public newDiversifier: string; - /** Proof leafHash. */ - public leafHash: Uint8Array; + /** + * Creates a new HeaderData instance using the specified properties. + * @param [properties] Properties to set + * @returns HeaderData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IHeaderData, + ): ibc.lightclients.solomachine.v1.HeaderData; - /** Proof aunts. */ - public aunts: Uint8Array[]; + /** + * Encodes the specified HeaderData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.HeaderData.verify|verify} messages. + * @param m HeaderData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IHeaderData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** - * Creates a new Proof instance using the specified properties. - * @param [properties] Properties to set - * @returns Proof instance - */ - public static create(properties?: tendermint.crypto.IProof): tendermint.crypto.Proof; + /** + * Decodes a HeaderData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns HeaderData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.HeaderData; + } - /** - * Encodes the specified Proof message. Does not implicitly {@link tendermint.crypto.Proof.verify|verify} messages. - * @param m Proof message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IProof, w?: $protobuf.Writer): $protobuf.Writer; + /** Properties of a ClientStateData. */ + interface IClientStateData { + /** ClientStateData path */ + path?: Uint8Array | null; - /** - * Decodes a Proof message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Proof - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.Proof; - } + /** ClientStateData clientState */ + clientState?: google.protobuf.IAny | null; + } - /** Properties of a ValueOp. */ - interface IValueOp { - /** ValueOp key */ - key?: Uint8Array | null; + /** Represents a ClientStateData. */ + class ClientStateData implements IClientStateData { + /** + * Constructs a new ClientStateData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IClientStateData); - /** ValueOp proof */ - proof?: tendermint.crypto.IProof | null; - } + /** ClientStateData path. */ + public path: Uint8Array; - /** Represents a ValueOp. */ - class ValueOp implements IValueOp { - /** - * Constructs a new ValueOp. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IValueOp); + /** ClientStateData clientState. */ + public clientState?: google.protobuf.IAny | null; - /** ValueOp key. */ - public key: Uint8Array; + /** + * Creates a new ClientStateData instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientStateData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IClientStateData, + ): ibc.lightclients.solomachine.v1.ClientStateData; - /** ValueOp proof. */ - public proof?: tendermint.crypto.IProof | null; + /** + * Encodes the specified ClientStateData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ClientStateData.verify|verify} messages. + * @param m ClientStateData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IClientStateData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** - * Creates a new ValueOp instance using the specified properties. - * @param [properties] Properties to set - * @returns ValueOp instance - */ - public static create(properties?: tendermint.crypto.IValueOp): tendermint.crypto.ValueOp; + /** + * Decodes a ClientStateData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ClientStateData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ClientStateData; + } - /** - * Encodes the specified ValueOp message. Does not implicitly {@link tendermint.crypto.ValueOp.verify|verify} messages. - * @param m ValueOp message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IValueOp, w?: $protobuf.Writer): $protobuf.Writer; + /** Properties of a ConsensusStateData. */ + interface IConsensusStateData { + /** ConsensusStateData path */ + path?: Uint8Array | null; - /** - * Decodes a ValueOp message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ValueOp - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.ValueOp; - } + /** ConsensusStateData consensusState */ + consensusState?: google.protobuf.IAny | null; + } - /** Properties of a DominoOp. */ - interface IDominoOp { - /** DominoOp key */ - key?: string | null; + /** Represents a ConsensusStateData. */ + class ConsensusStateData implements IConsensusStateData { + /** + * Constructs a new ConsensusStateData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IConsensusStateData); - /** DominoOp input */ - input?: string | null; + /** ConsensusStateData path. */ + public path: Uint8Array; - /** DominoOp output */ - output?: string | null; - } + /** ConsensusStateData consensusState. */ + public consensusState?: google.protobuf.IAny | null; - /** Represents a DominoOp. */ - class DominoOp implements IDominoOp { - /** - * Constructs a new DominoOp. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IDominoOp); + /** + * Creates a new ConsensusStateData instance using the specified properties. + * @param [properties] Properties to set + * @returns ConsensusStateData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IConsensusStateData, + ): ibc.lightclients.solomachine.v1.ConsensusStateData; - /** DominoOp key. */ - public key: string; + /** + * Encodes the specified ConsensusStateData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ConsensusStateData.verify|verify} messages. + * @param m ConsensusStateData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IConsensusStateData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** DominoOp input. */ - public input: string; + /** + * Decodes a ConsensusStateData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ConsensusStateData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ConsensusStateData; + } - /** DominoOp output. */ - public output: string; + /** Properties of a ConnectionStateData. */ + interface IConnectionStateData { + /** ConnectionStateData path */ + path?: Uint8Array | null; - /** - * Creates a new DominoOp instance using the specified properties. - * @param [properties] Properties to set - * @returns DominoOp instance - */ - public static create(properties?: tendermint.crypto.IDominoOp): tendermint.crypto.DominoOp; + /** ConnectionStateData connection */ + connection?: ibc.core.connection.v1.IConnectionEnd | null; + } - /** - * Encodes the specified DominoOp message. Does not implicitly {@link tendermint.crypto.DominoOp.verify|verify} messages. - * @param m DominoOp message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IDominoOp, w?: $protobuf.Writer): $protobuf.Writer; + /** Represents a ConnectionStateData. */ + class ConnectionStateData implements IConnectionStateData { + /** + * Constructs a new ConnectionStateData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IConnectionStateData); - /** - * Decodes a DominoOp message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns DominoOp - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.DominoOp; - } + /** ConnectionStateData path. */ + public path: Uint8Array; - /** Properties of a ProofOp. */ - interface IProofOp { - /** ProofOp type */ - type?: string | null; + /** ConnectionStateData connection. */ + public connection?: ibc.core.connection.v1.IConnectionEnd | null; - /** ProofOp key */ - key?: Uint8Array | null; + /** + * Creates a new ConnectionStateData instance using the specified properties. + * @param [properties] Properties to set + * @returns ConnectionStateData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IConnectionStateData, + ): ibc.lightclients.solomachine.v1.ConnectionStateData; - /** ProofOp data */ - data?: Uint8Array | null; - } + /** + * Encodes the specified ConnectionStateData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ConnectionStateData.verify|verify} messages. + * @param m ConnectionStateData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IConnectionStateData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Represents a ProofOp. */ - class ProofOp implements IProofOp { - /** - * Constructs a new ProofOp. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IProofOp); + /** + * Decodes a ConnectionStateData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ConnectionStateData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ConnectionStateData; + } - /** ProofOp type. */ - public type: string; + /** Properties of a ChannelStateData. */ + interface IChannelStateData { + /** ChannelStateData path */ + path?: Uint8Array | null; - /** ProofOp key. */ - public key: Uint8Array; + /** ChannelStateData channel */ + channel?: ibc.core.channel.v1.IChannel | null; + } - /** ProofOp data. */ - public data: Uint8Array; + /** Represents a ChannelStateData. */ + class ChannelStateData implements IChannelStateData { + /** + * Constructs a new ChannelStateData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IChannelStateData); - /** - * Creates a new ProofOp instance using the specified properties. - * @param [properties] Properties to set - * @returns ProofOp instance - */ - public static create(properties?: tendermint.crypto.IProofOp): tendermint.crypto.ProofOp; + /** ChannelStateData path. */ + public path: Uint8Array; - /** - * Encodes the specified ProofOp message. Does not implicitly {@link tendermint.crypto.ProofOp.verify|verify} messages. - * @param m ProofOp message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IProofOp, w?: $protobuf.Writer): $protobuf.Writer; + /** ChannelStateData channel. */ + public channel?: ibc.core.channel.v1.IChannel | null; - /** - * Decodes a ProofOp message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ProofOp - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.ProofOp; - } + /** + * Creates a new ChannelStateData instance using the specified properties. + * @param [properties] Properties to set + * @returns ChannelStateData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IChannelStateData, + ): ibc.lightclients.solomachine.v1.ChannelStateData; - /** Properties of a ProofOps. */ - interface IProofOps { - /** ProofOps ops */ - ops?: tendermint.crypto.IProofOp[] | null; - } + /** + * Encodes the specified ChannelStateData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.ChannelStateData.verify|verify} messages. + * @param m ChannelStateData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IChannelStateData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Represents a ProofOps. */ - class ProofOps implements IProofOps { - /** - * Constructs a new ProofOps. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IProofOps); + /** + * Decodes a ChannelStateData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns ChannelStateData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.ChannelStateData; + } - /** ProofOps ops. */ - public ops: tendermint.crypto.IProofOp[]; + /** Properties of a PacketCommitmentData. */ + interface IPacketCommitmentData { + /** PacketCommitmentData path */ + path?: Uint8Array | null; - /** - * Creates a new ProofOps instance using the specified properties. - * @param [properties] Properties to set - * @returns ProofOps instance - */ - public static create(properties?: tendermint.crypto.IProofOps): tendermint.crypto.ProofOps; + /** PacketCommitmentData commitment */ + commitment?: Uint8Array | null; + } - /** - * Encodes the specified ProofOps message. Does not implicitly {@link tendermint.crypto.ProofOps.verify|verify} messages. - * @param m ProofOps message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IProofOps, w?: $protobuf.Writer): $protobuf.Writer; + /** Represents a PacketCommitmentData. */ + class PacketCommitmentData implements IPacketCommitmentData { + /** + * Constructs a new PacketCommitmentData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IPacketCommitmentData); - /** - * Decodes a ProofOps message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns ProofOps - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.ProofOps; - } + /** PacketCommitmentData path. */ + public path: Uint8Array; - /** Properties of a PublicKey. */ - interface IPublicKey { - /** PublicKey ed25519 */ - ed25519?: Uint8Array | null; + /** PacketCommitmentData commitment. */ + public commitment: Uint8Array; - /** PublicKey secp256k1 */ - secp256k1?: Uint8Array | null; - } + /** + * Creates a new PacketCommitmentData instance using the specified properties. + * @param [properties] Properties to set + * @returns PacketCommitmentData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IPacketCommitmentData, + ): ibc.lightclients.solomachine.v1.PacketCommitmentData; - /** Represents a PublicKey. */ - class PublicKey implements IPublicKey { - /** - * Constructs a new PublicKey. - * @param [p] Properties to set - */ - constructor(p?: tendermint.crypto.IPublicKey); + /** + * Encodes the specified PacketCommitmentData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.PacketCommitmentData.verify|verify} messages. + * @param m PacketCommitmentData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IPacketCommitmentData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** PublicKey ed25519. */ - public ed25519: Uint8Array; + /** + * Decodes a PacketCommitmentData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PacketCommitmentData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.PacketCommitmentData; + } - /** PublicKey secp256k1. */ - public secp256k1: Uint8Array; + /** Properties of a PacketAcknowledgementData. */ + interface IPacketAcknowledgementData { + /** PacketAcknowledgementData path */ + path?: Uint8Array | null; - /** PublicKey sum. */ - public sum?: 'ed25519' | 'secp256k1'; + /** PacketAcknowledgementData acknowledgement */ + acknowledgement?: Uint8Array | null; + } - /** - * Creates a new PublicKey instance using the specified properties. - * @param [properties] Properties to set - * @returns PublicKey instance - */ - public static create(properties?: tendermint.crypto.IPublicKey): tendermint.crypto.PublicKey; + /** Represents a PacketAcknowledgementData. */ + class PacketAcknowledgementData implements IPacketAcknowledgementData { + /** + * Constructs a new PacketAcknowledgementData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IPacketAcknowledgementData); - /** - * Encodes the specified PublicKey message. Does not implicitly {@link tendermint.crypto.PublicKey.verify|verify} messages. - * @param m PublicKey message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.crypto.IPublicKey, w?: $protobuf.Writer): $protobuf.Writer; + /** PacketAcknowledgementData path. */ + public path: Uint8Array; - /** - * Decodes a PublicKey message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns PublicKey - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.crypto.PublicKey; - } - } + /** PacketAcknowledgementData acknowledgement. */ + public acknowledgement: Uint8Array; - /** Namespace version. */ - namespace version { - /** Properties of an App. */ - interface IApp { - /** App protocol */ - protocol?: Long | null; + /** + * Creates a new PacketAcknowledgementData instance using the specified properties. + * @param [properties] Properties to set + * @returns PacketAcknowledgementData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IPacketAcknowledgementData, + ): ibc.lightclients.solomachine.v1.PacketAcknowledgementData; - /** App software */ - software?: string | null; - } + /** + * Encodes the specified PacketAcknowledgementData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.PacketAcknowledgementData.verify|verify} messages. + * @param m PacketAcknowledgementData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IPacketAcknowledgementData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Represents an App. */ - class App implements IApp { - /** - * Constructs a new App. - * @param [p] Properties to set - */ - constructor(p?: tendermint.version.IApp); + /** + * Decodes a PacketAcknowledgementData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PacketAcknowledgementData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.PacketAcknowledgementData; + } - /** App protocol. */ - public protocol: Long; + /** Properties of a PacketReceiptAbsenceData. */ + interface IPacketReceiptAbsenceData { + /** PacketReceiptAbsenceData path */ + path?: Uint8Array | null; + } - /** App software. */ - public software: string; + /** Represents a PacketReceiptAbsenceData. */ + class PacketReceiptAbsenceData implements IPacketReceiptAbsenceData { + /** + * Constructs a new PacketReceiptAbsenceData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.IPacketReceiptAbsenceData); - /** - * Creates a new App instance using the specified properties. - * @param [properties] Properties to set - * @returns App instance - */ - public static create(properties?: tendermint.version.IApp): tendermint.version.App; + /** PacketReceiptAbsenceData path. */ + public path: Uint8Array; - /** - * Encodes the specified App message. Does not implicitly {@link tendermint.version.App.verify|verify} messages. - * @param m App message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.version.IApp, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Creates a new PacketReceiptAbsenceData instance using the specified properties. + * @param [properties] Properties to set + * @returns PacketReceiptAbsenceData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.IPacketReceiptAbsenceData, + ): ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData; - /** - * Decodes an App message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns App - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.version.App; - } + /** + * Encodes the specified PacketReceiptAbsenceData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData.verify|verify} messages. + * @param m PacketReceiptAbsenceData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.IPacketReceiptAbsenceData, + w?: $protobuf.Writer, + ): $protobuf.Writer; - /** Properties of a Consensus. */ - interface IConsensus { - /** Consensus block */ - block?: Long | null; + /** + * Decodes a PacketReceiptAbsenceData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns PacketReceiptAbsenceData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData; + } - /** Consensus app */ - app?: Long | null; - } + /** Properties of a NextSequenceRecvData. */ + interface INextSequenceRecvData { + /** NextSequenceRecvData path */ + path?: Uint8Array | null; - /** Represents a Consensus. */ - class Consensus implements IConsensus { - /** - * Constructs a new Consensus. - * @param [p] Properties to set - */ - constructor(p?: tendermint.version.IConsensus); + /** NextSequenceRecvData nextSeqRecv */ + nextSeqRecv?: Long | null; + } - /** Consensus block. */ - public block: Long; + /** Represents a NextSequenceRecvData. */ + class NextSequenceRecvData implements INextSequenceRecvData { + /** + * Constructs a new NextSequenceRecvData. + * @param [p] Properties to set + */ + constructor(p?: ibc.lightclients.solomachine.v1.INextSequenceRecvData); - /** Consensus app. */ - public app: Long; + /** NextSequenceRecvData path. */ + public path: Uint8Array; - /** - * Creates a new Consensus instance using the specified properties. - * @param [properties] Properties to set - * @returns Consensus instance - */ - public static create(properties?: tendermint.version.IConsensus): tendermint.version.Consensus; + /** NextSequenceRecvData nextSeqRecv. */ + public nextSeqRecv: Long; - /** - * Encodes the specified Consensus message. Does not implicitly {@link tendermint.version.Consensus.verify|verify} messages. - * @param m Consensus message or plain object to encode - * @param [w] Writer to encode to - * @returns Writer - */ - public static encode(m: tendermint.version.IConsensus, w?: $protobuf.Writer): $protobuf.Writer; + /** + * Creates a new NextSequenceRecvData instance using the specified properties. + * @param [properties] Properties to set + * @returns NextSequenceRecvData instance + */ + public static create( + properties?: ibc.lightclients.solomachine.v1.INextSequenceRecvData, + ): ibc.lightclients.solomachine.v1.NextSequenceRecvData; - /** - * Decodes a Consensus message from the specified reader or buffer. - * @param r Reader or buffer to decode from - * @param [l] Message length if known beforehand - * @returns Consensus - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(r: $protobuf.Reader | Uint8Array, l?: number): tendermint.version.Consensus; + /** + * Encodes the specified NextSequenceRecvData message. Does not implicitly {@link ibc.lightclients.solomachine.v1.NextSequenceRecvData.verify|verify} messages. + * @param m NextSequenceRecvData message or plain object to encode + * @param [w] Writer to encode to + * @returns Writer + */ + public static encode( + m: ibc.lightclients.solomachine.v1.INextSequenceRecvData, + w?: $protobuf.Writer, + ): $protobuf.Writer; + + /** + * Decodes a NextSequenceRecvData message from the specified reader or buffer. + * @param r Reader or buffer to decode from + * @param [l] Message length if known beforehand + * @returns NextSequenceRecvData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode( + r: $protobuf.Reader | Uint8Array, + l?: number, + ): ibc.lightclients.solomachine.v1.NextSequenceRecvData; + } + } } } } diff --git a/lib/src/cosmos/v1beta1/codec/generated/codecimpl.js b/lib/src/cosmos/v1beta1/codec/generated/codecimpl.js index 3ed74967..3c28be8e 100644 --- a/lib/src/cosmos/v1beta1/codec/generated/codecimpl.js +++ b/lib/src/cosmos/v1beta1/codec/generated/codecimpl.js @@ -1,6 +1,6 @@ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); -exports.chainmain = exports.tendermint = exports.ibc = exports.google = exports.cosmos = void 0; +exports.chainmain = exports.ibc = exports.tendermintV2 = exports.ics23 = exports.google = exports.cosmos = void 0; var $protobuf = require('protobufjs/minimal'); const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, @@ -1449,7 +1449,7 @@ exports.cosmos = $root.cosmos = (() => { HistoricalInfo.encode = function encode(m, w) { if (!w) w = $Writer.create(); if (m.header != null && Object.hasOwnProperty.call(m, 'header')) - $root.tendermint.types.Header.encode(m.header, w.uint32(10).fork()).ldelim(); + $root.tendermintV2.types.Header.encode(m.header, w.uint32(10).fork()).ldelim(); if (m.valset != null && m.valset.length) { for (var i = 0; i < m.valset.length; ++i) $root.cosmos.staking.v1beta1.Validator.encode(m.valset[i], w.uint32(18).fork()).ldelim(); @@ -1464,7 +1464,7 @@ exports.cosmos = $root.cosmos = (() => { var t = r.uint32(); switch (t >>> 3) { case 1: - m.header = $root.tendermint.types.Header.decode(r, r.uint32()); + m.header = $root.tendermintV2.types.Header.decode(r, r.uint32()); break; case 2: if (!(m.valset && m.valset.length)) m.valset = []; @@ -2940,6 +2940,101 @@ exports.cosmos = $root.cosmos = (() => { })(); return staking; })(); + cosmos.slashing = (function () { + const slashing = {}; + slashing.v1beta1 = (function () { + const v1beta1 = {}; + v1beta1.Msg = (function () { + function Msg(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; + Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + Object.defineProperty( + (Msg.prototype.unjail = function unjail(request, callback) { + return this.rpcCall( + unjail, + $root.cosmos.slashing.v1beta1.MsgUnjail, + $root.cosmos.slashing.v1beta1.MsgUnjailResponse, + request, + callback, + ); + }), + 'name', + { value: 'Unjail' }, + ); + return Msg; + })(); + v1beta1.MsgUnjail = (function () { + function MsgUnjail(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUnjail.prototype.validatorAddr = ''; + MsgUnjail.create = function create(properties) { + return new MsgUnjail(properties); + }; + MsgUnjail.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.validatorAddr != null && Object.hasOwnProperty.call(m, 'validatorAddr')) + w.uint32(10).string(m.validatorAddr); + return w; + }; + MsgUnjail.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.cosmos.slashing.v1beta1.MsgUnjail(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.validatorAddr = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUnjail; + })(); + v1beta1.MsgUnjailResponse = (function () { + function MsgUnjailResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUnjailResponse.create = function create(properties) { + return new MsgUnjailResponse(properties); + }; + MsgUnjailResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgUnjailResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.cosmos.slashing.v1beta1.MsgUnjailResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUnjailResponse; + })(); + return v1beta1; + })(); + return slashing; + })(); cosmos.base = (function () { const base = {}; base.v1beta1 = (function () { @@ -3180,6 +3275,51 @@ exports.cosmos = $root.cosmos = (() => { })(); return v1beta1; })(); + multisig.LegacyAminoPubKey = (function () { + function LegacyAminoPubKey(p) { + this.publicKeys = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + LegacyAminoPubKey.prototype.threshold = 0; + LegacyAminoPubKey.prototype.publicKeys = $util.emptyArray; + LegacyAminoPubKey.create = function create(properties) { + return new LegacyAminoPubKey(properties); + }; + LegacyAminoPubKey.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.threshold != null && Object.hasOwnProperty.call(m, 'threshold')) + w.uint32(8).uint32(m.threshold); + if (m.publicKeys != null && m.publicKeys.length) { + for (var i = 0; i < m.publicKeys.length; ++i) + $root.google.protobuf.Any.encode(m.publicKeys[i], w.uint32(18).fork()).ldelim(); + } + return w; + }; + LegacyAminoPubKey.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.cosmos.crypto.multisig.LegacyAminoPubKey(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.threshold = r.uint32(); + break; + case 2: + if (!(m.publicKeys && m.publicKeys.length)) m.publicKeys = []; + m.publicKeys.push($root.google.protobuf.Any.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return LegacyAminoPubKey; + })(); return multisig; })(); crypto.secp256k1 = (function () { @@ -5207,170 +5347,3459 @@ exports.google = $root.google = (() => { })(); return google; })(); -exports.ibc = $root.ibc = (() => { - const ibc = {}; - ibc.applications = (function () { - const applications = {}; - applications.transfer = (function () { - const transfer = {}; - transfer.v1 = (function () { - const v1 = {}; - v1.Msg = (function () { - function Msg(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; - Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { - return new this(rpcImpl, requestDelimited, responseDelimited); - }; - Object.defineProperty( - (Msg.prototype.transfer = function transfer(request, callback) { - return this.rpcCall( - transfer, - $root.ibc.applications.transfer.v1.MsgTransfer, - $root.ibc.applications.transfer.v1.MsgTransferResponse, - request, - callback, - ); - }), - 'name', - { value: 'Transfer' }, - ); - return Msg; - })(); - v1.MsgTransfer = (function () { - function MsgTransfer(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - MsgTransfer.prototype.sourcePort = ''; - MsgTransfer.prototype.sourceChannel = ''; - MsgTransfer.prototype.token = null; - MsgTransfer.prototype.sender = ''; - MsgTransfer.prototype.receiver = ''; - MsgTransfer.prototype.timeoutHeight = null; - MsgTransfer.prototype.timeoutTimestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - MsgTransfer.create = function create(properties) { - return new MsgTransfer(properties); - }; - MsgTransfer.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.sourcePort != null && Object.hasOwnProperty.call(m, 'sourcePort')) - w.uint32(10).string(m.sourcePort); - if (m.sourceChannel != null && Object.hasOwnProperty.call(m, 'sourceChannel')) - w.uint32(18).string(m.sourceChannel); - if (m.token != null && Object.hasOwnProperty.call(m, 'token')) - $root.cosmos.base.v1beta1.Coin.encode(m.token, w.uint32(26).fork()).ldelim(); - if (m.sender != null && Object.hasOwnProperty.call(m, 'sender')) w.uint32(34).string(m.sender); - if (m.receiver != null && Object.hasOwnProperty.call(m, 'receiver')) - w.uint32(42).string(m.receiver); - if (m.timeoutHeight != null && Object.hasOwnProperty.call(m, 'timeoutHeight')) - $root.ibc.core.client.v1.Height.encode(m.timeoutHeight, w.uint32(50).fork()).ldelim(); - if (m.timeoutTimestamp != null && Object.hasOwnProperty.call(m, 'timeoutTimestamp')) - w.uint32(56).uint64(m.timeoutTimestamp); - return w; - }; - MsgTransfer.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.applications.transfer.v1.MsgTransfer(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.sourcePort = r.string(); - break; - case 2: - m.sourceChannel = r.string(); - break; - case 3: - m.token = $root.cosmos.base.v1beta1.Coin.decode(r, r.uint32()); - break; - case 4: - m.sender = r.string(); - break; - case 5: - m.receiver = r.string(); - break; - case 6: - m.timeoutHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); - break; - case 7: - m.timeoutTimestamp = r.uint64(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - return MsgTransfer; - })(); - v1.MsgTransferResponse = (function () { - function MsgTransferResponse(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - MsgTransferResponse.create = function create(properties) { - return new MsgTransferResponse(properties); - }; - MsgTransferResponse.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - return w; - }; - MsgTransferResponse.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.applications.transfer.v1.MsgTransferResponse(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - return MsgTransferResponse; - })(); - return v1; - })(); - return transfer; - })(); - return applications; +exports.ics23 = $root.ics23 = (() => { + const ics23 = {}; + ics23.HashOp = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'NO_HASH')] = 0; + values[(valuesById[1] = 'SHA256')] = 1; + values[(valuesById[2] = 'SHA512')] = 2; + values[(valuesById[3] = 'KECCAK')] = 3; + values[(valuesById[4] = 'RIPEMD160')] = 4; + values[(valuesById[5] = 'BITCOIN')] = 5; + return values; })(); - ibc.core = (function () { - const core = {}; - core.client = (function () { - const client = {}; - client.v1 = (function () { - const v1 = {}; - v1.Msg = (function () { - function Msg(rpcImpl, requestDelimited, responseDelimited) { - $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); - } - (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; - Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { - return new this(rpcImpl, requestDelimited, responseDelimited); - }; - Object.defineProperty( - (Msg.prototype.createClient = function createClient(request, callback) { - return this.rpcCall( - createClient, - $root.ibc.core.client.v1.MsgCreateClient, - $root.ibc.core.client.v1.MsgCreateClientResponse, - request, - callback, - ); - }), - 'name', - { value: 'CreateClient' }, - ); - Object.defineProperty( + ics23.LengthOp = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'NO_PREFIX')] = 0; + values[(valuesById[1] = 'VAR_PROTO')] = 1; + values[(valuesById[2] = 'VAR_RLP')] = 2; + values[(valuesById[3] = 'FIXED32_BIG')] = 3; + values[(valuesById[4] = 'FIXED32_LITTLE')] = 4; + values[(valuesById[5] = 'FIXED64_BIG')] = 5; + values[(valuesById[6] = 'FIXED64_LITTLE')] = 6; + values[(valuesById[7] = 'REQUIRE_32_BYTES')] = 7; + values[(valuesById[8] = 'REQUIRE_64_BYTES')] = 8; + return values; + })(); + ics23.ExistenceProof = (function () { + function ExistenceProof(p) { + this.path = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ExistenceProof.prototype.key = $util.newBuffer([]); + ExistenceProof.prototype.value = $util.newBuffer([]); + ExistenceProof.prototype.leaf = null; + ExistenceProof.prototype.path = $util.emptyArray; + ExistenceProof.create = function create(properties) { + return new ExistenceProof(properties); + }; + ExistenceProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); + if (m.value != null && Object.hasOwnProperty.call(m, 'value')) w.uint32(18).bytes(m.value); + if (m.leaf != null && Object.hasOwnProperty.call(m, 'leaf')) + $root.ics23.LeafOp.encode(m.leaf, w.uint32(26).fork()).ldelim(); + if (m.path != null && m.path.length) { + for (var i = 0; i < m.path.length; ++i) + $root.ics23.InnerOp.encode(m.path[i], w.uint32(34).fork()).ldelim(); + } + return w; + }; + ExistenceProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.ExistenceProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.bytes(); + break; + case 2: + m.value = r.bytes(); + break; + case 3: + m.leaf = $root.ics23.LeafOp.decode(r, r.uint32()); + break; + case 4: + if (!(m.path && m.path.length)) m.path = []; + m.path.push($root.ics23.InnerOp.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ExistenceProof; + })(); + ics23.NonExistenceProof = (function () { + function NonExistenceProof(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + NonExistenceProof.prototype.key = $util.newBuffer([]); + NonExistenceProof.prototype.left = null; + NonExistenceProof.prototype.right = null; + NonExistenceProof.create = function create(properties) { + return new NonExistenceProof(properties); + }; + NonExistenceProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); + if (m.left != null && Object.hasOwnProperty.call(m, 'left')) + $root.ics23.ExistenceProof.encode(m.left, w.uint32(18).fork()).ldelim(); + if (m.right != null && Object.hasOwnProperty.call(m, 'right')) + $root.ics23.ExistenceProof.encode(m.right, w.uint32(26).fork()).ldelim(); + return w; + }; + NonExistenceProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.NonExistenceProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.bytes(); + break; + case 2: + m.left = $root.ics23.ExistenceProof.decode(r, r.uint32()); + break; + case 3: + m.right = $root.ics23.ExistenceProof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return NonExistenceProof; + })(); + ics23.CommitmentProof = (function () { + function CommitmentProof(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CommitmentProof.prototype.exist = null; + CommitmentProof.prototype.nonexist = null; + CommitmentProof.prototype.batch = null; + CommitmentProof.prototype.compressed = null; + let $oneOfFields; + Object.defineProperty(CommitmentProof.prototype, 'proof', { + get: $util.oneOfGetter(($oneOfFields = ['exist', 'nonexist', 'batch', 'compressed'])), + set: $util.oneOfSetter($oneOfFields), + }); + CommitmentProof.create = function create(properties) { + return new CommitmentProof(properties); + }; + CommitmentProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.exist != null && Object.hasOwnProperty.call(m, 'exist')) + $root.ics23.ExistenceProof.encode(m.exist, w.uint32(10).fork()).ldelim(); + if (m.nonexist != null && Object.hasOwnProperty.call(m, 'nonexist')) + $root.ics23.NonExistenceProof.encode(m.nonexist, w.uint32(18).fork()).ldelim(); + if (m.batch != null && Object.hasOwnProperty.call(m, 'batch')) + $root.ics23.BatchProof.encode(m.batch, w.uint32(26).fork()).ldelim(); + if (m.compressed != null && Object.hasOwnProperty.call(m, 'compressed')) + $root.ics23.CompressedBatchProof.encode(m.compressed, w.uint32(34).fork()).ldelim(); + return w; + }; + CommitmentProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.CommitmentProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.exist = $root.ics23.ExistenceProof.decode(r, r.uint32()); + break; + case 2: + m.nonexist = $root.ics23.NonExistenceProof.decode(r, r.uint32()); + break; + case 3: + m.batch = $root.ics23.BatchProof.decode(r, r.uint32()); + break; + case 4: + m.compressed = $root.ics23.CompressedBatchProof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CommitmentProof; + })(); + ics23.LeafOp = (function () { + function LeafOp(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + LeafOp.prototype.hash = 0; + LeafOp.prototype.prehashKey = 0; + LeafOp.prototype.prehashValue = 0; + LeafOp.prototype.length = 0; + LeafOp.prototype.prefix = $util.newBuffer([]); + LeafOp.create = function create(properties) { + return new LeafOp(properties); + }; + LeafOp.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(8).int32(m.hash); + if (m.prehashKey != null && Object.hasOwnProperty.call(m, 'prehashKey')) w.uint32(16).int32(m.prehashKey); + if (m.prehashValue != null && Object.hasOwnProperty.call(m, 'prehashValue')) + w.uint32(24).int32(m.prehashValue); + if (m.length != null && Object.hasOwnProperty.call(m, 'length')) w.uint32(32).int32(m.length); + if (m.prefix != null && Object.hasOwnProperty.call(m, 'prefix')) w.uint32(42).bytes(m.prefix); + return w; + }; + LeafOp.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.LeafOp(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.hash = r.int32(); + break; + case 2: + m.prehashKey = r.int32(); + break; + case 3: + m.prehashValue = r.int32(); + break; + case 4: + m.length = r.int32(); + break; + case 5: + m.prefix = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return LeafOp; + })(); + ics23.InnerOp = (function () { + function InnerOp(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + InnerOp.prototype.hash = 0; + InnerOp.prototype.prefix = $util.newBuffer([]); + InnerOp.prototype.suffix = $util.newBuffer([]); + InnerOp.create = function create(properties) { + return new InnerOp(properties); + }; + InnerOp.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(8).int32(m.hash); + if (m.prefix != null && Object.hasOwnProperty.call(m, 'prefix')) w.uint32(18).bytes(m.prefix); + if (m.suffix != null && Object.hasOwnProperty.call(m, 'suffix')) w.uint32(26).bytes(m.suffix); + return w; + }; + InnerOp.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.InnerOp(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.hash = r.int32(); + break; + case 2: + m.prefix = r.bytes(); + break; + case 3: + m.suffix = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return InnerOp; + })(); + ics23.ProofSpec = (function () { + function ProofSpec(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ProofSpec.prototype.leafSpec = null; + ProofSpec.prototype.innerSpec = null; + ProofSpec.prototype.maxDepth = 0; + ProofSpec.prototype.minDepth = 0; + ProofSpec.create = function create(properties) { + return new ProofSpec(properties); + }; + ProofSpec.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.leafSpec != null && Object.hasOwnProperty.call(m, 'leafSpec')) + $root.ics23.LeafOp.encode(m.leafSpec, w.uint32(10).fork()).ldelim(); + if (m.innerSpec != null && Object.hasOwnProperty.call(m, 'innerSpec')) + $root.ics23.InnerSpec.encode(m.innerSpec, w.uint32(18).fork()).ldelim(); + if (m.maxDepth != null && Object.hasOwnProperty.call(m, 'maxDepth')) w.uint32(24).int32(m.maxDepth); + if (m.minDepth != null && Object.hasOwnProperty.call(m, 'minDepth')) w.uint32(32).int32(m.minDepth); + return w; + }; + ProofSpec.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.ProofSpec(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.leafSpec = $root.ics23.LeafOp.decode(r, r.uint32()); + break; + case 2: + m.innerSpec = $root.ics23.InnerSpec.decode(r, r.uint32()); + break; + case 3: + m.maxDepth = r.int32(); + break; + case 4: + m.minDepth = r.int32(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ProofSpec; + })(); + ics23.InnerSpec = (function () { + function InnerSpec(p) { + this.childOrder = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + InnerSpec.prototype.childOrder = $util.emptyArray; + InnerSpec.prototype.childSize = 0; + InnerSpec.prototype.minPrefixLength = 0; + InnerSpec.prototype.maxPrefixLength = 0; + InnerSpec.prototype.emptyChild = $util.newBuffer([]); + InnerSpec.prototype.hash = 0; + InnerSpec.create = function create(properties) { + return new InnerSpec(properties); + }; + InnerSpec.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.childOrder != null && m.childOrder.length) { + w.uint32(10).fork(); + for (var i = 0; i < m.childOrder.length; ++i) w.int32(m.childOrder[i]); + w.ldelim(); + } + if (m.childSize != null && Object.hasOwnProperty.call(m, 'childSize')) w.uint32(16).int32(m.childSize); + if (m.minPrefixLength != null && Object.hasOwnProperty.call(m, 'minPrefixLength')) + w.uint32(24).int32(m.minPrefixLength); + if (m.maxPrefixLength != null && Object.hasOwnProperty.call(m, 'maxPrefixLength')) + w.uint32(32).int32(m.maxPrefixLength); + if (m.emptyChild != null && Object.hasOwnProperty.call(m, 'emptyChild')) w.uint32(42).bytes(m.emptyChild); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(48).int32(m.hash); + return w; + }; + InnerSpec.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.InnerSpec(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.childOrder && m.childOrder.length)) m.childOrder = []; + if ((t & 7) === 2) { + var c2 = r.uint32() + r.pos; + while (r.pos < c2) m.childOrder.push(r.int32()); + } else m.childOrder.push(r.int32()); + break; + case 2: + m.childSize = r.int32(); + break; + case 3: + m.minPrefixLength = r.int32(); + break; + case 4: + m.maxPrefixLength = r.int32(); + break; + case 5: + m.emptyChild = r.bytes(); + break; + case 6: + m.hash = r.int32(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return InnerSpec; + })(); + ics23.BatchProof = (function () { + function BatchProof(p) { + this.entries = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + BatchProof.prototype.entries = $util.emptyArray; + BatchProof.create = function create(properties) { + return new BatchProof(properties); + }; + BatchProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.entries != null && m.entries.length) { + for (var i = 0; i < m.entries.length; ++i) + $root.ics23.BatchEntry.encode(m.entries[i], w.uint32(10).fork()).ldelim(); + } + return w; + }; + BatchProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.BatchProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.entries && m.entries.length)) m.entries = []; + m.entries.push($root.ics23.BatchEntry.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return BatchProof; + })(); + ics23.BatchEntry = (function () { + function BatchEntry(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + BatchEntry.prototype.exist = null; + BatchEntry.prototype.nonexist = null; + let $oneOfFields; + Object.defineProperty(BatchEntry.prototype, 'proof', { + get: $util.oneOfGetter(($oneOfFields = ['exist', 'nonexist'])), + set: $util.oneOfSetter($oneOfFields), + }); + BatchEntry.create = function create(properties) { + return new BatchEntry(properties); + }; + BatchEntry.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.exist != null && Object.hasOwnProperty.call(m, 'exist')) + $root.ics23.ExistenceProof.encode(m.exist, w.uint32(10).fork()).ldelim(); + if (m.nonexist != null && Object.hasOwnProperty.call(m, 'nonexist')) + $root.ics23.NonExistenceProof.encode(m.nonexist, w.uint32(18).fork()).ldelim(); + return w; + }; + BatchEntry.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.BatchEntry(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.exist = $root.ics23.ExistenceProof.decode(r, r.uint32()); + break; + case 2: + m.nonexist = $root.ics23.NonExistenceProof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return BatchEntry; + })(); + ics23.CompressedBatchProof = (function () { + function CompressedBatchProof(p) { + this.entries = []; + this.lookupInners = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CompressedBatchProof.prototype.entries = $util.emptyArray; + CompressedBatchProof.prototype.lookupInners = $util.emptyArray; + CompressedBatchProof.create = function create(properties) { + return new CompressedBatchProof(properties); + }; + CompressedBatchProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.entries != null && m.entries.length) { + for (var i = 0; i < m.entries.length; ++i) + $root.ics23.CompressedBatchEntry.encode(m.entries[i], w.uint32(10).fork()).ldelim(); + } + if (m.lookupInners != null && m.lookupInners.length) { + for (var i = 0; i < m.lookupInners.length; ++i) + $root.ics23.InnerOp.encode(m.lookupInners[i], w.uint32(18).fork()).ldelim(); + } + return w; + }; + CompressedBatchProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.CompressedBatchProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.entries && m.entries.length)) m.entries = []; + m.entries.push($root.ics23.CompressedBatchEntry.decode(r, r.uint32())); + break; + case 2: + if (!(m.lookupInners && m.lookupInners.length)) m.lookupInners = []; + m.lookupInners.push($root.ics23.InnerOp.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CompressedBatchProof; + })(); + ics23.CompressedBatchEntry = (function () { + function CompressedBatchEntry(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CompressedBatchEntry.prototype.exist = null; + CompressedBatchEntry.prototype.nonexist = null; + let $oneOfFields; + Object.defineProperty(CompressedBatchEntry.prototype, 'proof', { + get: $util.oneOfGetter(($oneOfFields = ['exist', 'nonexist'])), + set: $util.oneOfSetter($oneOfFields), + }); + CompressedBatchEntry.create = function create(properties) { + return new CompressedBatchEntry(properties); + }; + CompressedBatchEntry.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.exist != null && Object.hasOwnProperty.call(m, 'exist')) + $root.ics23.CompressedExistenceProof.encode(m.exist, w.uint32(10).fork()).ldelim(); + if (m.nonexist != null && Object.hasOwnProperty.call(m, 'nonexist')) + $root.ics23.CompressedNonExistenceProof.encode(m.nonexist, w.uint32(18).fork()).ldelim(); + return w; + }; + CompressedBatchEntry.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.CompressedBatchEntry(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.exist = $root.ics23.CompressedExistenceProof.decode(r, r.uint32()); + break; + case 2: + m.nonexist = $root.ics23.CompressedNonExistenceProof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CompressedBatchEntry; + })(); + ics23.CompressedExistenceProof = (function () { + function CompressedExistenceProof(p) { + this.path = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CompressedExistenceProof.prototype.key = $util.newBuffer([]); + CompressedExistenceProof.prototype.value = $util.newBuffer([]); + CompressedExistenceProof.prototype.leaf = null; + CompressedExistenceProof.prototype.path = $util.emptyArray; + CompressedExistenceProof.create = function create(properties) { + return new CompressedExistenceProof(properties); + }; + CompressedExistenceProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); + if (m.value != null && Object.hasOwnProperty.call(m, 'value')) w.uint32(18).bytes(m.value); + if (m.leaf != null && Object.hasOwnProperty.call(m, 'leaf')) + $root.ics23.LeafOp.encode(m.leaf, w.uint32(26).fork()).ldelim(); + if (m.path != null && m.path.length) { + w.uint32(34).fork(); + for (var i = 0; i < m.path.length; ++i) w.int32(m.path[i]); + w.ldelim(); + } + return w; + }; + CompressedExistenceProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.CompressedExistenceProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.bytes(); + break; + case 2: + m.value = r.bytes(); + break; + case 3: + m.leaf = $root.ics23.LeafOp.decode(r, r.uint32()); + break; + case 4: + if (!(m.path && m.path.length)) m.path = []; + if ((t & 7) === 2) { + var c2 = r.uint32() + r.pos; + while (r.pos < c2) m.path.push(r.int32()); + } else m.path.push(r.int32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CompressedExistenceProof; + })(); + ics23.CompressedNonExistenceProof = (function () { + function CompressedNonExistenceProof(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CompressedNonExistenceProof.prototype.key = $util.newBuffer([]); + CompressedNonExistenceProof.prototype.left = null; + CompressedNonExistenceProof.prototype.right = null; + CompressedNonExistenceProof.create = function create(properties) { + return new CompressedNonExistenceProof(properties); + }; + CompressedNonExistenceProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); + if (m.left != null && Object.hasOwnProperty.call(m, 'left')) + $root.ics23.CompressedExistenceProof.encode(m.left, w.uint32(18).fork()).ldelim(); + if (m.right != null && Object.hasOwnProperty.call(m, 'right')) + $root.ics23.CompressedExistenceProof.encode(m.right, w.uint32(26).fork()).ldelim(); + return w; + }; + CompressedNonExistenceProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ics23.CompressedNonExistenceProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.bytes(); + break; + case 2: + m.left = $root.ics23.CompressedExistenceProof.decode(r, r.uint32()); + break; + case 3: + m.right = $root.ics23.CompressedExistenceProof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CompressedNonExistenceProof; + })(); + return ics23; +})(); +exports.tendermintV2 = $root.tendermintV2 = (() => { + const tendermintV2 = {}; + tendermintV2.types = (function () { + const types = {}; + types.BlockIDFlag = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'BLOCK_ID_FLAG_UNKNOWN')] = 0; + values[(valuesById[1] = 'BLOCK_ID_FLAG_ABSENT')] = 1; + values[(valuesById[2] = 'BLOCK_ID_FLAG_COMMIT')] = 2; + values[(valuesById[3] = 'BLOCK_ID_FLAG_NIL')] = 3; + return values; + })(); + types.SignedMsgType = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'SIGNED_MSG_TYPE_UNKNOWN')] = 0; + values[(valuesById[1] = 'SIGNED_MSG_TYPE_PREVOTE')] = 1; + values[(valuesById[2] = 'SIGNED_MSG_TYPE_PRECOMMIT')] = 2; + values[(valuesById[32] = 'SIGNED_MSG_TYPE_PROPOSAL')] = 32; + return values; + })(); + types.PartSetHeader = (function () { + function PartSetHeader(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + PartSetHeader.prototype.total = 0; + PartSetHeader.prototype.hash = $util.newBuffer([]); + PartSetHeader.create = function create(properties) { + return new PartSetHeader(properties); + }; + PartSetHeader.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.total != null && Object.hasOwnProperty.call(m, 'total')) w.uint32(8).uint32(m.total); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(18).bytes(m.hash); + return w; + }; + PartSetHeader.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.PartSetHeader(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.total = r.uint32(); + break; + case 2: + m.hash = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PartSetHeader; + })(); + types.Part = (function () { + function Part(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Part.prototype.index = 0; + Part.prototype.bytes = $util.newBuffer([]); + Part.prototype.proof = null; + Part.create = function create(properties) { + return new Part(properties); + }; + Part.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.index != null && Object.hasOwnProperty.call(m, 'index')) w.uint32(8).uint32(m.index); + if (m.bytes != null && Object.hasOwnProperty.call(m, 'bytes')) w.uint32(18).bytes(m.bytes); + if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) + $root.tendermintV2.crypto.Proof.encode(m.proof, w.uint32(26).fork()).ldelim(); + return w; + }; + Part.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Part(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.index = r.uint32(); + break; + case 2: + m.bytes = r.bytes(); + break; + case 3: + m.proof = $root.tendermintV2.crypto.Proof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Part; + })(); + types.BlockID = (function () { + function BlockID(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + BlockID.prototype.hash = $util.newBuffer([]); + BlockID.prototype.partSetHeader = null; + BlockID.create = function create(properties) { + return new BlockID(properties); + }; + BlockID.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(10).bytes(m.hash); + if (m.partSetHeader != null && Object.hasOwnProperty.call(m, 'partSetHeader')) + $root.tendermintV2.types.PartSetHeader.encode(m.partSetHeader, w.uint32(18).fork()).ldelim(); + return w; + }; + BlockID.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.BlockID(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.hash = r.bytes(); + break; + case 2: + m.partSetHeader = $root.tendermintV2.types.PartSetHeader.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return BlockID; + })(); + types.Header = (function () { + function Header(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Header.prototype.version = null; + Header.prototype.chainId = ''; + Header.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Header.prototype.time = null; + Header.prototype.lastBlockId = null; + Header.prototype.lastCommitHash = $util.newBuffer([]); + Header.prototype.dataHash = $util.newBuffer([]); + Header.prototype.validatorsHash = $util.newBuffer([]); + Header.prototype.nextValidatorsHash = $util.newBuffer([]); + Header.prototype.consensusHash = $util.newBuffer([]); + Header.prototype.appHash = $util.newBuffer([]); + Header.prototype.lastResultsHash = $util.newBuffer([]); + Header.prototype.evidenceHash = $util.newBuffer([]); + Header.prototype.proposerAddress = $util.newBuffer([]); + Header.create = function create(properties) { + return new Header(properties); + }; + Header.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.version != null && Object.hasOwnProperty.call(m, 'version')) + $root.tendermintV2.version.Consensus.encode(m.version, w.uint32(10).fork()).ldelim(); + if (m.chainId != null && Object.hasOwnProperty.call(m, 'chainId')) w.uint32(18).string(m.chainId); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(24).int64(m.height); + if (m.time != null && Object.hasOwnProperty.call(m, 'time')) + $root.google.protobuf.Timestamp.encode(m.time, w.uint32(34).fork()).ldelim(); + if (m.lastBlockId != null && Object.hasOwnProperty.call(m, 'lastBlockId')) + $root.tendermintV2.types.BlockID.encode(m.lastBlockId, w.uint32(42).fork()).ldelim(); + if (m.lastCommitHash != null && Object.hasOwnProperty.call(m, 'lastCommitHash')) + w.uint32(50).bytes(m.lastCommitHash); + if (m.dataHash != null && Object.hasOwnProperty.call(m, 'dataHash')) w.uint32(58).bytes(m.dataHash); + if (m.validatorsHash != null && Object.hasOwnProperty.call(m, 'validatorsHash')) + w.uint32(66).bytes(m.validatorsHash); + if (m.nextValidatorsHash != null && Object.hasOwnProperty.call(m, 'nextValidatorsHash')) + w.uint32(74).bytes(m.nextValidatorsHash); + if (m.consensusHash != null && Object.hasOwnProperty.call(m, 'consensusHash')) + w.uint32(82).bytes(m.consensusHash); + if (m.appHash != null && Object.hasOwnProperty.call(m, 'appHash')) w.uint32(90).bytes(m.appHash); + if (m.lastResultsHash != null && Object.hasOwnProperty.call(m, 'lastResultsHash')) + w.uint32(98).bytes(m.lastResultsHash); + if (m.evidenceHash != null && Object.hasOwnProperty.call(m, 'evidenceHash')) + w.uint32(106).bytes(m.evidenceHash); + if (m.proposerAddress != null && Object.hasOwnProperty.call(m, 'proposerAddress')) + w.uint32(114).bytes(m.proposerAddress); + return w; + }; + Header.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Header(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.version = $root.tendermintV2.version.Consensus.decode(r, r.uint32()); + break; + case 2: + m.chainId = r.string(); + break; + case 3: + m.height = r.int64(); + break; + case 4: + m.time = $root.google.protobuf.Timestamp.decode(r, r.uint32()); + break; + case 5: + m.lastBlockId = $root.tendermintV2.types.BlockID.decode(r, r.uint32()); + break; + case 6: + m.lastCommitHash = r.bytes(); + break; + case 7: + m.dataHash = r.bytes(); + break; + case 8: + m.validatorsHash = r.bytes(); + break; + case 9: + m.nextValidatorsHash = r.bytes(); + break; + case 10: + m.consensusHash = r.bytes(); + break; + case 11: + m.appHash = r.bytes(); + break; + case 12: + m.lastResultsHash = r.bytes(); + break; + case 13: + m.evidenceHash = r.bytes(); + break; + case 14: + m.proposerAddress = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Header; + })(); + types.Data = (function () { + function Data(p) { + this.txs = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Data.prototype.txs = $util.emptyArray; + Data.create = function create(properties) { + return new Data(properties); + }; + Data.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.txs != null && m.txs.length) { + for (var i = 0; i < m.txs.length; ++i) w.uint32(10).bytes(m.txs[i]); + } + return w; + }; + Data.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Data(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.txs && m.txs.length)) m.txs = []; + m.txs.push(r.bytes()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Data; + })(); + types.Vote = (function () { + function Vote(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Vote.prototype.type = 0; + Vote.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Vote.prototype.round = 0; + Vote.prototype.blockId = null; + Vote.prototype.timestamp = null; + Vote.prototype.validatorAddress = $util.newBuffer([]); + Vote.prototype.validatorIndex = 0; + Vote.prototype.signature = $util.newBuffer([]); + Vote.create = function create(properties) { + return new Vote(properties); + }; + Vote.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(8).int32(m.type); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(16).int64(m.height); + if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(24).int32(m.round); + if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) + $root.tendermintV2.types.BlockID.encode(m.blockId, w.uint32(34).fork()).ldelim(); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(42).fork()).ldelim(); + if (m.validatorAddress != null && Object.hasOwnProperty.call(m, 'validatorAddress')) + w.uint32(50).bytes(m.validatorAddress); + if (m.validatorIndex != null && Object.hasOwnProperty.call(m, 'validatorIndex')) + w.uint32(56).int32(m.validatorIndex); + if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(66).bytes(m.signature); + return w; + }; + Vote.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Vote(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.type = r.int32(); + break; + case 2: + m.height = r.int64(); + break; + case 3: + m.round = r.int32(); + break; + case 4: + m.blockId = $root.tendermintV2.types.BlockID.decode(r, r.uint32()); + break; + case 5: + m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); + break; + case 6: + m.validatorAddress = r.bytes(); + break; + case 7: + m.validatorIndex = r.int32(); + break; + case 8: + m.signature = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Vote; + })(); + types.Commit = (function () { + function Commit(p) { + this.signatures = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Commit.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Commit.prototype.round = 0; + Commit.prototype.blockId = null; + Commit.prototype.signatures = $util.emptyArray; + Commit.create = function create(properties) { + return new Commit(properties); + }; + Commit.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(8).int64(m.height); + if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(16).int32(m.round); + if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) + $root.tendermintV2.types.BlockID.encode(m.blockId, w.uint32(26).fork()).ldelim(); + if (m.signatures != null && m.signatures.length) { + for (var i = 0; i < m.signatures.length; ++i) + $root.tendermintV2.types.CommitSig.encode(m.signatures[i], w.uint32(34).fork()).ldelim(); + } + return w; + }; + Commit.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Commit(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.height = r.int64(); + break; + case 2: + m.round = r.int32(); + break; + case 3: + m.blockId = $root.tendermintV2.types.BlockID.decode(r, r.uint32()); + break; + case 4: + if (!(m.signatures && m.signatures.length)) m.signatures = []; + m.signatures.push($root.tendermintV2.types.CommitSig.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Commit; + })(); + types.CommitSig = (function () { + function CommitSig(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + CommitSig.prototype.blockIdFlag = 0; + CommitSig.prototype.validatorAddress = $util.newBuffer([]); + CommitSig.prototype.timestamp = null; + CommitSig.prototype.signature = $util.newBuffer([]); + CommitSig.create = function create(properties) { + return new CommitSig(properties); + }; + CommitSig.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.blockIdFlag != null && Object.hasOwnProperty.call(m, 'blockIdFlag')) + w.uint32(8).int32(m.blockIdFlag); + if (m.validatorAddress != null && Object.hasOwnProperty.call(m, 'validatorAddress')) + w.uint32(18).bytes(m.validatorAddress); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(26).fork()).ldelim(); + if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(34).bytes(m.signature); + return w; + }; + CommitSig.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.CommitSig(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.blockIdFlag = r.int32(); + break; + case 2: + m.validatorAddress = r.bytes(); + break; + case 3: + m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); + break; + case 4: + m.signature = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return CommitSig; + })(); + types.Proposal = (function () { + function Proposal(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Proposal.prototype.type = 0; + Proposal.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Proposal.prototype.round = 0; + Proposal.prototype.polRound = 0; + Proposal.prototype.blockId = null; + Proposal.prototype.timestamp = null; + Proposal.prototype.signature = $util.newBuffer([]); + Proposal.create = function create(properties) { + return new Proposal(properties); + }; + Proposal.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(8).int32(m.type); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(16).int64(m.height); + if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(24).int32(m.round); + if (m.polRound != null && Object.hasOwnProperty.call(m, 'polRound')) w.uint32(32).int32(m.polRound); + if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) + $root.tendermintV2.types.BlockID.encode(m.blockId, w.uint32(42).fork()).ldelim(); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(50).fork()).ldelim(); + if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(58).bytes(m.signature); + return w; + }; + Proposal.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Proposal(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.type = r.int32(); + break; + case 2: + m.height = r.int64(); + break; + case 3: + m.round = r.int32(); + break; + case 4: + m.polRound = r.int32(); + break; + case 5: + m.blockId = $root.tendermintV2.types.BlockID.decode(r, r.uint32()); + break; + case 6: + m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); + break; + case 7: + m.signature = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Proposal; + })(); + types.SignedHeader = (function () { + function SignedHeader(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + SignedHeader.prototype.header = null; + SignedHeader.prototype.commit = null; + SignedHeader.create = function create(properties) { + return new SignedHeader(properties); + }; + SignedHeader.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.header != null && Object.hasOwnProperty.call(m, 'header')) + $root.tendermintV2.types.Header.encode(m.header, w.uint32(10).fork()).ldelim(); + if (m.commit != null && Object.hasOwnProperty.call(m, 'commit')) + $root.tendermintV2.types.Commit.encode(m.commit, w.uint32(18).fork()).ldelim(); + return w; + }; + SignedHeader.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.SignedHeader(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.header = $root.tendermintV2.types.Header.decode(r, r.uint32()); + break; + case 2: + m.commit = $root.tendermintV2.types.Commit.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return SignedHeader; + })(); + types.LightBlock = (function () { + function LightBlock(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + LightBlock.prototype.signedHeader = null; + LightBlock.prototype.validatorSet = null; + LightBlock.create = function create(properties) { + return new LightBlock(properties); + }; + LightBlock.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.signedHeader != null && Object.hasOwnProperty.call(m, 'signedHeader')) + $root.tendermintV2.types.SignedHeader.encode(m.signedHeader, w.uint32(10).fork()).ldelim(); + if (m.validatorSet != null && Object.hasOwnProperty.call(m, 'validatorSet')) + $root.tendermintV2.types.ValidatorSet.encode(m.validatorSet, w.uint32(18).fork()).ldelim(); + return w; + }; + LightBlock.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.LightBlock(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.signedHeader = $root.tendermintV2.types.SignedHeader.decode(r, r.uint32()); + break; + case 2: + m.validatorSet = $root.tendermintV2.types.ValidatorSet.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return LightBlock; + })(); + types.BlockMeta = (function () { + function BlockMeta(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + BlockMeta.prototype.blockId = null; + BlockMeta.prototype.blockSize = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + BlockMeta.prototype.header = null; + BlockMeta.prototype.numTxs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + BlockMeta.create = function create(properties) { + return new BlockMeta(properties); + }; + BlockMeta.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) + $root.tendermintV2.types.BlockID.encode(m.blockId, w.uint32(10).fork()).ldelim(); + if (m.blockSize != null && Object.hasOwnProperty.call(m, 'blockSize')) w.uint32(16).int64(m.blockSize); + if (m.header != null && Object.hasOwnProperty.call(m, 'header')) + $root.tendermintV2.types.Header.encode(m.header, w.uint32(26).fork()).ldelim(); + if (m.numTxs != null && Object.hasOwnProperty.call(m, 'numTxs')) w.uint32(32).int64(m.numTxs); + return w; + }; + BlockMeta.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.BlockMeta(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.blockId = $root.tendermintV2.types.BlockID.decode(r, r.uint32()); + break; + case 2: + m.blockSize = r.int64(); + break; + case 3: + m.header = $root.tendermintV2.types.Header.decode(r, r.uint32()); + break; + case 4: + m.numTxs = r.int64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return BlockMeta; + })(); + types.TxProof = (function () { + function TxProof(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + TxProof.prototype.rootHash = $util.newBuffer([]); + TxProof.prototype.data = $util.newBuffer([]); + TxProof.prototype.proof = null; + TxProof.create = function create(properties) { + return new TxProof(properties); + }; + TxProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.rootHash != null && Object.hasOwnProperty.call(m, 'rootHash')) w.uint32(10).bytes(m.rootHash); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(18).bytes(m.data); + if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) + $root.tendermintV2.crypto.Proof.encode(m.proof, w.uint32(26).fork()).ldelim(); + return w; + }; + TxProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.TxProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.rootHash = r.bytes(); + break; + case 2: + m.data = r.bytes(); + break; + case 3: + m.proof = $root.tendermintV2.crypto.Proof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return TxProof; + })(); + types.ValidatorSet = (function () { + function ValidatorSet(p) { + this.validators = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ValidatorSet.prototype.validators = $util.emptyArray; + ValidatorSet.prototype.proposer = null; + ValidatorSet.prototype.totalVotingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + ValidatorSet.create = function create(properties) { + return new ValidatorSet(properties); + }; + ValidatorSet.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.validators != null && m.validators.length) { + for (var i = 0; i < m.validators.length; ++i) + $root.tendermintV2.types.Validator.encode(m.validators[i], w.uint32(10).fork()).ldelim(); + } + if (m.proposer != null && Object.hasOwnProperty.call(m, 'proposer')) + $root.tendermintV2.types.Validator.encode(m.proposer, w.uint32(18).fork()).ldelim(); + if (m.totalVotingPower != null && Object.hasOwnProperty.call(m, 'totalVotingPower')) + w.uint32(24).int64(m.totalVotingPower); + return w; + }; + ValidatorSet.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.ValidatorSet(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.validators && m.validators.length)) m.validators = []; + m.validators.push($root.tendermintV2.types.Validator.decode(r, r.uint32())); + break; + case 2: + m.proposer = $root.tendermintV2.types.Validator.decode(r, r.uint32()); + break; + case 3: + m.totalVotingPower = r.int64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ValidatorSet; + })(); + types.Validator = (function () { + function Validator(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Validator.prototype.address = $util.newBuffer([]); + Validator.prototype.pubKey = null; + Validator.prototype.votingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Validator.prototype.proposerPriority = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Validator.create = function create(properties) { + return new Validator(properties); + }; + Validator.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.address != null && Object.hasOwnProperty.call(m, 'address')) w.uint32(10).bytes(m.address); + if (m.pubKey != null && Object.hasOwnProperty.call(m, 'pubKey')) + $root.tendermintV2.crypto.PublicKey.encode(m.pubKey, w.uint32(18).fork()).ldelim(); + if (m.votingPower != null && Object.hasOwnProperty.call(m, 'votingPower')) + w.uint32(24).int64(m.votingPower); + if (m.proposerPriority != null && Object.hasOwnProperty.call(m, 'proposerPriority')) + w.uint32(32).int64(m.proposerPriority); + return w; + }; + Validator.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.Validator(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.address = r.bytes(); + break; + case 2: + m.pubKey = $root.tendermintV2.crypto.PublicKey.decode(r, r.uint32()); + break; + case 3: + m.votingPower = r.int64(); + break; + case 4: + m.proposerPriority = r.int64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Validator; + })(); + types.SimpleValidator = (function () { + function SimpleValidator(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + SimpleValidator.prototype.pubKey = null; + SimpleValidator.prototype.votingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + SimpleValidator.create = function create(properties) { + return new SimpleValidator(properties); + }; + SimpleValidator.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.pubKey != null && Object.hasOwnProperty.call(m, 'pubKey')) + $root.tendermintV2.crypto.PublicKey.encode(m.pubKey, w.uint32(10).fork()).ldelim(); + if (m.votingPower != null && Object.hasOwnProperty.call(m, 'votingPower')) + w.uint32(16).int64(m.votingPower); + return w; + }; + SimpleValidator.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.types.SimpleValidator(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.pubKey = $root.tendermintV2.crypto.PublicKey.decode(r, r.uint32()); + break; + case 2: + m.votingPower = r.int64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return SimpleValidator; + })(); + return types; + })(); + tendermintV2.crypto = (function () { + const crypto = {}; + crypto.Proof = (function () { + function Proof(p) { + this.aunts = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Proof.prototype.total = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Proof.prototype.index = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; + Proof.prototype.leafHash = $util.newBuffer([]); + Proof.prototype.aunts = $util.emptyArray; + Proof.create = function create(properties) { + return new Proof(properties); + }; + Proof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.total != null && Object.hasOwnProperty.call(m, 'total')) w.uint32(8).int64(m.total); + if (m.index != null && Object.hasOwnProperty.call(m, 'index')) w.uint32(16).int64(m.index); + if (m.leafHash != null && Object.hasOwnProperty.call(m, 'leafHash')) w.uint32(26).bytes(m.leafHash); + if (m.aunts != null && m.aunts.length) { + for (var i = 0; i < m.aunts.length; ++i) w.uint32(34).bytes(m.aunts[i]); + } + return w; + }; + Proof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.Proof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.total = r.int64(); + break; + case 2: + m.index = r.int64(); + break; + case 3: + m.leafHash = r.bytes(); + break; + case 4: + if (!(m.aunts && m.aunts.length)) m.aunts = []; + m.aunts.push(r.bytes()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Proof; + })(); + crypto.ValueOp = (function () { + function ValueOp(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ValueOp.prototype.key = $util.newBuffer([]); + ValueOp.prototype.proof = null; + ValueOp.create = function create(properties) { + return new ValueOp(properties); + }; + ValueOp.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); + if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) + $root.tendermintV2.crypto.Proof.encode(m.proof, w.uint32(18).fork()).ldelim(); + return w; + }; + ValueOp.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.ValueOp(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.bytes(); + break; + case 2: + m.proof = $root.tendermintV2.crypto.Proof.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ValueOp; + })(); + crypto.DominoOp = (function () { + function DominoOp(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + DominoOp.prototype.key = ''; + DominoOp.prototype.input = ''; + DominoOp.prototype.output = ''; + DominoOp.create = function create(properties) { + return new DominoOp(properties); + }; + DominoOp.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).string(m.key); + if (m.input != null && Object.hasOwnProperty.call(m, 'input')) w.uint32(18).string(m.input); + if (m.output != null && Object.hasOwnProperty.call(m, 'output')) w.uint32(26).string(m.output); + return w; + }; + DominoOp.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.DominoOp(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.key = r.string(); + break; + case 2: + m.input = r.string(); + break; + case 3: + m.output = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return DominoOp; + })(); + crypto.ProofOp = (function () { + function ProofOp(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ProofOp.prototype.type = ''; + ProofOp.prototype.key = $util.newBuffer([]); + ProofOp.prototype.data = $util.newBuffer([]); + ProofOp.create = function create(properties) { + return new ProofOp(properties); + }; + ProofOp.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(10).string(m.type); + if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(18).bytes(m.key); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(26).bytes(m.data); + return w; + }; + ProofOp.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.ProofOp(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.type = r.string(); + break; + case 2: + m.key = r.bytes(); + break; + case 3: + m.data = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ProofOp; + })(); + crypto.ProofOps = (function () { + function ProofOps(p) { + this.ops = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ProofOps.prototype.ops = $util.emptyArray; + ProofOps.create = function create(properties) { + return new ProofOps(properties); + }; + ProofOps.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.ops != null && m.ops.length) { + for (var i = 0; i < m.ops.length; ++i) + $root.tendermintV2.crypto.ProofOp.encode(m.ops[i], w.uint32(10).fork()).ldelim(); + } + return w; + }; + ProofOps.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.ProofOps(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.ops && m.ops.length)) m.ops = []; + m.ops.push($root.tendermintV2.crypto.ProofOp.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ProofOps; + })(); + crypto.PublicKey = (function () { + function PublicKey(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + PublicKey.prototype.ed25519 = $util.newBuffer([]); + PublicKey.prototype.secp256k1 = $util.newBuffer([]); + let $oneOfFields; + Object.defineProperty(PublicKey.prototype, 'sum', { + get: $util.oneOfGetter(($oneOfFields = ['ed25519', 'secp256k1'])), + set: $util.oneOfSetter($oneOfFields), + }); + PublicKey.create = function create(properties) { + return new PublicKey(properties); + }; + PublicKey.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.ed25519 != null && Object.hasOwnProperty.call(m, 'ed25519')) w.uint32(10).bytes(m.ed25519); + if (m.secp256k1 != null && Object.hasOwnProperty.call(m, 'secp256k1')) w.uint32(18).bytes(m.secp256k1); + return w; + }; + PublicKey.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.crypto.PublicKey(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.ed25519 = r.bytes(); + break; + case 2: + m.secp256k1 = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PublicKey; + })(); + return crypto; + })(); + tendermintV2.version = (function () { + const version = {}; + version.App = (function () { + function App(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + App.prototype.protocol = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + App.prototype.software = ''; + App.create = function create(properties) { + return new App(properties); + }; + App.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.protocol != null && Object.hasOwnProperty.call(m, 'protocol')) w.uint32(8).uint64(m.protocol); + if (m.software != null && Object.hasOwnProperty.call(m, 'software')) w.uint32(18).string(m.software); + return w; + }; + App.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.version.App(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.protocol = r.uint64(); + break; + case 2: + m.software = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return App; + })(); + version.Consensus = (function () { + function Consensus(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Consensus.prototype.block = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Consensus.prototype.app = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Consensus.create = function create(properties) { + return new Consensus(properties); + }; + Consensus.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.block != null && Object.hasOwnProperty.call(m, 'block')) w.uint32(8).uint64(m.block); + if (m.app != null && Object.hasOwnProperty.call(m, 'app')) w.uint32(16).uint64(m.app); + return w; + }; + Consensus.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.tendermintV2.version.Consensus(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.block = r.uint64(); + break; + case 2: + m.app = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Consensus; + })(); + return version; + })(); + return tendermintV2; +})(); +exports.ibc = $root.ibc = (() => { + const ibc = {}; + ibc.core = (function () { + const core = {}; + core.commitment = (function () { + const commitment = {}; + commitment.v1 = (function () { + const v1 = {}; + v1.MerkleRoot = (function () { + function MerkleRoot(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MerkleRoot.prototype.hash = $util.newBuffer([]); + MerkleRoot.create = function create(properties) { + return new MerkleRoot(properties); + }; + MerkleRoot.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(10).bytes(m.hash); + return w; + }; + MerkleRoot.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.commitment.v1.MerkleRoot(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.hash = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MerkleRoot; + })(); + v1.MerklePrefix = (function () { + function MerklePrefix(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MerklePrefix.prototype.keyPrefix = $util.newBuffer([]); + MerklePrefix.create = function create(properties) { + return new MerklePrefix(properties); + }; + MerklePrefix.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.keyPrefix != null && Object.hasOwnProperty.call(m, 'keyPrefix')) + w.uint32(10).bytes(m.keyPrefix); + return w; + }; + MerklePrefix.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.commitment.v1.MerklePrefix(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.keyPrefix = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MerklePrefix; + })(); + v1.MerklePath = (function () { + function MerklePath(p) { + this.keyPath = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MerklePath.prototype.keyPath = $util.emptyArray; + MerklePath.create = function create(properties) { + return new MerklePath(properties); + }; + MerklePath.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.keyPath != null && m.keyPath.length) { + for (var i = 0; i < m.keyPath.length; ++i) w.uint32(10).string(m.keyPath[i]); + } + return w; + }; + MerklePath.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.commitment.v1.MerklePath(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.keyPath && m.keyPath.length)) m.keyPath = []; + m.keyPath.push(r.string()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MerklePath; + })(); + v1.MerkleProof = (function () { + function MerkleProof(p) { + this.proofs = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MerkleProof.prototype.proofs = $util.emptyArray; + MerkleProof.create = function create(properties) { + return new MerkleProof(properties); + }; + MerkleProof.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.proofs != null && m.proofs.length) { + for (var i = 0; i < m.proofs.length; ++i) + $root.ics23.CommitmentProof.encode(m.proofs[i], w.uint32(10).fork()).ldelim(); + } + return w; + }; + MerkleProof.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.commitment.v1.MerkleProof(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.proofs && m.proofs.length)) m.proofs = []; + m.proofs.push($root.ics23.CommitmentProof.decode(r, r.uint32())); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MerkleProof; + })(); + return v1; + })(); + return commitment; + })(); + core.channel = (function () { + const channel = {}; + channel.v1 = (function () { + const v1 = {}; + v1.Msg = (function () { + function Msg(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; + Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + Object.defineProperty( + (Msg.prototype.channelOpenInit = function channelOpenInit(request, callback) { + return this.rpcCall( + channelOpenInit, + $root.ibc.core.channel.v1.MsgChannelOpenInit, + $root.ibc.core.channel.v1.MsgChannelOpenInitResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelOpenInit' }, + ); + Object.defineProperty( + (Msg.prototype.channelOpenTry = function channelOpenTry(request, callback) { + return this.rpcCall( + channelOpenTry, + $root.ibc.core.channel.v1.MsgChannelOpenTry, + $root.ibc.core.channel.v1.MsgChannelOpenTryResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelOpenTry' }, + ); + Object.defineProperty( + (Msg.prototype.channelOpenAck = function channelOpenAck(request, callback) { + return this.rpcCall( + channelOpenAck, + $root.ibc.core.channel.v1.MsgChannelOpenAck, + $root.ibc.core.channel.v1.MsgChannelOpenAckResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelOpenAck' }, + ); + Object.defineProperty( + (Msg.prototype.channelOpenConfirm = function channelOpenConfirm(request, callback) { + return this.rpcCall( + channelOpenConfirm, + $root.ibc.core.channel.v1.MsgChannelOpenConfirm, + $root.ibc.core.channel.v1.MsgChannelOpenConfirmResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelOpenConfirm' }, + ); + Object.defineProperty( + (Msg.prototype.channelCloseInit = function channelCloseInit(request, callback) { + return this.rpcCall( + channelCloseInit, + $root.ibc.core.channel.v1.MsgChannelCloseInit, + $root.ibc.core.channel.v1.MsgChannelCloseInitResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelCloseInit' }, + ); + Object.defineProperty( + (Msg.prototype.channelCloseConfirm = function channelCloseConfirm(request, callback) { + return this.rpcCall( + channelCloseConfirm, + $root.ibc.core.channel.v1.MsgChannelCloseConfirm, + $root.ibc.core.channel.v1.MsgChannelCloseConfirmResponse, + request, + callback, + ); + }), + 'name', + { value: 'ChannelCloseConfirm' }, + ); + Object.defineProperty( + (Msg.prototype.recvPacket = function recvPacket(request, callback) { + return this.rpcCall( + recvPacket, + $root.ibc.core.channel.v1.MsgRecvPacket, + $root.ibc.core.channel.v1.MsgRecvPacketResponse, + request, + callback, + ); + }), + 'name', + { value: 'RecvPacket' }, + ); + Object.defineProperty( + (Msg.prototype.timeout = function timeout(request, callback) { + return this.rpcCall( + timeout, + $root.ibc.core.channel.v1.MsgTimeout, + $root.ibc.core.channel.v1.MsgTimeoutResponse, + request, + callback, + ); + }), + 'name', + { value: 'Timeout' }, + ); + Object.defineProperty( + (Msg.prototype.timeoutOnClose = function timeoutOnClose(request, callback) { + return this.rpcCall( + timeoutOnClose, + $root.ibc.core.channel.v1.MsgTimeoutOnClose, + $root.ibc.core.channel.v1.MsgTimeoutOnCloseResponse, + request, + callback, + ); + }), + 'name', + { value: 'TimeoutOnClose' }, + ); + Object.defineProperty( + (Msg.prototype.acknowledgement = function acknowledgement(request, callback) { + return this.rpcCall( + acknowledgement, + $root.ibc.core.channel.v1.MsgAcknowledgement, + $root.ibc.core.channel.v1.MsgAcknowledgementResponse, + request, + callback, + ); + }), + 'name', + { value: 'Acknowledgement' }, + ); + return Msg; + })(); + v1.MsgChannelOpenInit = (function () { + function MsgChannelOpenInit(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenInit.prototype.portId = ''; + MsgChannelOpenInit.prototype.channel = null; + MsgChannelOpenInit.prototype.signer = ''; + MsgChannelOpenInit.create = function create(properties) { + return new MsgChannelOpenInit(properties); + }; + MsgChannelOpenInit.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channel != null && Object.hasOwnProperty.call(m, 'channel')) + $root.ibc.core.channel.v1.Channel.encode(m.channel, w.uint32(18).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + return w; + }; + MsgChannelOpenInit.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenInit(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channel = $root.ibc.core.channel.v1.Channel.decode(r, r.uint32()); + break; + case 3: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenInit; + })(); + v1.MsgChannelOpenInitResponse = (function () { + function MsgChannelOpenInitResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenInitResponse.create = function create(properties) { + return new MsgChannelOpenInitResponse(properties); + }; + MsgChannelOpenInitResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelOpenInitResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenInitResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenInitResponse; + })(); + v1.MsgChannelOpenTry = (function () { + function MsgChannelOpenTry(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenTry.prototype.portId = ''; + MsgChannelOpenTry.prototype.previousChannelId = ''; + MsgChannelOpenTry.prototype.channel = null; + MsgChannelOpenTry.prototype.counterpartyVersion = ''; + MsgChannelOpenTry.prototype.proofInit = $util.newBuffer([]); + MsgChannelOpenTry.prototype.proofHeight = null; + MsgChannelOpenTry.prototype.signer = ''; + MsgChannelOpenTry.create = function create(properties) { + return new MsgChannelOpenTry(properties); + }; + MsgChannelOpenTry.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.previousChannelId != null && Object.hasOwnProperty.call(m, 'previousChannelId')) + w.uint32(18).string(m.previousChannelId); + if (m.channel != null && Object.hasOwnProperty.call(m, 'channel')) + $root.ibc.core.channel.v1.Channel.encode(m.channel, w.uint32(26).fork()).ldelim(); + if (m.counterpartyVersion != null && Object.hasOwnProperty.call(m, 'counterpartyVersion')) + w.uint32(34).string(m.counterpartyVersion); + if (m.proofInit != null && Object.hasOwnProperty.call(m, 'proofInit')) + w.uint32(42).bytes(m.proofInit); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(50).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(58).string(m.signer); + return w; + }; + MsgChannelOpenTry.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenTry(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.previousChannelId = r.string(); + break; + case 3: + m.channel = $root.ibc.core.channel.v1.Channel.decode(r, r.uint32()); + break; + case 4: + m.counterpartyVersion = r.string(); + break; + case 5: + m.proofInit = r.bytes(); + break; + case 6: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 7: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenTry; + })(); + v1.MsgChannelOpenTryResponse = (function () { + function MsgChannelOpenTryResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenTryResponse.create = function create(properties) { + return new MsgChannelOpenTryResponse(properties); + }; + MsgChannelOpenTryResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelOpenTryResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenTryResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenTryResponse; + })(); + v1.MsgChannelOpenAck = (function () { + function MsgChannelOpenAck(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenAck.prototype.portId = ''; + MsgChannelOpenAck.prototype.channelId = ''; + MsgChannelOpenAck.prototype.counterpartyChannelId = ''; + MsgChannelOpenAck.prototype.counterpartyVersion = ''; + MsgChannelOpenAck.prototype.proofTry = $util.newBuffer([]); + MsgChannelOpenAck.prototype.proofHeight = null; + MsgChannelOpenAck.prototype.signer = ''; + MsgChannelOpenAck.create = function create(properties) { + return new MsgChannelOpenAck(properties); + }; + MsgChannelOpenAck.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + if (m.counterpartyChannelId != null && Object.hasOwnProperty.call(m, 'counterpartyChannelId')) + w.uint32(26).string(m.counterpartyChannelId); + if (m.counterpartyVersion != null && Object.hasOwnProperty.call(m, 'counterpartyVersion')) + w.uint32(34).string(m.counterpartyVersion); + if (m.proofTry != null && Object.hasOwnProperty.call(m, 'proofTry')) + w.uint32(42).bytes(m.proofTry); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(50).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(58).string(m.signer); + return w; + }; + MsgChannelOpenAck.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenAck(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + case 3: + m.counterpartyChannelId = r.string(); + break; + case 4: + m.counterpartyVersion = r.string(); + break; + case 5: + m.proofTry = r.bytes(); + break; + case 6: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 7: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenAck; + })(); + v1.MsgChannelOpenAckResponse = (function () { + function MsgChannelOpenAckResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenAckResponse.create = function create(properties) { + return new MsgChannelOpenAckResponse(properties); + }; + MsgChannelOpenAckResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelOpenAckResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenAckResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenAckResponse; + })(); + v1.MsgChannelOpenConfirm = (function () { + function MsgChannelOpenConfirm(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenConfirm.prototype.portId = ''; + MsgChannelOpenConfirm.prototype.channelId = ''; + MsgChannelOpenConfirm.prototype.proofAck = $util.newBuffer([]); + MsgChannelOpenConfirm.prototype.proofHeight = null; + MsgChannelOpenConfirm.prototype.signer = ''; + MsgChannelOpenConfirm.create = function create(properties) { + return new MsgChannelOpenConfirm(properties); + }; + MsgChannelOpenConfirm.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + if (m.proofAck != null && Object.hasOwnProperty.call(m, 'proofAck')) + w.uint32(26).bytes(m.proofAck); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(34).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(42).string(m.signer); + return w; + }; + MsgChannelOpenConfirm.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenConfirm(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + case 3: + m.proofAck = r.bytes(); + break; + case 4: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 5: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenConfirm; + })(); + v1.MsgChannelOpenConfirmResponse = (function () { + function MsgChannelOpenConfirmResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelOpenConfirmResponse.create = function create(properties) { + return new MsgChannelOpenConfirmResponse(properties); + }; + MsgChannelOpenConfirmResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelOpenConfirmResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelOpenConfirmResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelOpenConfirmResponse; + })(); + v1.MsgChannelCloseInit = (function () { + function MsgChannelCloseInit(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelCloseInit.prototype.portId = ''; + MsgChannelCloseInit.prototype.channelId = ''; + MsgChannelCloseInit.prototype.signer = ''; + MsgChannelCloseInit.create = function create(properties) { + return new MsgChannelCloseInit(properties); + }; + MsgChannelCloseInit.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + return w; + }; + MsgChannelCloseInit.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelCloseInit(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + case 3: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelCloseInit; + })(); + v1.MsgChannelCloseInitResponse = (function () { + function MsgChannelCloseInitResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelCloseInitResponse.create = function create(properties) { + return new MsgChannelCloseInitResponse(properties); + }; + MsgChannelCloseInitResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelCloseInitResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelCloseInitResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelCloseInitResponse; + })(); + v1.MsgChannelCloseConfirm = (function () { + function MsgChannelCloseConfirm(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelCloseConfirm.prototype.portId = ''; + MsgChannelCloseConfirm.prototype.channelId = ''; + MsgChannelCloseConfirm.prototype.proofInit = $util.newBuffer([]); + MsgChannelCloseConfirm.prototype.proofHeight = null; + MsgChannelCloseConfirm.prototype.signer = ''; + MsgChannelCloseConfirm.create = function create(properties) { + return new MsgChannelCloseConfirm(properties); + }; + MsgChannelCloseConfirm.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + if (m.proofInit != null && Object.hasOwnProperty.call(m, 'proofInit')) + w.uint32(26).bytes(m.proofInit); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(34).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(42).string(m.signer); + return w; + }; + MsgChannelCloseConfirm.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelCloseConfirm(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + case 3: + m.proofInit = r.bytes(); + break; + case 4: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 5: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelCloseConfirm; + })(); + v1.MsgChannelCloseConfirmResponse = (function () { + function MsgChannelCloseConfirmResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgChannelCloseConfirmResponse.create = function create(properties) { + return new MsgChannelCloseConfirmResponse(properties); + }; + MsgChannelCloseConfirmResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgChannelCloseConfirmResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgChannelCloseConfirmResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgChannelCloseConfirmResponse; + })(); + v1.MsgRecvPacket = (function () { + function MsgRecvPacket(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgRecvPacket.prototype.packet = null; + MsgRecvPacket.prototype.proofCommitment = $util.newBuffer([]); + MsgRecvPacket.prototype.proofHeight = null; + MsgRecvPacket.prototype.signer = ''; + MsgRecvPacket.create = function create(properties) { + return new MsgRecvPacket(properties); + }; + MsgRecvPacket.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.packet != null && Object.hasOwnProperty.call(m, 'packet')) + $root.ibc.core.channel.v1.Packet.encode(m.packet, w.uint32(10).fork()).ldelim(); + if (m.proofCommitment != null && Object.hasOwnProperty.call(m, 'proofCommitment')) + w.uint32(18).bytes(m.proofCommitment); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(26).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(34).string(m.signer); + return w; + }; + MsgRecvPacket.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgRecvPacket(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.packet = $root.ibc.core.channel.v1.Packet.decode(r, r.uint32()); + break; + case 2: + m.proofCommitment = r.bytes(); + break; + case 3: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 4: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgRecvPacket; + })(); + v1.MsgRecvPacketResponse = (function () { + function MsgRecvPacketResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgRecvPacketResponse.create = function create(properties) { + return new MsgRecvPacketResponse(properties); + }; + MsgRecvPacketResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgRecvPacketResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgRecvPacketResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgRecvPacketResponse; + })(); + v1.MsgTimeout = (function () { + function MsgTimeout(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgTimeout.prototype.packet = null; + MsgTimeout.prototype.proofUnreceived = $util.newBuffer([]); + MsgTimeout.prototype.proofHeight = null; + MsgTimeout.prototype.nextSequenceRecv = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + MsgTimeout.prototype.signer = ''; + MsgTimeout.create = function create(properties) { + return new MsgTimeout(properties); + }; + MsgTimeout.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.packet != null && Object.hasOwnProperty.call(m, 'packet')) + $root.ibc.core.channel.v1.Packet.encode(m.packet, w.uint32(10).fork()).ldelim(); + if (m.proofUnreceived != null && Object.hasOwnProperty.call(m, 'proofUnreceived')) + w.uint32(18).bytes(m.proofUnreceived); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(26).fork()).ldelim(); + if (m.nextSequenceRecv != null && Object.hasOwnProperty.call(m, 'nextSequenceRecv')) + w.uint32(32).uint64(m.nextSequenceRecv); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(42).string(m.signer); + return w; + }; + MsgTimeout.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgTimeout(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.packet = $root.ibc.core.channel.v1.Packet.decode(r, r.uint32()); + break; + case 2: + m.proofUnreceived = r.bytes(); + break; + case 3: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 4: + m.nextSequenceRecv = r.uint64(); + break; + case 5: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTimeout; + })(); + v1.MsgTimeoutResponse = (function () { + function MsgTimeoutResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgTimeoutResponse.create = function create(properties) { + return new MsgTimeoutResponse(properties); + }; + MsgTimeoutResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgTimeoutResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgTimeoutResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTimeoutResponse; + })(); + v1.MsgTimeoutOnClose = (function () { + function MsgTimeoutOnClose(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgTimeoutOnClose.prototype.packet = null; + MsgTimeoutOnClose.prototype.proofUnreceived = $util.newBuffer([]); + MsgTimeoutOnClose.prototype.proofClose = $util.newBuffer([]); + MsgTimeoutOnClose.prototype.proofHeight = null; + MsgTimeoutOnClose.prototype.nextSequenceRecv = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + MsgTimeoutOnClose.prototype.signer = ''; + MsgTimeoutOnClose.create = function create(properties) { + return new MsgTimeoutOnClose(properties); + }; + MsgTimeoutOnClose.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.packet != null && Object.hasOwnProperty.call(m, 'packet')) + $root.ibc.core.channel.v1.Packet.encode(m.packet, w.uint32(10).fork()).ldelim(); + if (m.proofUnreceived != null && Object.hasOwnProperty.call(m, 'proofUnreceived')) + w.uint32(18).bytes(m.proofUnreceived); + if (m.proofClose != null && Object.hasOwnProperty.call(m, 'proofClose')) + w.uint32(26).bytes(m.proofClose); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(34).fork()).ldelim(); + if (m.nextSequenceRecv != null && Object.hasOwnProperty.call(m, 'nextSequenceRecv')) + w.uint32(40).uint64(m.nextSequenceRecv); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(50).string(m.signer); + return w; + }; + MsgTimeoutOnClose.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgTimeoutOnClose(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.packet = $root.ibc.core.channel.v1.Packet.decode(r, r.uint32()); + break; + case 2: + m.proofUnreceived = r.bytes(); + break; + case 3: + m.proofClose = r.bytes(); + break; + case 4: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 5: + m.nextSequenceRecv = r.uint64(); + break; + case 6: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTimeoutOnClose; + })(); + v1.MsgTimeoutOnCloseResponse = (function () { + function MsgTimeoutOnCloseResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgTimeoutOnCloseResponse.create = function create(properties) { + return new MsgTimeoutOnCloseResponse(properties); + }; + MsgTimeoutOnCloseResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgTimeoutOnCloseResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgTimeoutOnCloseResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTimeoutOnCloseResponse; + })(); + v1.MsgAcknowledgement = (function () { + function MsgAcknowledgement(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgAcknowledgement.prototype.packet = null; + MsgAcknowledgement.prototype.acknowledgement = $util.newBuffer([]); + MsgAcknowledgement.prototype.proofAcked = $util.newBuffer([]); + MsgAcknowledgement.prototype.proofHeight = null; + MsgAcknowledgement.prototype.signer = ''; + MsgAcknowledgement.create = function create(properties) { + return new MsgAcknowledgement(properties); + }; + MsgAcknowledgement.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.packet != null && Object.hasOwnProperty.call(m, 'packet')) + $root.ibc.core.channel.v1.Packet.encode(m.packet, w.uint32(10).fork()).ldelim(); + if (m.acknowledgement != null && Object.hasOwnProperty.call(m, 'acknowledgement')) + w.uint32(18).bytes(m.acknowledgement); + if (m.proofAcked != null && Object.hasOwnProperty.call(m, 'proofAcked')) + w.uint32(26).bytes(m.proofAcked); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(34).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(42).string(m.signer); + return w; + }; + MsgAcknowledgement.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgAcknowledgement(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.packet = $root.ibc.core.channel.v1.Packet.decode(r, r.uint32()); + break; + case 2: + m.acknowledgement = r.bytes(); + break; + case 3: + m.proofAcked = r.bytes(); + break; + case 4: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 5: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgAcknowledgement; + })(); + v1.MsgAcknowledgementResponse = (function () { + function MsgAcknowledgementResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgAcknowledgementResponse.create = function create(properties) { + return new MsgAcknowledgementResponse(properties); + }; + MsgAcknowledgementResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgAcknowledgementResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.MsgAcknowledgementResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgAcknowledgementResponse; + })(); + v1.Channel = (function () { + function Channel(p) { + this.connectionHops = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Channel.prototype.state = 0; + Channel.prototype.ordering = 0; + Channel.prototype.counterparty = null; + Channel.prototype.connectionHops = $util.emptyArray; + Channel.prototype.version = ''; + Channel.create = function create(properties) { + return new Channel(properties); + }; + Channel.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.state != null && Object.hasOwnProperty.call(m, 'state')) w.uint32(8).int32(m.state); + if (m.ordering != null && Object.hasOwnProperty.call(m, 'ordering')) + w.uint32(16).int32(m.ordering); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.channel.v1.Counterparty.encode(m.counterparty, w.uint32(26).fork()).ldelim(); + if (m.connectionHops != null && m.connectionHops.length) { + for (var i = 0; i < m.connectionHops.length; ++i) w.uint32(34).string(m.connectionHops[i]); + } + if (m.version != null && Object.hasOwnProperty.call(m, 'version')) + w.uint32(42).string(m.version); + return w; + }; + Channel.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.Channel(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.state = r.int32(); + break; + case 2: + m.ordering = r.int32(); + break; + case 3: + m.counterparty = $root.ibc.core.channel.v1.Counterparty.decode(r, r.uint32()); + break; + case 4: + if (!(m.connectionHops && m.connectionHops.length)) m.connectionHops = []; + m.connectionHops.push(r.string()); + break; + case 5: + m.version = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Channel; + })(); + v1.IdentifiedChannel = (function () { + function IdentifiedChannel(p) { + this.connectionHops = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + IdentifiedChannel.prototype.state = 0; + IdentifiedChannel.prototype.ordering = 0; + IdentifiedChannel.prototype.counterparty = null; + IdentifiedChannel.prototype.connectionHops = $util.emptyArray; + IdentifiedChannel.prototype.version = ''; + IdentifiedChannel.prototype.portId = ''; + IdentifiedChannel.prototype.channelId = ''; + IdentifiedChannel.create = function create(properties) { + return new IdentifiedChannel(properties); + }; + IdentifiedChannel.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.state != null && Object.hasOwnProperty.call(m, 'state')) w.uint32(8).int32(m.state); + if (m.ordering != null && Object.hasOwnProperty.call(m, 'ordering')) + w.uint32(16).int32(m.ordering); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.channel.v1.Counterparty.encode(m.counterparty, w.uint32(26).fork()).ldelim(); + if (m.connectionHops != null && m.connectionHops.length) { + for (var i = 0; i < m.connectionHops.length; ++i) w.uint32(34).string(m.connectionHops[i]); + } + if (m.version != null && Object.hasOwnProperty.call(m, 'version')) + w.uint32(42).string(m.version); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(50).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(58).string(m.channelId); + return w; + }; + IdentifiedChannel.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.IdentifiedChannel(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.state = r.int32(); + break; + case 2: + m.ordering = r.int32(); + break; + case 3: + m.counterparty = $root.ibc.core.channel.v1.Counterparty.decode(r, r.uint32()); + break; + case 4: + if (!(m.connectionHops && m.connectionHops.length)) m.connectionHops = []; + m.connectionHops.push(r.string()); + break; + case 5: + m.version = r.string(); + break; + case 6: + m.portId = r.string(); + break; + case 7: + m.channelId = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return IdentifiedChannel; + })(); + v1.State = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'STATE_UNINITIALIZED_UNSPECIFIED')] = 0; + values[(valuesById[1] = 'STATE_INIT')] = 1; + values[(valuesById[2] = 'STATE_TRYOPEN')] = 2; + values[(valuesById[3] = 'STATE_OPEN')] = 3; + values[(valuesById[4] = 'STATE_CLOSED')] = 4; + return values; + })(); + v1.Order = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'ORDER_NONE_UNSPECIFIED')] = 0; + values[(valuesById[1] = 'ORDER_UNORDERED')] = 1; + values[(valuesById[2] = 'ORDER_ORDERED')] = 2; + return values; + })(); + v1.Counterparty = (function () { + function Counterparty(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Counterparty.prototype.portId = ''; + Counterparty.prototype.channelId = ''; + Counterparty.create = function create(properties) { + return new Counterparty(properties); + }; + Counterparty.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + return w; + }; + Counterparty.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.Counterparty(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Counterparty; + })(); + v1.Packet = (function () { + function Packet(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Packet.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Packet.prototype.sourcePort = ''; + Packet.prototype.sourceChannel = ''; + Packet.prototype.destinationPort = ''; + Packet.prototype.destinationChannel = ''; + Packet.prototype.data = $util.newBuffer([]); + Packet.prototype.timeoutHeight = null; + Packet.prototype.timeoutTimestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Packet.create = function create(properties) { + return new Packet(properties); + }; + Packet.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(8).uint64(m.sequence); + if (m.sourcePort != null && Object.hasOwnProperty.call(m, 'sourcePort')) + w.uint32(18).string(m.sourcePort); + if (m.sourceChannel != null && Object.hasOwnProperty.call(m, 'sourceChannel')) + w.uint32(26).string(m.sourceChannel); + if (m.destinationPort != null && Object.hasOwnProperty.call(m, 'destinationPort')) + w.uint32(34).string(m.destinationPort); + if (m.destinationChannel != null && Object.hasOwnProperty.call(m, 'destinationChannel')) + w.uint32(42).string(m.destinationChannel); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(50).bytes(m.data); + if (m.timeoutHeight != null && Object.hasOwnProperty.call(m, 'timeoutHeight')) + $root.ibc.core.client.v1.Height.encode(m.timeoutHeight, w.uint32(58).fork()).ldelim(); + if (m.timeoutTimestamp != null && Object.hasOwnProperty.call(m, 'timeoutTimestamp')) + w.uint32(64).uint64(m.timeoutTimestamp); + return w; + }; + Packet.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.Packet(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.sequence = r.uint64(); + break; + case 2: + m.sourcePort = r.string(); + break; + case 3: + m.sourceChannel = r.string(); + break; + case 4: + m.destinationPort = r.string(); + break; + case 5: + m.destinationChannel = r.string(); + break; + case 6: + m.data = r.bytes(); + break; + case 7: + m.timeoutHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 8: + m.timeoutTimestamp = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Packet; + })(); + v1.PacketState = (function () { + function PacketState(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + PacketState.prototype.portId = ''; + PacketState.prototype.channelId = ''; + PacketState.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + PacketState.prototype.data = $util.newBuffer([]); + PacketState.create = function create(properties) { + return new PacketState(properties); + }; + PacketState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.portId != null && Object.hasOwnProperty.call(m, 'portId')) w.uint32(10).string(m.portId); + if (m.channelId != null && Object.hasOwnProperty.call(m, 'channelId')) + w.uint32(18).string(m.channelId); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(24).uint64(m.sequence); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(34).bytes(m.data); + return w; + }; + PacketState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.PacketState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.portId = r.string(); + break; + case 2: + m.channelId = r.string(); + break; + case 3: + m.sequence = r.uint64(); + break; + case 4: + m.data = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PacketState; + })(); + v1.Acknowledgement = (function () { + function Acknowledgement(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Acknowledgement.prototype.result = $util.newBuffer([]); + Acknowledgement.prototype.error = ''; + let $oneOfFields; + Object.defineProperty(Acknowledgement.prototype, 'response', { + get: $util.oneOfGetter(($oneOfFields = ['result', 'error'])), + set: $util.oneOfSetter($oneOfFields), + }); + Acknowledgement.create = function create(properties) { + return new Acknowledgement(properties); + }; + Acknowledgement.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.result != null && Object.hasOwnProperty.call(m, 'result')) w.uint32(170).bytes(m.result); + if (m.error != null && Object.hasOwnProperty.call(m, 'error')) w.uint32(178).string(m.error); + return w; + }; + Acknowledgement.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.channel.v1.Acknowledgement(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 21: + m.result = r.bytes(); + break; + case 22: + m.error = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Acknowledgement; + })(); + return v1; + })(); + return channel; + })(); + core.client = (function () { + const client = {}; + client.v1 = (function () { + const v1 = {}; + v1.Msg = (function () { + function Msg(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; + Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + Object.defineProperty( + (Msg.prototype.createClient = function createClient(request, callback) { + return this.rpcCall( + createClient, + $root.ibc.core.client.v1.MsgCreateClient, + $root.ibc.core.client.v1.MsgCreateClientResponse, + request, + callback, + ); + }), + 'name', + { value: 'CreateClient' }, + ); + Object.defineProperty( (Msg.prototype.updateClient = function updateClient(request, callback) { return this.rpcCall( updateClient, @@ -5411,43 +8840,400 @@ exports.ibc = $root.ibc = (() => { ); return Msg; })(); - v1.MsgCreateClient = (function () { - function MsgCreateClient(p) { + v1.MsgCreateClient = (function () { + function MsgCreateClient(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgCreateClient.prototype.clientState = null; + MsgCreateClient.prototype.consensusState = null; + MsgCreateClient.prototype.signer = ''; + MsgCreateClient.create = function create(properties) { + return new MsgCreateClient(properties); + }; + MsgCreateClient.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) + $root.google.protobuf.Any.encode(m.clientState, w.uint32(10).fork()).ldelim(); + if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) + $root.google.protobuf.Any.encode(m.consensusState, w.uint32(18).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + return w; + }; + MsgCreateClient.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgCreateClient(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 2: + m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 3: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgCreateClient; + })(); + v1.MsgCreateClientResponse = (function () { + function MsgCreateClientResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgCreateClientResponse.create = function create(properties) { + return new MsgCreateClientResponse(properties); + }; + MsgCreateClientResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgCreateClientResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgCreateClientResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgCreateClientResponse; + })(); + v1.MsgUpdateClient = (function () { + function MsgUpdateClient(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUpdateClient.prototype.clientId = ''; + MsgUpdateClient.prototype.header = null; + MsgUpdateClient.prototype.signer = ''; + MsgUpdateClient.create = function create(properties) { + return new MsgUpdateClient(properties); + }; + MsgUpdateClient.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.header != null && Object.hasOwnProperty.call(m, 'header')) + $root.google.protobuf.Any.encode(m.header, w.uint32(18).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + return w; + }; + MsgUpdateClient.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgUpdateClient(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.header = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 3: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUpdateClient; + })(); + v1.MsgUpdateClientResponse = (function () { + function MsgUpdateClientResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUpdateClientResponse.create = function create(properties) { + return new MsgUpdateClientResponse(properties); + }; + MsgUpdateClientResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgUpdateClientResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgUpdateClientResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUpdateClientResponse; + })(); + v1.MsgUpgradeClient = (function () { + function MsgUpgradeClient(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUpgradeClient.prototype.clientId = ''; + MsgUpgradeClient.prototype.clientState = null; + MsgUpgradeClient.prototype.consensusState = null; + MsgUpgradeClient.prototype.proofUpgradeClient = $util.newBuffer([]); + MsgUpgradeClient.prototype.proofUpgradeConsensusState = $util.newBuffer([]); + MsgUpgradeClient.prototype.signer = ''; + MsgUpgradeClient.create = function create(properties) { + return new MsgUpgradeClient(properties); + }; + MsgUpgradeClient.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) + $root.google.protobuf.Any.encode(m.clientState, w.uint32(18).fork()).ldelim(); + if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) + $root.google.protobuf.Any.encode(m.consensusState, w.uint32(26).fork()).ldelim(); + if (m.proofUpgradeClient != null && Object.hasOwnProperty.call(m, 'proofUpgradeClient')) + w.uint32(34).bytes(m.proofUpgradeClient); + if ( + m.proofUpgradeConsensusState != null && + Object.hasOwnProperty.call(m, 'proofUpgradeConsensusState') + ) + w.uint32(42).bytes(m.proofUpgradeConsensusState); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(50).string(m.signer); + return w; + }; + MsgUpgradeClient.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgUpgradeClient(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 3: + m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 4: + m.proofUpgradeClient = r.bytes(); + break; + case 5: + m.proofUpgradeConsensusState = r.bytes(); + break; + case 6: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUpgradeClient; + })(); + v1.MsgUpgradeClientResponse = (function () { + function MsgUpgradeClientResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgUpgradeClientResponse.create = function create(properties) { + return new MsgUpgradeClientResponse(properties); + }; + MsgUpgradeClientResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgUpgradeClientResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgUpgradeClientResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgUpgradeClientResponse; + })(); + v1.MsgSubmitMisbehaviour = (function () { + function MsgSubmitMisbehaviour(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgSubmitMisbehaviour.prototype.clientId = ''; + MsgSubmitMisbehaviour.prototype.misbehaviour = null; + MsgSubmitMisbehaviour.prototype.signer = ''; + MsgSubmitMisbehaviour.create = function create(properties) { + return new MsgSubmitMisbehaviour(properties); + }; + MsgSubmitMisbehaviour.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.misbehaviour != null && Object.hasOwnProperty.call(m, 'misbehaviour')) + $root.google.protobuf.Any.encode(m.misbehaviour, w.uint32(18).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + return w; + }; + MsgSubmitMisbehaviour.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgSubmitMisbehaviour(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.misbehaviour = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 3: + m.signer = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgSubmitMisbehaviour; + })(); + v1.MsgSubmitMisbehaviourResponse = (function () { + function MsgSubmitMisbehaviourResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + MsgSubmitMisbehaviourResponse.create = function create(properties) { + return new MsgSubmitMisbehaviourResponse(properties); + }; + MsgSubmitMisbehaviourResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgSubmitMisbehaviourResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.MsgSubmitMisbehaviourResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgSubmitMisbehaviourResponse; + })(); + v1.IdentifiedClientState = (function () { + function IdentifiedClientState(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgCreateClient.prototype.clientState = null; - MsgCreateClient.prototype.consensusState = null; - MsgCreateClient.prototype.signer = ''; - MsgCreateClient.create = function create(properties) { - return new MsgCreateClient(properties); + IdentifiedClientState.prototype.clientId = ''; + IdentifiedClientState.prototype.clientState = null; + IdentifiedClientState.create = function create(properties) { + return new IdentifiedClientState(properties); }; - MsgCreateClient.encode = function encode(m, w) { + IdentifiedClientState.encode = function encode(m, w) { if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) - $root.google.protobuf.Any.encode(m.clientState, w.uint32(10).fork()).ldelim(); + $root.google.protobuf.Any.encode(m.clientState, w.uint32(18).fork()).ldelim(); + return w; + }; + IdentifiedClientState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.IdentifiedClientState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return IdentifiedClientState; + })(); + v1.ConsensusStateWithHeight = (function () { + function ConsensusStateWithHeight(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ConsensusStateWithHeight.prototype.height = null; + ConsensusStateWithHeight.prototype.consensusState = null; + ConsensusStateWithHeight.create = function create(properties) { + return new ConsensusStateWithHeight(properties); + }; + ConsensusStateWithHeight.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) + $root.ibc.core.client.v1.Height.encode(m.height, w.uint32(10).fork()).ldelim(); if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) $root.google.protobuf.Any.encode(m.consensusState, w.uint32(18).fork()).ldelim(); - if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); return w; }; - MsgCreateClient.decode = function decode(r, l) { + ConsensusStateWithHeight.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgCreateClient(); + m = new $root.ibc.core.client.v1.ConsensusStateWithHeight(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + m.height = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); break; case 2: m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); break; - case 3: - m.signer = r.string(); - break; default: r.skipType(t & 7); break; @@ -5455,28 +9241,49 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgCreateClient; + return ConsensusStateWithHeight; })(); - v1.MsgCreateClientResponse = (function () { - function MsgCreateClientResponse(p) { + v1.ClientConsensusStates = (function () { + function ClientConsensusStates(p) { + this.consensusStates = []; if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgCreateClientResponse.create = function create(properties) { - return new MsgCreateClientResponse(properties); + ClientConsensusStates.prototype.clientId = ''; + ClientConsensusStates.prototype.consensusStates = $util.emptyArray; + ClientConsensusStates.create = function create(properties) { + return new ClientConsensusStates(properties); }; - MsgCreateClientResponse.encode = function encode(m, w) { + ClientConsensusStates.encode = function encode(m, w) { if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.consensusStates != null && m.consensusStates.length) { + for (var i = 0; i < m.consensusStates.length; ++i) + $root.ibc.core.client.v1.ConsensusStateWithHeight.encode( + m.consensusStates[i], + w.uint32(18).fork(), + ).ldelim(); + } return w; }; - MsgCreateClientResponse.decode = function decode(r, l) { + ClientConsensusStates.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgCreateClientResponse(); + m = new $root.ibc.core.client.v1.ClientConsensusStates(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + if (!(m.consensusStates && m.consensusStates.length)) m.consensusStates = []; + m.consensusStates.push( + $root.ibc.core.client.v1.ConsensusStateWithHeight.decode(r, r.uint32()), + ); + break; default: r.skipType(t & 7); break; @@ -5484,44 +9291,50 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgCreateClientResponse; + return ClientConsensusStates; })(); - v1.MsgUpdateClient = (function () { - function MsgUpdateClient(p) { + v1.ClientUpdateProposal = (function () { + function ClientUpdateProposal(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgUpdateClient.prototype.clientId = ''; - MsgUpdateClient.prototype.header = null; - MsgUpdateClient.prototype.signer = ''; - MsgUpdateClient.create = function create(properties) { - return new MsgUpdateClient(properties); + ClientUpdateProposal.prototype.title = ''; + ClientUpdateProposal.prototype.description = ''; + ClientUpdateProposal.prototype.clientId = ''; + ClientUpdateProposal.prototype.header = null; + ClientUpdateProposal.create = function create(properties) { + return new ClientUpdateProposal(properties); }; - MsgUpdateClient.encode = function encode(m, w) { + ClientUpdateProposal.encode = function encode(m, w) { if (!w) w = $Writer.create(); + if (m.title != null && Object.hasOwnProperty.call(m, 'title')) w.uint32(10).string(m.title); + if (m.description != null && Object.hasOwnProperty.call(m, 'description')) + w.uint32(18).string(m.description); if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) - w.uint32(10).string(m.clientId); + w.uint32(26).string(m.clientId); if (m.header != null && Object.hasOwnProperty.call(m, 'header')) - $root.google.protobuf.Any.encode(m.header, w.uint32(18).fork()).ldelim(); - if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + $root.google.protobuf.Any.encode(m.header, w.uint32(34).fork()).ldelim(); return w; }; - MsgUpdateClient.decode = function decode(r, l) { + ClientUpdateProposal.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgUpdateClient(); + m = new $root.ibc.core.client.v1.ClientUpdateProposal(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - m.clientId = r.string(); + m.title = r.string(); break; case 2: - m.header = $root.google.protobuf.Any.decode(r, r.uint32()); + m.description = r.string(); break; case 3: - m.signer = r.string(); + m.clientId = r.string(); + break; + case 4: + m.header = $root.google.protobuf.Any.decode(r, r.uint32()); break; default: r.skipType(t & 7); @@ -5530,28 +9343,40 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgUpdateClient; + return ClientUpdateProposal; })(); - v1.MsgUpdateClientResponse = (function () { - function MsgUpdateClientResponse(p) { + v1.Height = (function () { + function Height(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgUpdateClientResponse.create = function create(properties) { - return new MsgUpdateClientResponse(properties); + Height.prototype.revisionNumber = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Height.prototype.revisionHeight = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Height.create = function create(properties) { + return new Height(properties); }; - MsgUpdateClientResponse.encode = function encode(m, w) { + Height.encode = function encode(m, w) { if (!w) w = $Writer.create(); + if (m.revisionNumber != null && Object.hasOwnProperty.call(m, 'revisionNumber')) + w.uint32(8).uint64(m.revisionNumber); + if (m.revisionHeight != null && Object.hasOwnProperty.call(m, 'revisionHeight')) + w.uint32(16).uint64(m.revisionHeight); return w; }; - MsgUpdateClientResponse.decode = function decode(r, l) { + Height.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgUpdateClientResponse(); + m = new $root.ibc.core.client.v1.Height(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { + case 1: + m.revisionNumber = r.uint64(); + break; + case 2: + m.revisionHeight = r.uint64(); + break; default: r.skipType(t & 7); break; @@ -5559,45 +9384,150 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgUpdateClientResponse; + return Height; + })(); + v1.Params = (function () { + function Params(p) { + this.allowedClients = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Params.prototype.allowedClients = $util.emptyArray; + Params.create = function create(properties) { + return new Params(properties); + }; + Params.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.allowedClients != null && m.allowedClients.length) { + for (var i = 0; i < m.allowedClients.length; ++i) w.uint32(10).string(m.allowedClients[i]); + } + return w; + }; + Params.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.client.v1.Params(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.allowedClients && m.allowedClients.length)) m.allowedClients = []; + m.allowedClients.push(r.string()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Params; + })(); + return v1; + })(); + return client; + })(); + core.connection = (function () { + const connection = {}; + connection.v1 = (function () { + const v1 = {}; + v1.Msg = (function () { + function Msg(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; + Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + Object.defineProperty( + (Msg.prototype.connectionOpenInit = function connectionOpenInit(request, callback) { + return this.rpcCall( + connectionOpenInit, + $root.ibc.core.connection.v1.MsgConnectionOpenInit, + $root.ibc.core.connection.v1.MsgConnectionOpenInitResponse, + request, + callback, + ); + }), + 'name', + { value: 'ConnectionOpenInit' }, + ); + Object.defineProperty( + (Msg.prototype.connectionOpenTry = function connectionOpenTry(request, callback) { + return this.rpcCall( + connectionOpenTry, + $root.ibc.core.connection.v1.MsgConnectionOpenTry, + $root.ibc.core.connection.v1.MsgConnectionOpenTryResponse, + request, + callback, + ); + }), + 'name', + { value: 'ConnectionOpenTry' }, + ); + Object.defineProperty( + (Msg.prototype.connectionOpenAck = function connectionOpenAck(request, callback) { + return this.rpcCall( + connectionOpenAck, + $root.ibc.core.connection.v1.MsgConnectionOpenAck, + $root.ibc.core.connection.v1.MsgConnectionOpenAckResponse, + request, + callback, + ); + }), + 'name', + { value: 'ConnectionOpenAck' }, + ); + Object.defineProperty( + (Msg.prototype.connectionOpenConfirm = function connectionOpenConfirm(request, callback) { + return this.rpcCall( + connectionOpenConfirm, + $root.ibc.core.connection.v1.MsgConnectionOpenConfirm, + $root.ibc.core.connection.v1.MsgConnectionOpenConfirmResponse, + request, + callback, + ); + }), + 'name', + { value: 'ConnectionOpenConfirm' }, + ); + return Msg; })(); - v1.MsgUpgradeClient = (function () { - function MsgUpgradeClient(p) { + v1.MsgConnectionOpenInit = (function () { + function MsgConnectionOpenInit(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgUpgradeClient.prototype.clientId = ''; - MsgUpgradeClient.prototype.clientState = null; - MsgUpgradeClient.prototype.consensusState = null; - MsgUpgradeClient.prototype.proofUpgradeClient = $util.newBuffer([]); - MsgUpgradeClient.prototype.proofUpgradeConsensusState = $util.newBuffer([]); - MsgUpgradeClient.prototype.signer = ''; - MsgUpgradeClient.create = function create(properties) { - return new MsgUpgradeClient(properties); + MsgConnectionOpenInit.prototype.clientId = ''; + MsgConnectionOpenInit.prototype.counterparty = null; + MsgConnectionOpenInit.prototype.version = null; + MsgConnectionOpenInit.prototype.delayPeriod = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + MsgConnectionOpenInit.prototype.signer = ''; + MsgConnectionOpenInit.create = function create(properties) { + return new MsgConnectionOpenInit(properties); }; - MsgUpgradeClient.encode = function encode(m, w) { + MsgConnectionOpenInit.encode = function encode(m, w) { if (!w) w = $Writer.create(); if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) w.uint32(10).string(m.clientId); - if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) - $root.google.protobuf.Any.encode(m.clientState, w.uint32(18).fork()).ldelim(); - if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) - $root.google.protobuf.Any.encode(m.consensusState, w.uint32(26).fork()).ldelim(); - if (m.proofUpgradeClient != null && Object.hasOwnProperty.call(m, 'proofUpgradeClient')) - w.uint32(34).bytes(m.proofUpgradeClient); - if ( - m.proofUpgradeConsensusState != null && - Object.hasOwnProperty.call(m, 'proofUpgradeConsensusState') - ) - w.uint32(42).bytes(m.proofUpgradeConsensusState); - if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(50).string(m.signer); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.connection.v1.Counterparty.encode( + m.counterparty, + w.uint32(18).fork(), + ).ldelim(); + if (m.version != null && Object.hasOwnProperty.call(m, 'version')) + $root.ibc.core.connection.v1.Version.encode(m.version, w.uint32(26).fork()).ldelim(); + if (m.delayPeriod != null && Object.hasOwnProperty.call(m, 'delayPeriod')) + w.uint32(32).uint64(m.delayPeriod); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(42).string(m.signer); return w; }; - MsgUpgradeClient.decode = function decode(r, l) { + MsgConnectionOpenInit.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgUpgradeClient(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenInit(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { @@ -5605,18 +9535,15 @@ exports.ibc = $root.ibc = (() => { m.clientId = r.string(); break; case 2: - m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + m.counterparty = $root.ibc.core.connection.v1.Counterparty.decode(r, r.uint32()); break; case 3: - m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); + m.version = $root.ibc.core.connection.v1.Version.decode(r, r.uint32()); break; case 4: - m.proofUpgradeClient = r.bytes(); + m.delayPeriod = r.uint64(); break; case 5: - m.proofUpgradeConsensusState = r.bytes(); - break; - case 6: m.signer = r.string(); break; default: @@ -5626,25 +9553,25 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgUpgradeClient; + return MsgConnectionOpenInit; })(); - v1.MsgUpgradeClientResponse = (function () { - function MsgUpgradeClientResponse(p) { + v1.MsgConnectionOpenInitResponse = (function () { + function MsgConnectionOpenInitResponse(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgUpgradeClientResponse.create = function create(properties) { - return new MsgUpgradeClientResponse(properties); + MsgConnectionOpenInitResponse.create = function create(properties) { + return new MsgConnectionOpenInitResponse(properties); }; - MsgUpgradeClientResponse.encode = function encode(m, w) { + MsgConnectionOpenInitResponse.encode = function encode(m, w) { if (!w) w = $Writer.create(); return w; }; - MsgUpgradeClientResponse.decode = function decode(r, l) { + MsgConnectionOpenInitResponse.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgUpgradeClientResponse(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenInitResponse(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { @@ -5655,33 +9582,69 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgUpgradeClientResponse; + return MsgConnectionOpenInitResponse; })(); - v1.MsgSubmitMisbehaviour = (function () { - function MsgSubmitMisbehaviour(p) { + v1.MsgConnectionOpenTry = (function () { + function MsgConnectionOpenTry(p) { + this.counterpartyVersions = []; if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgSubmitMisbehaviour.prototype.clientId = ''; - MsgSubmitMisbehaviour.prototype.misbehaviour = null; - MsgSubmitMisbehaviour.prototype.signer = ''; - MsgSubmitMisbehaviour.create = function create(properties) { - return new MsgSubmitMisbehaviour(properties); + MsgConnectionOpenTry.prototype.clientId = ''; + MsgConnectionOpenTry.prototype.previousConnectionId = ''; + MsgConnectionOpenTry.prototype.clientState = null; + MsgConnectionOpenTry.prototype.counterparty = null; + MsgConnectionOpenTry.prototype.delayPeriod = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + MsgConnectionOpenTry.prototype.counterpartyVersions = $util.emptyArray; + MsgConnectionOpenTry.prototype.proofHeight = null; + MsgConnectionOpenTry.prototype.proofInit = $util.newBuffer([]); + MsgConnectionOpenTry.prototype.proofClient = $util.newBuffer([]); + MsgConnectionOpenTry.prototype.proofConsensus = $util.newBuffer([]); + MsgConnectionOpenTry.prototype.consensusHeight = null; + MsgConnectionOpenTry.prototype.signer = ''; + MsgConnectionOpenTry.create = function create(properties) { + return new MsgConnectionOpenTry(properties); }; - MsgSubmitMisbehaviour.encode = function encode(m, w) { + MsgConnectionOpenTry.encode = function encode(m, w) { if (!w) w = $Writer.create(); if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) w.uint32(10).string(m.clientId); - if (m.misbehaviour != null && Object.hasOwnProperty.call(m, 'misbehaviour')) - $root.google.protobuf.Any.encode(m.misbehaviour, w.uint32(18).fork()).ldelim(); - if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(26).string(m.signer); + if (m.previousConnectionId != null && Object.hasOwnProperty.call(m, 'previousConnectionId')) + w.uint32(18).string(m.previousConnectionId); + if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) + $root.google.protobuf.Any.encode(m.clientState, w.uint32(26).fork()).ldelim(); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.connection.v1.Counterparty.encode( + m.counterparty, + w.uint32(34).fork(), + ).ldelim(); + if (m.delayPeriod != null && Object.hasOwnProperty.call(m, 'delayPeriod')) + w.uint32(40).uint64(m.delayPeriod); + if (m.counterpartyVersions != null && m.counterpartyVersions.length) { + for (var i = 0; i < m.counterpartyVersions.length; ++i) + $root.ibc.core.connection.v1.Version.encode( + m.counterpartyVersions[i], + w.uint32(50).fork(), + ).ldelim(); + } + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(58).fork()).ldelim(); + if (m.proofInit != null && Object.hasOwnProperty.call(m, 'proofInit')) + w.uint32(66).bytes(m.proofInit); + if (m.proofClient != null && Object.hasOwnProperty.call(m, 'proofClient')) + w.uint32(74).bytes(m.proofClient); + if (m.proofConsensus != null && Object.hasOwnProperty.call(m, 'proofConsensus')) + w.uint32(82).bytes(m.proofConsensus); + if (m.consensusHeight != null && Object.hasOwnProperty.call(m, 'consensusHeight')) + $root.ibc.core.client.v1.Height.encode(m.consensusHeight, w.uint32(90).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(98).string(m.signer); return w; }; - MsgSubmitMisbehaviour.decode = function decode(r, l) { + MsgConnectionOpenTry.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgSubmitMisbehaviour(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenTry(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { @@ -5689,9 +9652,40 @@ exports.ibc = $root.ibc = (() => { m.clientId = r.string(); break; case 2: - m.misbehaviour = $root.google.protobuf.Any.decode(r, r.uint32()); + m.previousConnectionId = r.string(); break; case 3: + m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 4: + m.counterparty = $root.ibc.core.connection.v1.Counterparty.decode(r, r.uint32()); + break; + case 5: + m.delayPeriod = r.uint64(); + break; + case 6: + if (!(m.counterpartyVersions && m.counterpartyVersions.length)) + m.counterpartyVersions = []; + m.counterpartyVersions.push( + $root.ibc.core.connection.v1.Version.decode(r, r.uint32()), + ); + break; + case 7: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 8: + m.proofInit = r.bytes(); + break; + case 9: + m.proofClient = r.bytes(); + break; + case 10: + m.proofConsensus = r.bytes(); + break; + case 11: + m.consensusHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 12: m.signer = r.string(); break; default: @@ -5701,25 +9695,25 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgSubmitMisbehaviour; + return MsgConnectionOpenTry; })(); - v1.MsgSubmitMisbehaviourResponse = (function () { - function MsgSubmitMisbehaviourResponse(p) { + v1.MsgConnectionOpenTryResponse = (function () { + function MsgConnectionOpenTryResponse(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - MsgSubmitMisbehaviourResponse.create = function create(properties) { - return new MsgSubmitMisbehaviourResponse(properties); + MsgConnectionOpenTryResponse.create = function create(properties) { + return new MsgConnectionOpenTryResponse(properties); }; - MsgSubmitMisbehaviourResponse.encode = function encode(m, w) { + MsgConnectionOpenTryResponse.encode = function encode(m, w) { if (!w) w = $Writer.create(); return w; }; - MsgSubmitMisbehaviourResponse.decode = function decode(r, l) { + MsgConnectionOpenTryResponse.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.MsgSubmitMisbehaviourResponse(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenTryResponse(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { @@ -5730,40 +9724,90 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return MsgSubmitMisbehaviourResponse; + return MsgConnectionOpenTryResponse; })(); - v1.IdentifiedClientState = (function () { - function IdentifiedClientState(p) { + v1.MsgConnectionOpenAck = (function () { + function MsgConnectionOpenAck(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - IdentifiedClientState.prototype.clientId = ''; - IdentifiedClientState.prototype.clientState = null; - IdentifiedClientState.create = function create(properties) { - return new IdentifiedClientState(properties); + MsgConnectionOpenAck.prototype.connectionId = ''; + MsgConnectionOpenAck.prototype.counterpartyConnectionId = ''; + MsgConnectionOpenAck.prototype.version = null; + MsgConnectionOpenAck.prototype.clientState = null; + MsgConnectionOpenAck.prototype.proofHeight = null; + MsgConnectionOpenAck.prototype.proofTry = $util.newBuffer([]); + MsgConnectionOpenAck.prototype.proofClient = $util.newBuffer([]); + MsgConnectionOpenAck.prototype.proofConsensus = $util.newBuffer([]); + MsgConnectionOpenAck.prototype.consensusHeight = null; + MsgConnectionOpenAck.prototype.signer = ''; + MsgConnectionOpenAck.create = function create(properties) { + return new MsgConnectionOpenAck(properties); }; - IdentifiedClientState.encode = function encode(m, w) { + MsgConnectionOpenAck.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) - w.uint32(10).string(m.clientId); + if (m.connectionId != null && Object.hasOwnProperty.call(m, 'connectionId')) + w.uint32(10).string(m.connectionId); + if ( + m.counterpartyConnectionId != null && + Object.hasOwnProperty.call(m, 'counterpartyConnectionId') + ) + w.uint32(18).string(m.counterpartyConnectionId); + if (m.version != null && Object.hasOwnProperty.call(m, 'version')) + $root.ibc.core.connection.v1.Version.encode(m.version, w.uint32(26).fork()).ldelim(); if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) - $root.google.protobuf.Any.encode(m.clientState, w.uint32(18).fork()).ldelim(); + $root.google.protobuf.Any.encode(m.clientState, w.uint32(34).fork()).ldelim(); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(42).fork()).ldelim(); + if (m.proofTry != null && Object.hasOwnProperty.call(m, 'proofTry')) + w.uint32(50).bytes(m.proofTry); + if (m.proofClient != null && Object.hasOwnProperty.call(m, 'proofClient')) + w.uint32(58).bytes(m.proofClient); + if (m.proofConsensus != null && Object.hasOwnProperty.call(m, 'proofConsensus')) + w.uint32(66).bytes(m.proofConsensus); + if (m.consensusHeight != null && Object.hasOwnProperty.call(m, 'consensusHeight')) + $root.ibc.core.client.v1.Height.encode(m.consensusHeight, w.uint32(74).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(82).string(m.signer); return w; }; - IdentifiedClientState.decode = function decode(r, l) { + MsgConnectionOpenAck.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.IdentifiedClientState(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenAck(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - m.clientId = r.string(); + m.connectionId = r.string(); break; case 2: + m.counterpartyConnectionId = r.string(); + break; + case 3: + m.version = $root.ibc.core.connection.v1.Version.decode(r, r.uint32()); + break; + case 4: m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); break; + case 5: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 6: + m.proofTry = r.bytes(); + break; + case 7: + m.proofClient = r.bytes(); + break; + case 8: + m.proofConsensus = r.bytes(); + break; + case 9: + m.consensusHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 10: + m.signer = r.string(); + break; default: r.skipType(t & 7); break; @@ -5771,40 +9815,28 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return IdentifiedClientState; + return MsgConnectionOpenAck; })(); - v1.ConsensusStateWithHeight = (function () { - function ConsensusStateWithHeight(p) { + v1.MsgConnectionOpenAckResponse = (function () { + function MsgConnectionOpenAckResponse(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - ConsensusStateWithHeight.prototype.height = null; - ConsensusStateWithHeight.prototype.consensusState = null; - ConsensusStateWithHeight.create = function create(properties) { - return new ConsensusStateWithHeight(properties); + MsgConnectionOpenAckResponse.create = function create(properties) { + return new MsgConnectionOpenAckResponse(properties); }; - ConsensusStateWithHeight.encode = function encode(m, w) { + MsgConnectionOpenAckResponse.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.height != null && Object.hasOwnProperty.call(m, 'height')) - $root.ibc.core.client.v1.Height.encode(m.height, w.uint32(10).fork()).ldelim(); - if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) - $root.google.protobuf.Any.encode(m.consensusState, w.uint32(18).fork()).ldelim(); return w; }; - ConsensusStateWithHeight.decode = function decode(r, l) { + MsgConnectionOpenAckResponse.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.ConsensusStateWithHeight(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenAckResponse(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { - case 1: - m.height = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); - break; - case 2: - m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); - break; default: r.skipType(t & 7); break; @@ -5812,48 +9844,50 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return ConsensusStateWithHeight; + return MsgConnectionOpenAckResponse; })(); - v1.ClientConsensusStates = (function () { - function ClientConsensusStates(p) { - this.consensusStates = []; + v1.MsgConnectionOpenConfirm = (function () { + function MsgConnectionOpenConfirm(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - ClientConsensusStates.prototype.clientId = ''; - ClientConsensusStates.prototype.consensusStates = $util.emptyArray; - ClientConsensusStates.create = function create(properties) { - return new ClientConsensusStates(properties); + MsgConnectionOpenConfirm.prototype.connectionId = ''; + MsgConnectionOpenConfirm.prototype.proofAck = $util.newBuffer([]); + MsgConnectionOpenConfirm.prototype.proofHeight = null; + MsgConnectionOpenConfirm.prototype.signer = ''; + MsgConnectionOpenConfirm.create = function create(properties) { + return new MsgConnectionOpenConfirm(properties); }; - ClientConsensusStates.encode = function encode(m, w) { + MsgConnectionOpenConfirm.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) - w.uint32(10).string(m.clientId); - if (m.consensusStates != null && m.consensusStates.length) { - for (var i = 0; i < m.consensusStates.length; ++i) - $root.ibc.core.client.v1.ConsensusStateWithHeight.encode( - m.consensusStates[i], - w.uint32(18).fork(), - ).ldelim(); - } + if (m.connectionId != null && Object.hasOwnProperty.call(m, 'connectionId')) + w.uint32(10).string(m.connectionId); + if (m.proofAck != null && Object.hasOwnProperty.call(m, 'proofAck')) + w.uint32(18).bytes(m.proofAck); + if (m.proofHeight != null && Object.hasOwnProperty.call(m, 'proofHeight')) + $root.ibc.core.client.v1.Height.encode(m.proofHeight, w.uint32(26).fork()).ldelim(); + if (m.signer != null && Object.hasOwnProperty.call(m, 'signer')) w.uint32(34).string(m.signer); return w; }; - ClientConsensusStates.decode = function decode(r, l) { + MsgConnectionOpenConfirm.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.ClientConsensusStates(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenConfirm(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - m.clientId = r.string(); + m.connectionId = r.string(); break; case 2: - if (!(m.consensusStates && m.consensusStates.length)) m.consensusStates = []; - m.consensusStates.push( - $root.ibc.core.client.v1.ConsensusStateWithHeight.decode(r, r.uint32()), - ); + m.proofAck = r.bytes(); + break; + case 3: + m.proofHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 4: + m.signer = r.string(); break; default: r.skipType(t & 7); @@ -5862,51 +9896,28 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return ClientConsensusStates; + return MsgConnectionOpenConfirm; })(); - v1.ClientUpdateProposal = (function () { - function ClientUpdateProposal(p) { + v1.MsgConnectionOpenConfirmResponse = (function () { + function MsgConnectionOpenConfirmResponse(p) { if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - ClientUpdateProposal.prototype.title = ''; - ClientUpdateProposal.prototype.description = ''; - ClientUpdateProposal.prototype.clientId = ''; - ClientUpdateProposal.prototype.header = null; - ClientUpdateProposal.create = function create(properties) { - return new ClientUpdateProposal(properties); + MsgConnectionOpenConfirmResponse.create = function create(properties) { + return new MsgConnectionOpenConfirmResponse(properties); }; - ClientUpdateProposal.encode = function encode(m, w) { + MsgConnectionOpenConfirmResponse.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.title != null && Object.hasOwnProperty.call(m, 'title')) w.uint32(10).string(m.title); - if (m.description != null && Object.hasOwnProperty.call(m, 'description')) - w.uint32(18).string(m.description); - if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) - w.uint32(26).string(m.clientId); - if (m.header != null && Object.hasOwnProperty.call(m, 'header')) - $root.google.protobuf.Any.encode(m.header, w.uint32(34).fork()).ldelim(); return w; }; - ClientUpdateProposal.decode = function decode(r, l) { + MsgConnectionOpenConfirmResponse.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.ClientUpdateProposal(); + m = new $root.ibc.core.connection.v1.MsgConnectionOpenConfirmResponse(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { - case 1: - m.title = r.string(); - break; - case 2: - m.description = r.string(); - break; - case 3: - m.clientId = r.string(); - break; - case 4: - m.header = $root.google.protobuf.Any.decode(r, r.uint32()); - break; default: r.skipType(t & 7); break; @@ -5914,39 +9925,66 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return ClientUpdateProposal; + return MsgConnectionOpenConfirmResponse; })(); - v1.Height = (function () { - function Height(p) { + v1.ConnectionEnd = (function () { + function ConnectionEnd(p) { + this.versions = []; if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - Height.prototype.revisionNumber = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - Height.prototype.revisionHeight = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - Height.create = function create(properties) { - return new Height(properties); + ConnectionEnd.prototype.clientId = ''; + ConnectionEnd.prototype.versions = $util.emptyArray; + ConnectionEnd.prototype.state = 0; + ConnectionEnd.prototype.counterparty = null; + ConnectionEnd.prototype.delayPeriod = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + ConnectionEnd.create = function create(properties) { + return new ConnectionEnd(properties); }; - Height.encode = function encode(m, w) { + ConnectionEnd.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.revisionNumber != null && Object.hasOwnProperty.call(m, 'revisionNumber')) - w.uint32(8).uint64(m.revisionNumber); - if (m.revisionHeight != null && Object.hasOwnProperty.call(m, 'revisionHeight')) - w.uint32(16).uint64(m.revisionHeight); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.versions != null && m.versions.length) { + for (var i = 0; i < m.versions.length; ++i) + $root.ibc.core.connection.v1.Version.encode( + m.versions[i], + w.uint32(18).fork(), + ).ldelim(); + } + if (m.state != null && Object.hasOwnProperty.call(m, 'state')) w.uint32(24).int32(m.state); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.connection.v1.Counterparty.encode( + m.counterparty, + w.uint32(34).fork(), + ).ldelim(); + if (m.delayPeriod != null && Object.hasOwnProperty.call(m, 'delayPeriod')) + w.uint32(40).uint64(m.delayPeriod); return w; }; - Height.decode = function decode(r, l) { + ConnectionEnd.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.Height(); + m = new $root.ibc.core.connection.v1.ConnectionEnd(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - m.revisionNumber = r.uint64(); + m.clientId = r.string(); break; case 2: - m.revisionHeight = r.uint64(); + if (!(m.versions && m.versions.length)) m.versions = []; + m.versions.push($root.ibc.core.connection.v1.Version.decode(r, r.uint32())); + break; + case 3: + m.state = r.int32(); + break; + case 4: + m.counterparty = $root.ibc.core.connection.v1.Counterparty.decode(r, r.uint32()); + break; + case 5: + m.delayPeriod = r.uint64(); break; default: r.skipType(t & 7); @@ -5955,1268 +9993,1535 @@ exports.ibc = $root.ibc = (() => { } return m; }; - return Height; + return ConnectionEnd; })(); - v1.Params = (function () { - function Params(p) { - this.allowedClients = []; + v1.IdentifiedConnection = (function () { + function IdentifiedConnection(p) { + this.versions = []; if (p) for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - Params.prototype.allowedClients = $util.emptyArray; - Params.create = function create(properties) { - return new Params(properties); + IdentifiedConnection.prototype.id = ''; + IdentifiedConnection.prototype.clientId = ''; + IdentifiedConnection.prototype.versions = $util.emptyArray; + IdentifiedConnection.prototype.state = 0; + IdentifiedConnection.prototype.counterparty = null; + IdentifiedConnection.prototype.delayPeriod = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + IdentifiedConnection.create = function create(properties) { + return new IdentifiedConnection(properties); }; - Params.encode = function encode(m, w) { + IdentifiedConnection.encode = function encode(m, w) { if (!w) w = $Writer.create(); - if (m.allowedClients != null && m.allowedClients.length) { - for (var i = 0; i < m.allowedClients.length; ++i) w.uint32(10).string(m.allowedClients[i]); + if (m.id != null && Object.hasOwnProperty.call(m, 'id')) w.uint32(10).string(m.id); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(18).string(m.clientId); + if (m.versions != null && m.versions.length) { + for (var i = 0; i < m.versions.length; ++i) + $root.ibc.core.connection.v1.Version.encode( + m.versions[i], + w.uint32(26).fork(), + ).ldelim(); } + if (m.state != null && Object.hasOwnProperty.call(m, 'state')) w.uint32(32).int32(m.state); + if (m.counterparty != null && Object.hasOwnProperty.call(m, 'counterparty')) + $root.ibc.core.connection.v1.Counterparty.encode( + m.counterparty, + w.uint32(42).fork(), + ).ldelim(); + if (m.delayPeriod != null && Object.hasOwnProperty.call(m, 'delayPeriod')) + w.uint32(48).uint64(m.delayPeriod); return w; }; - Params.decode = function decode(r, l) { + IdentifiedConnection.decode = function decode(r, l) { if (!(r instanceof $Reader)) r = $Reader.create(r); var c = l === undefined ? r.len : r.pos + l, - m = new $root.ibc.core.client.v1.Params(); + m = new $root.ibc.core.connection.v1.IdentifiedConnection(); while (r.pos < c) { var t = r.uint32(); switch (t >>> 3) { case 1: - if (!(m.allowedClients && m.allowedClients.length)) m.allowedClients = []; - m.allowedClients.push(r.string()); - break; - default: - r.skipType(t & 7); + m.id = r.string(); break; - } - } - return m; - }; - return Params; - })(); - return v1; - })(); - return client; - })(); - return core; - })(); - return ibc; -})(); -exports.tendermint = $root.tendermint = (() => { - const tendermint = {}; - tendermint.types = (function () { - const types = {}; - types.BlockIDFlag = (function () { - const valuesById = {}, - values = Object.create(valuesById); - values[(valuesById[0] = 'BLOCK_ID_FLAG_UNKNOWN')] = 0; - values[(valuesById[1] = 'BLOCK_ID_FLAG_ABSENT')] = 1; - values[(valuesById[2] = 'BLOCK_ID_FLAG_COMMIT')] = 2; - values[(valuesById[3] = 'BLOCK_ID_FLAG_NIL')] = 3; - return values; - })(); - types.SignedMsgType = (function () { - const valuesById = {}, - values = Object.create(valuesById); - values[(valuesById[0] = 'SIGNED_MSG_TYPE_UNKNOWN')] = 0; - values[(valuesById[1] = 'SIGNED_MSG_TYPE_PREVOTE')] = 1; - values[(valuesById[2] = 'SIGNED_MSG_TYPE_PRECOMMIT')] = 2; - values[(valuesById[32] = 'SIGNED_MSG_TYPE_PROPOSAL')] = 32; - return values; - })(); - types.PartSetHeader = (function () { - function PartSetHeader(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - PartSetHeader.prototype.total = 0; - PartSetHeader.prototype.hash = $util.newBuffer([]); - PartSetHeader.create = function create(properties) { - return new PartSetHeader(properties); - }; - PartSetHeader.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.total != null && Object.hasOwnProperty.call(m, 'total')) w.uint32(8).uint32(m.total); - if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(18).bytes(m.hash); - return w; - }; - PartSetHeader.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.PartSetHeader(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.total = r.uint32(); - break; - case 2: - m.hash = r.bytes(); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - return PartSetHeader; - })(); - types.Part = (function () { - function Part(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Part.prototype.index = 0; - Part.prototype.bytes = $util.newBuffer([]); - Part.prototype.proof = null; - Part.create = function create(properties) { - return new Part(properties); - }; - Part.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.index != null && Object.hasOwnProperty.call(m, 'index')) w.uint32(8).uint32(m.index); - if (m.bytes != null && Object.hasOwnProperty.call(m, 'bytes')) w.uint32(18).bytes(m.bytes); - if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) - $root.tendermint.crypto.Proof.encode(m.proof, w.uint32(26).fork()).ldelim(); - return w; - }; - Part.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Part(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.index = r.uint32(); - break; - case 2: - m.bytes = r.bytes(); - break; - case 3: - m.proof = $root.tendermint.crypto.Proof.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - return Part; - })(); - types.BlockID = (function () { - function BlockID(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - BlockID.prototype.hash = $util.newBuffer([]); - BlockID.prototype.partSetHeader = null; - BlockID.create = function create(properties) { - return new BlockID(properties); - }; - BlockID.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.hash != null && Object.hasOwnProperty.call(m, 'hash')) w.uint32(10).bytes(m.hash); - if (m.partSetHeader != null && Object.hasOwnProperty.call(m, 'partSetHeader')) - $root.tendermint.types.PartSetHeader.encode(m.partSetHeader, w.uint32(18).fork()).ldelim(); - return w; - }; - BlockID.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.BlockID(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.hash = r.bytes(); - break; - case 2: - m.partSetHeader = $root.tendermint.types.PartSetHeader.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; - } - } - return m; - }; - return BlockID; - })(); - types.Header = (function () { - function Header(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Header.prototype.version = null; - Header.prototype.chainId = ''; - Header.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Header.prototype.time = null; - Header.prototype.lastBlockId = null; - Header.prototype.lastCommitHash = $util.newBuffer([]); - Header.prototype.dataHash = $util.newBuffer([]); - Header.prototype.validatorsHash = $util.newBuffer([]); - Header.prototype.nextValidatorsHash = $util.newBuffer([]); - Header.prototype.consensusHash = $util.newBuffer([]); - Header.prototype.appHash = $util.newBuffer([]); - Header.prototype.lastResultsHash = $util.newBuffer([]); - Header.prototype.evidenceHash = $util.newBuffer([]); - Header.prototype.proposerAddress = $util.newBuffer([]); - Header.create = function create(properties) { - return new Header(properties); - }; - Header.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.version != null && Object.hasOwnProperty.call(m, 'version')) - $root.tendermint.version.Consensus.encode(m.version, w.uint32(10).fork()).ldelim(); - if (m.chainId != null && Object.hasOwnProperty.call(m, 'chainId')) w.uint32(18).string(m.chainId); - if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(24).int64(m.height); - if (m.time != null && Object.hasOwnProperty.call(m, 'time')) - $root.google.protobuf.Timestamp.encode(m.time, w.uint32(34).fork()).ldelim(); - if (m.lastBlockId != null && Object.hasOwnProperty.call(m, 'lastBlockId')) - $root.tendermint.types.BlockID.encode(m.lastBlockId, w.uint32(42).fork()).ldelim(); - if (m.lastCommitHash != null && Object.hasOwnProperty.call(m, 'lastCommitHash')) - w.uint32(50).bytes(m.lastCommitHash); - if (m.dataHash != null && Object.hasOwnProperty.call(m, 'dataHash')) w.uint32(58).bytes(m.dataHash); - if (m.validatorsHash != null && Object.hasOwnProperty.call(m, 'validatorsHash')) - w.uint32(66).bytes(m.validatorsHash); - if (m.nextValidatorsHash != null && Object.hasOwnProperty.call(m, 'nextValidatorsHash')) - w.uint32(74).bytes(m.nextValidatorsHash); - if (m.consensusHash != null && Object.hasOwnProperty.call(m, 'consensusHash')) - w.uint32(82).bytes(m.consensusHash); - if (m.appHash != null && Object.hasOwnProperty.call(m, 'appHash')) w.uint32(90).bytes(m.appHash); - if (m.lastResultsHash != null && Object.hasOwnProperty.call(m, 'lastResultsHash')) - w.uint32(98).bytes(m.lastResultsHash); - if (m.evidenceHash != null && Object.hasOwnProperty.call(m, 'evidenceHash')) - w.uint32(106).bytes(m.evidenceHash); - if (m.proposerAddress != null && Object.hasOwnProperty.call(m, 'proposerAddress')) - w.uint32(114).bytes(m.proposerAddress); - return w; - }; - Header.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Header(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.version = $root.tendermint.version.Consensus.decode(r, r.uint32()); - break; - case 2: - m.chainId = r.string(); - break; - case 3: - m.height = r.int64(); - break; - case 4: - m.time = $root.google.protobuf.Timestamp.decode(r, r.uint32()); - break; - case 5: - m.lastBlockId = $root.tendermint.types.BlockID.decode(r, r.uint32()); - break; - case 6: - m.lastCommitHash = r.bytes(); - break; - case 7: - m.dataHash = r.bytes(); - break; - case 8: - m.validatorsHash = r.bytes(); - break; - case 9: - m.nextValidatorsHash = r.bytes(); - break; - case 10: - m.consensusHash = r.bytes(); - break; - case 11: - m.appHash = r.bytes(); - break; - case 12: - m.lastResultsHash = r.bytes(); - break; - case 13: - m.evidenceHash = r.bytes(); - break; - case 14: - m.proposerAddress = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + case 2: + m.clientId = r.string(); + break; + case 3: + if (!(m.versions && m.versions.length)) m.versions = []; + m.versions.push($root.ibc.core.connection.v1.Version.decode(r, r.uint32())); + break; + case 4: + m.state = r.int32(); + break; + case 5: + m.counterparty = $root.ibc.core.connection.v1.Counterparty.decode(r, r.uint32()); + break; + case 6: + m.delayPeriod = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return IdentifiedConnection; + })(); + v1.State = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'STATE_UNINITIALIZED_UNSPECIFIED')] = 0; + values[(valuesById[1] = 'STATE_INIT')] = 1; + values[(valuesById[2] = 'STATE_TRYOPEN')] = 2; + values[(valuesById[3] = 'STATE_OPEN')] = 3; + return values; + })(); + v1.Counterparty = (function () { + function Counterparty(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Header; - })(); - types.Data = (function () { - function Data(p) { - this.txs = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Data.prototype.txs = $util.emptyArray; - Data.create = function create(properties) { - return new Data(properties); - }; - Data.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.txs != null && m.txs.length) { - for (var i = 0; i < m.txs.length; ++i) w.uint32(10).bytes(m.txs[i]); - } - return w; - }; - Data.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Data(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.txs && m.txs.length)) m.txs = []; - m.txs.push(r.bytes()); - break; - default: - r.skipType(t & 7); - break; + Counterparty.prototype.clientId = ''; + Counterparty.prototype.connectionId = ''; + Counterparty.prototype.prefix = null; + Counterparty.create = function create(properties) { + return new Counterparty(properties); + }; + Counterparty.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.connectionId != null && Object.hasOwnProperty.call(m, 'connectionId')) + w.uint32(18).string(m.connectionId); + if (m.prefix != null && Object.hasOwnProperty.call(m, 'prefix')) + $root.ibc.core.commitment.v1.MerklePrefix.encode(m.prefix, w.uint32(26).fork()).ldelim(); + return w; + }; + Counterparty.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.connection.v1.Counterparty(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.connectionId = r.string(); + break; + case 3: + m.prefix = $root.ibc.core.commitment.v1.MerklePrefix.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Counterparty; + })(); + v1.ClientPaths = (function () { + function ClientPaths(p) { + this.paths = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Data; - })(); - types.Vote = (function () { - function Vote(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Vote.prototype.type = 0; - Vote.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Vote.prototype.round = 0; - Vote.prototype.blockId = null; - Vote.prototype.timestamp = null; - Vote.prototype.validatorAddress = $util.newBuffer([]); - Vote.prototype.validatorIndex = 0; - Vote.prototype.signature = $util.newBuffer([]); - Vote.create = function create(properties) { - return new Vote(properties); - }; - Vote.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(8).int32(m.type); - if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(16).int64(m.height); - if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(24).int32(m.round); - if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) - $root.tendermint.types.BlockID.encode(m.blockId, w.uint32(34).fork()).ldelim(); - if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) - $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(42).fork()).ldelim(); - if (m.validatorAddress != null && Object.hasOwnProperty.call(m, 'validatorAddress')) - w.uint32(50).bytes(m.validatorAddress); - if (m.validatorIndex != null && Object.hasOwnProperty.call(m, 'validatorIndex')) - w.uint32(56).int32(m.validatorIndex); - if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(66).bytes(m.signature); - return w; - }; - Vote.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Vote(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.type = r.int32(); - break; - case 2: - m.height = r.int64(); - break; - case 3: - m.round = r.int32(); - break; - case 4: - m.blockId = $root.tendermint.types.BlockID.decode(r, r.uint32()); - break; - case 5: - m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); - break; - case 6: - m.validatorAddress = r.bytes(); - break; - case 7: - m.validatorIndex = r.int32(); - break; - case 8: - m.signature = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + ClientPaths.prototype.paths = $util.emptyArray; + ClientPaths.create = function create(properties) { + return new ClientPaths(properties); + }; + ClientPaths.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.paths != null && m.paths.length) { + for (var i = 0; i < m.paths.length; ++i) w.uint32(10).string(m.paths[i]); + } + return w; + }; + ClientPaths.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.connection.v1.ClientPaths(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + if (!(m.paths && m.paths.length)) m.paths = []; + m.paths.push(r.string()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ClientPaths; + })(); + v1.ConnectionPaths = (function () { + function ConnectionPaths(p) { + this.paths = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Vote; - })(); - types.Commit = (function () { - function Commit(p) { - this.signatures = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Commit.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Commit.prototype.round = 0; - Commit.prototype.blockId = null; - Commit.prototype.signatures = $util.emptyArray; - Commit.create = function create(properties) { - return new Commit(properties); - }; - Commit.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(8).int64(m.height); - if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(16).int32(m.round); - if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) - $root.tendermint.types.BlockID.encode(m.blockId, w.uint32(26).fork()).ldelim(); - if (m.signatures != null && m.signatures.length) { - for (var i = 0; i < m.signatures.length; ++i) - $root.tendermint.types.CommitSig.encode(m.signatures[i], w.uint32(34).fork()).ldelim(); - } - return w; - }; - Commit.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Commit(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.height = r.int64(); - break; - case 2: - m.round = r.int32(); - break; - case 3: - m.blockId = $root.tendermint.types.BlockID.decode(r, r.uint32()); - break; - case 4: - if (!(m.signatures && m.signatures.length)) m.signatures = []; - m.signatures.push($root.tendermint.types.CommitSig.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; + ConnectionPaths.prototype.clientId = ''; + ConnectionPaths.prototype.paths = $util.emptyArray; + ConnectionPaths.create = function create(properties) { + return new ConnectionPaths(properties); + }; + ConnectionPaths.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.paths != null && m.paths.length) { + for (var i = 0; i < m.paths.length; ++i) w.uint32(18).string(m.paths[i]); + } + return w; + }; + ConnectionPaths.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.connection.v1.ConnectionPaths(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + if (!(m.paths && m.paths.length)) m.paths = []; + m.paths.push(r.string()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ConnectionPaths; + })(); + v1.Version = (function () { + function Version(p) { + this.features = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Commit; + Version.prototype.identifier = ''; + Version.prototype.features = $util.emptyArray; + Version.create = function create(properties) { + return new Version(properties); + }; + Version.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.identifier != null && Object.hasOwnProperty.call(m, 'identifier')) + w.uint32(10).string(m.identifier); + if (m.features != null && m.features.length) { + for (var i = 0; i < m.features.length; ++i) w.uint32(18).string(m.features[i]); + } + return w; + }; + Version.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.core.connection.v1.Version(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.identifier = r.string(); + break; + case 2: + if (!(m.features && m.features.length)) m.features = []; + m.features.push(r.string()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Version; + })(); + return v1; + })(); + return connection; })(); - types.CommitSig = (function () { - function CommitSig(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - CommitSig.prototype.blockIdFlag = 0; - CommitSig.prototype.validatorAddress = $util.newBuffer([]); - CommitSig.prototype.timestamp = null; - CommitSig.prototype.signature = $util.newBuffer([]); - CommitSig.create = function create(properties) { - return new CommitSig(properties); - }; - CommitSig.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.blockIdFlag != null && Object.hasOwnProperty.call(m, 'blockIdFlag')) - w.uint32(8).int32(m.blockIdFlag); - if (m.validatorAddress != null && Object.hasOwnProperty.call(m, 'validatorAddress')) - w.uint32(18).bytes(m.validatorAddress); - if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) - $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(26).fork()).ldelim(); - if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(34).bytes(m.signature); - return w; - }; - CommitSig.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.CommitSig(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.blockIdFlag = r.int32(); - break; - case 2: - m.validatorAddress = r.bytes(); - break; - case 3: - m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); - break; - case 4: - m.signature = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + return core; + })(); + ibc.applications = (function () { + const applications = {}; + applications.transfer = (function () { + const transfer = {}; + transfer.v1 = (function () { + const v1 = {}; + v1.Msg = (function () { + function Msg(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); } - } - return m; - }; - return CommitSig; - })(); - types.Proposal = (function () { - function Proposal(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Proposal.prototype.type = 0; - Proposal.prototype.height = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Proposal.prototype.round = 0; - Proposal.prototype.polRound = 0; - Proposal.prototype.blockId = null; - Proposal.prototype.timestamp = null; - Proposal.prototype.signature = $util.newBuffer([]); - Proposal.create = function create(properties) { - return new Proposal(properties); - }; - Proposal.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(8).int32(m.type); - if (m.height != null && Object.hasOwnProperty.call(m, 'height')) w.uint32(16).int64(m.height); - if (m.round != null && Object.hasOwnProperty.call(m, 'round')) w.uint32(24).int32(m.round); - if (m.polRound != null && Object.hasOwnProperty.call(m, 'polRound')) w.uint32(32).int32(m.polRound); - if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) - $root.tendermint.types.BlockID.encode(m.blockId, w.uint32(42).fork()).ldelim(); - if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) - $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(50).fork()).ldelim(); - if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) w.uint32(58).bytes(m.signature); - return w; - }; - Proposal.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Proposal(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.type = r.int32(); - break; - case 2: - m.height = r.int64(); - break; - case 3: - m.round = r.int32(); - break; - case 4: - m.polRound = r.int32(); - break; - case 5: - m.blockId = $root.tendermint.types.BlockID.decode(r, r.uint32()); - break; - case 6: - m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); - break; - case 7: - m.signature = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + (Msg.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Msg; + Msg.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + Object.defineProperty( + (Msg.prototype.transfer = function transfer(request, callback) { + return this.rpcCall( + transfer, + $root.ibc.applications.transfer.v1.MsgTransfer, + $root.ibc.applications.transfer.v1.MsgTransferResponse, + request, + callback, + ); + }), + 'name', + { value: 'Transfer' }, + ); + return Msg; + })(); + v1.MsgTransfer = (function () { + function MsgTransfer(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Proposal; - })(); - types.SignedHeader = (function () { - function SignedHeader(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - SignedHeader.prototype.header = null; - SignedHeader.prototype.commit = null; - SignedHeader.create = function create(properties) { - return new SignedHeader(properties); - }; - SignedHeader.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.header != null && Object.hasOwnProperty.call(m, 'header')) - $root.tendermint.types.Header.encode(m.header, w.uint32(10).fork()).ldelim(); - if (m.commit != null && Object.hasOwnProperty.call(m, 'commit')) - $root.tendermint.types.Commit.encode(m.commit, w.uint32(18).fork()).ldelim(); - return w; - }; - SignedHeader.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.SignedHeader(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.header = $root.tendermint.types.Header.decode(r, r.uint32()); - break; - case 2: - m.commit = $root.tendermint.types.Commit.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; + MsgTransfer.prototype.sourcePort = ''; + MsgTransfer.prototype.sourceChannel = ''; + MsgTransfer.prototype.token = null; + MsgTransfer.prototype.sender = ''; + MsgTransfer.prototype.receiver = ''; + MsgTransfer.prototype.timeoutHeight = null; + MsgTransfer.prototype.timeoutTimestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + MsgTransfer.create = function create(properties) { + return new MsgTransfer(properties); + }; + MsgTransfer.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.sourcePort != null && Object.hasOwnProperty.call(m, 'sourcePort')) + w.uint32(10).string(m.sourcePort); + if (m.sourceChannel != null && Object.hasOwnProperty.call(m, 'sourceChannel')) + w.uint32(18).string(m.sourceChannel); + if (m.token != null && Object.hasOwnProperty.call(m, 'token')) + $root.cosmos.base.v1beta1.Coin.encode(m.token, w.uint32(26).fork()).ldelim(); + if (m.sender != null && Object.hasOwnProperty.call(m, 'sender')) w.uint32(34).string(m.sender); + if (m.receiver != null && Object.hasOwnProperty.call(m, 'receiver')) + w.uint32(42).string(m.receiver); + if (m.timeoutHeight != null && Object.hasOwnProperty.call(m, 'timeoutHeight')) + $root.ibc.core.client.v1.Height.encode(m.timeoutHeight, w.uint32(50).fork()).ldelim(); + if (m.timeoutTimestamp != null && Object.hasOwnProperty.call(m, 'timeoutTimestamp')) + w.uint32(56).uint64(m.timeoutTimestamp); + return w; + }; + MsgTransfer.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.applications.transfer.v1.MsgTransfer(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.sourcePort = r.string(); + break; + case 2: + m.sourceChannel = r.string(); + break; + case 3: + m.token = $root.cosmos.base.v1beta1.Coin.decode(r, r.uint32()); + break; + case 4: + m.sender = r.string(); + break; + case 5: + m.receiver = r.string(); + break; + case 6: + m.timeoutHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 7: + m.timeoutTimestamp = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTransfer; + })(); + v1.MsgTransferResponse = (function () { + function MsgTransferResponse(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return SignedHeader; + MsgTransferResponse.create = function create(properties) { + return new MsgTransferResponse(properties); + }; + MsgTransferResponse.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + return w; + }; + MsgTransferResponse.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.applications.transfer.v1.MsgTransferResponse(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return MsgTransferResponse; + })(); + return v1; + })(); + return transfer; })(); - types.LightBlock = (function () { - function LightBlock(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - LightBlock.prototype.signedHeader = null; - LightBlock.prototype.validatorSet = null; - LightBlock.create = function create(properties) { - return new LightBlock(properties); - }; - LightBlock.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.signedHeader != null && Object.hasOwnProperty.call(m, 'signedHeader')) - $root.tendermint.types.SignedHeader.encode(m.signedHeader, w.uint32(10).fork()).ldelim(); - if (m.validatorSet != null && Object.hasOwnProperty.call(m, 'validatorSet')) - $root.tendermint.types.ValidatorSet.encode(m.validatorSet, w.uint32(18).fork()).ldelim(); - return w; - }; - LightBlock.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.LightBlock(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.signedHeader = $root.tendermint.types.SignedHeader.decode(r, r.uint32()); - break; - case 2: - m.validatorSet = $root.tendermint.types.ValidatorSet.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; + return applications; + })(); + ibc.lightclients = (function () { + const lightclients = {}; + lightclients.tendermint = (function () { + const tendermintV2 = {}; + tendermintV2.v1 = (function () { + const v1 = {}; + v1.ClientState = (function () { + function ClientState(p) { + this.proofSpecs = []; + this.upgradePath = []; + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return LightBlock; - })(); - types.BlockMeta = (function () { - function BlockMeta(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - BlockMeta.prototype.blockId = null; - BlockMeta.prototype.blockSize = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - BlockMeta.prototype.header = null; - BlockMeta.prototype.numTxs = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - BlockMeta.create = function create(properties) { - return new BlockMeta(properties); - }; - BlockMeta.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.blockId != null && Object.hasOwnProperty.call(m, 'blockId')) - $root.tendermint.types.BlockID.encode(m.blockId, w.uint32(10).fork()).ldelim(); - if (m.blockSize != null && Object.hasOwnProperty.call(m, 'blockSize')) w.uint32(16).int64(m.blockSize); - if (m.header != null && Object.hasOwnProperty.call(m, 'header')) - $root.tendermint.types.Header.encode(m.header, w.uint32(26).fork()).ldelim(); - if (m.numTxs != null && Object.hasOwnProperty.call(m, 'numTxs')) w.uint32(32).int64(m.numTxs); - return w; - }; - BlockMeta.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.BlockMeta(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.blockId = $root.tendermint.types.BlockID.decode(r, r.uint32()); - break; - case 2: - m.blockSize = r.int64(); - break; - case 3: - m.header = $root.tendermint.types.Header.decode(r, r.uint32()); - break; - case 4: - m.numTxs = r.int64(); - break; - default: - r.skipType(t & 7); - break; + ClientState.prototype.chainId = ''; + ClientState.prototype.trustLevel = null; + ClientState.prototype.trustingPeriod = null; + ClientState.prototype.unbondingPeriod = null; + ClientState.prototype.maxClockDrift = null; + ClientState.prototype.frozenHeight = null; + ClientState.prototype.latestHeight = null; + ClientState.prototype.proofSpecs = $util.emptyArray; + ClientState.prototype.upgradePath = $util.emptyArray; + ClientState.prototype.allowUpdateAfterExpiry = false; + ClientState.prototype.allowUpdateAfterMisbehaviour = false; + ClientState.create = function create(properties) { + return new ClientState(properties); + }; + ClientState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.chainId != null && Object.hasOwnProperty.call(m, 'chainId')) + w.uint32(10).string(m.chainId); + if (m.trustLevel != null && Object.hasOwnProperty.call(m, 'trustLevel')) + $root.ibc.lightclients.tendermint.v1.Fraction.encode( + m.trustLevel, + w.uint32(18).fork(), + ).ldelim(); + if (m.trustingPeriod != null && Object.hasOwnProperty.call(m, 'trustingPeriod')) + $root.google.protobuf.Duration.encode(m.trustingPeriod, w.uint32(26).fork()).ldelim(); + if (m.unbondingPeriod != null && Object.hasOwnProperty.call(m, 'unbondingPeriod')) + $root.google.protobuf.Duration.encode(m.unbondingPeriod, w.uint32(34).fork()).ldelim(); + if (m.maxClockDrift != null && Object.hasOwnProperty.call(m, 'maxClockDrift')) + $root.google.protobuf.Duration.encode(m.maxClockDrift, w.uint32(42).fork()).ldelim(); + if (m.frozenHeight != null && Object.hasOwnProperty.call(m, 'frozenHeight')) + $root.ibc.core.client.v1.Height.encode(m.frozenHeight, w.uint32(50).fork()).ldelim(); + if (m.latestHeight != null && Object.hasOwnProperty.call(m, 'latestHeight')) + $root.ibc.core.client.v1.Height.encode(m.latestHeight, w.uint32(58).fork()).ldelim(); + if (m.proofSpecs != null && m.proofSpecs.length) { + for (var i = 0; i < m.proofSpecs.length; ++i) + $root.ics23.ProofSpec.encode(m.proofSpecs[i], w.uint32(66).fork()).ldelim(); + } + if (m.upgradePath != null && m.upgradePath.length) { + for (var i = 0; i < m.upgradePath.length; ++i) w.uint32(74).string(m.upgradePath[i]); + } + if (m.allowUpdateAfterExpiry != null && Object.hasOwnProperty.call(m, 'allowUpdateAfterExpiry')) + w.uint32(80).bool(m.allowUpdateAfterExpiry); + if ( + m.allowUpdateAfterMisbehaviour != null && + Object.hasOwnProperty.call(m, 'allowUpdateAfterMisbehaviour') + ) + w.uint32(88).bool(m.allowUpdateAfterMisbehaviour); + return w; + }; + ClientState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.tendermint.v1.ClientState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.chainId = r.string(); + break; + case 2: + m.trustLevel = $root.ibc.lightclients.tendermint.v1.Fraction.decode(r, r.uint32()); + break; + case 3: + m.trustingPeriod = $root.google.protobuf.Duration.decode(r, r.uint32()); + break; + case 4: + m.unbondingPeriod = $root.google.protobuf.Duration.decode(r, r.uint32()); + break; + case 5: + m.maxClockDrift = $root.google.protobuf.Duration.decode(r, r.uint32()); + break; + case 6: + m.frozenHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 7: + m.latestHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 8: + if (!(m.proofSpecs && m.proofSpecs.length)) m.proofSpecs = []; + m.proofSpecs.push($root.ics23.ProofSpec.decode(r, r.uint32())); + break; + case 9: + if (!(m.upgradePath && m.upgradePath.length)) m.upgradePath = []; + m.upgradePath.push(r.string()); + break; + case 10: + m.allowUpdateAfterExpiry = r.bool(); + break; + case 11: + m.allowUpdateAfterMisbehaviour = r.bool(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ClientState; + })(); + v1.ConsensusState = (function () { + function ConsensusState(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ConsensusState.prototype.timestamp = null; + ConsensusState.prototype.root = null; + ConsensusState.prototype.nextValidatorsHash = $util.newBuffer([]); + ConsensusState.create = function create(properties) { + return new ConsensusState(properties); + }; + ConsensusState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + $root.google.protobuf.Timestamp.encode(m.timestamp, w.uint32(10).fork()).ldelim(); + if (m.root != null && Object.hasOwnProperty.call(m, 'root')) + $root.ibc.core.commitment.v1.MerkleRoot.encode(m.root, w.uint32(18).fork()).ldelim(); + if (m.nextValidatorsHash != null && Object.hasOwnProperty.call(m, 'nextValidatorsHash')) + w.uint32(26).bytes(m.nextValidatorsHash); + return w; + }; + ConsensusState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.tendermint.v1.ConsensusState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.timestamp = $root.google.protobuf.Timestamp.decode(r, r.uint32()); + break; + case 2: + m.root = $root.ibc.core.commitment.v1.MerkleRoot.decode(r, r.uint32()); + break; + case 3: + m.nextValidatorsHash = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ConsensusState; + })(); + v1.Misbehaviour = (function () { + function Misbehaviour(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Misbehaviour.prototype.clientId = ''; + Misbehaviour.prototype.header_1 = null; + Misbehaviour.prototype.header_2 = null; + Misbehaviour.create = function create(properties) { + return new Misbehaviour(properties); + }; + Misbehaviour.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.header_1 != null && Object.hasOwnProperty.call(m, 'header_1')) + $root.ibc.lightclients.tendermint.v1.Header.encode( + m.header_1, + w.uint32(18).fork(), + ).ldelim(); + if (m.header_2 != null && Object.hasOwnProperty.call(m, 'header_2')) + $root.ibc.lightclients.tendermint.v1.Header.encode( + m.header_2, + w.uint32(26).fork(), + ).ldelim(); + return w; + }; + Misbehaviour.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.tendermint.v1.Misbehaviour(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.header_1 = $root.ibc.lightclients.tendermint.v1.Header.decode(r, r.uint32()); + break; + case 3: + m.header_2 = $root.ibc.lightclients.tendermint.v1.Header.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Misbehaviour; + })(); + v1.Header = (function () { + function Header(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Header.prototype.signedHeader = null; + Header.prototype.validatorSet = null; + Header.prototype.trustedHeight = null; + Header.prototype.trustedValidators = null; + Header.create = function create(properties) { + return new Header(properties); + }; + Header.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.signedHeader != null && Object.hasOwnProperty.call(m, 'signedHeader')) + $root.tendermintV2.types.SignedHeader.encode(m.signedHeader, w.uint32(10).fork()).ldelim(); + if (m.validatorSet != null && Object.hasOwnProperty.call(m, 'validatorSet')) + $root.tendermintV2.types.ValidatorSet.encode(m.validatorSet, w.uint32(18).fork()).ldelim(); + if (m.trustedHeight != null && Object.hasOwnProperty.call(m, 'trustedHeight')) + $root.ibc.core.client.v1.Height.encode(m.trustedHeight, w.uint32(26).fork()).ldelim(); + if (m.trustedValidators != null && Object.hasOwnProperty.call(m, 'trustedValidators')) + $root.tendermintV2.types.ValidatorSet.encode( + m.trustedValidators, + w.uint32(34).fork(), + ).ldelim(); + return w; + }; + Header.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.tendermint.v1.Header(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.signedHeader = $root.tendermintV2.types.SignedHeader.decode(r, r.uint32()); + break; + case 2: + m.validatorSet = $root.tendermintV2.types.ValidatorSet.decode(r, r.uint32()); + break; + case 3: + m.trustedHeight = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + case 4: + m.trustedValidators = $root.tendermintV2.types.ValidatorSet.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Header; + })(); + v1.Fraction = (function () { + function Fraction(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return BlockMeta; + Fraction.prototype.numerator = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Fraction.prototype.denominator = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Fraction.create = function create(properties) { + return new Fraction(properties); + }; + Fraction.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.numerator != null && Object.hasOwnProperty.call(m, 'numerator')) + w.uint32(8).uint64(m.numerator); + if (m.denominator != null && Object.hasOwnProperty.call(m, 'denominator')) + w.uint32(16).uint64(m.denominator); + return w; + }; + Fraction.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.tendermint.v1.Fraction(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.numerator = r.uint64(); + break; + case 2: + m.denominator = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Fraction; + })(); + return v1; + })(); + return tendermintV2; })(); - types.TxProof = (function () { - function TxProof(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - TxProof.prototype.rootHash = $util.newBuffer([]); - TxProof.prototype.data = $util.newBuffer([]); - TxProof.prototype.proof = null; - TxProof.create = function create(properties) { - return new TxProof(properties); - }; - TxProof.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.rootHash != null && Object.hasOwnProperty.call(m, 'rootHash')) w.uint32(10).bytes(m.rootHash); - if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(18).bytes(m.data); - if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) - $root.tendermint.crypto.Proof.encode(m.proof, w.uint32(26).fork()).ldelim(); - return w; - }; - TxProof.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.TxProof(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.rootHash = r.bytes(); - break; - case 2: - m.data = r.bytes(); - break; - case 3: - m.proof = $root.tendermint.crypto.Proof.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; + lightclients.localhost = (function () { + const localhost = {}; + localhost.v1 = (function () { + const v1 = {}; + v1.ClientState = (function () { + function ClientState(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return TxProof; + ClientState.prototype.chainId = ''; + ClientState.prototype.height = null; + ClientState.create = function create(properties) { + return new ClientState(properties); + }; + ClientState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.chainId != null && Object.hasOwnProperty.call(m, 'chainId')) + w.uint32(10).string(m.chainId); + if (m.height != null && Object.hasOwnProperty.call(m, 'height')) + $root.ibc.core.client.v1.Height.encode(m.height, w.uint32(18).fork()).ldelim(); + return w; + }; + ClientState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.localhost.v1.ClientState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.chainId = r.string(); + break; + case 2: + m.height = $root.ibc.core.client.v1.Height.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ClientState; + })(); + return v1; + })(); + return localhost; })(); - types.ValidatorSet = (function () { - function ValidatorSet(p) { - this.validators = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - ValidatorSet.prototype.validators = $util.emptyArray; - ValidatorSet.prototype.proposer = null; - ValidatorSet.prototype.totalVotingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - ValidatorSet.create = function create(properties) { - return new ValidatorSet(properties); - }; - ValidatorSet.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.validators != null && m.validators.length) { - for (var i = 0; i < m.validators.length; ++i) - $root.tendermint.types.Validator.encode(m.validators[i], w.uint32(10).fork()).ldelim(); - } - if (m.proposer != null && Object.hasOwnProperty.call(m, 'proposer')) - $root.tendermint.types.Validator.encode(m.proposer, w.uint32(18).fork()).ldelim(); - if (m.totalVotingPower != null && Object.hasOwnProperty.call(m, 'totalVotingPower')) - w.uint32(24).int64(m.totalVotingPower); - return w; - }; - ValidatorSet.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.ValidatorSet(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.validators && m.validators.length)) m.validators = []; - m.validators.push($root.tendermint.types.Validator.decode(r, r.uint32())); - break; - case 2: - m.proposer = $root.tendermint.types.Validator.decode(r, r.uint32()); - break; - case 3: - m.totalVotingPower = r.int64(); - break; - default: - r.skipType(t & 7); - break; + lightclients.solomachine = (function () { + const solomachine = {}; + solomachine.v1 = (function () { + const v1 = {}; + v1.ClientState = (function () { + function ClientState(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ClientState.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + ClientState.prototype.frozenSequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + ClientState.prototype.consensusState = null; + ClientState.prototype.allowUpdateAfterProposal = false; + ClientState.create = function create(properties) { + return new ClientState(properties); + }; + ClientState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(8).uint64(m.sequence); + if (m.frozenSequence != null && Object.hasOwnProperty.call(m, 'frozenSequence')) + w.uint32(16).uint64(m.frozenSequence); + if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) + $root.ibc.lightclients.solomachine.v1.ConsensusState.encode( + m.consensusState, + w.uint32(26).fork(), + ).ldelim(); + if ( + m.allowUpdateAfterProposal != null && + Object.hasOwnProperty.call(m, 'allowUpdateAfterProposal') + ) + w.uint32(32).bool(m.allowUpdateAfterProposal); + return w; + }; + ClientState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ClientState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.sequence = r.uint64(); + break; + case 2: + m.frozenSequence = r.uint64(); + break; + case 3: + m.consensusState = $root.ibc.lightclients.solomachine.v1.ConsensusState.decode( + r, + r.uint32(), + ); + break; + case 4: + m.allowUpdateAfterProposal = r.bool(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ClientState; + })(); + v1.ConsensusState = (function () { + function ConsensusState(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + ConsensusState.prototype.publicKey = null; + ConsensusState.prototype.diversifier = ''; + ConsensusState.prototype.timestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + ConsensusState.create = function create(properties) { + return new ConsensusState(properties); + }; + ConsensusState.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.publicKey != null && Object.hasOwnProperty.call(m, 'publicKey')) + $root.google.protobuf.Any.encode(m.publicKey, w.uint32(10).fork()).ldelim(); + if (m.diversifier != null && Object.hasOwnProperty.call(m, 'diversifier')) + w.uint32(18).string(m.diversifier); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + w.uint32(24).uint64(m.timestamp); + return w; + }; + ConsensusState.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ConsensusState(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.publicKey = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 2: + m.diversifier = r.string(); + break; + case 3: + m.timestamp = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ConsensusState; + })(); + v1.Header = (function () { + function Header(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Header.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Header.prototype.timestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Header.prototype.signature = $util.newBuffer([]); + Header.prototype.newPublicKey = null; + Header.prototype.newDiversifier = ''; + Header.create = function create(properties) { + return new Header(properties); + }; + Header.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(8).uint64(m.sequence); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + w.uint32(16).uint64(m.timestamp); + if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) + w.uint32(26).bytes(m.signature); + if (m.newPublicKey != null && Object.hasOwnProperty.call(m, 'newPublicKey')) + $root.google.protobuf.Any.encode(m.newPublicKey, w.uint32(34).fork()).ldelim(); + if (m.newDiversifier != null && Object.hasOwnProperty.call(m, 'newDiversifier')) + w.uint32(42).string(m.newDiversifier); + return w; + }; + Header.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.Header(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.sequence = r.uint64(); + break; + case 2: + m.timestamp = r.uint64(); + break; + case 3: + m.signature = r.bytes(); + break; + case 4: + m.newPublicKey = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 5: + m.newDiversifier = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Header; + })(); + v1.Misbehaviour = (function () { + function Misbehaviour(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + Misbehaviour.prototype.clientId = ''; + Misbehaviour.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + Misbehaviour.prototype.signatureOne = null; + Misbehaviour.prototype.signatureTwo = null; + Misbehaviour.create = function create(properties) { + return new Misbehaviour(properties); + }; + Misbehaviour.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.clientId != null && Object.hasOwnProperty.call(m, 'clientId')) + w.uint32(10).string(m.clientId); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(16).uint64(m.sequence); + if (m.signatureOne != null && Object.hasOwnProperty.call(m, 'signatureOne')) + $root.ibc.lightclients.solomachine.v1.SignatureAndData.encode( + m.signatureOne, + w.uint32(26).fork(), + ).ldelim(); + if (m.signatureTwo != null && Object.hasOwnProperty.call(m, 'signatureTwo')) + $root.ibc.lightclients.solomachine.v1.SignatureAndData.encode( + m.signatureTwo, + w.uint32(34).fork(), + ).ldelim(); + return w; + }; + Misbehaviour.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.Misbehaviour(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.clientId = r.string(); + break; + case 2: + m.sequence = r.uint64(); + break; + case 3: + m.signatureOne = $root.ibc.lightclients.solomachine.v1.SignatureAndData.decode( + r, + r.uint32(), + ); + break; + case 4: + m.signatureTwo = $root.ibc.lightclients.solomachine.v1.SignatureAndData.decode( + r, + r.uint32(), + ); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return Misbehaviour; + })(); + v1.SignatureAndData = (function () { + function SignatureAndData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return ValidatorSet; - })(); - types.Validator = (function () { - function Validator(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Validator.prototype.address = $util.newBuffer([]); - Validator.prototype.pubKey = null; - Validator.prototype.votingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Validator.prototype.proposerPriority = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Validator.create = function create(properties) { - return new Validator(properties); - }; - Validator.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.address != null && Object.hasOwnProperty.call(m, 'address')) w.uint32(10).bytes(m.address); - if (m.pubKey != null && Object.hasOwnProperty.call(m, 'pubKey')) - $root.tendermint.crypto.PublicKey.encode(m.pubKey, w.uint32(18).fork()).ldelim(); - if (m.votingPower != null && Object.hasOwnProperty.call(m, 'votingPower')) - w.uint32(24).int64(m.votingPower); - if (m.proposerPriority != null && Object.hasOwnProperty.call(m, 'proposerPriority')) - w.uint32(32).int64(m.proposerPriority); - return w; - }; - Validator.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.Validator(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.address = r.bytes(); - break; - case 2: - m.pubKey = $root.tendermint.crypto.PublicKey.decode(r, r.uint32()); - break; - case 3: - m.votingPower = r.int64(); - break; - case 4: - m.proposerPriority = r.int64(); - break; - default: - r.skipType(t & 7); - break; + SignatureAndData.prototype.signature = $util.newBuffer([]); + SignatureAndData.prototype.dataType = 0; + SignatureAndData.prototype.data = $util.newBuffer([]); + SignatureAndData.prototype.timestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + SignatureAndData.create = function create(properties) { + return new SignatureAndData(properties); + }; + SignatureAndData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.signature != null && Object.hasOwnProperty.call(m, 'signature')) + w.uint32(10).bytes(m.signature); + if (m.dataType != null && Object.hasOwnProperty.call(m, 'dataType')) + w.uint32(16).int32(m.dataType); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(26).bytes(m.data); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + w.uint32(32).uint64(m.timestamp); + return w; + }; + SignatureAndData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.SignatureAndData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.signature = r.bytes(); + break; + case 2: + m.dataType = r.int32(); + break; + case 3: + m.data = r.bytes(); + break; + case 4: + m.timestamp = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return SignatureAndData; + })(); + v1.TimestampedSignatureData = (function () { + function TimestampedSignatureData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Validator; - })(); - types.SimpleValidator = (function () { - function SimpleValidator(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - SimpleValidator.prototype.pubKey = null; - SimpleValidator.prototype.votingPower = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - SimpleValidator.create = function create(properties) { - return new SimpleValidator(properties); - }; - SimpleValidator.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.pubKey != null && Object.hasOwnProperty.call(m, 'pubKey')) - $root.tendermint.crypto.PublicKey.encode(m.pubKey, w.uint32(10).fork()).ldelim(); - if (m.votingPower != null && Object.hasOwnProperty.call(m, 'votingPower')) - w.uint32(16).int64(m.votingPower); - return w; - }; - SimpleValidator.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.types.SimpleValidator(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.pubKey = $root.tendermint.crypto.PublicKey.decode(r, r.uint32()); - break; - case 2: - m.votingPower = r.int64(); - break; - default: - r.skipType(t & 7); - break; + TimestampedSignatureData.prototype.signatureData = $util.newBuffer([]); + TimestampedSignatureData.prototype.timestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + TimestampedSignatureData.create = function create(properties) { + return new TimestampedSignatureData(properties); + }; + TimestampedSignatureData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.signatureData != null && Object.hasOwnProperty.call(m, 'signatureData')) + w.uint32(10).bytes(m.signatureData); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + w.uint32(16).uint64(m.timestamp); + return w; + }; + TimestampedSignatureData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.TimestampedSignatureData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.signatureData = r.bytes(); + break; + case 2: + m.timestamp = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return TimestampedSignatureData; + })(); + v1.SignBytes = (function () { + function SignBytes(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return SimpleValidator; - })(); - return types; - })(); - tendermint.crypto = (function () { - const crypto = {}; - crypto.Proof = (function () { - function Proof(p) { - this.aunts = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Proof.prototype.total = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Proof.prototype.index = $util.Long ? $util.Long.fromBits(0, 0, false) : 0; - Proof.prototype.leafHash = $util.newBuffer([]); - Proof.prototype.aunts = $util.emptyArray; - Proof.create = function create(properties) { - return new Proof(properties); - }; - Proof.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.total != null && Object.hasOwnProperty.call(m, 'total')) w.uint32(8).int64(m.total); - if (m.index != null && Object.hasOwnProperty.call(m, 'index')) w.uint32(16).int64(m.index); - if (m.leafHash != null && Object.hasOwnProperty.call(m, 'leafHash')) w.uint32(26).bytes(m.leafHash); - if (m.aunts != null && m.aunts.length) { - for (var i = 0; i < m.aunts.length; ++i) w.uint32(34).bytes(m.aunts[i]); - } - return w; - }; - Proof.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.Proof(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.total = r.int64(); - break; - case 2: - m.index = r.int64(); - break; - case 3: - m.leafHash = r.bytes(); - break; - case 4: - if (!(m.aunts && m.aunts.length)) m.aunts = []; - m.aunts.push(r.bytes()); - break; - default: - r.skipType(t & 7); - break; + SignBytes.prototype.sequence = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + SignBytes.prototype.timestamp = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + SignBytes.prototype.diversifier = ''; + SignBytes.prototype.dataType = 0; + SignBytes.prototype.data = $util.newBuffer([]); + SignBytes.create = function create(properties) { + return new SignBytes(properties); + }; + SignBytes.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.sequence != null && Object.hasOwnProperty.call(m, 'sequence')) + w.uint32(8).uint64(m.sequence); + if (m.timestamp != null && Object.hasOwnProperty.call(m, 'timestamp')) + w.uint32(16).uint64(m.timestamp); + if (m.diversifier != null && Object.hasOwnProperty.call(m, 'diversifier')) + w.uint32(26).string(m.diversifier); + if (m.dataType != null && Object.hasOwnProperty.call(m, 'dataType')) + w.uint32(32).int32(m.dataType); + if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(42).bytes(m.data); + return w; + }; + SignBytes.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.SignBytes(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.sequence = r.uint64(); + break; + case 2: + m.timestamp = r.uint64(); + break; + case 3: + m.diversifier = r.string(); + break; + case 4: + m.dataType = r.int32(); + break; + case 5: + m.data = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return SignBytes; + })(); + v1.DataType = (function () { + const valuesById = {}, + values = Object.create(valuesById); + values[(valuesById[0] = 'DATA_TYPE_UNINITIALIZED_UNSPECIFIED')] = 0; + values[(valuesById[1] = 'DATA_TYPE_CLIENT_STATE')] = 1; + values[(valuesById[2] = 'DATA_TYPE_CONSENSUS_STATE')] = 2; + values[(valuesById[3] = 'DATA_TYPE_CONNECTION_STATE')] = 3; + values[(valuesById[4] = 'DATA_TYPE_CHANNEL_STATE')] = 4; + values[(valuesById[5] = 'DATA_TYPE_PACKET_COMMITMENT')] = 5; + values[(valuesById[6] = 'DATA_TYPE_PACKET_ACKNOWLEDGEMENT')] = 6; + values[(valuesById[7] = 'DATA_TYPE_PACKET_RECEIPT_ABSENCE')] = 7; + values[(valuesById[8] = 'DATA_TYPE_NEXT_SEQUENCE_RECV')] = 8; + values[(valuesById[9] = 'DATA_TYPE_HEADER')] = 9; + return values; + })(); + v1.HeaderData = (function () { + function HeaderData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Proof; - })(); - crypto.ValueOp = (function () { - function ValueOp(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - ValueOp.prototype.key = $util.newBuffer([]); - ValueOp.prototype.proof = null; - ValueOp.create = function create(properties) { - return new ValueOp(properties); - }; - ValueOp.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).bytes(m.key); - if (m.proof != null && Object.hasOwnProperty.call(m, 'proof')) - $root.tendermint.crypto.Proof.encode(m.proof, w.uint32(18).fork()).ldelim(); - return w; - }; - ValueOp.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.ValueOp(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.key = r.bytes(); - break; - case 2: - m.proof = $root.tendermint.crypto.Proof.decode(r, r.uint32()); - break; - default: - r.skipType(t & 7); - break; + HeaderData.prototype.newPubKey = null; + HeaderData.prototype.newDiversifier = ''; + HeaderData.create = function create(properties) { + return new HeaderData(properties); + }; + HeaderData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.newPubKey != null && Object.hasOwnProperty.call(m, 'newPubKey')) + $root.google.protobuf.Any.encode(m.newPubKey, w.uint32(10).fork()).ldelim(); + if (m.newDiversifier != null && Object.hasOwnProperty.call(m, 'newDiversifier')) + w.uint32(18).string(m.newDiversifier); + return w; + }; + HeaderData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.HeaderData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.newPubKey = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + case 2: + m.newDiversifier = r.string(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return HeaderData; + })(); + v1.ClientStateData = (function () { + function ClientStateData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return ValueOp; - })(); - crypto.DominoOp = (function () { - function DominoOp(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - DominoOp.prototype.key = ''; - DominoOp.prototype.input = ''; - DominoOp.prototype.output = ''; - DominoOp.create = function create(properties) { - return new DominoOp(properties); - }; - DominoOp.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(10).string(m.key); - if (m.input != null && Object.hasOwnProperty.call(m, 'input')) w.uint32(18).string(m.input); - if (m.output != null && Object.hasOwnProperty.call(m, 'output')) w.uint32(26).string(m.output); - return w; - }; - DominoOp.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.DominoOp(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.key = r.string(); - break; - case 2: - m.input = r.string(); - break; - case 3: - m.output = r.string(); - break; - default: - r.skipType(t & 7); - break; + ClientStateData.prototype.path = $util.newBuffer([]); + ClientStateData.prototype.clientState = null; + ClientStateData.create = function create(properties) { + return new ClientStateData(properties); + }; + ClientStateData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.clientState != null && Object.hasOwnProperty.call(m, 'clientState')) + $root.google.protobuf.Any.encode(m.clientState, w.uint32(18).fork()).ldelim(); + return w; + }; + ClientStateData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ClientStateData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.clientState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ClientStateData; + })(); + v1.ConsensusStateData = (function () { + function ConsensusStateData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return DominoOp; - })(); - crypto.ProofOp = (function () { - function ProofOp(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - ProofOp.prototype.type = ''; - ProofOp.prototype.key = $util.newBuffer([]); - ProofOp.prototype.data = $util.newBuffer([]); - ProofOp.create = function create(properties) { - return new ProofOp(properties); - }; - ProofOp.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.type != null && Object.hasOwnProperty.call(m, 'type')) w.uint32(10).string(m.type); - if (m.key != null && Object.hasOwnProperty.call(m, 'key')) w.uint32(18).bytes(m.key); - if (m.data != null && Object.hasOwnProperty.call(m, 'data')) w.uint32(26).bytes(m.data); - return w; - }; - ProofOp.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.ProofOp(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.type = r.string(); - break; - case 2: - m.key = r.bytes(); - break; - case 3: - m.data = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + ConsensusStateData.prototype.path = $util.newBuffer([]); + ConsensusStateData.prototype.consensusState = null; + ConsensusStateData.create = function create(properties) { + return new ConsensusStateData(properties); + }; + ConsensusStateData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.consensusState != null && Object.hasOwnProperty.call(m, 'consensusState')) + $root.google.protobuf.Any.encode(m.consensusState, w.uint32(18).fork()).ldelim(); + return w; + }; + ConsensusStateData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ConsensusStateData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.consensusState = $root.google.protobuf.Any.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ConsensusStateData; + })(); + v1.ConnectionStateData = (function () { + function ConnectionStateData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return ProofOp; - })(); - crypto.ProofOps = (function () { - function ProofOps(p) { - this.ops = []; - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - ProofOps.prototype.ops = $util.emptyArray; - ProofOps.create = function create(properties) { - return new ProofOps(properties); - }; - ProofOps.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.ops != null && m.ops.length) { - for (var i = 0; i < m.ops.length; ++i) - $root.tendermint.crypto.ProofOp.encode(m.ops[i], w.uint32(10).fork()).ldelim(); - } - return w; - }; - ProofOps.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.ProofOps(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - if (!(m.ops && m.ops.length)) m.ops = []; - m.ops.push($root.tendermint.crypto.ProofOp.decode(r, r.uint32())); - break; - default: - r.skipType(t & 7); - break; + ConnectionStateData.prototype.path = $util.newBuffer([]); + ConnectionStateData.prototype.connection = null; + ConnectionStateData.create = function create(properties) { + return new ConnectionStateData(properties); + }; + ConnectionStateData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.connection != null && Object.hasOwnProperty.call(m, 'connection')) + $root.ibc.core.connection.v1.ConnectionEnd.encode( + m.connection, + w.uint32(18).fork(), + ).ldelim(); + return w; + }; + ConnectionStateData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ConnectionStateData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.connection = $root.ibc.core.connection.v1.ConnectionEnd.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ConnectionStateData; + })(); + v1.ChannelStateData = (function () { + function ChannelStateData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return ProofOps; - })(); - crypto.PublicKey = (function () { - function PublicKey(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - PublicKey.prototype.ed25519 = $util.newBuffer([]); - PublicKey.prototype.secp256k1 = $util.newBuffer([]); - let $oneOfFields; - Object.defineProperty(PublicKey.prototype, 'sum', { - get: $util.oneOfGetter(($oneOfFields = ['ed25519', 'secp256k1'])), - set: $util.oneOfSetter($oneOfFields), - }); - PublicKey.create = function create(properties) { - return new PublicKey(properties); - }; - PublicKey.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.ed25519 != null && Object.hasOwnProperty.call(m, 'ed25519')) w.uint32(10).bytes(m.ed25519); - if (m.secp256k1 != null && Object.hasOwnProperty.call(m, 'secp256k1')) w.uint32(18).bytes(m.secp256k1); - return w; - }; - PublicKey.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.crypto.PublicKey(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.ed25519 = r.bytes(); - break; - case 2: - m.secp256k1 = r.bytes(); - break; - default: - r.skipType(t & 7); - break; + ChannelStateData.prototype.path = $util.newBuffer([]); + ChannelStateData.prototype.channel = null; + ChannelStateData.create = function create(properties) { + return new ChannelStateData(properties); + }; + ChannelStateData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.channel != null && Object.hasOwnProperty.call(m, 'channel')) + $root.ibc.core.channel.v1.Channel.encode(m.channel, w.uint32(18).fork()).ldelim(); + return w; + }; + ChannelStateData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.ChannelStateData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.channel = $root.ibc.core.channel.v1.Channel.decode(r, r.uint32()); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return ChannelStateData; + })(); + v1.PacketCommitmentData = (function () { + function PacketCommitmentData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return PublicKey; - })(); - return crypto; - })(); - tendermint.version = (function () { - const version = {}; - version.App = (function () { - function App(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - App.prototype.protocol = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - App.prototype.software = ''; - App.create = function create(properties) { - return new App(properties); - }; - App.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.protocol != null && Object.hasOwnProperty.call(m, 'protocol')) w.uint32(8).uint64(m.protocol); - if (m.software != null && Object.hasOwnProperty.call(m, 'software')) w.uint32(18).string(m.software); - return w; - }; - App.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.version.App(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.protocol = r.uint64(); - break; - case 2: - m.software = r.string(); - break; - default: - r.skipType(t & 7); - break; + PacketCommitmentData.prototype.path = $util.newBuffer([]); + PacketCommitmentData.prototype.commitment = $util.newBuffer([]); + PacketCommitmentData.create = function create(properties) { + return new PacketCommitmentData(properties); + }; + PacketCommitmentData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.commitment != null && Object.hasOwnProperty.call(m, 'commitment')) + w.uint32(18).bytes(m.commitment); + return w; + }; + PacketCommitmentData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.PacketCommitmentData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.commitment = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PacketCommitmentData; + })(); + v1.PacketAcknowledgementData = (function () { + function PacketAcknowledgementData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return App; - })(); - version.Consensus = (function () { - function Consensus(p) { - if (p) - for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) - if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; - } - Consensus.prototype.block = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - Consensus.prototype.app = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; - Consensus.create = function create(properties) { - return new Consensus(properties); - }; - Consensus.encode = function encode(m, w) { - if (!w) w = $Writer.create(); - if (m.block != null && Object.hasOwnProperty.call(m, 'block')) w.uint32(8).uint64(m.block); - if (m.app != null && Object.hasOwnProperty.call(m, 'app')) w.uint32(16).uint64(m.app); - return w; - }; - Consensus.decode = function decode(r, l) { - if (!(r instanceof $Reader)) r = $Reader.create(r); - var c = l === undefined ? r.len : r.pos + l, - m = new $root.tendermint.version.Consensus(); - while (r.pos < c) { - var t = r.uint32(); - switch (t >>> 3) { - case 1: - m.block = r.uint64(); - break; - case 2: - m.app = r.uint64(); - break; - default: - r.skipType(t & 7); - break; + PacketAcknowledgementData.prototype.path = $util.newBuffer([]); + PacketAcknowledgementData.prototype.acknowledgement = $util.newBuffer([]); + PacketAcknowledgementData.create = function create(properties) { + return new PacketAcknowledgementData(properties); + }; + PacketAcknowledgementData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.acknowledgement != null && Object.hasOwnProperty.call(m, 'acknowledgement')) + w.uint32(18).bytes(m.acknowledgement); + return w; + }; + PacketAcknowledgementData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.PacketAcknowledgementData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.acknowledgement = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PacketAcknowledgementData; + })(); + v1.PacketReceiptAbsenceData = (function () { + function PacketReceiptAbsenceData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; } - } - return m; - }; - return Consensus; + PacketReceiptAbsenceData.prototype.path = $util.newBuffer([]); + PacketReceiptAbsenceData.create = function create(properties) { + return new PacketReceiptAbsenceData(properties); + }; + PacketReceiptAbsenceData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + return w; + }; + PacketReceiptAbsenceData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.PacketReceiptAbsenceData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return PacketReceiptAbsenceData; + })(); + v1.NextSequenceRecvData = (function () { + function NextSequenceRecvData(p) { + if (p) + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) + if (p[ks[i]] != null) this[ks[i]] = p[ks[i]]; + } + NextSequenceRecvData.prototype.path = $util.newBuffer([]); + NextSequenceRecvData.prototype.nextSeqRecv = $util.Long ? $util.Long.fromBits(0, 0, true) : 0; + NextSequenceRecvData.create = function create(properties) { + return new NextSequenceRecvData(properties); + }; + NextSequenceRecvData.encode = function encode(m, w) { + if (!w) w = $Writer.create(); + if (m.path != null && Object.hasOwnProperty.call(m, 'path')) w.uint32(10).bytes(m.path); + if (m.nextSeqRecv != null && Object.hasOwnProperty.call(m, 'nextSeqRecv')) + w.uint32(16).uint64(m.nextSeqRecv); + return w; + }; + NextSequenceRecvData.decode = function decode(r, l) { + if (!(r instanceof $Reader)) r = $Reader.create(r); + var c = l === undefined ? r.len : r.pos + l, + m = new $root.ibc.lightclients.solomachine.v1.NextSequenceRecvData(); + while (r.pos < c) { + var t = r.uint32(); + switch (t >>> 3) { + case 1: + m.path = r.bytes(); + break; + case 2: + m.nextSeqRecv = r.uint64(); + break; + default: + r.skipType(t & 7); + break; + } + } + return m; + }; + return NextSequenceRecvData; + })(); + return v1; + })(); + return solomachine; })(); - return version; + return lightclients; })(); - return tendermint; + return ibc; })(); exports.chainmain = $root.chainmain = (() => { const chainmain = {}; diff --git a/lib/src/cosmos/v1beta1/scripts/get-proto.sh b/lib/src/cosmos/v1beta1/scripts/get-proto.sh index 899353aa..83bd5add 100755 --- a/lib/src/cosmos/v1beta1/scripts/get-proto.sh +++ b/lib/src/cosmos/v1beta1/scripts/get-proto.sh @@ -9,18 +9,22 @@ command -v shellcheck > /dev/null && shellcheck "$0" PROTO_DIR="./proto" COSMOS_DIR="$PROTO_DIR/cosmos" +ICS23_DIR="$PROTO_DIR/ics23" NFT_DIR="$PROTO_DIR/nft" COSMOS_SDK_DIR="$COSMOS_DIR/cosmos-sdk" ZIP_FILE="$COSMOS_DIR/tmp.zip" -REF=${REF:-"master"} -SUFFIX=${REF} +COSMOS_REF=${COSMOS_REF:-"master"} +COSMOS_SUFFIX=${COSMOS_REF} +ICS23_REF=${ICS23_REF:-"master"} +CHAIN_MAIN_REF=${CHAIN_MAIN_REF:-"master"} -[[ $SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]] && SUFFIX=${SUFFIX#v} +[[ $COSMOS_SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]] && COSMOS_SUFFIX=${COSMOS_SUFFIX#v} mkdir -p "$COSMOS_DIR" -curl -sL -o "$ZIP_FILE" "https://github.com/cosmos/cosmos-sdk/archive/$REF.zip" +curl -sL -o "$ZIP_FILE" "https://github.com/cosmos/cosmos-sdk/archive/$COSMOS_REF.zip" unzip "$ZIP_FILE" "*.proto" -d "$COSMOS_DIR" -wget -P "$NFT_DIR" "https://raw.githubusercontent.com/crypto-org-chain/chain-main/master/proto/nft/v1/tx.proto" -mv "$COSMOS_SDK_DIR-$SUFFIX" "$COSMOS_SDK_DIR" +wget -P "$ICS23_DIR" "https://raw.githubusercontent.com/confio/ics23/$ICS23_REF/proofs.proto" +wget -P "$NFT_DIR" "https://raw.githubusercontent.com/crypto-org-chain/chain-main/$CHAIN_MAIN_REF/proto/nft/v1/tx.proto" +mv "$COSMOS_SDK_DIR-$COSMOS_SUFFIX" "$COSMOS_SDK_DIR" rm "$ZIP_FILE" diff --git a/lib/src/cosmos/v1beta1/scripts/predefine-proto.sh b/lib/src/cosmos/v1beta1/scripts/predefine-proto.sh index 3295cd7e..e2c02e41 100755 --- a/lib/src/cosmos/v1beta1/scripts/predefine-proto.sh +++ b/lib/src/cosmos/v1beta1/scripts/predefine-proto.sh @@ -9,6 +9,7 @@ command -v shellcheck > /dev/null && shellcheck "$0" GENERATED_DIR="./tmp" ROOT_PROTO_DIR="./proto/cosmos/cosmos-sdk" +ICS23_PROTO_DIR="./proto/ics23" NFT_PROTO_DIR="./proto/nft" COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/proto/cosmos" IBC_PROTO_DIR="$ROOT_PROTO_DIR/proto/ibc" @@ -32,8 +33,10 @@ mkdir -p "$GENERATED_DIR" "$COSMOS_PROTO_DIR/distribution/v1beta1/tx.proto" \ "$COSMOS_PROTO_DIR/staking/v1beta1/staking.proto" \ "$COSMOS_PROTO_DIR/staking/v1beta1/tx.proto" \ + "$COSMOS_PROTO_DIR/slashing/v1beta1/tx.proto" \ "$COSMOS_PROTO_DIR/base/v1beta1/coin.proto" \ "$COSMOS_PROTO_DIR/crypto/multisig/v1beta1/multisig.proto" \ + "$COSMOS_PROTO_DIR/crypto/multisig/keys.proto" \ "$COSMOS_PROTO_DIR/crypto/secp256k1/keys.proto" \ "$COSMOS_PROTO_DIR/crypto/ed25519/keys.proto" \ "$COSMOS_PROTO_DIR/tx/v1beta1/tx.proto" \ @@ -42,15 +45,25 @@ mkdir -p "$GENERATED_DIR" "$COSMOS_PROTO_DIR/gov/v1beta1/gov.proto" \ "$COSMOS_PROTO_DIR/params/v1beta1/params.proto" \ "$COSMOS_PROTO_DIR/upgrade/v1beta1/upgrade.proto" \ + "$ICS23_PROTO_DIR/proofs.proto" \ + "$IBC_PROTO_DIR/core/commitment/v1/commitment.proto" \ "$IBC_PROTO_DIR/applications/transfer/v1/tx.proto" \ + "$IBC_PROTO_DIR/core/channel/v1/tx.proto" \ + "$IBC_PROTO_DIR/core/channel/v1/channel.proto" \ "$IBC_PROTO_DIR/core/client/v1/tx.proto" \ "$IBC_PROTO_DIR/core/client/v1/client.proto" \ + "$IBC_PROTO_DIR/core/connection/v1/tx.proto" \ + "$IBC_PROTO_DIR/core/connection/v1/connection.proto" \ + "$IBC_PROTO_DIR/lightclients/tendermint/v1/tendermint.proto" \ + "$IBC_PROTO_DIR/lightclients/localhost/v1/localhost.proto" \ + "$IBC_PROTO_DIR/lightclients/solomachine/v1/solomachine.proto" \ + "$IBC_PROTO_DIR/lightclients/localhost/v1/client.proto" \ + "$NFT_PROTO_DIR/tx.proto" \ "$TENDERMINT_PROTO_DIR/types/types.proto" \ "$TENDERMINT_PROTO_DIR/crypto/proof.proto" \ "$TENDERMINT_PROTO_DIR/version/types.proto" \ "$TENDERMINT_PROTO_DIR/types/validator.proto" \ "$TENDERMINT_PROTO_DIR/crypto/keys.proto" \ - "$NFT_PROTO_DIR/tx.proto" \ # "$TENDERMINT_PROTO_DIR/protobuf/timestamp.proto" diff --git a/lib/src/cosmos/v1beta1/types/cosmostx.ts b/lib/src/cosmos/v1beta1/types/cosmostx.ts new file mode 100644 index 00000000..d5d9583c --- /dev/null +++ b/lib/src/cosmos/v1beta1/types/cosmostx.ts @@ -0,0 +1,86 @@ +/* eslint-disable camelcase */ +export interface CosmosTx { + body: Body; + auth_info: AuthInfo; + signatures: string[]; +} + +interface AuthInfo { + signer_infos: SignerInfo[]; + fee: Fee; +} + +interface Fee { + amount: Amount[]; + gas_limit: string; + payer: string; + granter: string; +} + +interface Amount { + denom: string; + amount: string; +} + +interface SignerInfo { + public_key: SingleSignerInfoPublicKey | MultiSignerInfoPublicKey; + mode_info: SignerInfoModeInfo; + sequence: string; +} + +interface SignerInfoModeInfo { + single?: Single; + multi?: Multi; +} + +interface Multi { + bitarray: Bitarray; + mode_infos: ModeInfoElement[]; +} + +interface Bitarray { + extra_bits_stored: number; + elems: string; +} + +interface ModeInfoElement { + single: Single; +} + +interface Single { + mode: string; +} + +interface SingleSignerInfoPublicKey { + '@type': string; + key: string; +} + +interface MultiSignerInfoPublicKey { + '@type': string; + threshold?: number; + public_keys: PublicKeyElement[]; +} + +interface PublicKeyElement { + '@type': string; + key: string; +} + +interface Body { + messages: Message[]; + memo: string; + timeout_height: string; + extension_options: any[]; + non_critical_extension_options: any[]; +} + +interface Message { + '@type': string; + [key: string]: any; +} + +interface Amount { + denom: string; + amount: string; +} diff --git a/lib/src/cosmos/v1beta1/types/ow.types.ts b/lib/src/cosmos/v1beta1/types/ow.types.ts index a52d791b..25c4fbac 100644 --- a/lib/src/cosmos/v1beta1/types/ow.types.ts +++ b/lib/src/cosmos/v1beta1/types/ow.types.ts @@ -1,12 +1,22 @@ import ow from 'ow'; import { owOptionalCoin } from '../../../coin/ow.types'; -import { owBig, owOptionalBig, owStrictObject } from '../../../ow.types'; +import { owBig, owOptionalBig, owStrictObject, owOptionalStrictObject } from '../../../ow.types'; import { owCosmosMsg } from '../../../transaction/msg/cosmosMsg'; import { owTimeoutHeight } from '../../../transaction/ow.types'; import { owBytes } from '../../../utils/bytes/ow.types'; import { cosmos } from '../codec'; +export const owOptionalTxBody = () => + owOptionalStrictObject().exactShape({ + typeUrl: ow.string.equals('/cosmos.tx.v1beta1.TxBody'), + value: owStrictObject().exactShape({ + messages: ow.array.ofType(owCosmosMsg()), + memo: ow.string, + timeoutHeight: owTimeoutHeight, + }), + }); + export const owTxBody = () => owStrictObject().exactShape({ typeUrl: ow.string.equals('/cosmos.tx.v1beta1.TxBody'), @@ -16,7 +26,6 @@ export const owTxBody = () => timeoutHeight: owTimeoutHeight, }), }); - export const owAuthInfo = () => owStrictObject().exactShape({ signerInfos: ow.array.ofType(owSignerInfo()), diff --git a/lib/src/cosmos/v1beta1/types/tx.ts b/lib/src/cosmos/v1beta1/types/tx.ts index b54adacb..42af0b6a 100644 --- a/lib/src/cosmos/v1beta1/types/tx.ts +++ b/lib/src/cosmos/v1beta1/types/tx.ts @@ -15,6 +15,16 @@ export type TxBody = { }; }; +export type AuthInfoV2 = { + signerInfos: SignerInfo[]; + fee: { + amount?: ICoin[]; + gasLimit?: Big; + payer?: string; + granter?: string; + }; +}; + export type AuthInfo = { signerInfos: SignerInfo[]; fee: { diff --git a/lib/src/cosmos/v1beta1/types/typeurls.ts b/lib/src/cosmos/v1beta1/types/typeurls.ts index 2daf7b7b..1b7cba3c 100644 --- a/lib/src/cosmos/v1beta1/types/typeurls.ts +++ b/lib/src/cosmos/v1beta1/types/typeurls.ts @@ -3,12 +3,13 @@ // Copyright © 2020 Simon Warta (licensed under the Apache License, Version 2.0) // Modifications Copyright (c) 2018 - 2020, Foris Limited (licensed under the Apache License, Version 2.0) import protobuf from 'protobufjs'; -import { cosmos, google, chainmain } from '../codec'; +import { cosmos, google, chainmain, ibc } from '../codec'; export const typeUrlMappings: { [key: string]: GeneratedType; } = { '/cosmos.base.v1beta1.Coin': cosmos.base.v1beta1.Coin, + '/cosmos.crypto.multisig.LegacyAminoPubKey': cosmos.crypto.multisig.LegacyAminoPubKey, '/cosmos.bank.v1beta1.MsgSend': cosmos.bank.v1beta1.MsgSend, '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward': cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward, '/cosmos.staking.v1beta1.MsgCreateValidator': cosmos.staking.v1beta1.MsgCreateValidator, @@ -18,11 +19,17 @@ export const typeUrlMappings: { '/cosmos.staking.v1beta1.MsgUndelegate': cosmos.staking.v1beta1.MsgUndelegate, '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission': cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission, + '/cosmos.slashing.v1beta1.MsgUnjail': cosmos.slashing.v1beta1.MsgUnjail, '/cosmos.crypto.ed25519.PubKey': cosmos.crypto.ed25519.PubKey, '/cosmos.crypto.secp256k1.PubKey': cosmos.crypto.secp256k1.PubKey, '/cosmos.gov.v1beta1.MsgDeposit': cosmos.gov.v1beta1.MsgDeposit, '/cosmos.gov.v1beta1.MsgVote': cosmos.gov.v1beta1.MsgVote, '/cosmos.gov.v1beta1.MsgSubmitProposal': cosmos.gov.v1beta1.MsgSubmitProposal, + '/cosmos.distribution.v1beta1.CommunityPoolSpendProposal': cosmos.distribution.v1beta1.CommunityPoolSpendProposal, + '/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal': cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal, + '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal': cosmos.upgrade.v1beta1.SoftwareUpgradeProposal, + '/cosmos.gov.v1beta1.TextProposal': cosmos.gov.v1beta1.TextProposal, + '/cosmos.params.v1beta1.ParameterChangeProposal': cosmos.params.v1beta1.ParameterChangeProposal, '/google.protobuf.Any': google.protobuf.Any, '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress': cosmos.distribution.v1beta1.MsgSetWithdrawAddress, '/cosmos.distribution.v1beta1.MsgFundCommunityPool': cosmos.distribution.v1beta1.MsgFundCommunityPool, @@ -31,6 +38,28 @@ export const typeUrlMappings: { '/chainmain.nft.v1.MsgEditNFT': chainmain.nft.v1.MsgEditNFT, '/chainmain.nft.v1.MsgTransferNFT': chainmain.nft.v1.MsgTransferNFT, '/chainmain.nft.v1.MsgBurnNFT': chainmain.nft.v1.MsgBurnNFT, + '/ibc.applications.transfer.v1.MsgTransfer': ibc.applications.transfer.v1.MsgTransfer, + '/ibc.core.channel.v1.MsgChannelOpenInit': ibc.core.channel.v1.MsgChannelOpenInit, + '/ibc.core.channel.v1.MsgChannelOpenAck': ibc.core.channel.v1.MsgChannelOpenAck, + '/ibc.core.channel.v1.MsgChannelOpenTry': ibc.core.channel.v1.MsgChannelOpenTry, + '/ibc.core.channel.v1.MsgChannelOpenConfirm': ibc.core.channel.v1.MsgChannelOpenConfirm, + '/ibc.core.channel.v1.MsgChannelCloseInit': ibc.core.channel.v1.MsgChannelCloseInit, + '/ibc.core.channel.v1.MsgChannelCloseConfirm': ibc.core.channel.v1.MsgChannelCloseConfirm, + '/ibc.core.connection.v1.MsgConnectionOpenInit': ibc.core.connection.v1.MsgConnectionOpenInit, + '/ibc.core.connection.v1.MsgConnectionOpenAck': ibc.core.connection.v1.MsgConnectionOpenAck, + '/ibc.core.connection.v1.MsgConnectionOpenTry': ibc.core.connection.v1.MsgConnectionOpenTry, + '/ibc.core.connection.v1.MsgConnectionOpenConfirm': ibc.core.connection.v1.MsgConnectionOpenConfirm, + '/ibc.core.channel.v1.MsgRecvPacket': ibc.core.channel.v1.MsgRecvPacket, + '/ibc.core.channel.v1.MsgTimeout': ibc.core.channel.v1.MsgTimeout, + '/ibc.core.channel.v1.MsgTimeoutOnClose': ibc.core.channel.v1.MsgTimeoutOnClose, + '/ibc.core.channel.v1.MsgAcknowledgement': ibc.core.channel.v1.MsgAcknowledgement, + '/ibc.core.client.v1.MsgCreateClient': ibc.core.client.v1.MsgCreateClient, + '/ibc.core.client.v1.MsgUpdateClient': ibc.core.client.v1.MsgUpdateClient, + '/ibc.core.client.v1.MsgUpgradeClient': ibc.core.client.v1.MsgUpgradeClient, + '/ibc.core.client.v1.MsgSubmitMisbehaviour': ibc.core.client.v1.MsgSubmitMisbehaviour, + '/ibc.lightclients.tendermint.v1.ClientState': ibc.lightclients.tendermint.v1.ClientState, + '/ibc.lightclients.tendermint.v1.ConsensusState': ibc.lightclients.tendermint.v1.ConsensusState, + '/ibc.lightclients.tendermint.v1.Header': ibc.lightclients.tendermint.v1.Header, }; export interface GeneratedType { diff --git a/lib/src/index.ts b/lib/src/index.ts index d1913ecc..21584458 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -4,6 +4,7 @@ import { Secp256k1KeyPair } from './keypair/secp256k1'; import utils from './utils'; import { CroNetwork, CroSDK } from './core/cro'; import { Units } from './coin/coin'; +import { TxDecoder } from './utils/txDecoder'; // The maximum number of decimal places of the results of operations involving division // By default it is 20. Here we explicitly set it to 20 for correctness. @@ -16,6 +17,7 @@ const _ = { CroSDK, CroNetwork, Units, + TxDecoder, }; export = _; diff --git a/lib/src/transaction/amino.spec.ts b/lib/src/transaction/amino.spec.ts index 1824a675..cae0a512 100644 --- a/lib/src/transaction/amino.spec.ts +++ b/lib/src/transaction/amino.spec.ts @@ -65,6 +65,66 @@ describe('Amino JSON sign mode', function () { '0a9f010a8c010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126c0a2b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a36383532717371733868783530122b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a363835327173717338687835301a100a08626173657463726f120431303030120a616d696e6f20746573741880ea30126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210223c9395d41013e6470c8d27da8b75850554faada3fe3e812660cbdf4534a85d712040a02087f180112170a110a08626173657463726f1205313030303010a08d061a40470b6d3e9c4a372eedd59214b9b72489429ec50fe60d94389d2a4809d516b6b820b7230adb6137d7e1555ac76b6164ffaf4841680e05040593a8cb3f4d4d6eb7'; expect(signedTx.getHexEncoded()).to.eq(expectedTxHex); + const expectedTxHash = 'E9B8FCAB8ED3ECD9F8E2746D8740FCC45E2B49B61A6D5999540DB2C66ECF85CF'; + expect(signedTx.getTxHash()).to.eq(expectedTxHash); + }); + it('should work for `v2`', function () { + const mnemonic = + 'source knee choice chef exact recall craft satoshi coffee intact fun eternal sudden client quote recall sausage injury return duck bottom security like title'; + const hdKey = HDKey.fromMnemonic(mnemonic); + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, + }); + const msg = new cro.bank.MsgSend({ + fromAddress: new cro.Address(keyPair).account(), + toAddress: 'tcro1fzcrza3j4f2677jfuxulkg33z6852qsqs8hx50', + amount: cro.Coin.fromBaseUnit('1000'), + }); + + const rawTx = new cro.v2.RawTransactionV2(); + const signableTx = rawTx + .appendMessage(msg) + .addSigner({ + publicKey: keyPair.getPubKey(), + accountNumber: new Big('179'), + accountSequence: new Big('1'), + signMode: SIGN_MODE.LEGACY_AMINO_JSON, + }) + .setFees([cro.v2.CoinV2.fromBaseUnit('10000')]) + .setGasLimit('100000') + .setMemo('amino test') + .setTimeOutHeight('800000') + .toSignable(); + + const signature = keyPair.sign(signableTx.toSignDocumentHash(0)); + const expectedSignature = + 'RwttPpxKNy7t1ZIUubckiUKexQ/mDZQ4nSpICdUWtrggtyMK22E31+FVWsdrYWT/r0hBaA4FBAWTqMs/TU1utw=='; + expect(signature.toBase64String()).to.eq(expectedSignature); + + const signedTx = signableTx.setSignature(0, signature).toSigned(); + + const expectedTxHex = + '0a9f010a8c010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126c0a2b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a36383532717371733868783530122b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a363835327173717338687835301a100a08626173657463726f120431303030120a616d696e6f20746573741880ea30126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210223c9395d41013e6470c8d27da8b75850554faada3fe3e812660cbdf4534a85d712040a02087f180112170a110a08626173657463726f1205313030303010a08d061a40470b6d3e9c4a372eedd59214b9b72489429ec50fe60d94389d2a4809d516b6b820b7230adb6137d7e1555ac76b6164ffaf4841680e05040593a8cb3f4d4d6eb7'; + expect(signedTx.getHexEncoded()).to.eq(expectedTxHex); + const expectedTxHash = 'E9B8FCAB8ED3ECD9F8E2746D8740FCC45E2B49B61A6D5999540DB2C66ECF85CF'; expect(signedTx.getTxHash()).to.eq(expectedTxHash); }); diff --git a/lib/src/transaction/common/constants/typeurl.ts b/lib/src/transaction/common/constants/typeurl.ts index bf376d68..5904dcd5 100644 --- a/lib/src/transaction/common/constants/typeurl.ts +++ b/lib/src/transaction/common/constants/typeurl.ts @@ -17,6 +17,8 @@ export const COSMOS_MSG_TYPEURL = { upgrade: { CancelSoftwareUpgradeProposal: '/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal', SoftwareUpgradeProposal: '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal', + ParameterChangeProposal: '/cosmos.params.v1beta1.ParameterChangeProposal', + CommunityPoolSpendProposal: '/cosmos.distribution.v1beta1.CommunityPoolSpendProposal', }, distribution: { MsgSetWithdrawAddress: '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress', @@ -32,4 +34,103 @@ export const COSMOS_MSG_TYPEURL = { MsgTransferNFT: '/chainmain.nft.v1.MsgTransferNFT', MsgBurnNFT: '/chainmain.nft.v1.MsgBurnNFT', }, + ibc: { + MsgTransfer: '/ibc.applications.transfer.v1.MsgTransfer', + MsgCreateClient: '/ibc.core.client.v1.MsgCreateClient', + MsgUpdateClient: '/ibc.core.client.v1.MsgUpdateClient', + MsgUpgradeClient: '/ibc.core.client.v1.MsgUpgradeClient', + MsgSubmitMisbehaviour: '/ibc.core.client.v1.MsgSubmitMisbehaviour', + LightClients: { + ClientState: '/ibc.lightclients.tendermint.v1.ClientState', + ConsensusState: '/ibc.lightclients.tendermint.v1.ConsensusState', + Header: '/ibc.lightclients.tendermint.v1.Header', + }, + connection: { + MsgConnectionOpenConfirm: '/ibc.core.connection.v1.MsgConnectionOpenConfirm', + MsgConnectionOpenTry: '/ibc.core.connection.v1.MsgConnectionOpenTry', + }, + }, +}; + +export const typeUrlToMsgClassMapping = (cro: any, typeUrl: string) => { + switch (typeUrl) { + // bank + case COSMOS_MSG_TYPEURL.MsgSend: + return cro.bank.MsgSend; + + // distribution + case COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool: + return cro.distribution.MsgFundCommunityPool; + case COSMOS_MSG_TYPEURL.distribution.MsgSetWithdrawAddress: + return cro.distribution.MsgSetWithdrawAddress; + case COSMOS_MSG_TYPEURL.MsgWithdrawDelegatorReward: + return cro.distribution.MsgWithdrawDelegatorReward; + case COSMOS_MSG_TYPEURL.MsgWithdrawValidatorCommission: + return cro.distribution.MsgWithdrawValidatorCommission; + + // staking + case COSMOS_MSG_TYPEURL.MsgBeginRedelegate: + return cro.staking.MsgBeginRedelegate; + case COSMOS_MSG_TYPEURL.MsgCreateValidator: + return cro.staking.MsgCreateValidator; + case COSMOS_MSG_TYPEURL.MsgDelegate: + return cro.staking.MsgDelegate; + case COSMOS_MSG_TYPEURL.MsgEditValidator: + return cro.staking.MsgEditValidator; + case COSMOS_MSG_TYPEURL.MsgUndelegate: + return cro.staking.MsgUndelegate; + + // governance + case COSMOS_MSG_TYPEURL.MsgDeposit: + return cro.gov.MsgDeposit; + case COSMOS_MSG_TYPEURL.MsgVote: + return cro.gov.MsgVote; + case COSMOS_MSG_TYPEURL.MsgSubmitProposal: + return cro.gov.MsgSubmitProposal; + + // proposal + case COSMOS_MSG_TYPEURL.gov.TextProposal: + return cro.gov.proposal.TextProposal; + case COSMOS_MSG_TYPEURL.upgrade.CancelSoftwareUpgradeProposal: + return cro.gov.proposal.CancelSoftwareUpgradeProposal; + case COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal: + return cro.gov.proposal.CommunityPoolSpendProposal; + case COSMOS_MSG_TYPEURL.upgrade.ParameterChangeProposal: + return cro.gov.proposal.ParamChangeProposal; + case COSMOS_MSG_TYPEURL.upgrade.SoftwareUpgradeProposal: + return cro.gov.proposal.SoftwareUpgradeProposal; + + // ibc + case COSMOS_MSG_TYPEURL.ibc.MsgTransfer: + return cro.ibc.MsgTransfer; + case COSMOS_MSG_TYPEURL.ibc.MsgCreateClient: + return cro.ibc.MsgCreateClient; + case COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient: + return cro.ibc.MsgUpdateClient; + case COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient: + return cro.ibc.MsgUpgradeClient; + case COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour: + return cro.ibc.MsgSubmitMisbehaviour; + + // ibc.connection + case COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm: + return cro.ibc.connection.MsgConnectionOpenConfirm; + case COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry: + return cro.ibc.connection.MsgConnectionOpenTry; + + // nft + case COSMOS_MSG_TYPEURL.nft.MsgIssueDenom: + return cro.nft.MsgIssueDenom; + case COSMOS_MSG_TYPEURL.nft.MsgMintNFT: + return cro.nft.MsgMintNFT; + case COSMOS_MSG_TYPEURL.nft.MsgEditNFT: + return cro.nft.MsgEditNFT; + case COSMOS_MSG_TYPEURL.nft.MsgTransferNFT: + return cro.nft.MsgTransferNFT; + case COSMOS_MSG_TYPEURL.nft.MsgBurnNFT: + return cro.nft.MsgBurnNFT; + + default: + throw new Error(`${typeUrl} not supported.`); + } }; diff --git a/lib/src/transaction/msg/bank/msgsend.spec.ts b/lib/src/transaction/msg/bank/msgsend.spec.ts index ef39781b..39bd2b92 100644 --- a/lib/src/transaction/msg/bank/msgsend.spec.ts +++ b/lib/src/transaction/msg/bank/msgsend.spec.ts @@ -29,6 +29,60 @@ const cro = CroSDK({ }); describe('Testing MsgSend', function () { + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgSend', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.bank.v1beta1.MsgSend but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the from field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `fromAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the to field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg" }'; + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `toAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg" , "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should throw on invalid `fromAddress`', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw( + 'Provided `fromAddress` does not match network selected', + ); + }); + it('should throw on invalid `toAddress`', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3", "to_address": "cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f" }'; + + expect(() => cro.bank.MsgSend.fromCosmosMsgJSON(json)).to.throw( + 'Provided `toAddress` does not match network selected', + ); + }); + it('should return the MsgSend corresponding to the JSON', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + const msgSend = cro.bank.MsgSend.fromCosmosMsgJSON(json); + expect(msgSend.fromAddress).to.eql('tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg'); + expect(msgSend.toAddress).to.eql('tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3'); + expect(msgSend.amount.toCosmosCoin().amount).to.eql('3478499933290496'); + expect(msgSend.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); + }); + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { const anyValidOptions = { fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', diff --git a/lib/src/transaction/msg/bank/msgsend.ts b/lib/src/transaction/msg/bank/msgsend.ts index 738885cc..c9054861 100644 --- a/lib/src/transaction/msg/bank/msgsend.ts +++ b/lib/src/transaction/msg/bank/msgsend.ts @@ -1,13 +1,26 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { ICoin } from '../../../coin/coin'; import { owMsgSendOptions } from '../ow.types'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { AddressType, validateAddress } from '../../../utils/address'; import { CosmosMsg } from '../cosmosMsg'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; import * as legacyAmino from '../../../cosmos/amino'; +export interface MsgSendRaw { + '@type': string; + amount: Amount[]; + from_address: string; + to_address: string; +} + +export interface Amount { + denom: string; + amount: string; +} + export const msgSend = function (config: InitConfigurations) { return class MsgSend implements CosmosMsg { public readonly fromAddress: string; @@ -32,6 +45,29 @@ export const msgSend = function (config: InitConfigurations) { this.validateAddresses(); } + /** + * Returns an instance of MsgSend + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSend} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSend { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSendRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgSend) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgSend} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.amount || parsedMsg.amount.length !== 1) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgSend({ + fromAddress: parsedMsg.from_address, + toAddress: parsedMsg.to_address, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount[0].amount, parsedMsg.amount[0].denom), + }); + } + /** * Returns the raw Msg representation of MsgSend * @returns {Msg} diff --git a/lib/src/transaction/msg/distribution/MsgFundCommunityPool.spec.ts b/lib/src/transaction/msg/distribution/MsgFundCommunityPool.spec.ts index 41485bb9..35f26e2f 100644 --- a/lib/src/transaction/msg/distribution/MsgFundCommunityPool.spec.ts +++ b/lib/src/transaction/msg/distribution/MsgFundCommunityPool.spec.ts @@ -70,7 +70,7 @@ describe('Testing MsgFundCommunityPool', function () { const signedTxHex = signedTx.encode().toHexString(); expect(signedTxHex).to.be.eql( - '0a640a620a312f636f736d6f732e646973747269627574696f6e2e763162657461312e4d736746756e64436f6d6d756e697479506f6f6c122d122b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b633312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a40dea8c5292e72ca736bc189d6214fdb44e45c1ad0cc91314d81e90f2d825124b2331a9aad56c2ba6af63071dc5d7e0a18712e68d473387033346de78f4cfdacf7', + '0a760a740a312f636f736d6f732e646973747269627574696f6e2e763162657461312e4d736746756e64436f6d6d756e697479506f6f6c123f0a100a08626173657463726f120431303030122b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b633312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a400c93f8e74991dde45638e3d4366f7607fd9711272d0602f1e2e797d9180d25c30031955522e7ddc380d7ac4435e7f6d01fbea5db685655ba0b04d43b4135bf3d', ); }); @@ -103,4 +103,37 @@ describe('Testing MsgFundCommunityPool', function () { }).to.throw('Provided `depositor` address doesnt match network selected'); }); }); -}); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgFundCommunityPool', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.distribution.MsgFundCommunityPool.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.MsgFundCommunityPool but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should throw Error when the `depositor` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","amount":[{ "denom": "basetcro", "amount": "3478499933290496" }]}'; + expect(() => cro.distribution.MsgFundCommunityPool.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `depositor` to be of type `string` but received type `undefined` in object `communityPoolOptions`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","depositor":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.distribution.MsgFundCommunityPool.fromCosmosMsgJSON(json)).to.throw( + 'Invalid amount in the Msg.', + ); + }); + it('should return the `MsgFundCommunityPool` corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","amount":[{ "denom": "basetcro", "amount": "3478499933290496" }],"depositor":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + + const msgFundCommPool = cro.distribution.MsgFundCommunityPool.fromCosmosMsgJSON(json); + expect(msgFundCommPool.depositor).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(msgFundCommPool.amount.toCosmosCoin().amount).to.eql('3478499933290496'); + expect(msgFundCommPool.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); + }); +}); \ No newline at end of file diff --git a/lib/src/transaction/msg/distribution/MsgFundCommunityPool.ts b/lib/src/transaction/msg/distribution/MsgFundCommunityPool.ts index bf92e08f..04ddc5b2 100644 --- a/lib/src/transaction/msg/distribution/MsgFundCommunityPool.ts +++ b/lib/src/transaction/msg/distribution/MsgFundCommunityPool.ts @@ -1,7 +1,7 @@ import ow from 'ow'; import { CosmosMsg } from '../cosmosMsg'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { AddressType, validateAddress } from '../../../utils/address'; import { owMsgFundCommunityPoolOptions } from '../ow.types'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; @@ -50,11 +50,35 @@ export const msgFundCommunityPool = function (config: InitConfigurations) { typeUrl: COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool, value: { depositor: this.depositor, - amount: this.amount, + amount: this.amount.toCosmosCoins(), }, }; } + /** + * Returns an instance of MsgFundCommunityPool + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgFundCommunityPool} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgFundCommunityPool { + const parsedMsg = JSON.parse(msgJsonStr) as MsgFundCommunityPoolRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool} but got ${parsedMsg['@type']}`, + ); + } + if (!parsedMsg.amount || parsedMsg.amount.length !== 1) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgFundCommunityPool({ + depositor: parsedMsg.depositor, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount[0].amount, parsedMsg.amount[0].denom), + }); + } + validateAddresses() { if ( !validateAddress({ @@ -73,3 +97,13 @@ export type MsgFundCommunityPoolOptions = { depositor: string; amount: ICoin; }; +interface MsgFundCommunityPoolRaw { + '@type': string; + amount: Amount[]; + depositor: string; +} + +interface Amount { + denom: string; + amount: string; +} diff --git a/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.spec.ts b/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.spec.ts index 06748515..fba70cde 100644 --- a/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.spec.ts +++ b/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.spec.ts @@ -68,7 +68,7 @@ describe('Testing MsgSetWithdrawAddress', function () { const signedTxHex = signedTx.encode().toHexString(); expect(signedTxHex).to.be.eql( - '0a650a630a322f636f736d6f732e646973747269627574696f6e2e763162657461312e4d7367536574576974686472617741646472657373122d0a2b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b633312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a407a98473a7ffdb8563e0d4adb598e1bff1d16b708d2709d953ca11d8ea53152c93d509c54b8956eaec0fd887654fb6074bd23559126af8501d9643d192f0618bb', + '0a93010a90010a322f636f736d6f732e646973747269627574696f6e2e763162657461312e4d7367536574576974686472617741646472657373125a0a2b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b6333122b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b633312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a401737cd71b6a4263544be64db99c93ed32974c37f8face69b7df860c35cd583873e6f5694f746d5bb7ab546ea461caadba354b3ed7a9a4e12cc46fe163de2bd1d', ); }); @@ -110,4 +110,36 @@ describe('Testing MsgSetWithdrawAddress', function () { }).to.throw('Provided `withdrawAddress` doesnt match network selected'); }); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgSetWithdrawAddress', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.distribution.MsgSetWithdrawAddress.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.MsgSetWithdrawAddress but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should throw Error when the `withdraw_address` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.distribution.MsgSetWithdrawAddress.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `withdrawAddress` to be of type `string` but received type `undefined` in object `setWithdrawOptions`', + ); + }); + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress","withdraw_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.distribution.MsgSetWithdrawAddress.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `setWithdrawOptions`', + ); + }); + it('should return the `MsgSetWithdrawAddress` corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","withdraw_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + + const MsgSetWithdrawAddress = cro.distribution.MsgSetWithdrawAddress.fromCosmosMsgJSON(json); + expect(MsgSetWithdrawAddress.withdrawAddress).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(MsgSetWithdrawAddress.delegatorAddress).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.ts b/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.ts index 17c654da..fdf71735 100644 --- a/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.ts +++ b/lib/src/transaction/msg/distribution/MsgSetWithdrawAddress.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { CosmosMsg } from '../cosmosMsg'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; @@ -50,11 +51,31 @@ export const msgSetWithdrawAddress = function (config: InitConfigurations) { typeUrl: COSMOS_MSG_TYPEURL.distribution.MsgSetWithdrawAddress, value: { delegatorAddress: this.delegatorAddress, - validatorAddress: this.withdrawAddress, + withdrawAddress: this.withdrawAddress, }, }; } + /** + * * Returns an instance of MsgSetWithdrawAddress + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSetWithdrawAddress} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSetWithdrawAddress { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSetWithdrawAddressRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.distribution.MsgSetWithdrawAddress) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.distribution.MsgSetWithdrawAddress} but got ${parsedMsg['@type']}`, + ); + } + + return new MsgSetWithdrawAddress({ + withdrawAddress: parsedMsg.withdraw_address, + delegatorAddress: parsedMsg.delegator_address, + }); + } + validateAddresses() { if ( !validateAddress({ @@ -83,3 +104,9 @@ export type MsgSetWithdrawAddressOptions = { delegatorAddress: string; withdrawAddress: string; }; + +interface MsgSetWithdrawAddressRaw { + '@type': string; + delegator_address: string; + withdraw_address: string; +} diff --git a/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.spec.ts b/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.spec.ts index aad74b43..929ab13a 100644 --- a/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.spec.ts +++ b/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.spec.ts @@ -89,4 +89,39 @@ describe('Testing MsgWithdrawDelegatorReward', function () { expect(MsgWithdrawDelegatatorReward.toRawAminoMsg()).to.eqls(rawMsg); }); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgWithdrawDelegatorReward', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.distribution.MsgWithdrawDelegatorReward.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should throw Error when the `validator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.distribution.MsgWithdrawDelegatorReward.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorAddress` to be of type `string` but received type `undefined` in object `rewardOptions`', + ); + }); + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward","validator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.distribution.MsgWithdrawDelegatorReward.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `rewardOptions`', + ); + }); + it('should return the `MsgWithdrawDelegatorReward` corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","validator_address":"tcrocncl1reyshfdygf7673xm9p8v0xvtd96m6cd6canhu3"}'; + + const MsgWithdrawDelegatorReward = cro.distribution.MsgWithdrawDelegatorReward.fromCosmosMsgJSON(json); + expect(MsgWithdrawDelegatorReward.validatorAddress).to.eql( + 'tcrocncl1reyshfdygf7673xm9p8v0xvtd96m6cd6canhu3', + ); + expect(MsgWithdrawDelegatorReward.delegatorAddress).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.ts b/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.ts index 96e1a423..8bc0bf3f 100644 --- a/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.ts +++ b/lib/src/transaction/msg/distribution/MsgWithdrawDelegatorReward.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { CosmosMsg } from '../cosmosMsg'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; @@ -55,6 +56,26 @@ export const msgWithdrawDelegateReward = function (config: InitConfigurations) { }; } + /** + * * Returns an instance of MsgWithdrawDelegatorReward + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgWithdrawDelegatorReward} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgWithdrawDelegatorReward { + const parsedMsg = JSON.parse(msgJsonStr) as MsgWithdrawDelegatorRewardRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgWithdrawDelegatorReward) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.MsgWithdrawDelegatorReward} but got ${parsedMsg['@type']}`, + ); + } + + return new MsgWithdrawDelegatorReward({ + validatorAddress: parsedMsg.validator_address, + delegatorAddress: parsedMsg.delegator_address, + }); + } + validateAddresses() { if ( !validateAddress({ @@ -83,3 +104,9 @@ export type MsgWithdrawDelegatorRewardOptions = { delegatorAddress: string; validatorAddress: string; }; + +interface MsgWithdrawDelegatorRewardRaw { + '@type': string; + delegator_address: string; + validator_address: string; +} diff --git a/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.spec.ts b/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.spec.ts index a62836f0..59ffb057 100644 --- a/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.spec.ts +++ b/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.spec.ts @@ -69,4 +69,33 @@ describe('Testing MsgWithdrawValidatorCommission', function () { '0a720a700a3b2f636f736d6f732e646973747269627574696f6e2e763162657461312e4d7367576974686472617756616c696461746f72436f6d6d697373696f6e12310a2f7463726f636e636c317265797368666479676637363733786d39703876307876746439366d3663643663616e68753312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a4006045a84d818932356613207e122d972d3af6b6757b2eef702cdd716e53c10cf478a8d639169f14551c9aa77ec928d817dfee5856d172b21d191f4a03d33b40f', ); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgWithdrawValidatorCommission', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.distribution.MsgWithdrawValidatorCommission.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should throw Error when the `validator_address` field is missing', function () { + const json = '{"@type":"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission"}'; + expect(() => cro.distribution.MsgWithdrawValidatorCommission.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorAddress` to be of type `string` but received type `undefined` in object `commissionWithdrawalOptions`', + ); + }); + + it('should return the `MsgWithdrawValidatorCommission` corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission","validator_address":"tcrocncl1reyshfdygf7673xm9p8v0xvtd96m6cd6canhu3"}'; + + const MsgWithdrawValidatorCommission = cro.distribution.MsgWithdrawValidatorCommission.fromCosmosMsgJSON( + json, + ); + expect(MsgWithdrawValidatorCommission.validatorAddress).to.eql( + 'tcrocncl1reyshfdygf7673xm9p8v0xvtd96m6cd6canhu3', + ); + }); + }); }); diff --git a/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.ts b/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.ts index 86c0b4c1..cca0b595 100644 --- a/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.ts +++ b/lib/src/transaction/msg/distribution/MsgWithdrawValidatorCommission.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { InitConfigurations } from '../../../core/cro'; import { CosmosMsg } from '../cosmosMsg'; @@ -42,6 +43,25 @@ export const msgWithdrawValidatorCommission = function (config: InitConfiguratio }; } + /** + * * Returns an instance of MsgWithdrawValidatorCommission + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgWithdrawValidatorCommission} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgWithdrawValidatorCommission { + const parsedMsg = JSON.parse(msgJsonStr) as MsgWithdrawValidatorCommissionRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgWithdrawValidatorCommission) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.MsgWithdrawValidatorCommission} but got ${parsedMsg['@type']}`, + ); + } + + return new MsgWithdrawValidatorCommission({ + validatorAddress: parsedMsg.validator_address, + }); + } + /** * Validate address * @throws {Error} when the validatorAddress is invalid @@ -63,3 +83,8 @@ export const msgWithdrawValidatorCommission = function (config: InitConfiguratio export type MsgWithdrawValidatorCommissionOptions = { validatorAddress: string; }; + +interface MsgWithdrawValidatorCommissionRaw { + '@type': string; + validator_address: string; +} diff --git a/lib/src/transaction/msg/gov/MsgDeposit.spec.ts b/lib/src/transaction/msg/gov/MsgDeposit.spec.ts index 413b1ca9..8b82792d 100644 --- a/lib/src/transaction/msg/gov/MsgDeposit.spec.ts +++ b/lib/src/transaction/msg/gov/MsgDeposit.spec.ts @@ -104,4 +104,39 @@ describe('Testing MsgDeposit', function () { '0a730a710a1e2f636f736d6f732e676f762e763162657461312e4d73674465706f736974124f08e0f64b122b7463726f3138346c7461326c7379753437767779703265387a6d746361336b3579713835703663347670331a1c0a08626173657463726f12103132303030353030303030303030303012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030bf28c5f92c336db4703791691fa650fee408690b0a22c5ee4afb7e2508d32a712040a0208011800120410c09a0c1a40ba8c80028a85015ac737ca56603bef0a82e0fbd83f701ccbba02a4f381e5ee4a3d83af13cd02f1e9c1e8b386995d8468c2db1db73952c30fac6114004fe269c0', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgDeposit', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.MsgDeposit.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.MsgDeposit but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `proposal_id` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + expect(() => cro.gov.MsgDeposit.fromCosmosMsgJSON(json)).to.throw('Invalid `proposal_id` in JSON.'); + }); + it('should throw Error when the `depositor` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + expect(() => cro.gov.MsgDeposit.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `depositor` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `amount` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3"}'; + expect(() => cro.gov.MsgDeposit.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should return the MsgDeposit corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + const MsgDeposit = cro.gov.MsgDeposit.fromCosmosMsgJSON(json); + expect(MsgDeposit.depositor).to.eql('tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3'); + expect((MsgDeposit.proposalId as Big).toString()).to.eql('1244000'); + expect(MsgDeposit.amount.toCosmosCoin().amount).to.eql('1234567890'); + expect(MsgDeposit.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/MsgDeposit.ts b/lib/src/transaction/msg/gov/MsgDeposit.ts index 34e2eca1..ecf284f7 100644 --- a/lib/src/transaction/msg/gov/MsgDeposit.ts +++ b/lib/src/transaction/msg/gov/MsgDeposit.ts @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ import Big from 'big.js'; import Long from 'long'; import ow from 'ow'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { CosmosMsg } from '../cosmosMsg'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { ICoin } from '../../../coin/coin'; @@ -9,6 +10,7 @@ import { AddressType, validateAddress } from '../../../utils/address'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; import { owMsgDepositOptions } from '../ow.types'; import * as legacyAmino from '../../../cosmos/amino'; +import { Amount } from '../bank/msgsend'; export const msgDeposit = function (config: InitConfigurations) { return class MsgDeposit implements CosmosMsg { @@ -61,6 +63,35 @@ export const msgDeposit = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgDeposit + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgDeposit} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgDeposit { + const parsedMsg = JSON.parse(msgJsonStr) as MsgDepositRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgDeposit) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgDeposit} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.proposal_id) { + throw new Error('Invalid `proposal_id` in JSON.'); + } + + if (!parsedMsg.amount || parsedMsg.amount.length !== 1) { + throw new Error('Invalid amount in the Msg.'); + } + + const cro = CroSDK({ network: config.network }); + + return new MsgDeposit({ + proposalId: new Big(parsedMsg.proposal_id), + depositor: parsedMsg.depositor, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount[0].amount, parsedMsg.amount[0].denom), + }); + } + validate() { if ( !validateAddress({ @@ -80,3 +111,10 @@ export type MsgDepositOptions = { depositor: string; amount: ICoin; }; + +interface MsgDepositRaw { + '@type': string; + proposal_id: string; + depositor: string; + amount: Amount[]; +} diff --git a/lib/src/transaction/msg/gov/MsgSubmitProposal.spec.ts b/lib/src/transaction/msg/gov/MsgSubmitProposal.spec.ts index b51b1fea..690ababf 100644 --- a/lib/src/transaction/msg/gov/MsgSubmitProposal.spec.ts +++ b/lib/src/transaction/msg/gov/MsgSubmitProposal.spec.ts @@ -205,4 +205,25 @@ describe('Testing MsgSubmitProposal and its content types', function () { expect(() => msgSubmitProposalCommunitySpend.toRawAminoMsg()).to.throw('Method not implemented.'); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgSubmitProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.MsgSubmitProposal.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.MsgSubmitProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should return the MsgSubmitProposal corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgSubmitProposal","initial_deposit":[{"denom":"basetcro","amount":"12000000000"}],"content":{"@type":"/cosmos.params.v1beta1.ParameterChangeProposal","changes":[{"subspace":"staking","key":"MaxValidators","value":"12"}],"title":"Change a param to something more optimized","description":"Lorem Ipsum ... The param should be changed to something more optimized"},"proposer":"tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a"}'; + const MsgDeposit = cro.gov.MsgSubmitProposal.fromCosmosMsgJSON(json); + expect(MsgDeposit.initialDeposit.toCosmosCoins()[0].amount).to.eql('12000000000'); + expect(MsgDeposit.initialDeposit.toCosmosCoins()[0].denom).to.eql('basetcro'); + + expect(MsgDeposit.proposer).to.eql('tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a'); + + expect(MsgDeposit.content.getEncoded().type_url).to.eql('/cosmos.params.v1beta1.ParameterChangeProposal'); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/MsgSubmitProposal.ts b/lib/src/transaction/msg/gov/MsgSubmitProposal.ts index 2ceb7125..4d473020 100644 --- a/lib/src/transaction/msg/gov/MsgSubmitProposal.ts +++ b/lib/src/transaction/msg/gov/MsgSubmitProposal.ts @@ -1,13 +1,15 @@ +/* eslint-disable camelcase */ import ow from 'ow'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { ICoin } from '../../../coin/coin'; -import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; +import { COSMOS_MSG_TYPEURL, typeUrlToMsgClassMapping } from '../../common/constants/typeurl'; import { AddressType, validateAddress } from '../../../utils/address'; import { owMsgSubmitProposalOptions } from '../ow.types'; import { IMsgProposalContent } from './IMsgProposalContent'; import { CosmosMsg } from '../cosmosMsg'; import * as legacyAmino from '../../../cosmos/amino'; +import { Amount } from '../bank/msgsend'; export const msgSubmitProposal = function (config: InitConfigurations) { return class MsgSubmitProposal implements CosmosMsg { @@ -18,7 +20,7 @@ export const msgSubmitProposal = function (config: InitConfigurations) { public readonly content: IMsgProposalContent; /** - * Constructor to create a new MsgDeposit + * Constructor to create a new MsgSubmitProposal * @param {ProposalOptions} options * @returns {MsgSubmitProposal} * @throws {Error} when options is invalid @@ -58,6 +60,40 @@ export const msgSubmitProposal = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgSubmitProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSubmitProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSubmitProposal { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSubmitProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgSubmitProposal) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgSubmitProposal} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.initial_deposit || parsedMsg.initial_deposit.length !== 1) { + throw new Error('Invalid initial_deposit in the Msg.'); + } + + const cro = CroSDK({ network: config.network }); + + const jsonContentRaw = parsedMsg.content; + const contentClassInstance = typeUrlToMsgClassMapping(cro, jsonContentRaw['@type']); + const nativeContentMsg: IMsgProposalContent = contentClassInstance.fromCosmosMsgJSON( + JSON.stringify(jsonContentRaw), + ); + + return new MsgSubmitProposal({ + proposer: parsedMsg.proposer, + initialDeposit: cro.v2.CoinV2.fromCustomAmountDenom( + parsedMsg.initial_deposit[0].amount, + parsedMsg.initial_deposit[0].denom, + ), + content: nativeContentMsg, + }); + } + validate() { if ( !validateAddress({ @@ -77,3 +113,15 @@ export type ProposalOptions = { initialDeposit: ICoin; content: IMsgProposalContent; }; + +export interface MsgSubmitProposalRaw { + '@type': string; + initial_deposit: Amount[]; + content: Content; + proposer: string; +} + +export interface Content { + '@type': string; + [key: string]: any; +} diff --git a/lib/src/transaction/msg/gov/MsgVote.spec.ts b/lib/src/transaction/msg/gov/MsgVote.spec.ts index 3e2b6ace..81adc15a 100644 --- a/lib/src/transaction/msg/gov/MsgVote.spec.ts +++ b/lib/src/transaction/msg/gov/MsgVote.spec.ts @@ -181,4 +181,40 @@ describe('Testing MsgVote', function () { }; expect(msgVote.toRawAminoMsg()).to.eqls(rawMsg); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgVote', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.MsgVote.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.MsgVote but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `proposal_id` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgVote","voter":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","option":2}'; + expect(() => cro.gov.MsgVote.fromCosmosMsgJSON(json)).to.throw('Invalid `proposal_id` in JSON.'); + }); + it('should throw Error when the `voter` field is missing', function () { + const json = '{"@type":"/cosmos.gov.v1beta1.MsgVote","proposal_id":"1244000","option":2}'; + expect(() => cro.gov.MsgVote.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `voter` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `option` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgVote","proposal_id":"1244000","voter":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3"}'; + expect(() => cro.gov.MsgVote.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `option` to be of type `number` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgVote corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgVote","proposal_id":"1244000","voter":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","option":2}'; + const MsgVote = cro.gov.MsgVote.fromCosmosMsgJSON(json); + expect(MsgVote.voter).to.eql('tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3'); + expect((MsgVote.proposalId as Big).toString()).to.eql('1244000'); + expect(MsgVote.option).to.eql(VoteOption.VOTE_OPTION_ABSTAIN); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/MsgVote.ts b/lib/src/transaction/msg/gov/MsgVote.ts index cb95ffc8..25735141 100644 --- a/lib/src/transaction/msg/gov/MsgVote.ts +++ b/lib/src/transaction/msg/gov/MsgVote.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import Big from 'big.js'; import Long from 'long'; import ow from 'ow'; @@ -80,6 +81,29 @@ export const msgVote = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgVote + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgVote} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgVote { + const parsedMsg = JSON.parse(msgJsonStr) as MsgVoteRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgVote) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgVote} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.proposal_id) { + throw new Error('Invalid `proposal_id` in JSON.'); + } + + return new MsgVote({ + proposalId: new Big(parsedMsg.proposal_id), + voter: parsedMsg.voter, + option: parsedMsg.option, + }); + } + validate() { if ( !validateAddress({ @@ -99,3 +123,10 @@ export type MsgVoteOptions = { voter: string; option: VoteOption; }; + +interface MsgVoteRaw { + '@type': string; + proposal_id: string; + voter: string; + option: number; +} diff --git a/lib/src/transaction/msg/gov/ow.types.ts b/lib/src/transaction/msg/gov/ow.types.ts index 9571f249..1f008063 100644 --- a/lib/src/transaction/msg/gov/ow.types.ts +++ b/lib/src/transaction/msg/gov/ow.types.ts @@ -54,7 +54,7 @@ export const owOptionalTimestamp = () => export const owSoftwareUpgradeProposalOptions = owStrictObject().exactShape({ title: ow.string, description: ow.string, - plan: ow.object.exactShape({ + plan: ow.optional.object.exactShape({ name: ow.string, time: owOptionalTimestamp(), height: owLong(), diff --git a/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.spec.ts b/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.spec.ts index f171dc1a..dfdd5b46 100644 --- a/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.spec.ts +++ b/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.spec.ts @@ -93,4 +93,25 @@ describe('Testing CancelSoftwareUpgradeProposal and its content types', function '0a85020a82020a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c12d8010a8f010a352f636f736d6f732e757067726164652e763162657461312e43616e63656c536f6674776172655570677261646550726f706f73616c12560a2243616e63656c206120736f66747761726520757067726164652070726f706f73616c12304c6f72656d20497073756d202e2e2e20436865636b696e672063616e63656c20736f667477617265207570677261646512170a08626173657463726f120b31323030303030303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a4027db503252eb62270faa07e6b0f62d88e3434bf3db7cb07ed7ddb2c5429d12c9241449323875d8b3b7cd359a1e23c2137aef72102e707f9f50bc2e64618b3e89', ); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a CancelSoftwareUpgradeProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.proposal.CancelSoftwareUpgradeProposal.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should return the CancelSoftwareUpgradeProposal corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal"}'; + const CancelSoftwareUpgradeProposal = cro.gov.proposal.CancelSoftwareUpgradeProposal.fromCosmosMsgJSON( + json, + ); + + expect(CancelSoftwareUpgradeProposal.title).to.eql('Text Proposal Title'); + expect(CancelSoftwareUpgradeProposal.description).to.eql('Lorem Ipsum ... Checking text proposal'); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.ts b/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.ts index 54b80f82..bc1a0e1c 100644 --- a/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.ts +++ b/lib/src/transaction/msg/gov/proposal/CancelSoftwareUpgradeProposal.ts @@ -19,6 +19,26 @@ export const cancelSoftwareUpgradeProposal = function () { this.description = options.description; } + /** + * Returns an instance of CancelSoftwareUpgradeProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {CancelSoftwareUpgradeProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): CancelSoftwareUpgradeProposal { + const parsedMsg = JSON.parse(msgJsonStr) as CancelSoftwareUpgradeProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.upgrade.CancelSoftwareUpgradeProposal) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.upgrade.CancelSoftwareUpgradeProposal} but got ${parsedMsg['@type']}`, + ); + } + + return new CancelSoftwareUpgradeProposal({ + description: parsedMsg.description, + title: parsedMsg.title, + }); + } + /** * Returns the proto encoding representation of CancelSoftwareUpgradeProposal * @returns {google.protobuf.Any} @@ -43,3 +63,9 @@ export type CancelSoftwareUpgradeProposalOptions = { title: string; description: string; }; + +interface CancelSoftwareUpgradeProposalRaw { + '@type': string; + title: string; + description: string; +} diff --git a/lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.spec.ts b/lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.spec.ts new file mode 100644 index 00000000..3ebe57bd --- /dev/null +++ b/lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.spec.ts @@ -0,0 +1,124 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Big from 'big.js'; +import { Network } from '../../../../network/network'; +import { CroSDK } from '../../../../core/cro'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Units } from '../../../../coin/coin'; +import { HDKey } from '../../../../hdkey/hdkey'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; + +const PystaportTestNet: Network = { + rpcUrl: '', + defaultNodeUrl: '', + chainId: 'chainmaind', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, +}; +const cro = CroSDK({ network: PystaportTestNet }); +const coin = cro.Coin.fromBaseUnit('10000'); + +describe('Testing CommunityPoolSpendProposal and its content types', function () { + const anyContent = new cro.gov.proposal.CommunityPoolSpendProposal({ + title: 'Make new cosmos version backward compatible with pre release', + description: 'Lorem Ipsum ...', + recipient: 'tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg', + amount: coin, + }); + + fuzzyDescribe('should throw Error when CommunityPoolSpendProposal options is invalid', function (fuzzy) { + const anyValidProposalSubmission = { + proposer: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + initialDeposit: new cro.Coin('1200', Units.BASE), + content: anyContent, + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidProposalSubmission)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.gov.proposal.CommunityPoolSpendProposal(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test Signing CommunityPoolSpendProposal Type', function () { + const hdKey = HDKey.fromMnemonic( + 'order envelope snack half demand merry help obscure slogan like universe pond gain between brass settle pig float torch drama liberty grace check luxury', + ); + + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const CommunityPoolSpendProposalContent = new cro.gov.proposal.CommunityPoolSpendProposal({ + title: 'Text Proposal Title', + description: 'Lorem Ipsum ... Checking cancel software upgrade', + recipient: 'tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg', + amount: coin, + }); + + const CommunityPoolSpendProposalChangeParam = new cro.gov.MsgSubmitProposal({ + proposer: 'tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a', + initialDeposit: coin, + content: CommunityPoolSpendProposalContent, + }); + + const anySigner = { + publicKey: keyPair.getPubKey(), + accountNumber: new Big(6), + accountSequence: new Big(0), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(CommunityPoolSpendProposalChangeParam).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.getHexEncoded(); + expect(signedTx.getTxHash()).to.be.eq('B68228C66AC221329AD61AB8924327F9062F80B9230C4947CBD5105A63896F99'); + expect(signedTxHex).to.be.eql( + '0ab3020ab0020a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c1286020ac3010a372f636f736d6f732e646973747269627574696f6e2e763162657461312e436f6d6d756e697479506f6f6c5370656e6450726f706f73616c1287010a13546578742050726f706f73616c205469746c6512304c6f72656d20497073756d202e2e2e20436865636b696e672063616e63656c20736f66747761726520757067726164651a2b7463726f317830376b6b6b6570666a32686c3865746c63757168656a376a6a366d7971727034387934686722110a08626173657463726f1205313030303012110a08626173657463726f120531303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a403ad1334095809e6daa04a1a3583703fd7ef651a97e8518450fe9c893f26296e462cd6734306c4d374a1fabf2e0387bf987c4440010507789c57ef5ae320f659a', + ); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a CommunityPoolSpendProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.proposal.CommunityPoolSpendProposal.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.CommunityPoolSpendProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('Should throw on invalid depositor', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal","amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "recipient": "cro1xh3dqgljnydpwelzqf265edryrqrq7wzacx2nr"}'; + expect(() => cro.gov.proposal.CommunityPoolSpendProposal.fromCosmosMsgJSON(json)).to.throw( + 'Provided `recipient` doesnt match network selected', + ); + }); + + it('should return the CommunityPoolSpendProposal corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal","amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "recipient": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg"}'; + const CommunityPoolSpendProposal = cro.gov.proposal.CommunityPoolSpendProposal.fromCosmosMsgJSON(json); + + expect(CommunityPoolSpendProposal.title).to.eql('Text Proposal Title'); + + expect(CommunityPoolSpendProposal.description).to.eql('Lorem Ipsum ... Checking text proposal'); + expect(CommunityPoolSpendProposal.recipient).to.eql('tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg'); + }); + }); +}); diff --git a/lib/src/transaction/msg/gov/CommunityPoolSpendProposal.ts b/lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.ts similarity index 53% rename from lib/src/transaction/msg/gov/CommunityPoolSpendProposal.ts rename to lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.ts index 6bb5b784..26589abb 100644 --- a/lib/src/transaction/msg/gov/CommunityPoolSpendProposal.ts +++ b/lib/src/transaction/msg/gov/proposal/CommunityPoolSpendProposal.ts @@ -1,10 +1,12 @@ import ow from 'ow'; -import { ICoin } from '../../../coin/coin'; -import { cosmos, google } from '../../../cosmos/v1beta1/codec'; -import { IMsgProposalContent } from './IMsgProposalContent'; -import { InitConfigurations } from '../../../core/cro'; -import { AddressType, validateAddress } from '../../../utils/address'; -import { owCommunityPoolSpendProposalOptions } from './ow.types'; +import { ICoin } from '../../../../coin/coin'; +import { cosmos, google } from '../../../../cosmos/v1beta1/codec'; +import { IMsgProposalContent } from '../IMsgProposalContent'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { AddressType, validateAddress } from '../../../../utils/address'; +import { owCommunityPoolSpendProposalOptions } from '../ow.types'; +import { Amount } from '../../bank/msgsend'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; export const communityPoolSpendProposal = function (config: InitConfigurations) { return class CommunityPoolSpendProposal implements IMsgProposalContent { @@ -27,6 +29,7 @@ export const communityPoolSpendProposal = function (config: InitConfigurations) this.description = options.description; this.recipient = options.recipient; this.amount = options.amount; + this.validate(); } /** @@ -51,11 +54,37 @@ export const communityPoolSpendProposal = function (config: InitConfigurations) const spendProposal = cosmos.distribution.v1beta1.CommunityPoolSpendProposal.create(communityPoolSpend); return google.protobuf.Any.create({ - type_url: '/cosmos.distribution.v1beta1.CommunityPoolSpendProposal', + type_url: COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal, value: cosmos.distribution.v1beta1.CommunityPoolSpendProposal.encode(spendProposal).finish(), }); } + /** + * Returns an instance of CommunityPoolSpendProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {CommunityPoolSpendProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): CommunityPoolSpendProposal { + const parsedMsg = JSON.parse(msgJsonStr) as CommunityPoolSpendProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal} but got ${parsedMsg['@type']}`, + ); + } + if (!parsedMsg.amount || parsedMsg.amount.length !== 1) { + throw new Error('Invalid amount in the Msg.'); + } + const cro = CroSDK({ network: config.network }); + + return new CommunityPoolSpendProposal({ + description: parsedMsg.description, + title: parsedMsg.title, + recipient: parsedMsg.recipient, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount[0].amount, parsedMsg.amount[0].denom), + }); + } + validate() { if ( !validateAddress({ @@ -76,3 +105,11 @@ export type CommunityPoolSpendProposalOptions = { recipient: string; amount: ICoin; }; + +export interface CommunityPoolSpendProposalRaw { + '@type': string; + title: string; + description: string; + recipient: string; + amount: Amount[]; +} diff --git a/lib/src/transaction/msg/gov/ParamChangeProposal.ts b/lib/src/transaction/msg/gov/proposal/ParamChangeProposal.ts similarity index 59% rename from lib/src/transaction/msg/gov/ParamChangeProposal.ts rename to lib/src/transaction/msg/gov/proposal/ParamChangeProposal.ts index 8d31eedc..3e9e273a 100644 --- a/lib/src/transaction/msg/gov/ParamChangeProposal.ts +++ b/lib/src/transaction/msg/gov/proposal/ParamChangeProposal.ts @@ -1,7 +1,8 @@ import ow from 'ow'; -import { cosmos, google } from '../../../cosmos/v1beta1/codec'; -import { IMsgProposalContent } from './IMsgProposalContent'; -import { owParamChangeProposalOptions } from './ow.types'; +import { cosmos, google } from '../../../../cosmos/v1beta1/codec'; +import { IMsgProposalContent } from '../IMsgProposalContent'; +import { owParamChangeProposalOptions } from '../ow.types'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; export const paramChangeProposal = function () { return class ParamChangeProposal implements IMsgProposalContent { @@ -42,10 +43,31 @@ export const paramChangeProposal = function () { const spendProposal = cosmos.params.v1beta1.ParameterChangeProposal.create(paramChange); return google.protobuf.Any.create({ - type_url: '/cosmos.params.v1beta1.ParameterChangeProposal', + type_url: COSMOS_MSG_TYPEURL.upgrade.ParameterChangeProposal, value: cosmos.params.v1beta1.ParameterChangeProposal.encode(spendProposal).finish(), }); } + + /** + * Returns an instance of ParamChangeProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {ParamChangeProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): ParamChangeProposal { + const parsedMsg = JSON.parse(msgJsonStr) as ParamChangeProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.upgrade.ParameterChangeProposal) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.upgrade.ParameterChangeProposal} but got ${parsedMsg['@type']}`, + ); + } + + return new ParamChangeProposal({ + description: parsedMsg.description, + title: parsedMsg.title, + paramChanges: parsedMsg.changes, + }); + } }; }; @@ -65,3 +87,10 @@ export type ParamChangeProposalOptions = { description: string; paramChanges: ParamChange[]; }; + +export interface ParamChangeProposalRaw { + '@type': string; + changes: ParamChange[]; + title: string; + description: string; +} diff --git a/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.spec.ts b/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.spec.ts index ac02bde0..8dca21b7 100644 --- a/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.spec.ts +++ b/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.spec.ts @@ -104,4 +104,53 @@ describe('Testing SoftwareUpgradeProposal and its content types', function () { '0aa3020aa0020a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c12f6010aad010a2f2f636f736d6f732e757067726164652e763162657461312e536f6674776172655570677261646550726f706f73616c127a0a2750726f706f73652061206e657720736f66747761726520757067726164652070726f706f73616c12324c6f72656d20497073756d202e2e2e20436865636b696e6720736f66747761726520757067726164652070726f706f73616c1a1b0a046e616d65120a08f8bdef051080ade20418e8072204696e666f12170a08626173657463726f120b31323030303030303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a40a5b7174278f1cc4caae7a8b098ac477ea282595a8d0cc318587992ca7a42434a49923c2a85cd058516d538823868c141f4f5dc6975738d3e22f5bf347cb08da3', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a SoftwareUpgradeProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.proposal.SoftwareUpgradeProposal.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.upgrade.v1beta1.SoftwareUpgradeProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should return the SoftwareUpgradeProposal corresponding to the JSON', function () { + const json = `{"@type":"/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal", + "plan": { + "height": "1000", + "name": "name", + "info": "info", + "time": { "nanos": "10000000", "seconds": "12312312" } + }}`; + const SoftwareUpgradeProposal = cro.gov.proposal.SoftwareUpgradeProposal.fromCosmosMsgJSON(json); + + expect(SoftwareUpgradeProposal.title).to.eql('Text Proposal Title'); + + expect(SoftwareUpgradeProposal.description).to.eql('Lorem Ipsum ... Checking text proposal'); + }); + it('should throw when `upgradedClientState` is non-empty', function () { + const json = `{"@type":"/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal", + "plan": { + "height": "1000", + "name": "name", + "info": "info", + "time": { "nanos": "10000000", "seconds": "12312312" }, + "upgraded_client_state": { "typeUrl": "someTypeUrl", "value": "someValue"} + } + }`; + expect(() => cro.gov.proposal.SoftwareUpgradeProposal.fromCosmosMsgJSON(json)).to.throw( + 'Non-empty upgraded client state is not supported.', + ); + }); + it('should throw on invalid plan.height', function () { + const json = `{"@type":"/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal", + "plan": { + "name": "name", + "info": "info", + "time": { "nanos": "10000000", "seconds": "12312312" } + }}`; + expect(() => { + cro.gov.proposal.SoftwareUpgradeProposal.fromCosmosMsgJSON(json); + }).to.throw('Invalid `height` attribute in Plan.'); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.ts b/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.ts index 4458bd2b..aef1eb9c 100644 --- a/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.ts +++ b/lib/src/transaction/msg/gov/proposal/SoftwareUpgradeProposal.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import Long from 'long'; import { cosmos, google } from '../../../../cosmos/v1beta1/codec'; @@ -24,6 +25,62 @@ export const softwareUpgradeProposal = function () { this.plan = options.plan; } + /** + * Returns an instance of SoftwareUpgradeProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {SoftwareUpgradeProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): SoftwareUpgradeProposal { + const parsedMsg = JSON.parse(msgJsonStr) as SoftwareUpgradeProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.upgrade.SoftwareUpgradeProposal) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.upgrade.SoftwareUpgradeProposal} but got ${parsedMsg['@type']}`, + ); + } + + const { plan } = parsedMsg; + + let timeSecondsLong; + let timeNanos; + + // Plan time checks + if (plan.time) { + if (plan.time.seconds) { + timeSecondsLong = Long.fromString(plan.time.seconds, true, 10); + } + if (plan.time.nanos) { + timeNanos = Number(plan.time.nanos); + } + } + + // Plan height checks + if (!plan.height) { + throw new Error('Invalid `height` attribute in Plan.'); + } + + // Plan `upgradedClientState` checks + // TODO: check for any live example (if any), keeping empty `value` now + if (plan.upgraded_client_state && Object.keys(plan.upgraded_client_state).length > 0) { + throw new Error('Non-empty upgraded client state is not supported.'); + } + + return new SoftwareUpgradeProposal({ + description: parsedMsg.description, + title: parsedMsg.title, + plan: { + height: Long.fromString(plan.height, true, 10), + info: plan.info, + name: plan.name, + time: { + nanos: timeNanos, + seconds: timeSecondsLong, + }, + upgradedClientState: undefined, + }, + }); + } + /** * Returns the proto encoding representation of SoftwareUpgradeProposal * @returns {google.protobuf.Any} @@ -77,3 +134,20 @@ export type SoftwareUpgradeProposalOptions = { description: string; plan?: IPlan; }; + +interface SoftwareUpgradeProposalRaw { + '@type': string; + title: string; + description: string; + plan: PlanRaw; +} +interface PlanRaw { + name: string; + time?: { + seconds?: string; + nanos?: number; + }; + height: string; + info: string; + upgraded_client_state?: any; +} diff --git a/lib/src/transaction/msg/gov/proposal/TextProposal.spec.ts b/lib/src/transaction/msg/gov/proposal/TextProposal.spec.ts index 8e76b73f..b91f7c01 100644 --- a/lib/src/transaction/msg/gov/proposal/TextProposal.spec.ts +++ b/lib/src/transaction/msg/gov/proposal/TextProposal.spec.ts @@ -90,4 +90,23 @@ describe('Testing TextProposal and its content types', function () { '0ae0010add010a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c12b3010a6b0a202f636f736d6f732e676f762e763162657461312e5465787450726f706f73616c12470a13546578742050726f706f73616c205469746c6512304c6f72656d20497073756d202e2e2e20436865636b696e672063616e63656c20736f667477617265207570677261646512170a08626173657463726f120b31323030303030303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a40e3fe5009273f539d4f6e37b55136ce776855e45da95800a1e23e8fffd83dc3f96874f6d3ec116a19b9b6e2e19031f11ae533e0de26edec1eccca57fd6f1e0bef', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a TextProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.gov.proposal.TextProposal.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.TextProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should return the TextProposal corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.TextProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal"}'; + const TextProposal = cro.gov.proposal.TextProposal.fromCosmosMsgJSON(json); + + expect(TextProposal.title).to.eql('Text Proposal Title'); + + expect(TextProposal.description).to.eql('Lorem Ipsum ... Checking text proposal'); + }); + }); }); diff --git a/lib/src/transaction/msg/gov/proposal/TextProposal.ts b/lib/src/transaction/msg/gov/proposal/TextProposal.ts index 6608d58c..c3739634 100644 --- a/lib/src/transaction/msg/gov/proposal/TextProposal.ts +++ b/lib/src/transaction/msg/gov/proposal/TextProposal.ts @@ -19,6 +19,24 @@ export const textProposal = function () { this.description = options.description; } + /** + * Returns an instance of TextProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {TextProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): TextProposal { + const parsedMsg = JSON.parse(msgJsonStr) as TextProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.gov.TextProposal) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.gov.TextProposal} but got ${parsedMsg['@type']}`); + } + + return new TextProposal({ + description: parsedMsg.description, + title: parsedMsg.title, + }); + } + /** * Returns the proto encoding representation of TextProposal * @returns {google.protobuf.Any} @@ -43,3 +61,9 @@ export type TextProposalOptions = { title: string; description: string; }; + +interface TextProposalRaw { + '@type': string; + title: string; + description: string; +} diff --git a/lib/src/transaction/msg/ibc/IGoogleAny.ts b/lib/src/transaction/msg/ibc/IGoogleAny.ts new file mode 100644 index 00000000..ac71351b --- /dev/null +++ b/lib/src/transaction/msg/ibc/IGoogleAny.ts @@ -0,0 +1,15 @@ +import { google } from '../../../cosmos/v1beta1/codec'; + +export interface IGoogleAny { + /** + * Returns the proto encoding representation of any IGoogleAny implementation + * @returns {google.protobuf.Any} + */ + getEncoded(): google.protobuf.Any; +} + +// https://stackoverflow.com/questions/14425568/interface-type-check-with-typescript +export function isMsgGoogleAny(object: Object): boolean { + // eslint-disable-next-line no-prototype-builtins + return 'getEncoded' in object; +} diff --git a/lib/src/transaction/msg/ibc/applications/MsgTransfer.spec.ts b/lib/src/transaction/msg/ibc/applications/MsgTransfer.spec.ts new file mode 100644 index 00000000..ca969ff5 --- /dev/null +++ b/lib/src/transaction/msg/ibc/applications/MsgTransfer.spec.ts @@ -0,0 +1,327 @@ +/* eslint-disable camelcase */ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +const tokenAmount = cro.Coin.fromBaseUnit('1234'); +const timeoutHeight = { + revisionNumber: Long.fromString('0'), + revisionHeight: Long.fromString('1708515'), +}; + +describe('Testing MsgTransfer', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.MsgTransfer(options.value)).to.throw('Expected `options` to be of type `object`'); + }); + }); + + it('Test MsgTransfer conversion', function () { + const MsgTransfer = new cro.ibc.MsgTransfer({ + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgTransfer, + value: { + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount.toCosmosCoin(), + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }, + }; + + expect(MsgTransfer.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test appendTxBody MsgTransfer Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgTransfer = new cro.ibc.MsgTransfer({ + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgTransfer).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0ac7010ac4010a292f6962632e6170706c69636174696f6e732e7472616e736665722e76312e4d73675472616e736665721296010a087472616e73666572120a6368616e6e656c2d33331a100a08626173657463726f120431323334222b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e76727168742a2d636f736d6f7331767734756361656167746475763565703473613935653361717a7170736b356d6564613038633206080010e3a36838c4a7e1daaafaeabe1612580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40f1032ff3d1b53682d8038e4a06d7c1fadf17858a619e32cc3fa5f9463b35c6194f7ebff606dbe142fe63f3d978da2e4372831ea96faf94c80153416667bcd321', + ); + }); + + it('Should validate MsgTransfer provided addresses with network config', function () { + const params1 = { + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }; + + expect(() => new cro.ibc.MsgTransfer(params1)).to.throw('Provided `sender` does not match network selected'); + }); + + it('Should validate MsgTransfer provided `receiver` address', function () { + const params1 = { + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: '0x7e00664398A54AE12648CAe2785c36d00dd51672', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }; + + expect(() => new cro.ibc.MsgTransfer(params1)).to.throw( + 'Provided `receiver` is not a valid Bech-32 encoded address', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgTransfer = new cro.ibc.MsgTransfer({ + sourcePort: 'transfer', + sourceChannel: 'channel-33', + token: tokenAmount, + sender: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + receiver: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + timeoutHeight, + timeoutTimestamp: Long.fromString('1620640362229420996'), + }); + + expect(() => MsgTransfer.toRawAminoMsg()).to.throw('IBC Module not supported under amino encoding scheme'); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgTransfer', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Expected /ibc.applications.transfer.v1.MsgTransfer but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `timeout_timestamp` field is missing', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "source_channel": "channel-33", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8" + } + `; + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Invalid `timeout_timestamp` in the Msg.', + ); + }); + it('should throw Error when the `token` field is missing', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "source_channel": "channel-33", + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + } + `; + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw('Invalid `token` in the Msg.'); + }); + it('should throw when `source_port` is missing', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_channel": "channel-33", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + } + `; + + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sourcePort` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw when `source_channel` is missing', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + }`; + + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sourceChannel` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw on invalid `receiver`', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "source_channel": "channel-33", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + } + `; + + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Provided `receiver` is not a valid Bech-32 encoded address', + ); + }); + it('should throw on invalid `sender`', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "source_channel": "channel-33", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + } + `; + + expect(() => cro.ibc.MsgTransfer.fromCosmosMsgJSON(json)).to.throw( + 'Provided `sender` does not match network selected', + ); + }); + it('should return the IBC MsgTransfer corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.applications.transfer.v1.MsgTransfer", + "source_port": "transfer", + "source_channel": "channel-33", + "token": { + "denom": "basetcro", + "amount": "1234" + }, + "sender": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "receiver": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "timeout_height": { + "revision_number": "0", + "revision_height": "2390451" + }, + "timeout_timestamp": "1624612912351977705" + } + `; + + const MsgTransfer = cro.ibc.MsgTransfer.fromCosmosMsgJSON(json); + expect(MsgTransfer.sender).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgTransfer.receiver).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgTransfer.sourceChannel).to.eql('channel-33'); + expect(MsgTransfer.sourcePort).to.eql('transfer'); + expect(MsgTransfer.token?.toCosmosCoin().amount).to.eql('1234'); + expect(MsgTransfer.token?.toCosmosCoin().denom).to.eql('basetcro'); + expect(MsgTransfer.timeoutTimestamp.toString()).to.eql('1624612912351977705'); + expect(MsgTransfer.timeoutHeight).to.not.be.undefined; + expect(MsgTransfer.timeoutHeight?.revisionHeight!.toString()).to.eql('2390451'); + expect(MsgTransfer.timeoutHeight?.revisionNumber!.toString()).to.eql('0'); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/applications/MsgTransfer.ts b/lib/src/transaction/msg/ibc/applications/MsgTransfer.ts new file mode 100644 index 00000000..ed8eecab --- /dev/null +++ b/lib/src/transaction/msg/ibc/applications/MsgTransfer.ts @@ -0,0 +1,170 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import Long from 'long'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { ICoin } from '../../../../coin/coin'; +import { owMsgTransferIBCOptions } from '../../ow.types'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { AddressType, validateAddress, isValidBech32Address } from '../../../../utils/address'; +import { CosmosMsg } from '../../cosmosMsg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; + +export const msgTransferIBC = function (config: InitConfigurations) { + return class MsgTransfer implements CosmosMsg { + /** MsgTransfer sourcePort. */ + public sourcePort: string; + + /** MsgTransfer sourceChannel. */ + public sourceChannel: string; + + /** MsgTransfer token. */ + public token?: ICoin | null; + + /** MsgTransfer sender. */ + public sender: string; + + /** MsgTransfer receiver. */ + public receiver: string; + + /** MsgTransfer timeoutHeight. */ + public timeoutHeight?: IHeight | null; + + /** MsgTransfer timeoutTimestamp. */ + public timeoutTimestamp: Long; + + /** + * Constructor to create a new IBC.MsgTransfer + * @param {MsgTransferOptions} options + * @returns {MsgTransfer} + * @throws {Error} when options is invalid + */ + constructor(options: MsgTransferOptions) { + ow(options, 'options', owMsgTransferIBCOptions); + this.sourcePort = options.sourcePort; + this.sourceChannel = options.sourceChannel; + this.token = options.token; + this.sender = options.sender; + this.receiver = options.receiver; + this.timeoutHeight = options.timeoutHeight; + this.timeoutTimestamp = options.timeoutTimestamp; + + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of IBCTransfer + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgTransfer, + value: { + sourcePort: this.sourcePort, + sourceChannel: this.sourceChannel, + token: this.token?.toCosmosCoin(), + sender: this.sender, + receiver: this.receiver, + timeoutHeight: this.timeoutHeight, + timeoutTimestamp: this.timeoutTimestamp, + } as MsgTransferOptions, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgTransfer + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgTransfer} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgTransfer { + const parsedMsg = JSON.parse(msgJsonStr) as IBCMsgTransferRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.MsgTransfer) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.ibc.MsgTransfer} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.token || Object.keys(parsedMsg.token).length !== 2) { + throw new Error('Invalid `token` in the Msg.'); + } + let timeoutHeight; + if (typeof parsedMsg.timeout_height === 'object') { + timeoutHeight = { + revisionHeight: Long.fromString(parsedMsg.timeout_height?.revision_height!), + revisionNumber: Long.fromString(parsedMsg.timeout_height?.revision_number!), + }; + } + if (typeof parsedMsg.timeout_timestamp === 'undefined') { + throw new Error('Invalid `timeout_timestamp` in the Msg.'); + } + + return new MsgTransfer({ + sourcePort: parsedMsg.source_port, + sourceChannel: parsedMsg.source_channel, + token: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.token.amount, parsedMsg.token.denom), + sender: parsedMsg.sender, + receiver: parsedMsg.receiver, + timeoutTimestamp: Long.fromString(parsedMsg.timeout_timestamp), + timeoutHeight, + }); + } + + // @Todo: The `receiver` can belong to other network also? Right? + // Introduced a new validation method + validateAddresses() { + if ( + !validateAddress({ + address: this.sender, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `sender` does not match network selected'); + } + + if (!isValidBech32Address(this.receiver)) { + throw new TypeError('Provided `receiver` is not a valid Bech-32 encoded address'); + } + } + }; +}; + +export type MsgTransferOptions = { + sourcePort: string; + sourceChannel: string; + token?: ICoin | null; + sender: string; + receiver: string; + timeoutHeight?: IHeight | null; + timeoutTimestamp: Long; +}; + +export type IHeight = { + revisionNumber: Long; + revisionHeight: Long; +}; + +export interface IBCMsgTransferRaw { + '@type': string; + source_port: string; + source_channel: string; + token?: Token; + sender: string; + receiver: string; + timeout_height?: TimeoutHeight; + timeout_timestamp: string; +} + +export interface TimeoutHeight { + revision_number: string; + revision_height: string; +} + +export interface Token { + denom: string; + amount: string; +} diff --git a/lib/src/transaction/msg/ibc/core/MsgCreateClient.spec.ts b/lib/src/transaction/msg/ibc/core/MsgCreateClient.spec.ts new file mode 100644 index 00000000..482995a0 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgCreateClient.spec.ts @@ -0,0 +1,262 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { ics23 } from '../../../../cosmos/v1beta1/codec'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgCreateClient', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.MsgCreateClient(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgCreateClient conversion', function () { + const msgClientState = new cro.ibc.lightclient.ClientState({ + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }); + + const msgConsensusState = new cro.ibc.lightclient.ConsensusState({ + timestamp: null, + root: null, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }); + + const MsgCreateClient = new cro.ibc.MsgCreateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientState: msgClientState, + consensusState: msgConsensusState, + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgCreateClient, + value: { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientState: msgClientState.getEncoded(), + consensusState: msgConsensusState.getEncoded(), + }, + }; + + expect(MsgCreateClient.toRawMsg()).to.deep.equal(rawMsg); + }); + + it('Test appendTxBody MsgCreateClient Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + const msgClientState = new cro.ibc.lightclient.ClientState({ + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }); + + const msgConsensusState = new cro.ibc.lightclient.ConsensusState({ + timestamp: null, + root: null, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }); + const MsgCreateClient = new cro.ibc.MsgCreateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientState: msgClientState, + consensusState: msgConsensusState, + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgCreateClient).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0ab4020ab1020a232f6962632e636f72652e636c69656e742e76312e4d7367437265617465436c69656e741289020aa0010a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e74537461746512710a12746573746e65742d63726f65736569642d311204080110011a06086410a08d062206086410a08d062a06086410a08d063204086410643a040864106442280a0d08051005180520022a0300010212110a02010210011800200a2a03000102300518904e20904e4a036962635000580012370a2e2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436f6e73656e737573537461746512051a030102031a2b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40d4414a8cc77c85b9afcc53b76b4aaec7b793973c19f7a2a5b2c35c3d9fd80a0c51e11e77d42a190479e0a99ba02c7b957d5aec76afc9129835c178e19d42d237', + ); + }); + + it('Should validate MsgCreateClient provided addresses with network config', function () { + const params1 = { + signer: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + }; + + expect(() => new cro.ibc.MsgCreateClient(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgCreateClient = new cro.ibc.MsgCreateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + expect(() => MsgCreateClient.toRawAminoMsg()).to.throw('IBC Module not supported under amino encoding scheme'); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgCreateClient', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.MsgCreateClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected /ibc.core.client.v1.MsgCreateClient but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on invalid `sender`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgCreateClient", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g" + } + `; + + expect(() => cro.ibc.MsgCreateClient.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + it('should return the IBC MsgCreateClient corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgCreateClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8" + } + `; + + const MsgCreateClient = cro.ibc.MsgCreateClient.fromCosmosMsgJSON(json); + expect(MsgCreateClient.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/MsgCreateClient.ts b/lib/src/transaction/msg/ibc/core/MsgCreateClient.ts new file mode 100644 index 00000000..eeff23e2 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgCreateClient.ts @@ -0,0 +1,172 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { InitConfigurations } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../utils/address'; +import { owMsgCreateClientOptions } from '../../ow.types'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { IGoogleAny } from '../IGoogleAny'; + +export const msgCreateClientIBC = function (config: InitConfigurations) { + return class MsgCreateClient implements CosmosMsg { + /** MsgCreateClient clientState. */ + public clientState?: IGoogleAny | null; + + /** MsgCreateClient consensusState. */ + public consensusState?: IGoogleAny | null; + + /** MsgCreateClient signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgCreateClient + * @param {MsgCreateClientOptions} options + * @returns {MsgCreateClient} + * @throws {Error} when options is invalid + */ + constructor(options: MsgCreateClientOptions) { + ow(options, 'options', owMsgCreateClientOptions); + this.clientState = options.clientState; + this.consensusState = options.consensusState; + this.signer = options.signer; + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgCreateClient + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgCreateClient, + value: { + clientState: this.clientState?.getEncoded(), + consensusState: this.consensusState?.getEncoded(), + signer: this.signer, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgCreateClient + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgCreateClient} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgCreateClient { + const parsedMsg = JSON.parse(msgJsonStr) as MsgCreateClientJsonRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.MsgCreateClient) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.ibc.MsgCreateClient} but got ${parsedMsg['@type']}`); + } + + // TODO: The `client_state` value needs to be handled, currently keeping it as `undefined` + if (typeof parsedMsg.client_state === 'object' && Object.keys(parsedMsg.client_state).length > 0) { + throw new Error('IBC MsgUpdateClient does not support `client_state` decoding.'); + } + + // TODO: The `consensus_state` value needs to be handled, currently keeping it as `undefined` + if (typeof parsedMsg.consensus_state === 'object' && Object.keys(parsedMsg.consensus_state).length > 0) { + throw new Error('IBC MsgUpdateClient does not support `consensus_state` decoding.'); + } + + return new MsgCreateClient({ + clientState: undefined, + consensusState: undefined, + signer: parsedMsg.signer, + }); + } + + validateAddresses() { + // TODO: Can `signer` be from non-CRO network + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export type MsgCreateClientOptions = { + clientState?: IGoogleAny | null; + consensusState?: IGoogleAny | null; + signer: string; +}; + +export interface MsgCreateClientJsonRaw { + '@type': string; + client_state?: ClientState; + consensus_state?: ConsensusState; + signer: string; +} + +export interface ClientState { + '@type': string; + chain_id: string; + trust_level: TrustLevel; + trusting_period: string; + unbonding_period: string; + max_clock_drift: string; + frozen_height: Height; + latest_height: Height; + proof_specs: ProofSpec[]; + upgrade_path: string[]; + allow_update_after_expiry: boolean; + allow_update_after_misbehaviour: boolean; +} + +export interface Height { + revision_number: string; + revision_height: string; +} + +export interface ProofSpec { + leaf_spec: LeafSpec; + inner_spec: InnerSpec; + max_depth: number; + min_depth: number; +} + +export interface InnerSpec { + child_order: number[]; + child_size: number; + min_prefix_length: number; + max_prefix_length: number; + empty_child: null; + hash: string; +} + +export interface LeafSpec { + hash: string; + prehash_key: string; + prehash_value: string; + length: string; + prefix: string; +} + +export interface TrustLevel { + numerator: string; + denominator: string; +} + +export interface ConsensusState { + '@type': string; + timestamp: Date; + root: Root; + next_validators_hash: string; +} + +export interface Root { + hash: string; +} diff --git a/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.spec.ts b/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.spec.ts new file mode 100644 index 00000000..2fac8b3a --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.spec.ts @@ -0,0 +1,180 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgSubmitMisbehaviour', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.MsgSubmitMisbehaviour(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgSubmitMisbehaviour conversion', function () { + const MsgSubmitMisbehaviour = new cro.ibc.MsgSubmitMisbehaviour({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour, + value: { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + misbehaviour: undefined, + }, + }; + + expect(MsgSubmitMisbehaviour.toRawMsg()).to.deep.eq(rawMsg); + }); + + it('Test appendTxBody MsgSubmitMisbehaviour Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgSubmitMisbehaviour = new cro.ibc.MsgSubmitMisbehaviour({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + misbehaviour: undefined, + clientId: 'clientId', + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgSubmitMisbehaviour).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0a660a640a292f6962632e636f72652e636c69656e742e76312e4d73675375626d69744d69736265686176696f757212370a08636c69656e7449641a2b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40b38eea165bd21573402b2cdf8093e28f6241fc27bcaa68fffbcba93f5e2a8dd01edb3d5c242499083d39bd9c11124d20a11a331eec638498b9abd5974c49563d', + ); + }); + + it('Should validate MsgSubmitMisbehaviour provided addresses with network config', function () { + const params1 = { + signer: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + misbehaviour: undefined, + clientId: 'clientId', + }; + + expect(() => new cro.ibc.MsgSubmitMisbehaviour(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgSubmitMisbehaviour = new cro.ibc.MsgSubmitMisbehaviour({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + }); + + expect(() => MsgSubmitMisbehaviour.toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgSubmitMisbehaviour', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.MsgSubmitMisbehaviour.fromCosmosMsgJSON(json)).to.throw( + 'Expected /ibc.core.client.v1.MsgSubmitMisbehaviour but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on invalid `signer`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgSubmitMisbehaviour", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g", + "client_id": "07-tendermint-33" + } + `; + + expect(() => cro.ibc.MsgSubmitMisbehaviour.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + it('should throw on invalid `clientId`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgSubmitMisbehaviour", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g" + } + `; + + expect(() => cro.ibc.MsgSubmitMisbehaviour.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `clientId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw on non-empty field `misbehaviour`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgSubmitMisbehaviour", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33", + "misbehaviour": {"type": "07-tendermint-33"} + } + `; + + expect(() => cro.ibc.MsgSubmitMisbehaviour.fromCosmosMsgJSON(json)).to.throw( + 'IBC MsgSubmitMisbehaviour does not support `misbehaviour` decoding.', + ); + }); + it('should return the IBC MsgSubmitMisbehaviour corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgSubmitMisbehaviour", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33" + } + `; + + const MsgSubmitMisbehaviour = cro.ibc.MsgSubmitMisbehaviour.fromCosmosMsgJSON(json); + expect(MsgSubmitMisbehaviour.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgSubmitMisbehaviour.clientId).to.eql('07-tendermint-33'); + expect(MsgSubmitMisbehaviour.misbehaviour).to.be.null; + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.ts b/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.ts new file mode 100644 index 00000000..b17c6a81 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgSubmitMisbehaviour.ts @@ -0,0 +1,109 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { google } from '../../../../cosmos/v1beta1/codec/generated/codecimpl'; +import { InitConfigurations } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../utils/address'; +import { owMsgSubmitMisbehaviourOptions } from '../../ow.types'; +import * as legacyAmino from '../../../../cosmos/amino'; + +export const msgSubmitMisbehaviourIBC = function (config: InitConfigurations) { + return class MsgSubmitMisbehaviour implements CosmosMsg { + /** MsgSubmitMisbehaviour clientId. */ + public clientId: string; + + /** MsgSubmitMisbehaviour misbehaviour. */ + public misbehaviour?: google.protobuf.IAny | null; + + /** MsgSubmitMisbehaviour signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgSubmitMisbehaviour + * @param {MsgSubmitMisbehaviourOptions} options + * @returns {MsgSubmitMisbehaviour} + * @throws {Error} when options is invalid + */ + constructor(options: MsgSubmitMisbehaviourOptions) { + ow(options, 'options', owMsgSubmitMisbehaviourOptions); + this.clientId = options.clientId; + this.misbehaviour = options.misbehaviour; + this.signer = options.signer; + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgSubmitMisbehaviour + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour, + value: { + clientId: this.clientId, + misbehaviour: this.misbehaviour, + signer: this.signer, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgSubmitMisbehaviour + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSubmitMisbehaviour} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSubmitMisbehaviour { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSubmitMisbehaviourJsonRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour} but got ${parsedMsg['@type']}`, + ); + } + + // TODO: The `misbehaviour` value needs to be handled, currently keeping it as `null` + if (typeof parsedMsg.misbehaviour === 'object' && Object.keys(parsedMsg.misbehaviour).length > 0) { + throw new Error('IBC MsgSubmitMisbehaviour does not support `misbehaviour` decoding.'); + } + + return new MsgSubmitMisbehaviour({ + clientId: parsedMsg.client_id, + misbehaviour: null, + signer: parsedMsg.signer, + }); + } + + validateAddresses() { + // TODO: Can `signer` be from non-CRO network + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export type MsgSubmitMisbehaviourOptions = { + clientId: string; + misbehaviour?: google.protobuf.IAny | null; + signer: string; +}; + +export interface MsgSubmitMisbehaviourJsonRaw { + '@type': string; + client_id: string; + misbehaviour?: any; + signer: string; +} diff --git a/lib/src/transaction/msg/ibc/core/MsgUpdateClient.spec.ts b/lib/src/transaction/msg/ibc/core/MsgUpdateClient.spec.ts new file mode 100644 index 00000000..fca76bca --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgUpdateClient.spec.ts @@ -0,0 +1,400 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { tendermintV2 } from '../../../../cosmos/v1beta1/codec'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgUpdateClient', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.MsgUpdateClient(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgUpdateClient conversion', function () { + const params = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + const msgHeader = new cro.ibc.lightclient.Header(params); + + const MsgUpdateClient = new cro.ibc.MsgUpdateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + header: msgHeader, + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient, + value: { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + header: msgHeader.getEncoded(), + }, + }; + + expect(MsgUpdateClient.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test appendTxBody MsgUpdateClient Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + const params = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + const msgHeader = new cro.ibc.lightclient.Header(params); + + const MsgUpdateClient = new cro.ibc.MsgUpdateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + header: msgHeader, + clientId: 'clientId', + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgUpdateClient).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0aa7080aa4080a232f6962632e636f72652e636c69656e742e76312e4d7367557064617465436c69656e7412fc070a08636c69656e74496412c2070a262f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e4865616465721297070acb040a90030a04080b1000120b636f736d6f736875622d3418e9a2d702220608904e10e8072a480a20a16c45b687cff41c14f566bcf46b185e6a2aa1400b657530a2a9fe0de6f855c7122408011220133851ed2b01923ebc33d5e7bf04837af7ac4afdcd6130aa4a68791fb9b12e753220aad5b05f681ae03694bc7c96583a0259db7637617061c420e307102f5b303f023a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85542203e100a3435f7f0121710cd944379546aa2ce5f7e5d75e7463bc083dc1e2e560a4a203e100a3435f7f0121710cd944379546aa2ce5f7e5d75e7463bc083dc1e2e560a52200f2908883a105c793b74495eb7d6df2eea479ed7fc9349206a65cb0f9987a0b85a206b8a281cab99367e7568549ece0f715ab08125b2e6d635b02c5a71f015f4b54f6220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8556a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8557214cc87f56b58621811e2b5a47f38c6166e295ce36e12b50108e9a2d70210001a480a20a33f095d6a016c99c2cb3b5be268ddaf39e1b3d533ab5b3a65676595bdff750f122408011220494c5dbfc5bed9a6812e1615b9b9b823fd99c5efdf05d2854e65268ccf8c1f3f22620802121483f47d7747b0f633a6ba0df49b7dcf61f90aa1b01a0608904e10904e2240229b45ef7906e4fb9e63c938f769aeed49cf3d92be5d453eddfac00f1481450e7ec53127bcb93b7a4bf4443e37bdb3661cccc31a1ef58a1b6400a393dce22608129d010a4a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff01124a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff0118dcadc95b1a07080410eca1d702229d010a4a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff01124a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff0118dcadc95b1a2b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a4073919aa75f9f5e86b9d353ad5420f8b52199d600b5506c575f516e3964c86b3c5be9757f4a423492d52786657afdc2bce10a5aea7198dab1fd6d6c0d2463e521', + ); + }); + + it('Should validate MsgUpdateClient provided addresses with network config', function () { + const params1 = { + signer: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + clientId: 'clientId', + }; + + expect(() => new cro.ibc.MsgUpdateClient(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgUpdateClient = new cro.ibc.MsgUpdateClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + }); + + expect(() => MsgUpdateClient.toRawAminoMsg()).to.throw('IBC Module not supported under amino encoding scheme'); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgUpdateClient', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.MsgUpdateClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected /ibc.core.client.v1.MsgUpdateClient but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on invalid `signer`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgUpdateClient", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g", + "client_id": "07-tendermint-33" + } + `; + + expect(() => cro.ibc.MsgUpdateClient.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + it('should throw on invalid `clientId`', function () { + const json = ` + { + "@type": "/ibc.core.client.v1.MsgUpdateClient", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g" + } + `; + + expect(() => cro.ibc.MsgUpdateClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `clientId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the IBC MsgUpdateClient corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpdateClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33" + } + `; + + const MsgUpdateClient = cro.ibc.MsgUpdateClient.fromCosmosMsgJSON(json); + expect(MsgUpdateClient.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgUpdateClient.clientId).to.eql('07-tendermint-33'); + expect(MsgUpdateClient.header).to.be.null; + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/MsgUpdateClient.ts b/lib/src/transaction/msg/ibc/core/MsgUpdateClient.ts new file mode 100644 index 00000000..62b9e826 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgUpdateClient.ts @@ -0,0 +1,193 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { InitConfigurations } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../utils/address'; +import { owMsgUpdateClientOptions } from '../../ow.types'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { IGoogleAny } from '../IGoogleAny'; + +export const msgUpdateClientIBC = function (config: InitConfigurations) { + return class MsgUpdateClient implements CosmosMsg { + /** MsgUpdateClient clientId. */ + public clientId: string; + + /** MsgUpdateClient header. */ + public header?: IGoogleAny | null; + + /** MsgUpdateClient signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgUpdateClient + * @param {MsgUpdateClientOptions} options + * @returns {MsgUpdateClient} + * @throws {Error} when options is invalid + */ + constructor(options: MsgUpdateClientOptions) { + ow(options, 'options', owMsgUpdateClientOptions); + this.clientId = options.clientId; + this.header = options.header; + this.signer = options.signer; + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgUpdateClient + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient, + value: { + clientId: this.clientId, + header: this.header?.getEncoded(), + signer: this.signer, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgUpdateClient + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgUpdateClient} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgUpdateClient { + const parsedMsg = JSON.parse(msgJsonStr) as MsgUpdateClientJsonRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient} but got ${parsedMsg['@type']}`); + } + + // TODO: The `header` value needs to be handled, currently keeping it as `null` + if (typeof parsedMsg.header === 'object' && Object.keys(parsedMsg.header).length > 0) { + throw new Error('IBC MsgUpdateClient does not support `header` decoding.'); + } + + return new MsgUpdateClient({ + clientId: parsedMsg.client_id, + header: null, + signer: parsedMsg.signer, + }); + } + + validateAddresses() { + // TODO: Can `signer` be from non-CRO network + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export type MsgUpdateClientOptions = { + clientId: string; + header?: IGoogleAny | null; + signer: string; +}; + +export interface MsgUpdateClientJsonRaw { + '@type': string; + client_id: string; + header?: any | MsgUpdateClientJsonRawHeader; + signer: string; +} + +export interface MsgUpdateClientJsonRawHeader { + '@type': string; + signed_header: SignedHeader; + validator_set: TrustedValidators; + trusted_height: TrustedHeight; + trusted_validators: TrustedValidators; +} + +export interface SignedHeader { + header: SignedHeaderHeader; + commit: Commit; +} + +export interface Commit { + height: string; + round: number; + block_id: Blockid; + signatures: Signature[]; +} + +export interface Blockid { + hash: string; + part_set_header: PartSetHeader; +} + +export interface PartSetHeader { + total: number; + hash: string; +} + +export interface Signature { + block_id_flag: BlockidFlag; + validator_address: null | string; + timestamp: Date; + signature: null | string; +} + +export enum BlockidFlag { + BlockIDFlagAbsent = 'BLOCK_ID_FLAG_ABSENT', + BlockIDFlagCommit = 'BLOCK_ID_FLAG_COMMIT', +} + +export interface SignedHeaderHeader { + version: Version; + chain_id: string; + height: string; + time: Date; + last_block_id: Blockid; + last_commit_hash: string; + data_hash: string; + validators_hash: string; + next_validators_hash: string; + consensus_hash: string; + app_hash: string; + last_results_hash: string; + evidence_hash: string; + proposer_address: string; +} + +export interface Version { + block: string; + app: string; +} + +export interface TrustedHeight { + revision_number: string; + revision_height: string; +} + +export interface TrustedValidators { + validators: Proposer[]; + proposer: Proposer; + total_voting_power: string; +} + +export interface Proposer { + address: string; + pub_key: PubKey; + voting_power: string; + proposer_priority: string; +} + +export interface PubKey { + ed25519: string; +} diff --git a/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.spec.ts b/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.spec.ts new file mode 100644 index 00000000..38dc2c82 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.spec.ts @@ -0,0 +1,230 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { google } from '../../../../cosmos/v1beta1/codec'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgUpgradeClient', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.MsgUpgradeClient(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgUpgradeClient conversion', function () { + const MsgUpgradeClient = new cro.ibc.MsgUpgradeClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + proofUpgradeConsensusState: new Uint8Array([1, 2]), + proofUpgradeClient: new Uint8Array([3, 4]), + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient, + value: { + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + clientState: undefined, + proofUpgradeConsensusState: new Uint8Array([1, 2]), + proofUpgradeClient: new Uint8Array([3, 4]), + }, + }; + + expect(MsgUpgradeClient.toRawMsg()).to.deep.eq(rawMsg); + }); + + it('Test appendTxBody MsgUpgradeClient Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgUpgradeClient = new cro.ibc.MsgUpgradeClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + proofUpgradeClient: new Uint8Array([1]), + proofUpgradeConsensusState: new Uint8Array([1]), + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgUpgradeClient).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0a670a650a242f6962632e636f72652e636c69656e742e76312e4d736755706772616465436c69656e74123d0a08636c69656e7449642201012a0101322b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40e348e90785dfac9d7f9504bdbc935c3259802eea7710fa51cc3a6631ef5c599723dbcfaa8db94e6f4c7ac4441b2d0b8da445d7438e1190d27da2fc144922d09c', + ); + }); + + it('Should validate MsgUpgradeClient provided addresses with network config', function () { + const params1 = { + signer: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + clientState: google.protobuf.Any.create({ + type_url: '/some.valid.type.url', + value: new Uint8Array([1, 2, 35, 5]), + }), + consensusState: google.protobuf.Any.create({ + type_url: '/some.valid.type.url', + value: new Uint8Array([1, 2, 35, 5]), + }), + clientId: 'clientId', + proofUpgradeClient: new Uint8Array(), + proofUpgradeConsensusState: new Uint8Array(), + }; + + expect(() => new cro.ibc.MsgUpgradeClient(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgUpgradeClient = new cro.ibc.MsgUpgradeClient({ + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + clientId: 'clientId', + proofUpgradeClient: new Uint8Array(), + proofUpgradeConsensusState: new Uint8Array(), + }); + + expect(() => MsgUpgradeClient.toRawAminoMsg()).to.throw('IBC Module not supported under amino encoding scheme'); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgUpgradeClient', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected /ibc.core.client.v1.MsgUpgradeClient but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on missing field `signer`', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "client_id": "07-tendermint-33", + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `signer` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw on non-empty `clientState`', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33", + "client_state": {"typeurl":"07-tendermint-33"}, + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'IBC MsgUpgradeClient does not support `client_state` decoding.', + ); + }); + + it('should throw on non-empty `consensus_state`', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33", + "consensus_state": {"typeurl":"07-tendermint-33"}, + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'IBC MsgUpgradeClient does not support `consensus_state` decoding.', + ); + }); + it('should throw on invalid `signer`', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g", + "client_id": "07-tendermint-33", + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + it('should throw on invalid `clientId`', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + expect(() => cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `clientId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the IBC MsgUpgradeClient corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.client.v1.MsgUpgradeClient", + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8", + "client_id": "07-tendermint-33", + "proof_upgrade_client": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=", + "proof_upgrade_consensus_state": "EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8=" + } + `; + + const MsgUpgradeClient = cro.ibc.MsgUpgradeClient.fromCosmosMsgJSON(json); + expect(MsgUpgradeClient.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgUpgradeClient.clientId).to.eql('07-tendermint-33'); + expect(typeof MsgUpgradeClient.consensusState).to.eq('undefined'); + expect(MsgUpgradeClient.clientState).to.be.null; + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.ts b/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.ts new file mode 100644 index 00000000..8ebbf359 --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/MsgUpgradeClient.ts @@ -0,0 +1,139 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { google } from '../../../../cosmos/v1beta1/codec/generated/codecimpl'; +import { InitConfigurations } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../utils/address'; +import { owMsgUpgradeClientOptions } from '../../ow.types'; +import * as legacyAmino from '../../../../cosmos/amino'; + +export const msgUpgradeClientIBC = function (config: InitConfigurations) { + return class MsgUpgradeClient implements CosmosMsg { + /** MsgUpgradeClient clientId. */ + public clientId: string; + + /** MsgUpgradeClient clientState. */ + public clientState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient consensusState. */ + public consensusState?: google.protobuf.IAny | null; + + /** MsgUpgradeClient proofUpgradeClient. */ + public proofUpgradeClient: Uint8Array; + + /** MsgUpgradeClient proofUpgradeConsensusState. */ + public proofUpgradeConsensusState: Uint8Array; + + /** MsgUpgradeClient signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgUpgradeClient + * @param {MsgUpgradeClientOptions} options + * @returns {MsgUpgradeClient} + * @throws {Error} when options is invalid + */ + constructor(options: MsgUpgradeClientOptions) { + ow(options, 'options', owMsgUpgradeClientOptions); + this.clientId = options.clientId; + this.clientState = options.clientState; + this.proofUpgradeClient = options.proofUpgradeClient; + this.proofUpgradeConsensusState = options.proofUpgradeConsensusState; + this.signer = options.signer; + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgUpgradeClient + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient, + value: { + clientId: this.clientId, + clientState: this.clientState, + proofUpgradeClient: this.proofUpgradeClient, + proofUpgradeConsensusState: this.proofUpgradeConsensusState, + signer: this.signer, + }, + }; + } + + /** + * Returns an instance of IBC.MsgUpgradeClient + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgUpgradeClient} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgUpgradeClient { + const parsedMsg = JSON.parse(msgJsonStr) as MsgUpgradeClientJsonRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient} but got ${parsedMsg['@type']}`); + } + + // TODO: The `client_state` value needs to be handled, currently keeping it as `null` + if (typeof parsedMsg.client_state === 'object' && Object.keys(parsedMsg.client_state).length > 0) { + throw new Error('IBC MsgUpgradeClient does not support `client_state` decoding.'); + } + + // TODO: The `consensus_state` value needs to be handled, currently keeping it as `null` + if (typeof parsedMsg.consensus_state === 'object' && Object.keys(parsedMsg.consensus_state).length > 0) { + throw new Error('IBC MsgUpgradeClient does not support `consensus_state` decoding.'); + } + + return new MsgUpgradeClient({ + clientId: parsedMsg.client_id, + clientState: null, + consensusState: null, + proofUpgradeClient: new Uint8Array(Object.values(parsedMsg.proof_upgrade_client)), + proofUpgradeConsensusState: new Uint8Array(Object.values(parsedMsg.proof_upgrade_consensus_state)), + signer: parsedMsg.signer, + }); + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + validateAddresses() { + // TODO: Can `signer` be from non-CRO network + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export type MsgUpgradeClientOptions = { + clientId: string; + + clientState?: google.protobuf.IAny | null; + + consensusState?: google.protobuf.IAny | null; + + proofUpgradeClient: Uint8Array; + + proofUpgradeConsensusState: Uint8Array; + + signer: string; +}; + +export interface MsgUpgradeClientJsonRaw { + '@type': string; + client_id: string; + client_state?: any; + consensus_state?: any; + proof_upgrade_client: any; + proof_upgrade_consensus_state: any; + signer: string; +} diff --git a/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.spec.ts b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.spec.ts new file mode 100644 index 00000000..4f7a51ce --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.spec.ts @@ -0,0 +1,206 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../../keypair/secp256k1'; +import { Bytes } from '../../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../../common/constants/typeurl'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgConnectionOpenConfirm', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.connection.MsgConnectionOpenConfirm(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgConnectionOpenConfirm conversion', function () { + const MsgConnectionOpenConfirm = new cro.ibc.connection.MsgConnectionOpenConfirm({ + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm, + value: { + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }, + }; + + expect(MsgConnectionOpenConfirm.toRawMsg()).to.deep.equal(rawMsg); + }); + + it('Test appendTxBody MsgConnectionOpenConfirm Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgConnectionOpenConfirm = new cro.ibc.connection.MsgConnectionOpenConfirm({ + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgConnectionOpenConfirm).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0aa4020aa1020a302f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e436f6e6669726d12ec010a0c636f6e6e656374696f6e2d3012a5010aea040ae7040a1a636f6e6e656374696f6e732f636f6e6e656374696f6e2d31303912610a1030372d74656e6465726d696e742d333912230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f524445524544180322260a0f30372d74656e6465726d696e742d30120c636f6e6e656374696f6e2d301a050a036962631a0e0801180120012a060002e6b1ae05222c080112280204e6b1ae052096d7f01a07080410eca1d702222b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40d229e4846fa7efaaa1574ac5bda529cc60f43bfbf621fbca66e099bcb3af34e4090f929b8d2ccaa871595a9e6dd5a3fe521717dc5bc510c5e7e9be8dfc7bfc35', + ); + }); + + it('Should validate MsgConnectionOpenConfirm provided addresses with network config', function () { + const params1 = { + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'cosmos1vw4ucaeagtduv5ep4sa95e3aqzqpsk5meda08c', + }; + + expect(() => new cro.ibc.connection.MsgConnectionOpenConfirm(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgConnectionOpenConfirm = new cro.ibc.connection.MsgConnectionOpenConfirm({ + connectionId: 'connection-0', + proofAck: Bytes.fromBase64String( + 'CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw', + ).toUint8Array(), + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + expect(() => MsgConnectionOpenConfirm.toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgConnectionOpenConfirm', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.connection.MsgConnectionOpenConfirm.fromCosmosMsgJSON(json)).to.throw( + '/ibc.core.connection.v1.MsgConnectionOpenConfirm but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on invalid `signer`', function () { + const json = ` + { + "@type": "/ibc.core.connection.v1.MsgConnectionOpenConfirm", + "connection_id": "connection-0", + "proof_ack": "CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw/bo0CDtYmNNH7fv7vx+WjEcTkfac/kCPa7DedDEgIiwIARIoBAbmsa4FIB8xvqKimT34trzUuHIlW3G/2DP7N8YHwOSx/mzQ0ErpICIsCAESKAYK5rGuBSBWYYwmrC+uozPRr3ohRkyH3xIOwIaaW+1sq8AxiFNQYSAiLAgBEigIGuaxrgUgy8xshXqwIhiBGvcb4PNq5LIqnO0OUHaijkhQRqR7jqogIi4IARIHCibmsa4FIBohIItQjFFOZ3x/ji7vdITso/QHTHYeLi5uc7QUQSSwm0bUIi4IARIHDFjmsa4FIBohIKFbQ+eCfqDHa9oEnrivmdJwS67tg1C9ZxwmaEaqvX2+Ii0IARIpDpwB5rGuBSC9Zpf5w9YzCgKIVDlD16yj4NXh3l8fsJKmryTYqTnyqiAiLwgBEggQpgLmsa4FIBohIBEGzVfyfw8OTVskya1pMT5e8/DW5Yx5yPgIGOY0E4W9Ii8IARIIEt4D5rGuBSAaISC3sgTWB3c4n6lgqlNYSjFvMHSl6YZ3r+ebnNDCEmCfYiItCAESKRaKDOaxrgUg+jfbRK8vmXAywtaLcL/UaDT16iML9dND4OASW1eHSB0gCtUBCtIBCgNpYmMSIGDVVrQC1QnXBhhenB9j9iBD8d1AMShY+v3PLkaVo++3GgkIARgBIAEqAQAiJwgBEgEBGiD5Vt5/BBmvQQnMGXTh8TcjCr0rjLn1J3de7MoaiBcPIiIlCAESIQEFpaWk4Z4I+HrpIBDKAjoakmKcZxCuHLso78blOarPPiIlCAESIQFyMyfTXOtJCpzDuQ7cb70cKwRg+huJy6JykKxrRE6vYiInCAESAQEaIPGCxxt96/zj47Kv0wrrGBOqto+/vvvf4XGiiuxT7TZU", + "proof_height": { + "revision_number": "4", + "revision_height": "5622902" + }, + "signer": "cosmos1u8prj0rj3ur7kr23dhjgyteuq55ntahfuzlf6g" + } + `; + + expect(() => cro.ibc.connection.MsgConnectionOpenConfirm.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + it('should return the IBC MsgConnectionOpenConfirm corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.connection.v1.MsgConnectionOpenConfirm", + "connection_id": "connection-0", + "proof_ack": "CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw/bo0CDtYmNNH7fv7vx+WjEcTkfac/kCPa7DedDEgIiwIARIoBAbmsa4FIB8xvqKimT34trzUuHIlW3G/2DP7N8YHwOSx/mzQ0ErpICIsCAESKAYK5rGuBSBWYYwmrC+uozPRr3ohRkyH3xIOwIaaW+1sq8AxiFNQYSAiLAgBEigIGuaxrgUgy8xshXqwIhiBGvcb4PNq5LIqnO0OUHaijkhQRqR7jqogIi4IARIHCibmsa4FIBohIItQjFFOZ3x/ji7vdITso/QHTHYeLi5uc7QUQSSwm0bUIi4IARIHDFjmsa4FIBohIKFbQ+eCfqDHa9oEnrivmdJwS67tg1C9ZxwmaEaqvX2+Ii0IARIpDpwB5rGuBSC9Zpf5w9YzCgKIVDlD16yj4NXh3l8fsJKmryTYqTnyqiAiLwgBEggQpgLmsa4FIBohIBEGzVfyfw8OTVskya1pMT5e8/DW5Yx5yPgIGOY0E4W9Ii8IARIIEt4D5rGuBSAaISC3sgTWB3c4n6lgqlNYSjFvMHSl6YZ3r+ebnNDCEmCfYiItCAESKRaKDOaxrgUg+jfbRK8vmXAywtaLcL/UaDT16iML9dND4OASW1eHSB0gCtUBCtIBCgNpYmMSIGDVVrQC1QnXBhhenB9j9iBD8d1AMShY+v3PLkaVo++3GgkIARgBIAEqAQAiJwgBEgEBGiD5Vt5/BBmvQQnMGXTh8TcjCr0rjLn1J3de7MoaiBcPIiIlCAESIQEFpaWk4Z4I+HrpIBDKAjoakmKcZxCuHLso78blOarPPiIlCAESIQFyMyfTXOtJCpzDuQ7cb70cKwRg+huJy6JykKxrRE6vYiInCAESAQEaIPGCxxt96/zj47Kv0wrrGBOqto+/vvvf4XGiiuxT7TZU", + "proof_height": { + "revision_number": "4", + "revision_height": "5622902" + }, + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8" + } + `; + + const MsgConnectionOpenConfirm = cro.ibc.connection.MsgConnectionOpenConfirm.fromCosmosMsgJSON(json); + expect(MsgConnectionOpenConfirm.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + expect(MsgConnectionOpenConfirm.connectionId).to.eql('connection-0'); + expect(MsgConnectionOpenConfirm?.proofHeight?.revisionHeight!.toString()).to.eql('5622902'); + expect(MsgConnectionOpenConfirm?.proofHeight?.revisionNumber!.toString()).to.eql('4'); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.ts b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.ts new file mode 100644 index 00000000..224ab11f --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenConfirm.ts @@ -0,0 +1,134 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import Long from 'long'; +import { InitConfigurations } from '../../../../../core/cro'; +import { CosmosMsg } from '../../../cosmosMsg'; +import { Msg } from '../../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../../utils/address'; +import { owMsgConnectionOpenConfirmOptions } from '../../../ow.types'; +import * as legacyAmino from '../../../../../cosmos/amino'; +import { Bytes } from '../../../../../utils/bytes/bytes'; + +export const MsgConnectionOpenConfirmIBC = function (config: InitConfigurations) { + return class MsgConnectionOpenConfirm implements CosmosMsg { + /** MsgConnectionOpenConfirm connectionId. */ + public connectionId: string; + + /** MsgConnectionOpenConfirm proofAck. */ + public proofAck: Uint8Array; + + /** MsgConnectionOpenConfirm proofHeight. */ + public proofHeight?: IProofHeight | null; + + /** MsgConnectionOpenConfirm signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgConnectionOpenConfirm + * @param {MsgConnectionOpenConfirmOptions} options + * @returns {MsgConnectionOpenConfirm} + * @throws {Error} when options is invalid + */ + constructor(options: MsgConnectionOpenConfirmOptions) { + ow(options, 'options', owMsgConnectionOpenConfirmOptions); + this.connectionId = options.connectionId; + this.proofAck = options.proofAck; + this.proofHeight = options.proofHeight; + this.signer = options.signer; + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgConnectionOpenConfirm + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm, + value: { + connectionId: this.connectionId, + proofAck: this.proofAck, + proofHeight: this.proofHeight, + signer: this.signer, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgConnectionOpenConfirm + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgConnectionOpenConfirm} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgConnectionOpenConfirm { + const parsedMsg = JSON.parse(msgJsonStr) as MsgConnectionOpenConfirmJSON; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm} but got ${parsedMsg['@type']}`, + ); + } + + try { + Bytes.fromBase64String(parsedMsg.proof_ack); + } catch (error) { + throw new Error('Invalid `proof_ack` received in JSON.'); + } + + let proofHeight; + if (typeof parsedMsg.proof_height === 'object' && Object.keys(parsedMsg.proof_height).length > 0) { + proofHeight = { + revisionHeight: Long.fromString(parsedMsg.proof_height?.revision_height!), + revisionNumber: Long.fromString(parsedMsg.proof_height?.revision_number!), + }; + } + return new MsgConnectionOpenConfirm({ + connectionId: parsedMsg.connection_id, + proofAck: Bytes.fromBase64String(parsedMsg.proof_ack).toUint8Array(), + proofHeight, + signer: parsedMsg.signer, + }); + } + + validateAddresses() { + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export type MsgConnectionOpenConfirmOptions = { + connectionId: string; + proofAck: Uint8Array; + proofHeight?: IProofHeight | null; + signer: string; +}; + +export interface IProofHeight { + revisionNumber: Long; + revisionHeight: Long; +} + +export interface MsgConnectionOpenConfirmJSON { + '@type': string; + connection_id: string; + proof_ack: string; + proof_height: ProofHeightJSON; + signer: string; +} +export interface ProofHeightJSON { + revision_number: string; + revision_height: string; +} diff --git a/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.spec.ts b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.spec.ts new file mode 100644 index 00000000..cc00ac3c --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.spec.ts @@ -0,0 +1,863 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../../keypair/secp256k1'; +import { Bytes } from '../../../../../utils/bytes/bytes'; +import { CroSDK } from '../../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../../common/constants/typeurl'; +import { ics23 } from '../../../../../cosmos/v1beta1/codec'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgConnectionOpenTry', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'cro1l60esq8vche5nlk7ylvp0ssq7rmk453zh8rx6u', + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.connection.MsgConnectionOpenTry(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgConnectionOpenTry conversion', function () { + const MsgConnectionOpenTry = new cro.ibc.connection.MsgConnectionOpenTry({ + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + const rawMsg: Msg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry, + value: { + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }, + }; + + expect(MsgConnectionOpenTry.toRawMsg()).to.deep.equal(rawMsg); + }); + + it('Test appendTxBody MsgConnectionOpenTry Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgConnectionOpenTry = new cro.ibc.connection.MsgConnectionOpenTry({ + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgConnectionOpenTry).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0aa7170aa4170a2c2f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e54727912f3160a0f30372d74656e6465726d696e742d3012001a0022290a1030372d74656e6465726d696e742d3339120e636f6e6e656374696f6e2d3130391a050a03696263280032210a0131120c4f524445524f524445524544120e4f52444552554e4f5244455245443a07080410ec98d70242b7060adc040ad9040a1a636f6e6e656374696f6e732f636f6e6e656374696f6e2d31303912530a1030372d74656e6465726d696e742d333912230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f524445524544180122180a0f30372d74656e6465726d696e742d301a050a036962631a0e0801180120012a060002d4b1ae05222c080112280204d4b1ae052096d7f0fdba34083b5898d347edfbfbbf1f968c471391f69cfe408f6bb0de743120222c080112280406d4b1ae05201f31bea2a2993df8b6bcd4b872255b71bfd833fb37c607c0e4b1fe6cd0d04ae920222c08011228060ad4b1ae052056618c26ac2faea333d1af7a21464c87df120ec0869a5bed6cabc0318853506120222c08011228081ad4b1ae0520cbcc6c857ab02218811af71be0f36ae4b22a9ced0e5076a28e485046a47b8eaa20222e080112070a26d4b1ae05201a21208b508c514e677c7f8e2eef7484eca3f4074c761e2e2e6e73b4144124b09b46d4222e080112070c58d4b1ae05201a2120a15b43e7827ea0c76bda049eb8af99d2704baeed8350bd671c266846aabd7dbe222d080112290e9c01d4b1ae0520bd6697f9c3d6330a0288543943d7aca3e0d5e1de5f1fb092a6af24d8a939f2aa20222f0801120810a602d4b1ae05201a21201106cd57f27f0f0e4d5b24c9ad69313e5ef3f0d6e58c79c8f80818e6341385bd222f0801120812de03d4b1ae05201a2120b7b204d60777389fa960aa53584a316f3074a5e98677afe79b9cd0c212609f62222d0801122916860cd4b1ae052027ff652d2c5831b7e5aa5eb00607d86409fcf379d1a59a93c197f077b9e6ead9200ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf244ae2070a87060a84060a24636c69656e74732f30372d74656e6465726d696e742d33392f636c69656e74537461746512c2010a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651292010a1a63727970746f2d6f72672d636861696e2d6d61696e6e65742d311204080110031a040880ea4922050880d493012a0308d80432003a05080110d74142190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a1075706772616465644942435374617465500158011a0e0801180120012a060002d4b1ae05222e080112070204d4b1ae05201a212021afa31f920ad80cc97dbc2d50930e8d1faf040e3d0d4c82d9c61a1c18cbf98c222c080112280408d4b1ae05209a7fb7f61f5e58d46262d327fe5f597cacab4515676e13858cf761ea91321d8020222e080112070610d4b1ae05201a2120e140aad320cab4acceecf4aa8c19a9ee76d401895cbf0db41fa4fb9d138ac48f222c080112280820d4b1ae0520f1d4c8cf0fd548dfc4908fd230fd1b438eb9727b172279bef1e2165dbe29280520222e080112070a2ad4b1ae05201a212019b0655aa367603d3360b41f4bc237b5010e049d2e06af546d887d17004c7374222e080112070c66d4b1ae05201a21200a9250a2fd891c0392530325d02db55ebeb42b24d892e953c44d7690d3cca8b6222d080112290eae01d4b1ae052061c211a10f3343cda38ffe3b508937880cd12a52ea748c4a6134c617c69d0ed320222d0801122910ea01d4b1ae0520e6f0c13c29cc4fbc0f941f1ab737ab4962ab6656949ccb91575a78661908643420222d0801122912ea02d4b1ae0520f18ad71aae009d201acf938be932c63b98d65eed2266db0c11e91f68f18c543f20222d0801122914a808d4b1ae052055a5492d665f23e1c1917938cff166ca217eb10a09b0c7729ffbf872e069566b20222f0801120816860cd4b1ae05201a21206b96c95da8f21f092c33a78391c23d1692167a841e5f8450f2578c43c9ce80f80ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf2452af070ad4050ad1050a2f636c69656e74732f30372d74656e6465726d696e742d33392f636f6e73656e7375735374617465732f312d383430371286010a2e2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436f6e73656e737573537461746512540a0c0893d8f2820610fe8edac60312220a202f91b0403dcac16a7e3c565e43c473d29ba3c49bdc1e7f4115dddcc0e160dbde1a2015d4a1bd346a1c32898a55ee9e4095e035f19b0fabbd98c7f3798948f564929e1a0e0801180120012a060002d4b1ae05222e080112070204d4b1ae05201a2120390e107da915f545496db87c621174feb7add0af41b18e2289a3c08c05faad5c222c080112280408d4b1ae0520cf12973db134c9f7acf0702199dc16b589c16601b91c639dbf61ab8dbead02f820222c080112280610d4b1ae052066f93e42fb9c9d9232aefb47b065fc61c42de229f88701679d0e21be3ff193d220222c080112280820d4b1ae0520f1d4c8cf0fd548dfc4908fd230fd1b438eb9727b172279bef1e2165dbe29280520222e080112070a2ad4b1ae05201a212019b0655aa367603d3360b41f4bc237b5010e049d2e06af546d887d17004c7374222e080112070c66d4b1ae05201a21200a9250a2fd891c0392530325d02db55ebeb42b24d892e953c44d7690d3cca8b6222d080112290eae01d4b1ae052061c211a10f3343cda38ffe3b508937880cd12a52ea748c4a6134c617c69d0ed320222d0801122910ea01d4b1ae0520e6f0c13c29cc4fbc0f941f1ab737ab4962ab6656949ccb91575a78661908643420222d0801122912ea02d4b1ae0520f18ad71aae009d201acf938be932c63b98d65eed2266db0c11e91f68f18c543f20222d0801122914a808d4b1ae052055a5492d665f23e1c1917938cff166ca217eb10a09b0c7729ffbf872e069566b20222f0801120816860cd4b1ae05201a21206b96c95da8f21f092c33a78391c23d1692167a841e5f8450f2578c43c9ce80f80ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf245a05080110d741622b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40e8c37cdb1be95db31bd759e610619ec538f54c8873e6e2efc4f26fa52388a79976606e23f9329b8aaadb4c472bb2da36c58bd9a4101cad0bd36049cd59672529', + ); + }); + + it('Should validate MsgConnectionOpenTry provided addresses with network config', function () { + const params1 = { + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'cro1l60esq8vche5nlk7ylvp0ssq7rmk453zh8rx6u', + }; + + expect(() => new cro.ibc.connection.MsgConnectionOpenTry(params1)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('Should throw on getting toRawAminoMsg()', function () { + const MsgConnectionOpenTry = new cro.ibc.connection.MsgConnectionOpenTry({ + clientId: '07-tendermint-0', + previousConnectionId: '', + clientState: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + counterparty: { + clientId: '07-tendermint-39', + connectionId: 'connection-109', + prefix: { + keyPrefix: 'aWJj', + }, + }, + delayPeriod: Long.fromString('0'), + counterpartyVersions: [ + { + identifier: '1', + features: ['ORDERORDERED', 'ORDERUNORDERED'], + }, + ], + proofHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5622892'), + }, + proofInit: Bytes.fromBase64String( + 'CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofClient: Bytes.fromBase64String( + 'CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + proofConsensus: Bytes.fromBase64String( + 'CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==', + ).toUint8Array(), + consensusHeight: { + revisionNumber: Long.fromString('1'), + revisionHeight: Long.fromString('8407'), + }, + signer: 'tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht', + }); + + expect(() => MsgConnectionOpenTry.toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a IBC MsgConnectionOpenTry', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.ibc.connection.MsgConnectionOpenTry.fromCosmosMsgJSON(json)).to.throw( + '/ibc.core.connection.v1.MsgConnectionOpenTry but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw on invalid `signer`', function () { + const json = ` + { + "@type": "/ibc.core.connection.v1.MsgConnectionOpenTry", + "client_id": "07-tendermint-0", + "previous_connection_id": "", + "counterparty": { + "client_id": "07-tendermint-39", + "connection_id": "connection-109", + "prefix": { + "key_prefix": "aWJj" + } + }, + "delay_period": "0", + "counterparty_versions": [ + { + "identifier": "1", + "features": [ + "ORDER_ORDERED", + "ORDER_UNORDERED" + ] + } + ], + "proof_height": { + "revision_number": "4", + "revision_height": "5622892" + }, + "proof_init": "CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_client": "CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_consensus": "CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "consensus_height": { + "revision_number": "1", + "revision_height": "8407" + }, + "signer": "cro1l60esq8vche5nlk7ylvp0ssq7rmk453zh8rx6u" + } + `; + + expect(() => cro.ibc.connection.MsgConnectionOpenTry.fromCosmosMsgJSON(json)).to.throw( + 'Provided `signer` does not match network selected', + ); + }); + + it('should throw on invalid `base64` strings', function () { + const json = ` + { + "@type": "/ibc.core.connection.v1.MsgConnectionOpenTry", + "client_id": "07-tendermint-0", + "previous_connection_id": "", + "counterparty": { + "client_id": "07-tendermint-39", + "connection_id": "connection-109", + "prefix": { + "key_prefix": "aWJj" + } + }, + "delay_period": "0", + "counterparty_versions": [ + { + "identifier": "1", + "features": [ + "ORDER_ORDERED", + "ORDER_UNORDERED" + ] + } + ], + "proof_height": { + "revision_number": "4", + "revision_height": "5622892" + }, + "proof_init": "+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_client": "CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_consensus": "CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "consensus_height": { + "revision_number": "1", + "revision_height": "8407" + }, + "signer": "cro1l60esq8vche5nlk7ylvp0ssq7rmk453zh8rx6u" + } + `; + + expect(() => cro.ibc.connection.MsgConnectionOpenTry.fromCosmosMsgJSON(json)).to.throw( + 'Invalid Base64 string received in JSON.', + ); + }); + it('should throw on non empty `client-state`', function () { + const json = `{ + "@type": "/ibc.core.connection.v1.MsgConnectionOpenTry", + "client_id": "07-tendermint-0", + "previous_connection_id": "", + "client_state": { + "@type": "/ibc.lightclients.tendermint.v1.ClientState", + "chain_id": "crypto-org-chain-mainnet-1", + "trust_level": { + "numerator": "1", + "denominator": "3" + }, + "trusting_period": "1209600s", + "unbonding_period": "2419200s", + "max_clock_drift": "600s", + "frozen_height": { + "revision_number": "0", + "revision_height": "0" + }, + "latest_height": { + "revision_number": "1", + "revision_height": "8407" + }, + "proof_specs": [ + { + "leaf_spec": { + "hash": "SHA256", + "prehash_key": "NO_HASH", + "prehash_value": "SHA256", + "length": "VAR_PROTO", + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [ + 0, + 1 + ], + "child_size": 33, + "min_prefix_length": 4, + "max_prefix_length": 12, + "empty_child": null, + "hash": "SHA256" + }, + "max_depth": 0, + "min_depth": 0 + }, + { + "leaf_spec": { + "hash": "SHA256", + "prehash_key": "NO_HASH", + "prehash_value": "SHA256", + "length": "VAR_PROTO", + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [ + 0, + 1 + ], + "child_size": 32, + "min_prefix_length": 1, + "max_prefix_length": 1, + "empty_child": null, + "hash": "SHA256" + }, + "max_depth": 0, + "min_depth": 0 + } + ], + "upgrade_path": [ + "upgrade", + "upgradedIBCState" + ], + "allow_update_after_expiry": true, + "allow_update_after_misbehaviour": true + }, + "counterparty": { + "client_id": "07-tendermint-39", + "connection_id": "connection-109", + "prefix": { + "key_prefix": "aWJj" + } + }, + "delay_period": "0", + "counterparty_versions": [ + { + "identifier": "1", + "features": [ + "ORDER_ORDERED", + "ORDER_UNORDERED" + ] + } + ], + "proof_height": { + "revision_number": "4", + "revision_height": "5622892" + }, + "proof_init": "CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_client": "CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_consensus": "CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "consensus_height": { + "revision_number": "1", + "revision_height": "8407" + }, + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8" + } + `; + + expect(() => cro.ibc.connection.MsgConnectionOpenTry.fromCosmosMsgJSON(json)).to.throw( + 'MsgConnectionOpenTry doesnot support `client_state` JSON decoding.', + ); + }); + it('should return the IBC MsgConnectionOpenTry corresponding to the JSON', function () { + const json = `{ + "@type": "/ibc.core.connection.v1.MsgConnectionOpenTry", + "client_id": "07-tendermint-0", + "previous_connection_id": "", + "counterparty": { + "client_id": "07-tendermint-39", + "connection_id": "connection-109", + "prefix": { + "key_prefix": "aWJj" + } + }, + "delay_period": "0", + "counterparty_versions": [ + { + "identifier": "1", + "features": [ + "ORDER_ORDERED", + "ORDER_UNORDERED" + ] + } + ], + "proof_height": { + "revision_number": "4", + "revision_height": "5622892" + }, + "proof_init": "CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_client": "CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "proof_consensus": "CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", + "consensus_height": { + "revision_number": "1", + "revision_height": "8407" + }, + "signer": "tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8" + } + `; + + const MsgConnectionOpenTry = cro.ibc.connection.MsgConnectionOpenTry.fromCosmosMsgJSON(json); + expect(MsgConnectionOpenTry.signer).to.eql('tcro1agr5hwr6gxljf4kpg6fm7l7ehjxtyazg86nef8'); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.ts b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.ts new file mode 100644 index 00000000..d7fc77de --- /dev/null +++ b/lib/src/transaction/msg/ibc/core/connection/MsgConnectionOpenTry.ts @@ -0,0 +1,302 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import Long from 'long'; +import { InitConfigurations } from '../../../../../core/cro'; +import { CosmosMsg } from '../../../cosmosMsg'; +import { Msg } from '../../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../../utils/address'; +import { owMsgConnectionOpenTryOptions } from '../../../ow.types'; +import * as legacyAmino from '../../../../../cosmos/amino'; +import { Bytes } from '../../../../../utils/bytes/bytes'; +import { ibc } from '../../../../../cosmos/v1beta1/codec/generated/codecimpl'; + +export const MsgConnectionOpenTryIBC = function (config: InitConfigurations) { + return class MsgConnectionOpenTry implements CosmosMsg { + /** MsgConnectionOpenTry clientId. */ + public clientId: string; + + /** MsgConnectionOpenTry previousConnectionId. */ + public previousConnectionId: string; + + /** MsgConnectionOpenTry clientState. */ + public clientState?: ibc.lightclients.tendermint.v1.IClientState | null; + + /** MsgConnectionOpenTry counterparty. */ + public counterparty?: Counterparty | null; + + /** MsgConnectionOpenTry delayPeriod. */ + public delayPeriod: Long; + + /** MsgConnectionOpenTry counterpartyVersions. */ + public counterpartyVersions: CounterpartyVersion[]; + + /** MsgConnectionOpenTry proofHeight. */ + public proofHeight?: IHeight | null; + + /** MsgConnectionOpenTry proofInit. */ + public proofInit: Uint8Array; + + /** MsgConnectionOpenTry proofClient. */ + public proofClient: Uint8Array; + + /** MsgConnectionOpenTry proofConsensus. */ + public proofConsensus: Uint8Array; + + /** MsgConnectionOpenTry consensusHeight. */ + public consensusHeight?: IHeight | null; + + /** MsgConnectionOpenTry signer. */ + public signer: string; + + /** + * Constructor to create a new IBC.MsgConnectionOpenTry + * @param {MsgConnectionOpenTryOptions} options + * @returns {MsgConnectionOpenTry} + * @throws {Error} when options is invalid + */ + constructor(options: MsgConnectionOpenTryOptions) { + ow(options, 'options', owMsgConnectionOpenTryOptions); + this.clientId = options.clientId; + this.previousConnectionId = options.previousConnectionId; + this.clientState = options.clientState; + this.counterparty = options.counterparty; + this.delayPeriod = options.delayPeriod; + this.counterpartyVersions = options.counterpartyVersions; + this.proofHeight = options.proofHeight; + this.proofInit = options.proofInit; + this.proofClient = options.proofClient; + this.proofConsensus = options.proofConsensus; + this.consensusHeight = options.consensusHeight; + this.signer = options.signer; + + this.validateAddresses(); + } + + /** + * Returns the raw Msg representation of Ibc.MsgConnectionOpenTry + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry, + value: { + clientId: this.clientId, + previousConnectionId: this.previousConnectionId, + clientState: this.clientState, + counterparty: this.counterparty, + delayPeriod: this.delayPeriod, + counterpartyVersions: this.counterpartyVersions, + proofHeight: this.proofHeight, + proofInit: this.proofInit, + proofClient: this.proofClient, + proofConsensus: this.proofConsensus, + consensusHeight: this.consensusHeight, + signer: this.signer, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.MsgConnectionOpenTry + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgConnectionOpenTry} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgConnectionOpenTry { + const parsedMsg = JSON.parse(msgJsonStr) as MsgConnectionOpenTryJSON; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry} but got ${parsedMsg['@type']}`, + ); + } + + try { + Bytes.fromBase64String(parsedMsg.proof_init); + Bytes.fromBase64String(parsedMsg.proof_client); + Bytes.fromBase64String(parsedMsg.proof_consensus); + } catch (error) { + throw new Error('Invalid Base64 string received in JSON.'); + } + + // TODO: Not support `client_state`, Will need another issue + if (parsedMsg.client_state && Object.keys(parsedMsg.client_state).length > 0) { + throw new Error('MsgConnectionOpenTry doesnot support `client_state` JSON decoding.'); + } + + let proofHeight; + let consensusHeight; + let counterparty; + if (typeof parsedMsg.proof_height === 'object' && Object.keys(parsedMsg.proof_height).length > 0) { + proofHeight = { + revisionHeight: Long.fromString(parsedMsg.proof_height?.revision_height!), + revisionNumber: Long.fromString(parsedMsg.proof_height?.revision_number!), + }; + } + if (typeof parsedMsg.consensus_height === 'object' && Object.keys(parsedMsg.consensus_height).length > 0) { + consensusHeight = { + revisionNumber: Long.fromString(parsedMsg.consensus_height.revision_number), + revisionHeight: Long.fromString(parsedMsg.consensus_height.revision_height), + }; + } + if (typeof parsedMsg.counterparty === 'object' && Object.keys(parsedMsg.counterparty).length > 0) { + counterparty = { + clientId: parsedMsg.counterparty.client_id, + connectionId: parsedMsg.counterparty.connection_id, + prefix: { + keyPrefix: parsedMsg.counterparty.prefix.key_prefix, + }, + }; + } + + let counterPartyVersionList: CounterpartyVersion[] = []; + if (typeof parsedMsg.counterparty_versions === 'object' && parsedMsg.counterparty_versions.length > 0) { + counterPartyVersionList = parsedMsg.counterparty_versions.map((counterpartyVersion) => { + return { + identifier: counterpartyVersion.identifier, + features: counterpartyVersion.features, + }; + }); + } + + return new MsgConnectionOpenTry({ + clientId: parsedMsg.client_id, + previousConnectionId: parsedMsg.previous_connection_id, + clientState: undefined, // TODO, keeping default `undefined` + counterparty, + delayPeriod: Long.fromString(parsedMsg.delay_period), + counterpartyVersions: counterPartyVersionList, + proofHeight, + proofInit: Bytes.fromBase64String(parsedMsg.proof_init).toUint8Array(), + proofClient: Bytes.fromBase64String(parsedMsg.proof_client).toUint8Array(), + proofConsensus: Bytes.fromBase64String(parsedMsg.proof_consensus).toUint8Array(), + consensusHeight, + signer: parsedMsg.signer, + }); + } + + validateAddresses() { + if ( + !validateAddress({ + address: this.signer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `signer` does not match network selected'); + } + } + }; +}; + +export interface MsgConnectionOpenTryOptions { + clientId: string; + previousConnectionId: string; + clientState?: ibc.lightclients.tendermint.v1.IClientState | null; + counterparty?: Counterparty | null; + delayPeriod: Long; + counterpartyVersions: CounterpartyVersion[]; + proofHeight?: IHeight | null; + proofInit: Uint8Array; + proofClient: Uint8Array; + proofConsensus: Uint8Array; + consensusHeight?: IHeight | null; + signer: string; +} +export interface CounterpartyVersion { + identifier: string; + features: string[]; +} +export interface Counterparty { + clientId: string; + connectionId: string; + prefix: Prefix; +} +export interface Prefix { + keyPrefix: string; +} +export interface IHeight { + revisionNumber: Long; + revisionHeight: Long; +} + +/** JSON TYPES * */ + +export interface MsgConnectionOpenTryJSON { + '@type': string; + client_id: string; + previous_connection_id: string; + client_state: ClientStateJSON; + counterparty: CounterpartyJSON; + delay_period: string; + counterparty_versions: CounterpartyVersion[]; + proof_height: Height; + proof_init: string; + proof_client: string; + proof_consensus: string; + consensus_height: Height; + signer: string; +} + +export interface ClientStateJSON { + '@type': string; + chain_id: string; + trust_level: TrustLevelJSON; + trusting_period: string; + unbonding_period: string; + max_clock_drift: string; + frozen_height: Height; + latest_height: Height; + proof_specs: ProofSpecJSON[]; + upgrade_path: string[]; + allow_update_after_expiry: boolean; + allow_update_after_misbehaviour: boolean; +} +export interface Height { + revision_number: string; + revision_height: string; +} + +export interface ProofSpecJSON { + leaf_spec: LeafSpecJSON; + inner_spec: InnerSpecJSON; + max_depth: number; + min_depth: number; +} + +export interface InnerSpecJSON { + child_order: number[]; + child_size: number; + min_prefix_length: number; + max_prefix_length: number; + empty_child: null; + hash: string; +} + +export interface LeafSpecJSON { + hash: string; + prehash_key: string; + prehash_value: string; + length: string; + prefix: string; +} + +export interface TrustLevelJSON { + numerator: string; + denominator: string; +} + +export interface CounterpartyJSON { + client_id: string; + connection_id: string; + prefix: PrefixJSON; +} + +export interface PrefixJSON { + key_prefix: string; +} diff --git a/lib/src/transaction/msg/ibc/lightclients/ClientState.spec.ts b/lib/src/transaction/msg/ibc/lightclients/ClientState.spec.ts new file mode 100644 index 00000000..49b4437d --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/ClientState.spec.ts @@ -0,0 +1,442 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { ics23 } from '../../../../cosmos/v1beta1/codec'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing IBCClientState', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = [ + { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + ]; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.lightclient.ClientState(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test ClientState conversion', function () { + const ClientState = new cro.ibc.lightclient.ClientState({ + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }); + + const rawMsg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.ClientState, + value: { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }, + }; + + expect(ClientState.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test ClientState `getEncoded`', function () { + const params = { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }; + const ClientState = new cro.ibc.lightclient.ClientState(params); + + expect(ClientState.getEncoded().value).instanceOf(Uint8Array); + expect(ClientState.getEncoded().type_url).to.equal('/ibc.lightclients.tendermint.v1.ClientState'); + }); + + it('should throw on invalid values', function () { + const params = { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: 10, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }; + const params1 = { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: 11, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }; + + expect(() => new cro.ibc.lightclient.ClientState(params)).to.throw( + '(array `proofSpecs`) Expected property property property number `hash` to be one of enum ics23.HashOp, got `10` in object `leafSpec` in object `t` in object `options`', + ); + expect(() => new cro.ibc.lightclient.ClientState(params1)).to.throw( + '(array `proofSpecs`) Expected property property property number `length` to be one of enum ics23.LengthOp, got `11` in object `leafSpec` in object `t` in object `options`', + ); + }); + + context('should throw on unsupported functionalities', function () { + it('should throw on calling .toRawAminoMsg', function () { + const params = { + chainId: 'testnet-croeseid-1', + trustLevel: { + numerator: Long.fromString('1'), + denominator: Long.fromString('1'), + }, + trustingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + unbondingPeriod: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + maxClockDrift: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + frozenHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + latestHeight: { + revisionNumber: Long.fromString('100'), + revisionHeight: Long.fromString('100'), + }, + proofSpecs: [ + { + leafSpec: { + hash: ics23.HashOp.BITCOIN, + prehashKey: ics23.HashOp.BITCOIN, + prehashValue: ics23.HashOp.BITCOIN, + length: ics23.LengthOp.VAR_RLP, + prefix: Uint8Array.from([0, 1, 2]), + }, + innerSpec: { + childOrder: [1, 2], + childSize: 1, + minPrefixLength: 0, + maxPrefixLength: 10, + emptyChild: Uint8Array.from([0, 1, 2]), + hash: ics23.HashOp.BITCOIN, + }, + maxDepth: 10000, + minDepth: 10000, + }, + ], + upgradePath: ['ibc'], + allowUpdateAfterExpiry: false, + allowUpdateAfterMisbehaviour: false, + }; + + expect(() => new cro.ibc.lightclient.ClientState(params).toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + it('should throw on calling .fromCosmosMsgJSON', function () { + expect(() => cro.ibc.lightclient.ClientState.fromCosmosMsgJSON('json')).to.throw( + 'IBC Module does not support JSON decoding.', + ); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/lightclients/ClientState.ts b/lib/src/transaction/msg/ibc/lightclients/ClientState.ts new file mode 100644 index 00000000..55c298b1 --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/ClientState.ts @@ -0,0 +1,156 @@ +import ow from 'ow'; +import Long from 'long'; +import { ibc, ics23, google } from '../../../../cosmos/v1beta1/codec/generated/codecimpl'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { IGoogleAny } from '../IGoogleAny'; +import { owClientStateOptions } from '../../ow.types'; + +export const msgClientState = function () { + return class ClientState implements IGoogleAny, ibc.lightclients.tendermint.v1.IClientState { + /** ClientState chainId. */ + public chainId: string; + + /** ClientState trustLevel. */ + public trustLevel?: IFraction; + + /** ClientState trustingPeriod. */ + public trustingPeriod?: IDuration; + + /** ClientState unbondingPeriod. */ + public unbondingPeriod?: IDuration; + + /** ClientState maxClockDrift. */ + public maxClockDrift?: IDuration; + + /** ClientState frozenHeight. */ + public frozenHeight?: IHeight; + + /** ClientState latestHeight. */ + public latestHeight?: IHeight; + + /** ClientState proofSpecs. */ + public proofSpecs: ics23.IProofSpec[]; + + /** ClientState upgradePath. */ + public upgradePath: string[]; + + /** ClientState allowUpdateAfterExpiry. */ + public allowUpdateAfterExpiry: boolean; + + /** ClientState allowUpdateAfterMisbehaviour. */ + public allowUpdateAfterMisbehaviour: boolean; + + /** + * Constructor to create a new IBC.ClientState + * @param {ClientStateOptions} options + * @returns {ClientState} + * @throws {Error} when options is invalid + */ + constructor(options: ClientStateOptions) { + ow(options, 'options', owClientStateOptions); + + this.chainId = options.chainId; + this.trustLevel = options.trustLevel; + this.trustingPeriod = options.trustingPeriod; + this.unbondingPeriod = options.unbondingPeriod; + this.maxClockDrift = options.maxClockDrift; + this.frozenHeight = options.frozenHeight; + this.latestHeight = options.latestHeight; + this.proofSpecs = options.proofSpecs; + this.upgradePath = options.upgradePath; + this.allowUpdateAfterExpiry = options.allowUpdateAfterExpiry; + this.allowUpdateAfterMisbehaviour = options.allowUpdateAfterMisbehaviour; + } + + getEncoded(): google.protobuf.Any { + const clientStateOptions = { + chainId: this.chainId, + trustLevel: this.trustLevel, + trustingPeriod: this.trustingPeriod, + unbondingPeriod: this.unbondingPeriod, + maxClockDrift: this.maxClockDrift, + frozenHeight: this.frozenHeight, + latestHeight: this.latestHeight, + proofSpecs: this.proofSpecs, + upgradePath: this.upgradePath, + allowUpdateAfterExpiry: this.allowUpdateAfterExpiry, + allowUpdateAfterMisbehaviour: this.allowUpdateAfterMisbehaviour, + }; + + const clientStateWrapped = ibc.lightclients.tendermint.v1.ClientState.create(clientStateOptions); + return google.protobuf.Any.create({ + type_url: COSMOS_MSG_TYPEURL.ibc.LightClients.ClientState, + value: ibc.lightclients.tendermint.v1.ClientState.encode(clientStateWrapped).finish(), + }); + } + + /** + * Returns the raw Msg representation of Ibc.ClientState + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.ClientState, + value: { + chainId: this.chainId, + trustLevel: this.trustLevel, + trustingPeriod: this.trustingPeriod, + unbondingPeriod: this.unbondingPeriod, + maxClockDrift: this.maxClockDrift, + frozenHeight: this.frozenHeight, + latestHeight: this.latestHeight, + proofSpecs: this.proofSpecs, + upgradePath: this.upgradePath, + allowUpdateAfterExpiry: this.allowUpdateAfterExpiry, + allowUpdateAfterMisbehaviour: this.allowUpdateAfterMisbehaviour, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.ClientState + * @param {string} msgJsonStr + * @param {Network} network + * @returns {ClientState} + */ + public static fromCosmosMsgJSON(_msgJsonStr: string): ClientState { + throw new Error('IBC Module does not support JSON decoding.'); + } + }; +}; + +export type ClientStateOptions = { + chainId: string; + trustLevel?: IFraction; + trustingPeriod?: IDuration; + unbondingPeriod?: IDuration; + maxClockDrift?: IDuration; + frozenHeight?: IHeight; + latestHeight?: IHeight; + proofSpecs: ics23.ProofSpec[]; + upgradePath: string[]; + allowUpdateAfterExpiry: boolean; + allowUpdateAfterMisbehaviour: boolean; +}; + +export interface IFraction { + numerator: Long; + denominator: Long; +} + +export interface IDuration { + seconds: Long; + nanos: number; +} + +export interface IHeight { + revisionNumber: Long; + revisionHeight: Long; +} diff --git a/lib/src/transaction/msg/ibc/lightclients/ConsensusState.spec.ts b/lib/src/transaction/msg/ibc/lightclients/ConsensusState.spec.ts new file mode 100644 index 00000000..1d73f5c6 --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/ConsensusState.spec.ts @@ -0,0 +1,119 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { CroSDK } from '../../../../core/cro'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing IBCConsensusState', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = [ + { + timestamp: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + root: { + hash: Uint8Array.from([1, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]), + }, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }, + ]; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.lightclient.ConsensusState(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test ConsensusState conversion', function () { + const ConsensusState = new cro.ibc.lightclient.ConsensusState({ + timestamp: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + root: { + hash: Uint8Array.from([1, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]), + }, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }); + + const rawMsg = { + typeUrl: '/ibc.lightclients.tendermint.v1.ConsensusState', + value: { + timestamp: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + root: { + hash: Uint8Array.from([1, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]), + }, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }, + }; + + expect(ConsensusState.toRawMsg()).to.deep.equal(rawMsg); + }); + + it('Test ConsensusState `getEncoded`', function () { + const params = { + timestamp: { + seconds: Long.fromString('100'), + nanos: 100000, + }, + root: { + hash: Uint8Array.from([1, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]), + }, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }; + + const ConsensusState = new cro.ibc.lightclient.ConsensusState(params); + + expect(ConsensusState.getEncoded().value).instanceOf(Uint8Array); + expect(ConsensusState.getEncoded().type_url).to.equal('/ibc.lightclients.tendermint.v1.ConsensusState'); + }); + + context('should throw on unsupported functionalities', function () { + it('should throw on calling .toRawAminoMsg', function () { + const params = { + timestamp: null, + root: null, + nextValidatorsHash: Uint8Array.from([1, 2, 3]), + }; + + expect(() => new cro.ibc.lightclient.ConsensusState(params).toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + it('should throw on calling .fromCosmosMsgJSON', function () { + expect(() => cro.ibc.lightclient.ConsensusState.fromCosmosMsgJSON('json')).to.throw( + 'IBC Module does not support JSON decoding.', + ); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/lightclients/ConsensusState.ts b/lib/src/transaction/msg/ibc/lightclients/ConsensusState.ts new file mode 100644 index 00000000..085762a6 --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/ConsensusState.ts @@ -0,0 +1,94 @@ +import ow from 'ow'; +import Long from 'long'; +import { ibc, google } from '../../../../cosmos/v1beta1/codec/generated/codecimpl'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { IGoogleAny } from '../IGoogleAny'; +import { owConsensusStateOptions } from '../../ow.types'; + +export const msgConsensusState = function () { + return class ConsensusState implements IGoogleAny, ibc.lightclients.tendermint.v1.ConsensusState { + /** ConsensusState timestamp. */ + public timestamp?: IDuration | null; + + /** ConsensusState root. */ + public root?: IMerkleRoot | null; + + /** ConsensusState nextValidatorsHash. */ + public nextValidatorsHash: Uint8Array; + + /** + * Constructor to create a new IBC.ConsensusState + * @param {ConsensusStateOptions} options + * @returns {ConsensusState} + * @throws {Error} when options is invalid + */ + constructor(options: ConsensusStateOptions) { + ow(options, 'options', owConsensusStateOptions); + + this.timestamp = options.timestamp; + this.root = options.root; + this.nextValidatorsHash = options.nextValidatorsHash; + } + + getEncoded(): google.protobuf.Any { + const ConsensusStateOptions = { + timestamp: this.timestamp, + root: this.root, + nextValidatorsHash: this.nextValidatorsHash, + }; + + const ConsensusStateWrapped = ibc.lightclients.tendermint.v1.ConsensusState.create(ConsensusStateOptions); + return google.protobuf.Any.create({ + type_url: COSMOS_MSG_TYPEURL.ibc.LightClients.ConsensusState, + value: ibc.lightclients.tendermint.v1.ConsensusState.encode(ConsensusStateWrapped).finish(), + }); + } + + /** + * Returns the raw Msg representation of Ibc.ConsensusState + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.ConsensusState, + value: { + timestamp: this.timestamp, + root: this.root, + nextValidatorsHash: this.nextValidatorsHash, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.ConsensusState + * @param {string} msgJsonStr + * @param {Network} network + * @returns {ConsensusState} + */ + public static fromCosmosMsgJSON(_msgJsonStr: string): ConsensusState { + throw new Error('IBC Module does not support JSON decoding.'); + } + }; +}; + +export type ConsensusStateOptions = { + timestamp?: IDuration | null; + root?: IMerkleRoot | null; + nextValidatorsHash: Uint8Array; +}; + +export interface IDuration { + seconds: Long; + nanos: number; +} + +export interface IMerkleRoot { + hash: Uint8Array | null; +} diff --git a/lib/src/transaction/msg/ibc/lightclients/Header.spec.ts b/lib/src/transaction/msg/ibc/lightclients/Header.spec.ts new file mode 100644 index 00000000..55ef966b --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/Header.spec.ts @@ -0,0 +1,797 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Long from 'long'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { CroSDK } from '../../../../core/cro'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { tendermintV2 } from '../../../../cosmos/v1beta1/codec'; +import { Bytes } from '../../../../utils/bytes/bytes'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing IBC.lightclient.Header', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: null, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.ibc.lightclient.Header(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test Header conversion', function () { + const Header = new cro.ibc.lightclient.Header({ + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }); + + const rawMsg = { + typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.Header, + value: { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String( + 'EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=', + ).toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String( + 'SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=', + ).toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }, + }; + + expect(Header.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test Header `getEncoded`', function () { + const params = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + const Header = new cro.ibc.lightclient.Header(params); + + expect(Header.getEncoded().value).instanceOf(Uint8Array); + expect(Header.getEncoded().type_url).to.equal('/ibc.lightclients.tendermint.v1.Header'); + }); + + it('should throw on invalid values', function () { + const params = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=').toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String('SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=').toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: 4, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String('W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=').toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + + expect(() => new cro.ibc.lightclient.Header(params)).to.throw( + "(array `signatures`) Expected property property property property number `blockIdFlag` to be one of enum 'tendermintV2.types.BlockIDFlag', got `4` in object `t` in object `commit` in object `signedHeader` in object `options`", + ); + }); + + context('should throw on unsupported functionalities', function () { + it('should throw on calling .toRawAminoMsg', function () { + const params = { + signedHeader: { + header: { + version: { + block: Long.fromString('11'), + app: Long.fromString('0'), + }, + chainId: 'cosmoshub-4', + height: Long.fromString('5624169'), + time: { + nanos: 1000, + seconds: Long.fromString('10000'), + }, + lastBlockId: { + hash: Bytes.fromBase64String('oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String( + 'EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=', + ).toUint8Array(), + }, + }, + lastCommitHash: Bytes.fromBase64String( + 'qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=', + ).toUint8Array(), + dataHash: Bytes.fromBase64String('47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=').toUint8Array(), + validatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + nextValidatorsHash: Bytes.fromBase64String( + 'PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=', + ).toUint8Array(), + consensusHash: Bytes.fromBase64String( + 'DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=', + ).toUint8Array(), + appHash: Bytes.fromBase64String('a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=').toUint8Array(), + lastResultsHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + evidenceHash: Bytes.fromBase64String( + '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=', + ).toUint8Array(), + proposerAddress: Bytes.fromBase64String('zIf1a1hiGBHitaR/OMYWbilc424=').toUint8Array(), + }, + commit: { + height: Long.fromString('5624169'), + round: 0, + blockId: { + hash: Bytes.fromBase64String('oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=').toUint8Array(), + partSetHeader: { + total: 1, + hash: Bytes.fromBase64String( + 'SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=', + ).toUint8Array(), + }, + }, + signatures: [ + { + blockIdFlag: tendermintV2.types.BlockIDFlag.BLOCK_ID_FLAG_COMMIT, + validatorAddress: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + timestamp: { + nanos: 10000, + seconds: Long.fromString('10000'), + }, + signature: Bytes.fromBase64String( + 'IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==', + ).toUint8Array(), + }, + ], + }, + }, + validatorSet: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + trustedHeight: { + revisionNumber: Long.fromString('4'), + revisionHeight: Long.fromString('5624044'), + }, + trustedValidators: { + validators: [ + { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + ], + proposer: { + address: Bytes.fromBase64String('g/R9d0ew9jOmug30m33PYfkKobA=').toUint8Array(), + pubKey: { + ed25519: Bytes.fromBase64String( + 'W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=', + ).toUint8Array(), + }, + votingPower: Long.fromString('13595989'), + proposerPriority: Long.fromString('-178446727'), + }, + totalVotingPower: Long.fromString('192042716'), + }, + }; + + expect(() => new cro.ibc.lightclient.Header(params).toRawAminoMsg()).to.throw( + 'IBC Module not supported under amino encoding scheme', + ); + }); + it('should throw on calling .fromCosmosMsgJSON', function () { + expect(() => cro.ibc.lightclient.Header.fromCosmosMsgJSON('json')).to.throw( + 'IBC Module does not support JSON decoding.', + ); + }); + }); +}); diff --git a/lib/src/transaction/msg/ibc/lightclients/Header.ts b/lib/src/transaction/msg/ibc/lightclients/Header.ts new file mode 100644 index 00000000..6deb27e7 --- /dev/null +++ b/lib/src/transaction/msg/ibc/lightclients/Header.ts @@ -0,0 +1,96 @@ +import ow from 'ow'; +import Long from 'long'; +import { ibc, google, tendermintV2 } from '../../../../cosmos/v1beta1/codec/generated/codecimpl'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { IGoogleAny } from '../IGoogleAny'; +import { owHeaderOptions } from '../../ow.types'; + +export const msgHeader = function () { + return class Header implements IGoogleAny, ibc.lightclients.tendermint.v1.IHeader { + /** Header signedHeader. */ + public signedHeader?: tendermintV2.types.ISignedHeader | null; + + /** Header validatorSet. */ + public validatorSet?: tendermintV2.types.IValidatorSet | null; + + /** Header trustedHeight. */ + public trustedHeight?: IHeight | null; + + /** Header trustedValidators. */ + public trustedValidators?: tendermintV2.types.IValidatorSet | null; + + /** + * Constructor to create a new IBC.Header + * @param {HeaderOptions} options + * @returns {Header} + * @throws {Error} when options is invalid + */ + constructor(options: HeaderOptions) { + ow(options, 'options', owHeaderOptions); + this.signedHeader = options.signedHeader; + this.validatorSet = options.validatorSet; + this.trustedHeight = options.trustedHeight; + this.trustedValidators = options.trustedValidators; + } + + getEncoded(): google.protobuf.Any { + const HeaderOptions = { + signedHeader: this.signedHeader, + validatorSet: this.validatorSet, + trustedHeight: this.trustedHeight, + trustedValidators: this.trustedValidators, + }; + + const HeaderWrapped = ibc.lightclients.tendermint.v1.Header.create(HeaderOptions); + return google.protobuf.Any.create({ + type_url: COSMOS_MSG_TYPEURL.ibc.LightClients.Header, + value: ibc.lightclients.tendermint.v1.Header.encode(HeaderWrapped).finish(), + }); + } + + /** + * Returns the raw Msg representation of Ibc.Header + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.ibc.LightClients.Header, + value: { + signedHeader: this.signedHeader, + validatorSet: this.validatorSet, + trustedHeight: this.trustedHeight, + trustedValidators: this.trustedValidators, + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('IBC Module not supported under amino encoding scheme'); + } + + /** + * Returns an instance of IBC.Header + * @param {string} msgJsonStr + * @param {Network} network + * @returns {Header} + */ + public static fromCosmosMsgJSON(_msgJsonStr: string): Header { + throw new Error('IBC Module does not support JSON decoding.'); + } + }; +}; + +export type HeaderOptions = { + signedHeader?: tendermintV2.types.ISignedHeader | null; + validatorSet?: tendermintV2.types.IValidatorSet | null; + trustedHeight?: IHeight | null; + trustedValidators?: tendermintV2.types.IValidatorSet | null; +}; + +export interface IHeight { + revisionNumber: Long; + revisionHeight: Long; +} diff --git a/lib/src/transaction/msg/nft/MsgBurnNFT.spec.ts b/lib/src/transaction/msg/nft/MsgBurnNFT.spec.ts index 7cf8c710..3c85834c 100644 --- a/lib/src/transaction/msg/nft/MsgBurnNFT.spec.ts +++ b/lib/src/transaction/msg/nft/MsgBurnNFT.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import 'mocha'; import { expect } from 'chai'; import Big from 'big.js'; @@ -231,4 +232,44 @@ describe('Testing MsgBurnNFT', function () { expect(() => new cro.nft.MsgBurnNFT(params1)).to.throw('Provided `sender` does not match network selected'); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgBurnNFT', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.nft.MsgBurnNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected /chainmain.nft.v1.MsgBurnNFT but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgBurnNFT","denom_id":"nft123","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgBurnNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `id` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `denom_id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgBurnNFT","id":"alphanumericid123","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgBurnNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `denomId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + + it('should throw Error when the `sender` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgBurnNFT","id":"alphanumericid123","denom_id":"nft123","recipient":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgBurnNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sender` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgBurnNFT corresponding to the JSON', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgBurnNFT","id":"alphanumericid123","denom_id":"nft123", "sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + const MsgBurnNFT = cro.nft.MsgBurnNFT.fromCosmosMsgJSON(json); + expect(MsgBurnNFT.id).to.eql('alphanumericid123'); + expect(MsgBurnNFT.denomId.toString()).to.eql('nft123'); + expect(MsgBurnNFT.sender.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/nft/MsgBurnNFT.ts b/lib/src/transaction/msg/nft/MsgBurnNFT.ts index dd2d235f..9dd53127 100644 --- a/lib/src/transaction/msg/nft/MsgBurnNFT.ts +++ b/lib/src/transaction/msg/nft/MsgBurnNFT.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { owMsgBurnNFTOptions } from '../ow.types'; @@ -61,6 +62,25 @@ export const msgBurnNFT = function (config: InitConfigurations) { } as legacyAmino.MsgBurnNFT; } + /** + * Returns an instance of MsgBurnNFT + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgBurnNFT} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgBurnNFT { + const parsedMsg = JSON.parse(msgJsonStr) as MsgBurnNFTRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.nft.MsgBurnNFT) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.nft.MsgBurnNFT} but got ${parsedMsg['@type']}`); + } + + return new MsgBurnNFT({ + id: parsedMsg.id, + sender: parsedMsg.sender, + denomId: parsedMsg.denom_id, + }); + } + validateAddress() { if ( !validateAddress({ @@ -80,3 +100,9 @@ export type MsgBurnNFTOptions = { denomId: string; sender: string; }; +export type MsgBurnNFTRaw = { + '@type': string; + id: string; + denom_id: string; + sender: string; +}; diff --git a/lib/src/transaction/msg/nft/MsgEditNFT.spec.ts b/lib/src/transaction/msg/nft/MsgEditNFT.spec.ts index d22cd827..7306769d 100644 --- a/lib/src/transaction/msg/nft/MsgEditNFT.spec.ts +++ b/lib/src/transaction/msg/nft/MsgEditNFT.spec.ts @@ -254,19 +254,18 @@ describe('Testing MsgEditNFT', function () { expect(MsgEditNFT.toRawMsg()).to.eqls(rawMsg); }); - it('Test MsgMintNFT conversion Json', function () { - const msgMintNFT = new cro.nft.MsgMintNFT({ + it('Test MsgEditNFT conversion Json', function () { + const MsgEditNFT = new cro.nft.MsgEditNFT({ id: 'alphanumericid1234', name: 'nft_name', sender: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', denomId: 'basetcro', uri: 'https://someuri', data: 'some_data_nft', - recipient: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', }); const rawMsg: legacyAmino.Msg = { - type: 'chainmain/nft/MsgMintNFT', + type: 'chainmain/nft/MsgEditNFT', value: { id: 'alphanumericid1234', name: 'nft_name', @@ -274,11 +273,10 @@ describe('Testing MsgEditNFT', function () { denom_id: 'basetcro', uri: 'https://someuri', data: 'some_data_nft', - recipient: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', }, }; - expect(msgMintNFT.toRawAminoMsg()).to.eqls(rawMsg); + expect(MsgEditNFT.toRawAminoMsg()).to.eqls(rawMsg); }); it('Test appendTxBody MsgEditNFT Tx signing', function () { @@ -325,4 +323,69 @@ describe('Testing MsgEditNFT', function () { expect(() => new cro.nft.MsgEditNFT(params1)).to.throw('Provided `sender` does not match network selected'); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgEditNFT', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected /chainmain.nft.v1.MsgEditNFT but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `id` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `name` or `denom_id` field is missing', function () { + // name missing + const json = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","denom_id":"basetcro","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `name` to be of type `string` but received type `undefined` in object `options`', + ); + + // denom_id missing + const json1 = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json1)).to.throw( + 'Expected property `denomId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `data` or `uri` field is missing', function () { + // data missing + const json = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `data` to be of type `string` but received type `undefined` in object `options`', + ); + + // uri missing + const json1 = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json1)).to.throw( + 'Expected property `uri` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `sender` or `recipient` field is missing', function () { + // sender missing + const json = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft"}'; + expect(() => cro.nft.MsgEditNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sender` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgEditNFT corresponding to the JSON', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgEditNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + const MsgEditNFT = cro.nft.MsgEditNFT.fromCosmosMsgJSON(json); + expect(MsgEditNFT.id).to.eql('alphanumericid1234'); + expect(MsgEditNFT.denomId).to.eql('basetcro'); + expect(MsgEditNFT.name.toString()).to.eql('nft_name'); + expect(MsgEditNFT.uri.toString()).to.eql('https://someuri'); + expect(MsgEditNFT.sender.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/nft/MsgEditNFT.ts b/lib/src/transaction/msg/nft/MsgEditNFT.ts index bfd57288..158b7b20 100644 --- a/lib/src/transaction/msg/nft/MsgEditNFT.ts +++ b/lib/src/transaction/msg/nft/MsgEditNFT.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { owMsgEditNFTOptions } from '../ow.types'; @@ -79,6 +80,28 @@ export const msgEditNFT = function (config: InitConfigurations) { } as legacyAmino.MsgEditNFT; } + /** + * Returns an instance of MsgEditNFT + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgEditNFT} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgEditNFT { + const parsedMsg = JSON.parse(msgJsonStr) as MsgEditNFTRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.nft.MsgEditNFT) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.nft.MsgEditNFT} but got ${parsedMsg['@type']}`); + } + + return new MsgEditNFT({ + id: parsedMsg.id, + name: parsedMsg.name, + sender: parsedMsg.sender, + denomId: parsedMsg.denom_id, + uri: parsedMsg.uri, + data: parsedMsg.data, + }); + } + validateAddresses() { if ( !validateAddress({ @@ -101,3 +124,12 @@ export type MsgEditNFTOptions = { data: string; sender: string; }; +export interface MsgEditNFTRaw { + '@type': string; + id: string; + denom_id: string; + name: string; + uri: string; + data: string; + sender: string; +} diff --git a/lib/src/transaction/msg/nft/MsgIssueDenom.spec.ts b/lib/src/transaction/msg/nft/MsgIssueDenom.spec.ts index 63145772..adea248e 100644 --- a/lib/src/transaction/msg/nft/MsgIssueDenom.spec.ts +++ b/lib/src/transaction/msg/nft/MsgIssueDenom.spec.ts @@ -206,4 +206,50 @@ describe('Testing MsgIssueDenom', function () { expect(() => new cro.nft.MsgIssueDenom(params1)).to.throw('Provided `sender` does not match network selected'); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgIssueDenom', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json)).to.throw( + 'Expected /chainmain.nft.v1.MsgIssueDenom but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgIssueDenom","name":"nft_name","schema":"schema","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `id` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `name` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgIssueDenom","id":"alphanumericid123","schema":"schema","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `name` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `schema` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgIssueDenom","id":"alphanumericid123","name":"nft_name","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `schema` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `sender` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgIssueDenom","id":"alphanumericid123","name":"nft_name","schema":"schema"}'; + expect(() => cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sender` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgIssueDenom corresponding to the JSON', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgIssueDenom","id":"alphanumericid123","name":"nft_name","schema":"schema","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + const MsgIssueDenom = cro.nft.MsgIssueDenom.fromCosmosMsgJSON(json); + expect(MsgIssueDenom.id).to.eql('alphanumericid123'); + expect(MsgIssueDenom.name.toString()).to.eql('nft_name'); + expect(MsgIssueDenom.schema.toString()).to.eql('schema'); + expect(MsgIssueDenom.sender.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/nft/MsgIssueDenom.ts b/lib/src/transaction/msg/nft/MsgIssueDenom.ts index 95c00414..e2340719 100644 --- a/lib/src/transaction/msg/nft/MsgIssueDenom.ts +++ b/lib/src/transaction/msg/nft/MsgIssueDenom.ts @@ -67,6 +67,26 @@ export const msgIssueDenomNFT = function (config: InitConfigurations) { } as legacyAmino.MsgIssueDenom; } + /** + * Returns an instance of MsgIssueDenom + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgIssueDenom} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgIssueDenom { + const parsedMsg = JSON.parse(msgJsonStr) as MsgIssueDenomRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.nft.MsgIssueDenom) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.nft.MsgIssueDenom} but got ${parsedMsg['@type']}`); + } + + return new MsgIssueDenom({ + id: parsedMsg.id, + name: parsedMsg.name, + schema: parsedMsg.schema, + sender: parsedMsg.sender, + }); + } + validateAddress() { if ( !validateAddress({ @@ -87,3 +107,10 @@ export type MsgIssueDenomOptions = { schema: string; sender: string; }; +interface MsgIssueDenomRaw { + '@type': string; + id: string; + name: string; + schema: string; + sender: string; +} diff --git a/lib/src/transaction/msg/nft/MsgMintNFT.spec.ts b/lib/src/transaction/msg/nft/MsgMintNFT.spec.ts index 4caf4006..0346706c 100644 --- a/lib/src/transaction/msg/nft/MsgMintNFT.spec.ts +++ b/lib/src/transaction/msg/nft/MsgMintNFT.spec.ts @@ -356,4 +356,76 @@ describe('Testing MsgMintNFT', function () { expect(() => new cro.nft.MsgMintNFT(params2)).to.throw('Provided `recipient` does not match network selected'); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgMintNFT', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected /chainmain.nft.v1.MsgMintNFT but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `id` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `name` or `denom_id` field is missing', function () { + // name missing + const json = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `name` to be of type `string` but received type `undefined` in object `options`', + ); + + // denom_id missing + const json1 = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json1)).to.throw( + 'Expected property `denomId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `data` or `uri` field is missing', function () { + // data missing + const json = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `data` to be of type `string` but received type `undefined` in object `options`', + ); + + // uri missing + const json1 = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json1)).to.throw( + 'Expected property `uri` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `sender` or `recipient` field is missing', function () { + // sender missing + const json = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sender` to be of type `string` but received type `undefined` in object `options`', + ); + + // recipient missing + const json1 = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgMintNFT.fromCosmosMsgJSON(json1)).to.throw( + 'Expected property `recipient` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgMintNFT corresponding to the JSON', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgMintNFT","id":"alphanumericid1234","denom_id":"basetcro","name":"nft_name","uri":"https://someuri","data":"some_data_nft","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","recipient":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q"}'; + const MsgMintNFT = cro.nft.MsgMintNFT.fromCosmosMsgJSON(json); + expect(MsgMintNFT.id).to.eql('alphanumericid1234'); + expect(MsgMintNFT.denomId).to.eql('basetcro'); + expect(MsgMintNFT.name.toString()).to.eql('nft_name'); + expect(MsgMintNFT.uri.toString()).to.eql('https://someuri'); + expect(MsgMintNFT.sender.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(MsgMintNFT.recipient.toString()).to.eql('tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q'); + }); + }); }); diff --git a/lib/src/transaction/msg/nft/MsgMintNFT.ts b/lib/src/transaction/msg/nft/MsgMintNFT.ts index 532ef69d..bf0d9c03 100644 --- a/lib/src/transaction/msg/nft/MsgMintNFT.ts +++ b/lib/src/transaction/msg/nft/MsgMintNFT.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { owMsgMintNFTOptions } from '../ow.types'; @@ -84,6 +85,29 @@ export const msgMintNFT = function (config: InitConfigurations) { } as legacyAmino.MsgMintNFT; } + /** + * Returns an instance of MsgMintNFT + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgMintNFT} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgMintNFT { + const parsedMsg = JSON.parse(msgJsonStr) as MsgMintNFTRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.nft.MsgMintNFT) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.nft.MsgMintNFT} but got ${parsedMsg['@type']}`); + } + + return new MsgMintNFT({ + id: parsedMsg.id, + name: parsedMsg.name, + sender: parsedMsg.sender, + denomId: parsedMsg.denom_id, + recipient: parsedMsg.recipient, + uri: parsedMsg.uri, + data: parsedMsg.data, + }); + } + validateAddresses() { if ( !validateAddress({ @@ -117,3 +141,13 @@ export type MsgMintNFTOptions = { sender: string; recipient: string; }; +export interface MsgMintNFTRaw { + '@type': string; + id: string; + denom_id: string; + name: string; + uri: string; + data: string; + sender: string; + recipient: string; +} diff --git a/lib/src/transaction/msg/nft/MsgTransferNFT.spec.ts b/lib/src/transaction/msg/nft/MsgTransferNFT.spec.ts index 6d3d9859..56eeda04 100644 --- a/lib/src/transaction/msg/nft/MsgTransferNFT.spec.ts +++ b/lib/src/transaction/msg/nft/MsgTransferNFT.spec.ts @@ -263,4 +263,50 @@ describe('Testing MsgTransferNFT', function () { 'Provided `recipient` does not match network selected', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgTransferNFT', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected /chainmain.nft.v1.MsgTransferNFT but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgTransferNFT","denom_id":"nft123","recipient":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `id` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `denom_id` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgTransferNFT","id":"alphanumericid123","recipient":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `denomId` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `recipient` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgTransferNFT","id":"alphanumericid123","denom_id":"nft123","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `recipient` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `sender` field is missing', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgTransferNFT","id":"alphanumericid123","denom_id":"nft123","recipient":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `sender` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should return the MsgTransferNFT corresponding to the JSON', function () { + const json = + '{"@type":"/chainmain.nft.v1.MsgTransferNFT","id":"alphanumericid123","denom_id":"nft123","recipient":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","sender":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + const MsgTransferNFT = cro.nft.MsgTransferNFT.fromCosmosMsgJSON(json); + expect(MsgTransferNFT.id).to.eql('alphanumericid123'); + expect(MsgTransferNFT.denomId.toString()).to.eql('nft123'); + expect(MsgTransferNFT.recipient.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(MsgTransferNFT.sender.toString()).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + }); + }); }); diff --git a/lib/src/transaction/msg/nft/MsgTransferNFT.ts b/lib/src/transaction/msg/nft/MsgTransferNFT.ts index 09ed7c26..9c364ff9 100644 --- a/lib/src/transaction/msg/nft/MsgTransferNFT.ts +++ b/lib/src/transaction/msg/nft/MsgTransferNFT.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { owMsgTransferNFTOptions } from '../ow.types'; @@ -67,6 +68,26 @@ export const msgTransferNFT = function (config: InitConfigurations) { } as legacyAmino.MsgTransferNFT; } + /** + * Returns an instance of MsgTransferNFT + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgTransferNFT} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgTransferNFT { + const parsedMsg = JSON.parse(msgJsonStr) as MsgTransferNFTRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.nft.MsgTransferNFT) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.nft.MsgTransferNFT} but got ${parsedMsg['@type']}`); + } + + return new MsgTransferNFT({ + id: parsedMsg.id, + sender: parsedMsg.sender, + denomId: parsedMsg.denom_id, + recipient: parsedMsg.recipient, + }); + } + validateAddresses() { if ( !validateAddress({ @@ -97,3 +118,10 @@ export type MsgTransferNFTOptions = { sender: string; recipient: string; }; +export type MsgTransferNFTRaw = { + '@type': string; + id: string; + denom_id: string; + sender: string; + recipient: string; +}; diff --git a/lib/src/transaction/msg/ow.types.ts b/lib/src/transaction/msg/ow.types.ts index 71ae8404..07338d42 100644 --- a/lib/src/transaction/msg/ow.types.ts +++ b/lib/src/transaction/msg/ow.types.ts @@ -1,14 +1,23 @@ import ow from 'ow'; -import { owCoin } from '../../coin/ow.types'; -import { owBig, owStrictObject } from '../../ow.types'; +import { owCoin, owOptionalCoin } from '../../coin/ow.types'; +import { owBig, owStrictObject, owOptionalStrictObject } from '../../ow.types'; import { VoteOption } from './gov/MsgVote'; import { isMsgProposalContent } from './gov/IMsgProposalContent'; +import { owLong, owOptionalTimestamp } from './gov/ow.types'; +import { ics23, tendermintV2 } from '../../cosmos/v1beta1/codec'; const voteOptionValidator = (val: number) => ({ validator: Object.values(VoteOption).includes(val as any), message: (label: string) => `Expected ${label} to be one of the Vote options, got \`${val}\``, }); +const proposalContentValidatorFn = (val: object) => ({ + validator: isMsgProposalContent(val), + message: (label: string) => `Expected ${label} to be an instance of \`IMsgProposalContent\`, got \`${val}\``, +}); + +const owContent = () => owStrictObject().validate(proposalContentValidatorFn); + export const owVoteOption = () => ow.number.validate(voteOptionValidator); export const owMsgSendOptions = owStrictObject().exactShape({ @@ -16,13 +25,33 @@ export const owMsgSendOptions = owStrictObject().exactShape({ toAddress: ow.string, amount: owCoin(), }); - -const proposalContentValidatorFn = (val: object) => ({ - validator: isMsgProposalContent(val), - message: (label: string) => `Expected ${label} to be an instance of \`IMsgProposalContent\`, got \`${val}\``, -}); - -const owContent = () => owStrictObject().validate(proposalContentValidatorFn); +export const v2 = { + owMsgSendOptions: owStrictObject().exactShape({ + fromAddress: ow.string, + toAddress: ow.string, + amount: ow.array.ofType(owCoin()), + }), + owMsgFundCommunityPoolOptions: owStrictObject().exactShape({ + depositor: ow.string, + amount: ow.array.ofType(owCoin()), + }), + owMsgDepositOptions: owStrictObject().exactShape({ + depositor: ow.string, + proposalId: owBig(), + amount: ow.array.ofType(owCoin()), + }), + owCommunityPoolSpendProposalOptions: owStrictObject().exactShape({ + title: ow.string, + description: ow.string, + recipient: ow.string, + amount: ow.array.ofType(owCoin()), + }), + owMsgSubmitProposalOptions: owStrictObject().exactShape({ + proposer: ow.string, + initialDeposit: ow.array.ofType(owCoin()), + content: owContent(), + }), +}; export const owMsgSubmitProposalOptions = owStrictObject().exactShape({ proposer: ow.string, @@ -178,3 +207,234 @@ export const owMsgBurnNFTOptions = owStrictObject().exactShape({ denomId: owNFTId, sender: ow.string, }); + +/** + * IBC ow types + */ + +const owIBCHeightOptional = () => + owOptionalStrictObject().exactShape({ + revisionHeight: owLong(), + revisionNumber: owLong(), + }); + +const owGoogleProtoAnyOptional = () => + owOptionalStrictObject().exactShape({ + type_url: ow.optional.string, + value: ow.optional.uint8Array, + }); + +export const owMsgTransferIBCOptions = owStrictObject().exactShape({ + sourcePort: ow.string, + sourceChannel: ow.string, + token: owOptionalCoin(), + sender: ow.string, + receiver: ow.string, + timeoutHeight: owIBCHeightOptional(), + timeoutTimestamp: owLong(), +}); + +export const owMsgUpgradeClientOptions = owStrictObject().exactShape({ + clientId: ow.string, + clientState: ow.optional.any(owGoogleProtoAnyOptional(), ow.optional.null), + consensusState: ow.optional.any(owGoogleProtoAnyOptional(), ow.optional.null), + proofUpgradeClient: ow.uint8Array, + proofUpgradeConsensusState: ow.uint8Array, + signer: ow.string, +}); +export const owMsgSubmitMisbehaviourOptions = owStrictObject().exactShape({ + clientId: ow.string, + misbehaviour: ow.optional.any(owGoogleProtoAnyOptional(), ow.optional.null), + signer: ow.string, +}); + +export const owOptionalFraction = owOptionalStrictObject().exactShape({ + numerator: owLong(), + denominator: owLong(), +}); + +export const owHashOp = ow.number.validate((val) => ({ + validator: Object.values(ics23.HashOp).includes(val as any), + message: (label) => `Expected ${label} to be one of enum ics23.HashOp, got \`${val}\``, +})); + +export const owLengthOp = ow.number.validate((val) => ({ + validator: Object.values(ics23.LengthOp).includes(val as any), + message: (label) => `Expected ${label} to be one of enum ics23.LengthOp, got \`${val}\``, +})); + +export const owOptionalLeafSpec = owOptionalStrictObject().exactShape({ + hash: owHashOp, + prehashKey: owHashOp, + prehashValue: owHashOp, + length: owLengthOp, + prefix: ow.uint8Array, +}); +export const owOptionalInnerSpec = owOptionalStrictObject().exactShape({ + childOrder: ow.array.ofType(ow.number), + childSize: ow.number, + minPrefixLength: ow.number, + maxPrefixLength: ow.number, + emptyChild: ow.uint8Array, + hash: owHashOp, +}); + +export const owOptionalProofSpec = owOptionalStrictObject().exactShape({ + leafSpec: owOptionalLeafSpec, + innerSpec: owOptionalInnerSpec, + maxDepth: ow.number, + minDepth: ow.number, +}); + +export const owOptionalMerkleRoot = owOptionalStrictObject().exactShape({ + hash: ow.any(ow.uint8Array, ow.null), +}); + +export const owClientStateOptions = owStrictObject().exactShape({ + chainId: ow.string, + trustLevel: owOptionalFraction, + trustingPeriod: owOptionalTimestamp(), + unbondingPeriod: owOptionalTimestamp(), + maxClockDrift: owOptionalTimestamp(), + frozenHeight: owIBCHeightOptional(), + latestHeight: owIBCHeightOptional(), + proofSpecs: ow.array.ofType(owOptionalProofSpec), + upgradePath: ow.array.ofType(ow.string), + allowUpdateAfterExpiry: ow.boolean, + allowUpdateAfterMisbehaviour: ow.boolean, +}); + +export const owConsensusStateOptions = owStrictObject().exactShape({ + timestamp: ow.any(owOptionalTimestamp(), ow.null), + root: ow.any(owOptionalMerkleRoot, ow.null), + nextValidatorsHash: ow.uint8Array, +}); + +export const owMsgCreateClientOptions = owStrictObject().exactShape({ + signer: ow.string, + clientState: ow.optional.any(owClientStateOptions, ow.null), + consensusState: ow.optional.any(owConsensusStateOptions, ow.null), +}); + +export const owOptionalPublicKey = owOptionalStrictObject().exactShape({ + ed25519: ow.optional.uint8Array, + secp256k1: ow.optional.uint8Array, + sum: ow.optional.string, +}); +export const owOptionalTendermintValidator = owOptionalStrictObject().exactShape({ + address: ow.uint8Array, + pubKey: ow.optional.any(owOptionalPublicKey, ow.null), + votingPower: owLong(), + proposerPriority: owLong(), +}); +export const owOptionalLightClientValidatorSet = owOptionalStrictObject().exactShape({ + validators: ow.array.ofType(owOptionalTendermintValidator), + proposer: ow.optional.any(owOptionalTendermintValidator, ow.null), + totalVotingPower: owLong(), +}); + +export const owOptionalTendermintTypesPartSetHeader = owOptionalStrictObject().exactShape({ + total: ow.number, + hash: ow.uint8Array, +}); + +export const owOptionalTendermintBlockID = owOptionalStrictObject().exactShape({ + hash: ow.uint8Array, + partSetHeader: ow.optional.any(owOptionalTendermintTypesPartSetHeader, ow.null), +}); +export const owOptionalTendermintConsensus = owOptionalStrictObject().exactShape({ + block: owLong(), + app: owLong(), +}); +export const validateBlockIDFlag = (val: number) => ({ + validator: Object.values(tendermintV2.types.BlockIDFlag).includes(val as any), + message: (label: any) => `Expected ${label} to be one of enum 'tendermintV2.types.BlockIDFlag', got \`${val}\``, +}); +export const owTendermintTypesBlockIDFlag = ow.number.validate(validateBlockIDFlag); + +export const owTendermintTypesCommitSig = owStrictObject().exactShape({ + blockIdFlag: owTendermintTypesBlockIDFlag, + validatorAddress: ow.uint8Array, + timestamp: ow.optional.any(owOptionalTimestamp(), ow.null), + signature: ow.uint8Array, +}); + +export const owOptionalSignedHeaderParamsHeader = () => + owOptionalStrictObject().exactShape({ + version: ow.optional.any(owOptionalTendermintConsensus, ow.null), + chainId: ow.string, + height: owLong(), + time: ow.optional.any(owOptionalTimestamp(), ow.null), + lastBlockId: ow.optional.any(owOptionalTendermintBlockID, ow.null), + lastCommitHash: ow.uint8Array, + dataHash: ow.uint8Array, + validatorsHash: ow.uint8Array, + nextValidatorsHash: ow.uint8Array, + consensusHash: ow.uint8Array, + appHash: ow.uint8Array, + lastResultsHash: ow.uint8Array, + evidenceHash: ow.uint8Array, + proposerAddress: ow.uint8Array, + }); + +export const owOptionalSignedHeaderParamsCommit = () => + owOptionalStrictObject().exactShape({ + height: owLong(), + round: ow.number, + blockId: ow.any(owOptionalTendermintBlockID, ow.null), + signatures: ow.array.ofType(owTendermintTypesCommitSig), + }); + +export const owOptionalSignedHeader = () => + owOptionalStrictObject().exactShape({ + header: owOptionalSignedHeaderParamsHeader(), + commit: owOptionalSignedHeaderParamsCommit(), + }); + +export const owHeaderOptions = owStrictObject().exactShape({ + signedHeader: owOptionalSignedHeader(), + validatorSet: ow.any(owOptionalLightClientValidatorSet, ow.optional.null), + trustedHeight: owIBCHeightOptional(), + trustedValidators: ow.optional.any(owOptionalLightClientValidatorSet, ow.null), +}); + +export const owMsgUpdateClientOptions = owStrictObject().exactShape({ + signer: ow.string, + clientId: ow.string, + header: ow.optional.any(owHeaderOptions, ow.optional.null), +}); + +export const owMsgConnectionOpenConfirmOptions = owStrictObject().exactShape({ + signer: ow.string, + connectionId: ow.string, + proofAck: ow.uint8Array, + proofHeight: ow.any(owIBCHeightOptional(), ow.null), +}); + +export const owCounterPartyVersion = owStrictObject().exactShape({ + identifier: ow.string, + features: ow.array.ofType(ow.string), +}); + +export const owCounterPartyOptional = owOptionalStrictObject().exactShape({ + clientId: ow.string, + connectionId: ow.string, + prefix: owStrictObject().exactShape({ + keyPrefix: ow.string, + }), +}); + +export const owMsgConnectionOpenTryOptions = owStrictObject().exactShape({ + clientId: ow.string, + previousConnectionId: ow.string, + clientState: ow.optional.any(owClientStateOptions), + counterparty: ow.any(owCounterPartyOptional, ow.null), + delayPeriod: owLong(), + counterpartyVersions: ow.array.ofType(owCounterPartyVersion), + proofHeight: ow.any(owIBCHeightOptional(), ow.null), + proofInit: ow.uint8Array, + proofClient: ow.uint8Array, + proofConsensus: ow.uint8Array, + consensusHeight: ow.any(owIBCHeightOptional(), ow.null), + signer: ow.string, +}); diff --git a/lib/src/transaction/msg/staking/MsgBeginRedelegate.spec.ts b/lib/src/transaction/msg/staking/MsgBeginRedelegate.spec.ts index b55be439..1222ef46 100644 --- a/lib/src/transaction/msg/staking/MsgBeginRedelegate.spec.ts +++ b/lib/src/transaction/msg/staking/MsgBeginRedelegate.spec.ts @@ -51,7 +51,7 @@ describe('Testing MsgBeginRedelegate', function () { it('Test MsgBeginRedelegate conversion', function () { const coin = new cro.Coin('12000500', Units.BASE); - const msgSend = new cro.staking.MsgBeginRedelegate({ + const msgBeginRedelegate = new cro.staking.MsgBeginRedelegate({ delegatorAddress: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', validatorDstAddress: 'tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr', validatorSrcAddress: 'tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx', @@ -68,13 +68,13 @@ describe('Testing MsgBeginRedelegate', function () { }, }; - expect(msgSend.toRawMsg()).to.eqls(rawMsg); + expect(msgBeginRedelegate.toRawMsg()).to.eqls(rawMsg); }); it('Test MsgBeginRedelegate conversion Json', function () { const coin = new cro.Coin('12000500', Units.BASE); - const msgSend = new cro.staking.MsgBeginRedelegate({ + const msgBeginRedelegate = new cro.staking.MsgBeginRedelegate({ delegatorAddress: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', validatorDstAddress: 'tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr', validatorSrcAddress: 'tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx', @@ -94,7 +94,7 @@ describe('Testing MsgBeginRedelegate', function () { }, }; - expect(msgSend.toRawAminoMsg()).to.eqls(rawMsg); + expect(msgBeginRedelegate.toRawAminoMsg()).to.eqls(rawMsg); }); it('Test appendTxBody MsgBeginRedelegate Tx signing', function () { @@ -142,11 +142,87 @@ describe('Testing MsgBeginRedelegate', function () { amount: coin, }; + const params4 = { + delegatorAddress: 'cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f', + validatorDstAddress: 'tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr', + validatorSrcAddress: 'tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx', + amount: coin, + }; + + const params5 = { + delegatorAddress: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', + validatorDstAddress: 'crocncl1pndm4ywdf4qtmupa0fqe75krmqed2znj8le094', + validatorSrcAddress: 'tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx', + amount: coin, + }; + + const params6 = { + delegatorAddress: 'tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q', + validatorDstAddress: 'tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx', + validatorSrcAddress: 'crocncl1pndm4ywdf4qtmupa0fqe75krmqed2znj8le094', + amount: coin, + }; + expect(() => new cro.staking.MsgBeginRedelegate(params2)).to.throw( 'Source and destination validator addresses cannot be the same.', ); expect(() => new cro.staking.MsgBeginRedelegate(params3)).to.throw( 'Invalid checksum for tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625', ); + expect(() => new cro.staking.MsgBeginRedelegate(params4)).to.throw( + 'Provided `delegatorAddress` does not match with selected network', + ); + expect(() => new cro.staking.MsgBeginRedelegate(params5)).to.throw( + 'Provided `validatorDstAddress` does not match with selected network', + ); + expect(() => new cro.staking.MsgBeginRedelegate(params6)).to.throw( + 'Provided `validatorSrcAddress` does not match with selected network', + ); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgBeginRedelegate', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.staking.v1beta1.MsgBeginRedelegate but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `validator_src_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgBeginRedelegate","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_dst_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorSrcAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `validator_dst_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgBeginRedelegate","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_src_address":"tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorDstAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgBeginRedelegate","validator_src_address":"tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx","validator_dst_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgBeginRedelegate","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_src_address":"tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx","validator_dst_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr"}'; + expect(() => cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should return the MsgBeginRedelegate corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgBeginRedelegate","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_src_address":"tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx","validator_dst_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + const MsgBeginRedelegate = cro.staking.MsgBeginRedelegate.fromCosmosMsgJSON(json); + expect(MsgBeginRedelegate.validatorDstAddress).to.eql('tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr'); + expect(MsgBeginRedelegate.validatorSrcAddress).to.eql('tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3wx'); + expect(MsgBeginRedelegate.delegatorAddress).to.eql('tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q'); + expect(MsgBeginRedelegate.amount.toCosmosCoin().amount).to.eql('1200050000000000'); + expect(MsgBeginRedelegate.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); }); }); diff --git a/lib/src/transaction/msg/staking/MsgBeginRedelegate.ts b/lib/src/transaction/msg/staking/MsgBeginRedelegate.ts index 9f7836a3..34f7a8a2 100644 --- a/lib/src/transaction/msg/staking/MsgBeginRedelegate.ts +++ b/lib/src/transaction/msg/staking/MsgBeginRedelegate.ts @@ -1,13 +1,27 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { CosmosMsg } from '../cosmosMsg'; import { ICoin } from '../../../coin/coin'; import { owMsgBeginRedelgateOptions } from '../ow.types'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { validateAddress, AddressType } from '../../../utils/address'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; import * as legacyAmino from '../../../cosmos/amino'; +export interface MsgBeginRedelegateRaw { + '@type': string; + delegator_address: string; + validator_src_address: string; + validator_dst_address: string; + amount: Amount; +} + +export interface Amount { + denom: string; + amount: string; +} + export const msgBeginRedelegate = function (config: InitConfigurations) { return class MsgBeginRedelegate implements CosmosMsg { /** MsgBeginRedelegate delegatorAddress. */ @@ -37,6 +51,30 @@ export const msgBeginRedelegate = function (config: InitConfigurations) { this.validateAddresses(); } + /** + * Returns an instance of MsgBeginRedelegate + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgBeginRedelegate} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgBeginRedelegate { + const parsedMsg = JSON.parse(msgJsonStr) as MsgBeginRedelegateRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgBeginRedelegate) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgBeginRedelegate} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.amount || Object.keys(parsedMsg.amount).length !== 2) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgBeginRedelegate({ + delegatorAddress: parsedMsg.delegator_address, + validatorDstAddress: parsedMsg.validator_dst_address, + validatorSrcAddress: parsedMsg.validator_src_address, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount.amount, parsedMsg.amount.denom), + }); + } + // eslint-disable-next-line class-methods-use-this toRawAminoMsg(): legacyAmino.Msg { return { diff --git a/lib/src/transaction/msg/staking/MsgCreateValidator.spec.ts b/lib/src/transaction/msg/staking/MsgCreateValidator.spec.ts index ac1da265..e4a0cb69 100644 --- a/lib/src/transaction/msg/staking/MsgCreateValidator.spec.ts +++ b/lib/src/transaction/msg/staking/MsgCreateValidator.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import 'mocha'; import { expect } from 'chai'; import Big from 'big.js'; @@ -211,4 +212,84 @@ describe('Testing MsgCreateValidator', function () { 'Invalid checksum for tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenr', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgCreateValidator', function () { + const json = + '{ "@type": "/cosmos.staking.v1beta1.MsgEditValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.staking.v1beta1.MsgCreateValidator but got /cosmos.staking.v1beta1.MsgEditValidator', + ); + }); + + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + + it('should throw Error when the `minSelfDelegation` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `minSelfDelegation` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `validator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `value` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="}}'; + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw('Invalid value in the Msg.'); + }); + + it('should throw Error when the `pubkey` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","value":{"denom":"basetcro","amount":"50000000000000"}}'; + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw('Invalid pubkey in the Msg.'); + }); + it('should throw Error when the `commission` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Invalid commission in the Msg.', + ); + }); + it('should throw Error when the `description` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + expect(() => cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json)).to.throw( + 'Invalid description in the Msg.', + ); + }); + + it('should return the MsgCreateValidator corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"commission":{"rate":"0.100000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1","delegator_address":"tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"EHT8l6A+bKFLLcyuh88Se+eN4mDkfWeUdE7gv5E97a8="},"value":{"denom":"basetcro","amount":"50000000000000"}}'; + + const MsgCreateValidator = cro.staking.MsgCreateValidator.fromCosmosMsgJSON(json); + expect(MsgCreateValidator.validatorAddress).to.eql('tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr'); + expect(MsgCreateValidator.delegatorAddress).to.eql('tcro1j7pej8kplem4wt50p4hfvndhuw5jprxxn5625q'); + expect(MsgCreateValidator.minSelfDelegation).to.eql('1'); + + expect(MsgCreateValidator.value.toCosmosCoin().amount).to.eql('50000000000000'); + expect(MsgCreateValidator.value.toCosmosCoin().denom).to.eql('basetcro'); + + expect(MsgCreateValidator.commission.rate).to.eql('0.100000000000000000'); + expect(MsgCreateValidator.commission.maxRate).to.eql('0.200000000000000000'); + expect(MsgCreateValidator.commission.maxChangeRate).to.eql('0.010000000000000000'); + + expect(MsgCreateValidator.description.securityContact).to.eql('hitesh.goel@crypto.com'); + expect(MsgCreateValidator.description.moniker).to.eql('hiteshTest'); + }); + }); }); diff --git a/lib/src/transaction/msg/staking/MsgCreateValidator.ts b/lib/src/transaction/msg/staking/MsgCreateValidator.ts index 868dac0a..550f4aaf 100644 --- a/lib/src/transaction/msg/staking/MsgCreateValidator.ts +++ b/lib/src/transaction/msg/staking/MsgCreateValidator.ts @@ -1,9 +1,10 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { CosmosMsg } from '../cosmosMsg'; import { ICoin } from '../../../coin/coin'; import { owMsgCreateValidatorOptions } from '../ow.types'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { validateAddress, AddressType } from '../../../utils/address'; import { IDescription } from '../../common/interface/IDescription'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; @@ -75,6 +76,58 @@ export const msgCreateValidator = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgCreateValidator + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgCreateValidator} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgCreateValidator { + const parsedMsg = JSON.parse(msgJsonStr) as MsgCreateValidatorRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgCreateValidator) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgCreateValidator} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.value || Object.keys(parsedMsg.value).length !== 2) { + throw new Error('Invalid value in the Msg.'); + } + + if (!parsedMsg.commission || Object.keys(parsedMsg.commission).length < 1) { + throw new Error('Invalid commission in the Msg.'); + } + + if (!parsedMsg.description || Object.keys(parsedMsg.description).length < 1) { + throw new Error('Invalid description in the Msg.'); + } + + if (!parsedMsg.pubkey || Object.keys(parsedMsg.pubkey).length !== 2) { + throw new Error('Invalid pubkey in the Msg.'); + } + const pubkey: string = parsedMsg.pubkey.key; + + const cro = CroSDK({ network: config.network }); + + return new MsgCreateValidator({ + description: { + moniker: parsedMsg.description.moniker, + identity: parsedMsg.description.identity, + website: parsedMsg.description.website, + securityContact: parsedMsg.description.security_contact, + details: parsedMsg.description.details, + }, + commission: { + rate: parsedMsg.commission.rate, + maxChangeRate: parsedMsg.commission.max_change_rate, + maxRate: parsedMsg.commission.max_rate, + }, + value: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.value.amount, parsedMsg.value.denom), + validatorAddress: parsedMsg.validator_address, + pubkey, + minSelfDelegation: parsedMsg.min_self_delegation, + delegatorAddress: parsedMsg.delegator_address, + }); + } + validateAddresses(): void { if ( !validateAddress({ @@ -98,6 +151,40 @@ export const msgCreateValidator = function (config: InitConfigurations) { } }; }; +export interface MsgCreateValidatorRaw { + '@type': string; + description: Description; + commission: Commission; + min_self_delegation: string; + delegator_address: string; + validator_address: string; + pubkey: Pubkey; + value: Amount; +} + +export interface Commission { + rate: string; + max_rate: string; + max_change_rate: string; +} + +export interface Description { + moniker: string; + identity: string; + website: string; + security_contact: string; + details: string; +} + +export interface Pubkey { + '@type': string; + key: string; +} + +export interface Amount { + denom: string; + amount: string; +} export type MsgCreateValidatorParams = { description: IDescription; diff --git a/lib/src/transaction/msg/staking/MsgDelegate.spec.ts b/lib/src/transaction/msg/staking/MsgDelegate.spec.ts index d24526ae..a2c3a75c 100644 --- a/lib/src/transaction/msg/staking/MsgDelegate.spec.ts +++ b/lib/src/transaction/msg/staking/MsgDelegate.spec.ts @@ -159,4 +159,43 @@ describe('Testing MsgDelegate', function () { expect(MsgDelegate.toRawAminoMsg()).to.eqls(rawMsg); }); }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgDelegate', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.staking.MsgDelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.staking.v1beta1.MsgDelegate but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `validator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgDelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgDelegate","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgDelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr"}'; + expect(() => cro.staking.MsgDelegate.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should return the MsgDelegate corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgDelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + const MsgDelegate = cro.staking.MsgDelegate.fromCosmosMsgJSON(json); + expect(MsgDelegate.validatorAddress).to.eql('tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr'); + expect(MsgDelegate.delegatorAddress).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(MsgDelegate.amount.toCosmosCoin().amount).to.eql('1200050000000000'); + expect(MsgDelegate.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); + }); }); diff --git a/lib/src/transaction/msg/staking/MsgDelegate.ts b/lib/src/transaction/msg/staking/MsgDelegate.ts index 758041f5..fc64b01b 100644 --- a/lib/src/transaction/msg/staking/MsgDelegate.ts +++ b/lib/src/transaction/msg/staking/MsgDelegate.ts @@ -1,13 +1,26 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { CosmosMsg } from '../cosmosMsg'; import { owMsgDelegateOptions } from '../ow.types'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { validateAddress, AddressType } from '../../../utils/address'; import { ICoin } from '../../../coin/coin'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; import * as legacyAmino from '../../../cosmos/amino'; +export interface MsgDelegateRaw { + '@type': string; + delegator_address: string; + validator_address: string; + amount: Amount; +} + +export interface Amount { + denom: string; + amount: string; +} + export const msgDelegate = function (config: InitConfigurations) { return class MsgDelegate implements CosmosMsg { /** MsgDelegate delegatorAddress. */ @@ -64,6 +77,29 @@ export const msgDelegate = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgDelegate + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgDelegate} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgDelegate { + const parsedMsg = JSON.parse(msgJsonStr) as MsgDelegateRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgDelegate) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgDelegate} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.amount || Object.keys(parsedMsg.amount).length !== 2) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgDelegate({ + delegatorAddress: parsedMsg.delegator_address, + validatorAddress: parsedMsg.validator_address, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount.amount, parsedMsg.amount.denom), + }); + } + validateAddresses(): void { const { network } = config; diff --git a/lib/src/transaction/msg/staking/MsgEditValidator.spec.ts b/lib/src/transaction/msg/staking/MsgEditValidator.spec.ts index 77d6f69b..fd6ff665 100644 --- a/lib/src/transaction/msg/staking/MsgEditValidator.spec.ts +++ b/lib/src/transaction/msg/staking/MsgEditValidator.spec.ts @@ -173,4 +173,43 @@ describe('Testing MsgEditValidator', function () { 'Invalid checksum for tcrocncl16mmzexp3zqfpgqtnn927m5ph560qgxrs52a3w', ); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgEditValidator', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.staking.v1beta1.MsgEditValidator but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should NOT throw Error when the `commission_rate` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgEditValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","min_self_delegation":"1"}'; + expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json)).to.not.throw( + 'Expected `commissionRate` to be of type `null` but received type `undefined` in object `options`', + ); + const msgEdit = cro.staking.MsgEditValidator.fromCosmosMsgJSON(json); + expect(msgEdit.commissionRate).to.be.null; + }); + it('should NOT throw Error when the `min_self_delegation` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgEditValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","commission_rate":"0.100000000000000000"}'; + expect(() => cro.staking.MsgEditValidator.fromCosmosMsgJSON(json)).to.not.throw( + 'Expected `minSelfDelegation` to be of type `null` but received type `undefined` in object `options`', + ); + const msgEdit = cro.staking.MsgEditValidator.fromCosmosMsgJSON(json); + expect(msgEdit.minSelfDelegation).to.be.null; + }); + + it('should return the MsgEditValidator corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgEditValidator","description":{"moniker":"hiteshTest","identity":"","website":"","security_contact":"hitesh.goel@crypto.com","details":""},"validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","commission_rate":"0.100000000000000000","min_self_delegation":"1"}'; + const MsgEditValidator = cro.staking.MsgEditValidator.fromCosmosMsgJSON(json); + expect(MsgEditValidator.validatorAddress).to.eql('tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr'); + expect(MsgEditValidator.minSelfDelegation).to.eql('1'); + expect(MsgEditValidator.commissionRate).to.eql('0.100000000000000000'); + expect(MsgEditValidator.description.securityContact).to.eql('hitesh.goel@crypto.com'); + expect(MsgEditValidator.description.moniker).to.eql('hiteshTest'); + }); + }); }); diff --git a/lib/src/transaction/msg/staking/MsgEditValidator.ts b/lib/src/transaction/msg/staking/MsgEditValidator.ts index 3c9d95de..389edda2 100644 --- a/lib/src/transaction/msg/staking/MsgEditValidator.ts +++ b/lib/src/transaction/msg/staking/MsgEditValidator.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { CosmosMsg } from '../cosmosMsg'; @@ -54,6 +55,32 @@ export const msgEditValidator = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgEditValidator + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgEditValidator} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgEditValidator { + const parsedMsg = JSON.parse(msgJsonStr) as MsgEditValidatorRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgEditValidator) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgEditValidator} but got ${parsedMsg['@type']}`); + } + + return new MsgEditValidator({ + description: { + moniker: parsedMsg.description.moniker, + identity: parsedMsg.description.identity, + website: parsedMsg.description.website, + securityContact: parsedMsg.description.security_contact, + details: parsedMsg.description.details, + }, + validatorAddress: parsedMsg.validator_address, + commissionRate: parsedMsg.commission_rate || null, + minSelfDelegation: parsedMsg.min_self_delegation || null, + }); + } + validateAddresses(): void { const { network } = config; @@ -64,6 +91,22 @@ export const msgEditValidator = function (config: InitConfigurations) { }; }; +export interface MsgEditValidatorRaw { + '@type': string; + description: DescriptionRaw; + validator_address: string; + commission_rate: string; + min_self_delegation: string; +} + +export interface DescriptionRaw { + moniker?: string | null; + identity?: string | null; + website?: string | null; + security_contact?: string | null; + details?: string | null; +} + export type MsgCreateEditOptions = { description: IDescription; commissionRate: string | null; diff --git a/lib/src/transaction/msg/staking/MsgUndelegate.spec.ts b/lib/src/transaction/msg/staking/MsgUndelegate.spec.ts index 4c8c3214..d287f42d 100644 --- a/lib/src/transaction/msg/staking/MsgUndelegate.spec.ts +++ b/lib/src/transaction/msg/staking/MsgUndelegate.spec.ts @@ -159,4 +159,42 @@ describe('Testing MsgUndelegate (Unbonding)', function () { expect(MsgUndelegate.toRawAminoMsg()).to.eqls(rawMsg); }); }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgUndelegate', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.staking.MsgUndelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.staking.v1beta1.MsgUndelegate but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `validator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgUndelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `validatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + + it('should throw Error when the `delegator_address` field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + expect(() => cro.staking.MsgUndelegate.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `delegatorAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr"}'; + expect(() => cro.staking.MsgUndelegate.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should return the MsgUndelegate corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.staking.v1beta1.MsgUndelegate","delegator_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","validator_address":"tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr","amount":{"denom":"basetcro","amount":"1200050000000000"}}'; + const MsgUndelegate = cro.staking.MsgUndelegate.fromCosmosMsgJSON(json); + expect(MsgUndelegate.validatorAddress).to.eql('tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr'); + expect(MsgUndelegate.delegatorAddress).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(MsgUndelegate.amount.toCosmosCoin().amount).to.eql('1200050000000000'); + expect(MsgUndelegate.amount.toCosmosCoin().denom).to.eql('basetcro'); + }); + }); }); diff --git a/lib/src/transaction/msg/staking/MsgUndelegate.ts b/lib/src/transaction/msg/staking/MsgUndelegate.ts index 0eb47edb..1bb00108 100644 --- a/lib/src/transaction/msg/staking/MsgUndelegate.ts +++ b/lib/src/transaction/msg/staking/MsgUndelegate.ts @@ -1,13 +1,26 @@ +/* eslint-disable camelcase */ import ow from 'ow'; import { Msg } from '../../../cosmos/v1beta1/types/msg'; import { CosmosMsg } from '../cosmosMsg'; import { owMsgUndelegateOptions } from '../ow.types'; -import { InitConfigurations } from '../../../core/cro'; +import { InitConfigurations, CroSDK } from '../../../core/cro'; import { validateAddress, AddressType } from '../../../utils/address'; import { ICoin } from '../../../coin/coin'; import { COSMOS_MSG_TYPEURL } from '../../common/constants/typeurl'; import * as legacyAmino from '../../../cosmos/amino'; +export interface MsgUndelegateRaw { + '@type': string; + delegator_address: string; + validator_address: string; + amount: Amount; +} + +export interface Amount { + denom: string; + amount: string; +} + export const msgUndelegate = function (config: InitConfigurations) { return class MsgUndelegate implements CosmosMsg { /** MsgUndelegate delegatorAddress. */ @@ -64,6 +77,29 @@ export const msgUndelegate = function (config: InitConfigurations) { }; } + /** + * Returns an instance of MsgUndelegate + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgUndelegate} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgUndelegate { + const parsedMsg = JSON.parse(msgJsonStr) as MsgUndelegateRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgUndelegate) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgUndelegate} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.amount || Object.keys(parsedMsg.amount).length !== 2) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgUndelegate({ + delegatorAddress: parsedMsg.delegator_address, + validatorAddress: parsedMsg.validator_address, + amount: cro.v2.CoinV2.fromCustomAmountDenom(parsedMsg.amount.amount, parsedMsg.amount.denom), + }); + } + /** * Validates the user provided addresses * @returns {void} diff --git a/lib/src/transaction/msg/v2/bank/v2.msgsend.spec.ts b/lib/src/transaction/msg/v2/bank/v2.msgsend.spec.ts new file mode 100644 index 00000000..f8cf336c --- /dev/null +++ b/lib/src/transaction/msg/v2/bank/v2.msgsend.spec.ts @@ -0,0 +1,191 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; + +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import { Units } from '../../../../coin/coin'; +import { CroSDK } from '../../../../core/cro'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgSend', function () { + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgSend', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.bank.v1beta1.MsgSend but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the from field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `fromAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the to field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg" }'; + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `toAddress` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg" , "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should throw on invalid `fromAddress`', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw( + 'Provided `fromAddress` does not match network selected', + ); + }); + it('should throw on invalid `toAddress`', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3", "to_address": "cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f" }'; + + expect(() => cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json)).to.throw( + 'Provided `toAddress` does not match network selected', + ); + }); + it('should return the MsgSend corresponding to the JSON', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + const msgSend = cro.v2.bank.MsgSendV2.fromCosmosMsgJSON(json); + expect(msgSend.fromAddress).to.eql('tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg'); + expect(msgSend.toAddress).to.eql('tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3'); + expect(msgSend.amount[0].toCosmosCoin().amount).to.eql('3478499933290496'); + expect(msgSend.amount[0].toCosmosCoin().denom).to.eql('basetcro'); + }); + }); + + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: new cro.Coin('1000', Units.BASE), + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.bank.MsgSendV2(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgSend conversion', function () { + const coin = new cro.Coin('12000500', Units.BASE); + + const msgSend = new cro.v2.bank.MsgSendV2({ + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }); + + const rawMsg: Msg = { + typeUrl: '/cosmos.bank.v1beta1.MsgSend', + value: { + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [ + { + denom: 'basetcro', + amount: '12000500', + }, + ], + }, + }; + + expect(msgSend.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test appendTxBody MsgSend Tx signing', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + const coin = new cro.Coin('12000500', Units.CRO); + + const msgSend = new cro.v2.bank.MsgSendV2({ + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(2), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(msgSend).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0a9b010a98010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412780a2b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b6333122b7463726f3138346c7461326c7379753437767779703265387a6d746361336b3579713835703663347670331a1c0a08626173657463726f12103132303030353030303030303030303012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40b28cefb83735e05253f641d0bca790a6f95481bc857a7d57a493125af1804ed440dffc080950d6ff39dee4ea113e5e686f8235e98d34870d9b64b4a9a057f686', + ); + }); + + it('Should validate MsgSend provided addresses with network config', function () { + const coin = new cro.Coin('12000500', Units.BASE); + + const params1 = { + fromAddress: 'cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f', + toAddress: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }; + + const params2 = { + fromAddress: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + toAddress: 'cro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8f', + amount: [coin], + }; + + const params3 = { + fromAddress: 'tcro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8fzqa', + toAddress: 'cro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }; + + expect(() => new cro.v2.bank.MsgSendV2(params1)).to.throw( + 'Provided `fromAddress` does not match network selected', + ); + expect(() => new cro.v2.bank.MsgSendV2(params2)).to.throw( + 'Provided `toAddress` does not match network selected', + ); + expect(() => new cro.v2.bank.MsgSendV2(params3)).to.throw( + 'Invalid checksum for tcro1pndm4ywdf4qtmupa0fqe75krmqed2znjyj6x8fzqa', + ); + }); +}); diff --git a/lib/src/transaction/msg/v2/bank/v2.msgsend.ts b/lib/src/transaction/msg/v2/bank/v2.msgsend.ts new file mode 100644 index 00000000..14874a85 --- /dev/null +++ b/lib/src/transaction/msg/v2/bank/v2.msgsend.ts @@ -0,0 +1,126 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { ICoin } from '../../../../coin/coin'; +import { v2 } from '../../ow.types'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { AddressType, validateAddress } from '../../../../utils/address'; +import { CosmosMsg } from '../../cosmosMsg'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; + +export const msgSendV2 = function (config: InitConfigurations) { + return class MsgSendV2 implements CosmosMsg { + public readonly fromAddress: string; + + public readonly toAddress: string; + + public amount: ICoin[]; + + /** + * Constructor to create a new MsgSend + * @param {MsgSendOptions} options + * @returns {MsgSendV2} + * @throws {Error} when options is invalid + */ + constructor(options: MsgSendOptions) { + ow(options, 'options', v2.owMsgSendOptions); + + this.fromAddress = options.fromAddress; + this.toAddress = options.toAddress; + this.amount = options.amount; + + this.validateAddresses(); + } + + /** + * Returns an instance of MsgSend + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSendV2} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSendV2 { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSendRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgSend) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgSend} but got ${parsedMsg['@type']}`); + } + if (!parsedMsg.amount || parsedMsg.amount.length < 1) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgSendV2({ + fromAddress: parsedMsg.from_address, + toAddress: parsedMsg.to_address, + amount: parsedMsg.amount.map((coin) => cro.v2.CoinV2.fromCustomAmountDenom(coin.amount, coin.denom)), + }); + } + + /** + * Returns the raw Msg representation of MsgSend + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.MsgSend, + value: { + fromAddress: this.fromAddress, + toAddress: this.toAddress, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }, + }; + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + return { + type: 'cosmos-sdk/MsgSend', + value: { + from_address: this.fromAddress, + to_address: this.toAddress, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }, + } as legacyAmino.MsgSend; + } + + validateAddresses() { + if ( + !validateAddress({ + address: this.fromAddress, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `fromAddress` does not match network selected'); + } + + if ( + !validateAddress({ + address: this.toAddress, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `toAddress` does not match network selected'); + } + } + }; +}; + +type MsgSendOptions = { + fromAddress: string; + toAddress: string; + amount: ICoin[]; +}; + +interface MsgSendRaw { + '@type': string; + amount: Amount[]; + from_address: string; + to_address: string; +} + +interface Amount { + denom: string; + amount: string; +} diff --git a/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.spec.ts b/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.spec.ts new file mode 100644 index 00000000..88bf1543 --- /dev/null +++ b/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.spec.ts @@ -0,0 +1,139 @@ +/* eslint-disable */ +import { expect } from 'chai'; +import Big from 'big.js'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { CroSDK } from '../../../../core/cro'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Bytes } from '../../../../utils/bytes/bytes'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { Units } from '../../../../coin/coin'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); +let amount = new cro.Coin('1000', Units.BASE) + +describe('Testing MsgFundCommunityPool', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + depositor: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + amount: [amount], + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.distribution.MsgFundCommunityPoolV2(options.value)).to.throw( + 'Expected `communityPoolOptions` to be of type `object`', + ); + }); + }); + + it('Test appending MsgFundCommunityPool and signing it', function () { + const anyKeyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('66633d18513bec30dd11a209f1ceb1787aa9e2069d5d47e590174dc9665102b3'), + ); + + const MsgFundCommunityPool = new cro.v2.distribution.MsgFundCommunityPoolV2({ + depositor: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + amount: [amount], + }); + + const anySigner = { + publicKey: anyKeyPair.getPubKey(), + accountNumber: new Big(0), + accountSequence: new Big(10), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(MsgFundCommunityPool).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, anyKeyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0a760a740a312f636f736d6f732e646973747269627574696f6e2e763162657461312e4d736746756e64436f6d6d756e697479506f6f6c123f0a100a08626173657463726f120431303030122b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b633312580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a020801180a120410c09a0c1a400c93f8e74991dde45638e3d4366f7607fd9711272d0602f1e2e797d9180d25c30031955522e7ddc380d7ac4435e7f6d01fbea5db685655ba0b04d43b4135bf3d', + ); + }); + + describe('Testing MsgFundCommunityPool json', function () { + it('Test MsgFundCommunityPool conversion for amino json', function () { + const MsgWithdrawDelegatatorReward = new cro.v2.distribution.MsgFundCommunityPoolV2({ + depositor: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + amount: [amount], + }); + + const rawMsg: legacyAmino.Msg = { + type: 'cosmos-sdk/MsgFundCommunityPool', + value: { + depositor: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + amount: amount.toCosmosCoins(), + }, + }; + + expect(MsgWithdrawDelegatatorReward.toRawAminoMsg()).to.eqls(rawMsg); + }); + }); + + describe('Testing throw scenarios', function () { + it('Should throw on invalid depositor', function () { + expect(() => { + new cro.v2.distribution.MsgFundCommunityPoolV2({ + depositor: 'cro1xh3dqgljnydpwelzqf265edryrqrq7wzacx2nr', + amount: [amount], + }); + }).to.throw('Provided `depositor` address doesnt match network selected'); + }); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgFundCommunityPool', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.distribution.MsgFundCommunityPoolV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.MsgFundCommunityPool but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should throw Error when the `depositor` field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","amount":[{ "denom": "basetcro", "amount": "3478499933290496" }]}'; + expect(() => cro.v2.distribution.MsgFundCommunityPoolV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `depositor` to be of type `string` but received type `undefined` in object `communityPoolOptions`', + ); + }); + it('should throw Error when the amount field is missing', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","depositor":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + expect(() => cro.v2.distribution.MsgFundCommunityPoolV2.fromCosmosMsgJSON(json)).to.throw( + 'Invalid amount in the Msg.', + ); + }); + it('should return the `MsgFundCommunityPool` corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.MsgFundCommunityPool","amount":[{ "denom": "basetcro", "amount": "3478499933290496" }],"depositor":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3"}'; + + const msgFundCommPool = cro.v2.distribution.MsgFundCommunityPoolV2.fromCosmosMsgJSON(json); + expect(msgFundCommPool.depositor).to.eql('tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3'); + expect(msgFundCommPool.amount[0].toCosmosCoin().amount).to.eql('3478499933290496'); + expect(msgFundCommPool.amount[0].toCosmosCoin().denom).to.eql('basetcro'); + }); + }); +}); diff --git a/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.ts b/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.ts new file mode 100644 index 00000000..4b12ce0d --- /dev/null +++ b/lib/src/transaction/msg/v2/distribution/v2.MsgFundCommunityPool.ts @@ -0,0 +1,109 @@ +import ow from 'ow'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { AddressType, validateAddress } from '../../../../utils/address'; +import { v2 } from '../../ow.types'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { ICoin } from '../../../../coin/coin'; + +export const msgFundCommunityPoolV2 = function (config: InitConfigurations) { + return class MsgFundCommunityPoolV2 implements CosmosMsg { + // Normal user addresses with (t)cro prefix + public readonly depositor: string; + + public amount: ICoin[]; + + /** + * Constructor to create a new MsgFundCommunityPool + * @param {MsgFundCommunityPoolOptions} options + * @returns {MsgFundCommunityPoolV2} + * @throws {Error} when options is invalid + */ + constructor(options: MsgFundCommunityPoolOptions) { + ow(options, 'communityPoolOptions', v2.owMsgFundCommunityPoolOptions); + + this.depositor = options.depositor; + this.amount = options.amount; + + this.validateAddresses(); + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + return { + type: 'cosmos-sdk/MsgFundCommunityPool', + value: { + depositor: this.depositor, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }, + } as legacyAmino.MsgFundCommunityPool; + } + + /** + * Returns the raw Msg representation of MsgFundCommunityPool + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool, + value: { + depositor: this.depositor, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }, + }; + } + + /** + * Returns an instance of MsgFundCommunityPool + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgFundCommunityPool} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgFundCommunityPoolV2 { + const parsedMsg = JSON.parse(msgJsonStr) as MsgFundCommunityPoolRaw; + const cro = CroSDK({ network: config.network }); + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool} but got ${parsedMsg['@type']}`, + ); + } + if (!parsedMsg.amount || parsedMsg.amount.length < 1) { + throw new Error('Invalid amount in the Msg.'); + } + + return new MsgFundCommunityPoolV2({ + depositor: parsedMsg.depositor, + amount: parsedMsg.amount.map((coin) => cro.v2.CoinV2.fromCustomAmountDenom(coin.amount, coin.denom)), + }); + } + + validateAddresses() { + if ( + !validateAddress({ + address: this.depositor, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `depositor` address doesnt match network selected'); + } + } + }; +}; + +export type MsgFundCommunityPoolOptions = { + depositor: string; + amount: ICoin[]; +}; +interface MsgFundCommunityPoolRaw { + '@type': string; + amount: Amount[]; + depositor: string; +} + +interface Amount { + denom: string; + amount: string; +} diff --git a/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.spec.ts b/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.spec.ts new file mode 100644 index 00000000..482a6d4f --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.spec.ts @@ -0,0 +1,129 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Big from 'big.js'; +import { Network } from '../../../../../network/network'; +import { CroSDK } from '../../../../../core/cro'; +import { fuzzyDescribe } from '../../../../../test/mocha-fuzzy/suite'; +import { Units } from '../../../../../coin/coin'; +import { HDKey } from '../../../../../hdkey/hdkey'; +import { Secp256k1KeyPair } from '../../../../../keypair/secp256k1'; + +const PystaportTestNet: Network = { + rpcUrl: '', + defaultNodeUrl: '', + chainId: 'chainmaind', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, +}; +const cro = CroSDK({ network: PystaportTestNet }); +const coin = cro.Coin.fromBaseUnit('10000'); + +describe('Testing CommunityPoolSpendProposalV2 and its content types', function () { + const anyContent = new cro.v2.gov.proposal.CommunityPoolSpendProposalV2({ + title: 'Make new cosmos version backward compatible with pre release', + description: 'Lorem Ipsum ...', + recipient: 'tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg', + amount: [coin], + }); + + fuzzyDescribe('should throw Error when CommunityPoolSpendProposalV2 options is invalid', function (fuzzy) { + const anyValidProposalSubmission = { + proposer: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + initialDeposit: new cro.Coin('1200', Units.BASE), + content: anyContent, + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidProposalSubmission)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.gov.proposal.CommunityPoolSpendProposalV2(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test Signing CommunityPoolSpendProposalV2 Type', function () { + const hdKey = HDKey.fromMnemonic( + 'order envelope snack half demand merry help obscure slogan like universe pond gain between brass settle pig float torch drama liberty grace check luxury', + ); + + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const CommunityPoolSpendProposalV2Content = new cro.v2.gov.proposal.CommunityPoolSpendProposalV2({ + title: 'Text Proposal Title', + description: 'Lorem Ipsum ... Checking cancel software upgrade', + recipient: 'tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg', + amount: [coin], + }); + + const CommunityPoolSpendProposalV2ChangeParam = new cro.gov.MsgSubmitProposal({ + proposer: 'tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a', + initialDeposit: coin, + content: CommunityPoolSpendProposalV2Content, + }); + + const anySigner = { + publicKey: keyPair.getPubKey(), + accountNumber: new Big(6), + accountSequence: new Big(0), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx + .appendMessage(CommunityPoolSpendProposalV2ChangeParam) + .addSigner(anySigner) + .toSignable(); + + const signedTx = signableTx.setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.getHexEncoded(); + expect(signedTx.getTxHash()).to.be.eq('B68228C66AC221329AD61AB8924327F9062F80B9230C4947CBD5105A63896F99'); + expect(signedTxHex).to.be.eql( + '0ab3020ab0020a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c1286020ac3010a372f636f736d6f732e646973747269627574696f6e2e763162657461312e436f6d6d756e697479506f6f6c5370656e6450726f706f73616c1287010a13546578742050726f706f73616c205469746c6512304c6f72656d20497073756d202e2e2e20436865636b696e672063616e63656c20736f66747761726520757067726164651a2b7463726f317830376b6b6b6570666a32686c3865746c63757168656a376a6a366d7971727034387934686722110a08626173657463726f1205313030303012110a08626173657463726f120531303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a403ad1334095809e6daa04a1a3583703fd7ef651a97e8518450fe9c893f26296e462cd6734306c4d374a1fabf2e0387bf987c4440010507789c57ef5ae320f659a', + ); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a CommunityPoolSpendProposalV2', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.gov.proposal.CommunityPoolSpendProposalV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.distribution.v1beta1.CommunityPoolSpendProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('Should throw on invalid depositor', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal","amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "recipient": "cro1xh3dqgljnydpwelzqf265edryrqrq7wzacx2nr"}'; + expect(() => cro.v2.gov.proposal.CommunityPoolSpendProposalV2.fromCosmosMsgJSON(json)).to.throw( + 'Provided `recipient` doesnt match network selected', + ); + }); + + it('should return the CommunityPoolSpendProposalV2 corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal","title": "Text Proposal Title", "description": "Lorem Ipsum ... Checking text proposal","amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "recipient": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg"}'; + const CommunityPoolSpendProposalV2 = cro.v2.gov.proposal.CommunityPoolSpendProposalV2.fromCosmosMsgJSON( + json, + ); + + expect(CommunityPoolSpendProposalV2.title).to.eql('Text Proposal Title'); + + expect(CommunityPoolSpendProposalV2.description).to.eql('Lorem Ipsum ... Checking text proposal'); + expect(CommunityPoolSpendProposalV2.recipient).to.eql('tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg'); + }); + }); +}); diff --git a/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.ts b/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.ts new file mode 100644 index 00000000..b0b3c965 --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/proposal/v2.CommunityPoolSpendProposal.ts @@ -0,0 +1,108 @@ +import ow from 'ow'; +import { v2 } from '../../../ow.types'; +import { InitConfigurations, CroSDK } from '../../../../../core/cro'; +import { IMsgProposalContent } from '../../../gov/IMsgProposalContent'; +import { ICoin } from '../../../../../coin/coin'; +import { google, cosmos } from '../../../../../cosmos/v1beta1/codec'; +import { COSMOS_MSG_TYPEURL } from '../../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../../utils/address'; +import { Amount } from '../../../bank/msgsend'; + +export const communityPoolSpendProposalV2 = function (config: InitConfigurations) { + return class CommunityPoolSpendProposalV2 implements IMsgProposalContent { + /** CommunityPoolSpendProposal title. */ + public title: string; + + /** CommunityPoolSpendProposal description. */ + public description: string; + + /** CommunityPoolSpendProposal recipient. */ + public recipient: string; + + /** CommunityPoolSpendProposal amount. */ + public amount: ICoin[]; + + constructor(options: CommunityPoolSpendProposalOptions) { + ow(options, 'options', v2.owCommunityPoolSpendProposalOptions); + + this.title = options.title; + this.description = options.description; + this.recipient = options.recipient; + this.amount = options.amount; + this.validate(); + } + + /** + * Returns the proto encoding representation of CommunityPoolSpendProposal + * @returns {google.protobuf.Any} + */ + getEncoded(): google.protobuf.Any { + const communityPoolSpend = { + title: this.title, + description: this.description, + recipient: this.recipient, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }; + + const spendProposal = cosmos.distribution.v1beta1.CommunityPoolSpendProposal.create(communityPoolSpend); + + return google.protobuf.Any.create({ + type_url: COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal, + value: cosmos.distribution.v1beta1.CommunityPoolSpendProposal.encode(spendProposal).finish(), + }); + } + + /** + * Returns an instance of CommunityPoolSpendProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {CommunityPoolSpendProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): CommunityPoolSpendProposalV2 { + const parsedMsg = JSON.parse(msgJsonStr) as CommunityPoolSpendProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal) { + throw new Error( + `Expected ${COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal} but got ${parsedMsg['@type']}`, + ); + } + if (!parsedMsg.amount || parsedMsg.amount.length < 1) { + throw new Error('Invalid amount in the Msg.'); + } + const cro = CroSDK({ network: config.network }); + + return new CommunityPoolSpendProposalV2({ + description: parsedMsg.description, + title: parsedMsg.title, + recipient: parsedMsg.recipient, + amount: parsedMsg.amount.map((coin) => cro.v2.CoinV2.fromCustomAmountDenom(coin.amount, coin.denom)), + }); + } + + validate() { + if ( + !validateAddress({ + address: this.recipient, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `recipient` doesnt match network selected'); + } + } + }; +}; + +export type CommunityPoolSpendProposalOptions = { + title: string; + description: string; + recipient: string; + amount: ICoin[]; +}; + +export interface CommunityPoolSpendProposalRaw { + '@type': string; + title: string; + description: string; + recipient: string; + amount: Amount[]; +} diff --git a/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.spec.ts b/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.spec.ts new file mode 100644 index 00000000..9b9997b4 --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.spec.ts @@ -0,0 +1,144 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; +import Long from 'long'; + +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Units } from '../../../../coin/coin'; +import { CroSDK } from '../../../../core/cro'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { HDKey } from '../../../../hdkey/hdkey'; + +const cro = CroSDK({ + network: { + defaultNodeUrl: '', + chainId: 'testnet-croeseid-1', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', + }, +}); + +describe('Testing MsgDeposit', function () { + fuzzyDescribe('should throw Error when options is invalid', function (fuzzy) { + const anyValidOptions = { + proposalId: Big(1244000), + depositor: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: new cro.Coin('1200', Units.BASE), + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidOptions)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.gov.MsgDepositV2(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test MsgDeposit conversion', function () { + const coin = new cro.Coin('12000500', Units.BASE); + + const msgDeposit = new cro.v2.gov.MsgDepositV2({ + proposalId: Big(1244000), + depositor: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }); + + const rawMsg: Msg = { + typeUrl: '/cosmos.gov.v1beta1.MsgDeposit', + value: { + proposalId: Long.fromNumber(1244000, true), + depositor: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [ + { + denom: 'basetcro', + amount: '12000500', + }, + ], + }, + }; + expect(msgDeposit.toRawMsg()).to.eqls(rawMsg); + }); + + it('Test appendTxBody MsgDeposit Tx signing', function () { + const hdKey = HDKey.fromMnemonic( + 'team school reopen cave banner pass autumn march immune album hockey region baby critic insect armor pigeon owner number velvet romance flight blame tone', + ); + + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const coin = new cro.Coin('12000500', Units.CRO); + + const msgDeposit = new cro.v2.gov.MsgDepositV2({ + proposalId: Big(1244000), + depositor: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + amount: [coin], + }); + + const anySigner = { + publicKey: keyPair.getPubKey(), + accountNumber: new Big(1250), + accountSequence: new Big(0), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(msgDeposit).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.encode().toHexString(); + expect(signedTxHex).to.be.eql( + '0a730a710a1e2f636f736d6f732e676f762e763162657461312e4d73674465706f736974124f08e0f64b122b7463726f3138346c7461326c7379753437767779703265387a6d746361336b3579713835703663347670331a1c0a08626173657463726f12103132303030353030303030303030303012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21030bf28c5f92c336db4703791691fa650fee408690b0a22c5ee4afb7e2508d32a712040a0208011800120410c09a0c1a40ba8c80028a85015ac737ca56603bef0a82e0fbd83f701ccbba02a4f381e5ee4a3d83af13cd02f1e9c1e8b386995d8468c2db1db73952c30fac6114004fe269c0', + ); + }); + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgDeposit', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.gov.MsgDepositV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.MsgDeposit but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + it('should throw Error when the `proposal_id` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + expect(() => cro.v2.gov.MsgDepositV2.fromCosmosMsgJSON(json)).to.throw('Invalid `proposal_id` in JSON.'); + }); + it('should throw Error when the `depositor` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + expect(() => cro.v2.gov.MsgDepositV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected property `depositor` to be of type `string` but received type `undefined` in object `options`', + ); + }); + it('should throw Error when the `amount` field is missing', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3"}'; + expect(() => cro.v2.gov.MsgDepositV2.fromCosmosMsgJSON(json)).to.throw('Invalid amount in the Msg.'); + }); + it('should return the MsgDeposit corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgDeposit","proposal_id":"1244000","depositor":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3","amount":[{"amount": "1234567890", "denom":"basetcro"}]}'; + const MsgDeposit = cro.v2.gov.MsgDepositV2.fromCosmosMsgJSON(json); + expect(MsgDeposit.depositor).to.eql('tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3'); + expect((MsgDeposit.proposalId as Big).toString()).to.eql('1244000'); + expect(MsgDeposit.amount[0].toCosmosCoin().amount).to.eql('1234567890'); + expect(MsgDeposit.amount[0].toCosmosCoin().denom).to.eql('basetcro'); + }); + }); +}); diff --git a/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.ts b/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.ts new file mode 100644 index 00000000..5ad4230b --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/v2.MsgDeposit.ts @@ -0,0 +1,114 @@ +/* eslint-disable camelcase */ +import Big from 'big.js'; +import Long from 'long'; +import ow from 'ow'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { ICoin } from '../../../../coin/coin'; +import { AddressType, validateAddress } from '../../../../utils/address'; +import { COSMOS_MSG_TYPEURL } from '../../../common/constants/typeurl'; +import { v2 } from '../../ow.types'; +import * as legacyAmino from '../../../../cosmos/amino'; +import { Amount } from '../../bank/msgsend'; + +export const msgDepositV2 = function (config: InitConfigurations) { + return class MsgDepositV2 implements CosmosMsg { + public proposalId: Big; + + public depositor: string; + + public amount: ICoin[]; + + /** + * Constructor to create a new MsgDeposit + * @param {MsgDepositOptions} options + * @returns {MsgDeposit} + * @throws {Error} when options is invalid + */ + constructor(options: MsgDepositOptions) { + ow(options, 'options', v2.owMsgDepositOptions); + + this.proposalId = options.proposalId; + this.depositor = options.depositor; + this.amount = options.amount; + + this.validate(); + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('Method not implemented.'); + } + + /** + * Returns the raw Msg representation of MsgDeposit + * @returns {Msg} + */ + toRawMsg(): Msg { + const proposal = Long.fromNumber(this.proposalId.toNumber(), true); + return { + typeUrl: COSMOS_MSG_TYPEURL.MsgDeposit, + value: { + proposalId: proposal, + depositor: this.depositor, + amount: this.amount.map((coin) => coin.toCosmosCoin()), + }, + }; + } + + /** + * Returns an instance of MsgDeposit + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgDeposit} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgDepositV2 { + const parsedMsg = JSON.parse(msgJsonStr) as MsgDepositRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgDeposit) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgDeposit} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.proposal_id) { + throw new Error('Invalid `proposal_id` in JSON.'); + } + + if (!parsedMsg.amount || parsedMsg.amount.length < 1) { + throw new Error('Invalid amount in the Msg.'); + } + + const cro = CroSDK({ network: config.network }); + + return new MsgDepositV2({ + proposalId: new Big(parsedMsg.proposal_id), + depositor: parsedMsg.depositor, + amount: parsedMsg.amount.map((coin) => cro.v2.CoinV2.fromCustomAmountDenom(coin.amount, coin.denom)), + }); + } + + validate() { + if ( + !validateAddress({ + address: this.depositor, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `depositor` doesnt match network selected'); + } + } + }; +}; + +export type MsgDepositOptions = { + proposalId: Big; + depositor: string; + amount: ICoin[]; +}; + +interface MsgDepositRaw { + '@type': string; + proposal_id: string; + depositor: string; + amount: Amount[]; +} diff --git a/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.spec.ts b/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.spec.ts new file mode 100644 index 00000000..595d3827 --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.spec.ts @@ -0,0 +1,209 @@ +import 'mocha'; +import { expect } from 'chai'; + +import Big from 'big.js'; +import { fuzzyDescribe } from '../../../../test/mocha-fuzzy/suite'; +import { Units } from '../../../../coin/coin'; +import { CroSDK } from '../../../../core/cro'; +import { HDKey } from '../../../../hdkey/hdkey'; +import { Secp256k1KeyPair } from '../../../../keypair/secp256k1'; +import { Network } from '../../../../network/network'; + +const PystaportTestNet: Network = { + defaultNodeUrl: '', + chainId: 'chainmaind', + addressPrefix: 'tcro', + validatorAddressPrefix: 'tcrocncl', + validatorPubKeyPrefix: 'tcrocnclconspub', + coin: { + baseDenom: 'basetcro', + croDenom: 'tcro', + }, + bip44Path: { + coinType: 1, + account: 0, + }, + rpcUrl: '', +}; +const cro = CroSDK({ network: PystaportTestNet }); + +describe('Testing MsgSubmitProposalV2 and its content types', function () { + const anyContent = new cro.v2.gov.proposal.CommunityPoolSpendProposalV2({ + title: 'Make new cosmos version backward compatible with pre release', + description: 'Lorem Ipsum ... A great proposal to increate backward compatibility and initial work on IBC', + recipient: 'tcro1nhe3qasy0ayhje95mtsvppyg67d3zswf04sda8', + amount: [new cro.Coin('1200', Units.BASE)], + }); + + fuzzyDescribe('should throw Error when MsgSubmitProposal options is invalid', function (fuzzy) { + const anyValidProposalSubmission = { + proposer: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + initialDeposit: [new cro.Coin('1200', Units.BASE)], + content: anyContent, + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidProposalSubmission)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.gov.MsgSubmitProposalV2(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + fuzzyDescribe('should throw Error when CommunityPoolSpendProposal options is invalid', function (fuzzy) { + const anyValidCommunityPoolSpendProposal = { + title: 'Make new cosmos version backward compatible with pre release', + description: 'Lorem Ipsum ... A great proposal to ...', + recipient: 'tcro1nhe3qasy0ayhje95mtsvppyg67d3zswf04sda8', + amount: [new cro.Coin('1200', Units.BASE)], + }; + const testRunner = fuzzy(fuzzy.ObjArg(anyValidCommunityPoolSpendProposal)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.v2.gov.proposal.CommunityPoolSpendProposalV2(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + fuzzyDescribe('should throw Error when ParamChangeProposal options is invalid', function (fuzzy) { + const anyValidParamChangeProposal = new cro.gov.proposal.ParamChangeProposal({ + title: 'Change a param to something more optimized', + description: 'Lorem Ipsum ... The param should be changed to something more optimized', + paramChanges: [ + { + subspace: 'staking', + key: 'MaxValidators', + value: '12', + }, + ], + }); + const testRunner = fuzzy(fuzzy.ObjArg(anyValidParamChangeProposal)); + + testRunner(function (options) { + if (options.valid) { + return; + } + expect(() => new cro.gov.proposal.ParamChangeProposal(options.value)).to.throw( + 'Expected `options` to be of type `object`', + ); + }); + }); + + it('Test Signing MsgSubmitProposal of CommunityPoolSpendProposal Type', function () { + const hdKey = HDKey.fromMnemonic( + 'guilt shield sting fluid wet east video business fold agree capital galaxy rapid almost melt piano taste guide spoil pull pigeon wood fit escape', + ); + + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const coin = new cro.Coin('120', Units.CRO); + + const communityPoolSpentContent = new cro.v2.gov.proposal.CommunityPoolSpendProposalV2({ + title: 'Make new cosmos version backward compatible with pre release', + description: 'Lorem Ipsum ... A great proposal to increate backward compatibility and initial work on IBC', + recipient: 'tcro1nhe3qasy0ayhje95mtsvppyg67d3zswf04sda8', + amount: [coin], + }); + + const msgSubmitProposalCommunitySpend = new cro.v2.gov.MsgSubmitProposalV2({ + proposer: 'tcro1nhe3qasy0ayhje95mtsvppyg67d3zswf04sda8', + initialDeposit: [coin], + content: communityPoolSpentContent, + }); + + const anySigner = { + publicKey: keyPair.getPubKey(), + accountNumber: new Big(6), + accountSequence: new Big(0), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(msgSubmitProposalCommunitySpend).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.getHexEncoded(); + expect(signedTx.getTxHash()).to.be.eq('2A177BC5B770C503096F5AA2CCF0B89EC8FC2D33C135630A38922266E6EE1EF1'); + expect(signedTxHex).to.be.eql( + '0a93030a90030a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c12e6020a9d020a372f636f736d6f732e646973747269627574696f6e2e763162657461312e436f6d6d756e697479506f6f6c5370656e6450726f706f73616c12e1010a3c4d616b65206e657720636f736d6f732076657273696f6e206261636b7761726420636f6d70617469626c652077697468207072652072656c65617365125b4c6f72656d20497073756d202e2e2e20412067726561742070726f706f73616c20746f20696e637265617465206261636b7761726420636f6d7061746962696c69747920616e6420696e697469616c20776f726b206f6e204942431a2b7463726f316e68653371617379306179686a6539356d74737670707967363764337a73776630347364613822170a08626173657463726f120b313230303030303030303012170a08626173657463726f120b31323030303030303030301a2b7463726f316e68653371617379306179686a6539356d74737670707967363764337a73776630347364613812580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2102046b34d613be4ad7e79dcadf13fb4ce8d8d7ffeee7b554c32e924906d4e5664b12040a0208011800120410c09a0c1a4044e8f4777960420e4759bbe527ba18ad47bafff359d02c1eabb5fa14dd68a7c15373f5773810104d56a4fcb43033cb354b4c4c92c568be99ed1f06422f7d7d60', + ); + }); + + it('Test Signing MsgSubmitProposal of ParamChangeProposal Type', function () { + const hdKey = HDKey.fromMnemonic( + 'order envelope snack half demand merry help obscure slogan like universe pond gain between brass settle pig float torch drama liberty grace check luxury', + ); + + const privKey = hdKey.derivePrivKey("m/44'/1'/0'/0/0"); + const keyPair = Secp256k1KeyPair.fromPrivKey(privKey); + + const coin = new cro.Coin('120', Units.CRO); + + const communityPoolSpentContent = new cro.gov.proposal.ParamChangeProposal({ + title: 'Change a param to something more optimized', + description: 'Lorem Ipsum ... The param should be changed to something more optimized', + paramChanges: [ + { + subspace: 'staking', + key: 'MaxValidators', + value: '12', + }, + ], + }); + + const msgSubmitProposalChangeParam = new cro.v2.gov.MsgSubmitProposalV2({ + proposer: 'tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a', + initialDeposit: [coin], + content: communityPoolSpentContent, + }); + + const anySigner = { + publicKey: keyPair.getPubKey(), + accountNumber: new Big(6), + accountSequence: new Big(0), + }; + + const rawTx = new cro.RawTransaction(); + + const signableTx = rawTx.appendMessage(msgSubmitProposalChangeParam).addSigner(anySigner).toSignable(); + + const signedTx = signableTx.setSignature(0, keyPair.sign(signableTx.toSignDocumentHash(0))).toSigned(); + + const signedTxHex = signedTx.getHexEncoded(); + expect(signedTx.getTxHash()).to.be.eq('AFEBA2DE9891AF22040359C8AACEF2836E8BF1276D66505DE36559F3E912EFF8'); + expect(signedTxHex).to.be.eql( + '0abc020ab9020a252f636f736d6f732e676f762e763162657461312e4d73675375626d697450726f706f73616c128f020ac6010a2e2f636f736d6f732e706172616d732e763162657461312e506172616d657465724368616e676550726f706f73616c1293010a2a4368616e6765206120706172616d20746f20736f6d657468696e67206d6f7265206f7074696d697a656412474c6f72656d20497073756d202e2e2e2054686520706172616d2073686f756c64206265206368616e67656420746f20736f6d657468696e67206d6f7265206f7074696d697a65641a1c0a077374616b696e67120d4d617856616c696461746f72731a02313212170a08626173657463726f120b31323030303030303030301a2b7463726f31347368343930776b3739646c7465613475646b39356b376d773430776d7666373770306c356112580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210280c5e37a2bc3e68cc7c4aac78eac8c769cf58ce269ecd4307427aa16c2ba05a412040a0208011800120410c09a0c1a4072bd47137d440036995ea6b5c4754b4f15609df2fdd17496d6c39f47d6663d0e51d171bcae92fc6078496cf657e2a705cd59b0d882cf0356463e57b26e285941', + ); + }); + + describe('fromCosmosJSON', function () { + it('should throw Error if the JSON is not a MsgSubmitProposal', function () { + const json = + '{ "@type": "/cosmos.bank.v1beta1.MsgCreateValidator", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }'; + expect(() => cro.v2.gov.MsgSubmitProposalV2.fromCosmosMsgJSON(json)).to.throw( + 'Expected /cosmos.gov.v1beta1.MsgSubmitProposal but got /cosmos.bank.v1beta1.MsgCreateValidator', + ); + }); + + it('should return the MsgSubmitProposal corresponding to the JSON', function () { + const json = + '{"@type":"/cosmos.gov.v1beta1.MsgSubmitProposal","initial_deposit":[{"denom":"basetcro","amount":"12000000000"}],"content":{"@type":"/cosmos.params.v1beta1.ParameterChangeProposal","changes":[{"subspace":"staking","key":"MaxValidators","value":"12"}],"title":"Change a param to something more optimized","description":"Lorem Ipsum ... The param should be changed to something more optimized"},"proposer":"tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a"}'; + const MsgDeposit = cro.v2.gov.MsgSubmitProposalV2.fromCosmosMsgJSON(json); + expect(MsgDeposit.initialDeposit[0].toCosmosCoin().amount).to.eql('12000000000'); + expect(MsgDeposit.initialDeposit[0].toCosmosCoin().denom).to.eql('basetcro'); + + expect(MsgDeposit.proposer).to.eql('tcro14sh490wk79dltea4udk95k7mw40wmvf77p0l5a'); + + expect(MsgDeposit.content.getEncoded().type_url).to.eql('/cosmos.params.v1beta1.ParameterChangeProposal'); + }); + }); +}); diff --git a/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.ts b/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.ts new file mode 100644 index 00000000..d6c4d3f0 --- /dev/null +++ b/lib/src/transaction/msg/v2/gov/v2.MsgSubmitProposal.ts @@ -0,0 +1,120 @@ +/* eslint-disable camelcase */ +import ow from 'ow'; +import { IMsgProposalContent } from '../../gov/IMsgProposalContent'; +import { InitConfigurations, CroSDK } from '../../../../core/cro'; +import { CosmosMsg } from '../../cosmosMsg'; +import { ICoin } from '../../../../coin/coin'; +import { v2 } from '../../ow.types'; +import { Msg } from '../../../../cosmos/v1beta1/types/msg'; +import { COSMOS_MSG_TYPEURL, typeUrlToMsgClassMapping } from '../../../common/constants/typeurl'; +import { validateAddress, AddressType } from '../../../../utils/address'; +import { Amount } from '../../bank/msgsend'; +import * as legacyAmino from '../../../../cosmos/amino'; + +export const msgSubmitProposalV2 = function (config: InitConfigurations) { + return class MsgSubmitProposalV2 implements CosmosMsg { + public readonly proposer: string; + + public readonly initialDeposit: ICoin[]; + + public readonly content: IMsgProposalContent; + + /** + * Constructor to create a new MsgSubmitProposal + * @param {ProposalOptions} options + * @returns {MsgSubmitProposal} + * @throws {Error} when options is invalid + */ + constructor(options: ProposalOptions) { + ow(options, 'options', v2.owMsgSubmitProposalOptions); + this.proposer = options.proposer; + this.initialDeposit = options.initialDeposit; + this.content = options.content; + + this.validate(); + } + + // eslint-disable-next-line class-methods-use-this + toRawAminoMsg(): legacyAmino.Msg { + throw new Error('Method not implemented.'); + } + + /** + * Returns the raw Msg representation of MsgSubmitProposal + * @returns {Msg} + */ + toRawMsg(): Msg { + return { + typeUrl: COSMOS_MSG_TYPEURL.MsgSubmitProposal, + value: { + proposer: this.proposer, + content: this.content.getEncoded(), + initialDeposit: this.initialDeposit.map((coin) => coin.toCosmosCoin()), + }, + }; + } + + /** + * Returns an instance of MsgSubmitProposal + * @param {string} msgJsonStr + * @param {Network} network + * @returns {MsgSubmitProposal} + */ + public static fromCosmosMsgJSON(msgJsonStr: string): MsgSubmitProposalV2 { + const parsedMsg = JSON.parse(msgJsonStr) as MsgSubmitProposalRaw; + if (parsedMsg['@type'] !== COSMOS_MSG_TYPEURL.MsgSubmitProposal) { + throw new Error(`Expected ${COSMOS_MSG_TYPEURL.MsgSubmitProposal} but got ${parsedMsg['@type']}`); + } + + if (!parsedMsg.initial_deposit || parsedMsg.initial_deposit.length < 1) { + throw new Error('Invalid initial_deposit in the Msg.'); + } + + const cro = CroSDK({ network: config.network }); + + const jsonContentRaw = parsedMsg.content; + const contentClassInstance = typeUrlToMsgClassMapping(cro, jsonContentRaw['@type']); + const nativeContentMsg: IMsgProposalContent = contentClassInstance.fromCosmosMsgJSON( + JSON.stringify(jsonContentRaw), + ); + + return new MsgSubmitProposalV2({ + proposer: parsedMsg.proposer, + initialDeposit: parsedMsg.initial_deposit.map((coin) => + cro.v2.CoinV2.fromCustomAmountDenom(coin.amount, coin.denom), + ), + content: nativeContentMsg, + }); + } + + validate() { + if ( + !validateAddress({ + address: this.proposer, + network: config.network, + type: AddressType.USER, + }) + ) { + throw new TypeError('Provided `proposer` doesnt match network selected'); + } + } + }; +}; + +export type ProposalOptions = { + proposer: string; + initialDeposit: ICoin[]; + content: IMsgProposalContent; +}; + +export interface MsgSubmitProposalRaw { + '@type': string; + initial_deposit: Amount[]; + content: Content; + proposer: string; +} + +export interface Content { + '@type': string; + [key: string]: any; +} diff --git a/lib/src/transaction/ow.types.ts b/lib/src/transaction/ow.types.ts index 992d56e7..bcce49f9 100644 --- a/lib/src/transaction/ow.types.ts +++ b/lib/src/transaction/ow.types.ts @@ -1,10 +1,9 @@ import ow from 'ow'; import Big from 'big.js'; - import { owAuthInfo, owTxBody } from '../cosmos/v1beta1/types/ow.types'; import { owNetwork } from '../network/ow.types'; import { owBig, owStrictObject } from '../ow.types'; -import { owBytes } from '../utils/bytes/ow.types'; +import { owBase64String, owBytes } from '../utils/bytes/ow.types'; import { isBigInteger } from '../utils/big'; import { SIGN_MODE } from './types'; @@ -12,8 +11,10 @@ export const owRawTransactionOptions = owStrictObject().exactShape({ network: owNetwork(), }); +const SignModeValidator = (value: number) => Object.values(SIGN_MODE).includes(value as any); + const validateSignMode = (value: number) => ({ - validator: Object.values(SIGN_MODE).includes(value as any), + validator: SignModeValidator(value), message: (label: string) => `Expected ${label} to be one of the sign mode, got \`${value}\``, }); @@ -49,9 +50,37 @@ export const owSignerAccount = () => signMode: owSignMode(), }); +export const owSignableTransactionParamsV2 = owStrictObject().exactShape({ + rawTxJSON: ow.string, + network: owNetwork(), + signerAccounts: ow.optional.array.ofType(owSignerAccount()), +}); + export const owSignableTransactionParams = owStrictObject().exactShape({ txBody: owTxBody(), authInfo: owAuthInfo(), network: owNetwork(), signerAccounts: ow.array.ofType(owSignerAccount()), }); + +export const owRawSignerAccount = () => + owStrictObject().exactShape({ + publicKey: owBase64String, + accountNumber: owIntegerString(), + signMode: owSignModeString(), + }); + +// eslint-disable-next-line no-self-compare +const isNaN = (v: any) => v !== v; + +export const owIntegerString = () => + ow.string.validate((value: string) => ({ + validator: !isNaN(parseInt(value, 10)) && Number.isInteger(parseFloat(value)), + message: (label: string) => `Expected ${label} to be an integer string, got \`${value}\``, + })); + +export const owSignModeString = () => + owIntegerString().validate((value: string) => ({ + validator: SignModeValidator(parseInt(value, 10)), + message: (label: string) => `Expected ${label} to be SignMode in string, got \`${value}\``, + })); diff --git a/lib/src/transaction/test.ts b/lib/src/transaction/test.ts index d5db0842..5c410608 100644 --- a/lib/src/transaction/test.ts +++ b/lib/src/transaction/test.ts @@ -6,11 +6,12 @@ import { Secp256k1KeyPair } from '../keypair/secp256k1'; import { Network } from '../network/network'; import { TransactionSigner } from './raw'; import { SignableTransaction, SignableTransactionParams } from './signable'; -import { cosmos } from '../cosmos/v1beta1/codec'; import { TxRaw } from '../cosmos/v1beta1/types/tx'; import { CroNetwork, CroSDK } from '../core/cro'; import { CosmosMsg } from './msg/cosmosMsg'; import { SIGN_MODE } from './types'; +import { cosmos } from '../cosmos/v1beta1/codec'; +import { SignableTransactionV2Params, SignableTransactionV2 } from './v2.signable'; const chance = new Chance(); @@ -37,6 +38,21 @@ export const CosmosMsgSuiteFactory = new Factory() }), ); +export const CosmosMsgSuiteFactoryV2 = new Factory() + .option('network', CroNetwork.Testnet) + .attr('keyPair', () => Secp256k1KeyPair.generateRandom()) + .attr('toAddress', 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3') + .attr( + 'message', + ['network', 'keyPair', 'toAddress'], + (_: Network, keyPair: Secp256k1KeyPair, toAddress: string): CosmosMsg => + new cro.v2.bank.MsgSendV2({ + fromAddress: new cro.Address(keyPair.getPubKey()).account(), + toAddress, + amount: [cro.Coin.fromBaseUnit(chance.integer({ min: 0 }).toString())], + }), + ); + export const TransactionSignerFactory = new Factory() .option('keyPair', () => Secp256k1KeyPair.generateRandom()) .attr('publicKey', ['keyPair'], (keyPair: Secp256k1KeyPair) => keyPair.getPubKey()) @@ -46,6 +62,76 @@ export const TransactionSignerFactory = new Factory() + .option('network', CroNetwork.Testnet) + .attr('keyPair', () => Secp256k1KeyPair.generateRandom()) + .attr( + 'params', + ['network', 'keyPair'], + (network: Network, keyPair: Secp256k1KeyPair): SignableTransactionV2Params => { + const pubKey = keyPair.getPubKey(); + + return { + rawTxJSON: JSON.stringify({ + body: { + messages: [ + { + '@type': '/cosmos.bank.v1beta1.MsgSend', + amount: [{ denom: 'basetcro', amount: '1200050000000000' }], + from_address: 'tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3', + to_address: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + }, + ], + memo: '', + timeout_height: '0', + extension_options: [], + non_critical_extension_options: [], + }, + auth_info: { + signer_infos: [ + { + public_key: { + '@type': '/cosmos.crypto.secp256k1.PubKey', + key: 'A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn', + }, + mode_info: { single: { mode: 'SIGN_MODE_DIRECT' } }, + sequence: '2', + }, + ], + fee: { amount: [], gas_limit: '200000', payer: '', granter: '' }, + }, + signatures: [], + }), + network, + signerAccounts: [ + { + publicKey: pubKey, + accountNumber: new Big(chance.integer({ min: 0 })), + signMode: SIGN_MODE.DIRECT, + }, + ], + }; + }, + ); + +export const txRawFactoryV2 = { + build: (): TxRaw => { + const { keyPair, params } = SignableTransactionParamsSuiteFactoryV2.build(); + const signableTx = new SignableTransactionV2(params); + const signDoc = signableTx.toSignDocumentHash(0); + + const signature = keyPair.sign(signDoc); + signableTx.setSignature(0, signature); + + return signableTx.getTxRaw(); + }, +}; + export type SignableTransactionParamsSuite = { network: Network; // option keyPair: Secp256k1KeyPair; diff --git a/lib/src/transaction/types.ts b/lib/src/transaction/types.ts index c66ae234..2a620651 100644 --- a/lib/src/transaction/types.ts +++ b/lib/src/transaction/types.ts @@ -9,8 +9,15 @@ export type SignerAccount = { }; export enum SIGN_MODE { - LEGACY_AMINO_JSON = 0, + UNSPECIFIED = 0, + TEXTUAL = 2, + LEGACY_AMINO_JSON = 127, DIRECT = 1, } export const EMPTY_SIGNATURE = Bytes.fromHexString(''); + +export const getSignModeFromValue = (targetValue: number): SIGN_MODE | undefined => { + const maybeSignMode = Object.values(SIGN_MODE).find((v) => v === targetValue) as SIGN_MODE | undefined; + return maybeSignMode || undefined; +}; diff --git a/lib/src/transaction/v2.raw.spec.ts b/lib/src/transaction/v2.raw.spec.ts new file mode 100644 index 00000000..39981d81 --- /dev/null +++ b/lib/src/transaction/v2.raw.spec.ts @@ -0,0 +1,496 @@ +import 'mocha'; +import { expect } from 'chai'; +import Big from 'big.js'; +import { fuzzyDescribe } from '../test/mocha-fuzzy/suite'; +import { CosmosMsgSuiteFactoryV2, TransactionSignerFactory, CosmosMsgSuiteFactory } from './test'; + +import { CroNetwork, CroSDK } from '../core/cro'; +import { Bytes } from '../utils/bytes/bytes'; +import { SignableTransactionV2 } from './v2.signable'; +import utils from '../utils'; +import { SIGN_MODE } from './types'; + +const cro = CroSDK({ network: CroNetwork.Testnet }); + +const anyTransaction = () => new cro.v2.RawTransactionV2(); + +describe('Transaction', function () { + context('v2 messages', function name() { + describe('appendTxBodyMessage', function () { + fuzzyDescribe('should throw Error when message is invalid', function (fuzzy) { + const { message: anyMessage } = CosmosMsgSuiteFactoryV2.build(); + const testRunner = fuzzy(fuzzy.ObjArg(anyMessage)); + + testRunner(function (msg) { + if (msg.valid) { + return; + } + const tx = anyTransaction(); + expect(() => tx.addMessage(msg.value)).to.throw('Expected `message` to be of type `object`'); + }); + }); + + it('should append message to txBody', function () { + const { message: anyMessage } = CosmosMsgSuiteFactoryV2.build(); + const tx = anyTransaction(); + tx.addMessage(anyMessage); + + let actualMessages = tx.getTxBody().value.messages; + expect(actualMessages.length).to.eq(1); + expect(actualMessages[0]).to.deep.eq(anyMessage); + + const { message: anotherMessage } = CosmosMsgSuiteFactoryV2.build(); + tx.addMessage(anotherMessage); + + actualMessages = tx.getTxBody().value.messages; + expect(actualMessages.length).to.eq(2); + expect(actualMessages).to.deep.eq([anyMessage, anotherMessage]); + }); + }); + + describe('addSigner', function () { + fuzzyDescribe('should throw Error when signer is invalid', function (fuzzy) { + const anyValidTransactionSigner = TransactionSignerFactory.build(); + const testRunner = fuzzy(fuzzy.ObjArg(anyValidTransactionSigner)); + + testRunner(function (signer) { + if (signer.valid) { + return; + } + const tx = anyTransaction(); + expect(() => tx.addSigner(signer.value)).to.throw('Expected `signer` to be of type `object`'); + }); + }); + + it('should append signer to AuthInfo', function () { + const anySigner = TransactionSignerFactory.build(); + + const tx = anyTransaction(); + tx.addSigner(anySigner); + let actualSignerInfos = tx.getAuthInfo().signerInfos; + expect(actualSignerInfos.length).to.eq(1); + expect(actualSignerInfos[0].publicKey).to.deep.eq(anySigner.publicKey); + expect(actualSignerInfos[0].sequence).to.deep.eq(anySigner.accountSequence); + + const anotherSigner = TransactionSignerFactory.build(); + tx.addSigner(anotherSigner); + actualSignerInfos = tx.getAuthInfo().signerInfos; + expect(actualSignerInfos.length).to.eq(2); + expect(actualSignerInfos[1].publicKey).to.deep.eq(anotherSigner.publicKey); + expect(actualSignerInfos[1].sequence).to.deep.eq(anotherSigner.accountSequence); + }); + + it('should set a single fee `amount` to AuthInfo', function () { + const tx = anyTransaction(); + tx.setFee(cro.Coin.fromBaseUnit('10000')); + + expect(tx.getAuthInfo().fee.amount).to.have.length(1); + expect(tx.getAuthInfo().fee!.amount![0].toCosmosCoin()).to.deep.eq({ + amount: '10000', + denom: 'basetcro', + }); + }); + + it('should append fee `amount` to AuthInfo', function () { + const tx = anyTransaction(); + tx.appendFeeAmount(cro.Coin.fromBaseUnit('88888')); + tx.appendFeeAmount(cro.Coin.fromBaseUnit('99999')); + + expect(tx.getAuthInfo().fee.amount).to.have.length(2); + expect(tx.getAuthInfo().fee!.amount![0].toCosmosCoin()).to.deep.eq({ + amount: '88888', + denom: 'basetcro', + }); + expect(tx.getAuthInfo().fee!.amount![1].toCosmosCoin()).to.deep.eq({ + amount: '99999', + denom: 'basetcro', + }); + }); + + it('should append signer to signerAccountNumbers', function () { + const anySigner = TransactionSignerFactory.build(); + + const tx = anyTransaction(); + tx.addSigner(anySigner); + + let actualSignerAccountNumbers = tx.getSignerAccounts(); + expect(actualSignerAccountNumbers.length).to.eq(1); + expect(actualSignerAccountNumbers[0]).to.deep.eq({ + publicKey: anySigner.publicKey, + accountNumber: anySigner.accountNumber, + signMode: anySigner.signMode, + }); + + const anotherSigner = TransactionSignerFactory.build(); + tx.addSigner(anotherSigner); + actualSignerAccountNumbers = tx.getSignerAccounts(); + expect(actualSignerAccountNumbers.length).to.eq(2); + expect(actualSignerAccountNumbers[1]).to.deep.eq({ + publicKey: anotherSigner.publicKey, + accountNumber: anotherSigner.accountNumber, + signMode: anotherSigner.signMode, + }); + }); + }); + + describe('toSignable', function () { + it('should throw Error when no message is added', function () { + const anySigner = TransactionSignerFactory.build(); + const tx = anyTransaction(); + + tx.addSigner(anySigner); + expect(() => tx.toSignable()).to.throw('Expected message in transaction, got none'); + }); + + it('should throw Error when no signer is added', function () { + const { message: anyMessage } = CosmosMsgSuiteFactoryV2.build(); + const tx = anyTransaction(); + + tx.addMessage(anyMessage); + + expect(() => tx.toSignable()).to.throw('Expected signer in transaction, got none'); + }); + + it('should return SignableTransactionV2', function () { + const { keyPair, message: anyMessage } = CosmosMsgSuiteFactoryV2.build(); + const anySigner = TransactionSignerFactory.build( + {}, + { + keyPair, + }, + ); + const tx = anyTransaction(); + + tx.addMessage(anyMessage).addSigner(anySigner); + + expect(tx.toSignable()).to.be.an.instanceOf(SignableTransactionV2); + }); + }); + + describe('toCosmosJSON', function () { + it('should not throw', function () { + const anyTx = anyTransaction(); + + expect(() => { + anyTx.toCosmosJSON(); + }).not.throw(); + }); + + it('should create correct JSON', function () { + const anyTx = anyTransaction(); + + anyTx.addMessage( + cro.bank.MsgSend.fromCosmosMsgJSON( + `{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }`, + ), + ); + + // { "body": { "messages": [{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "Ap/w6zWJiX6QCKLTt6jLM1sFJsUmBWaS6VUi7zxqqb0V" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "794129105682432" }], "fee": { "amount": [], "gas_limit": "8105066556817408", "payer": "", "granter": "" } }, "signatures": [""] } + + anyTx.addSigner({ + accountNumber: new Big(0), + accountSequence: new Big(79), + publicKey: Bytes.fromHexString( + '03a52c32db89513a187ceb00a4520b52dec06f583f2e12afcf1da78e370a5358e6', + ), + }); + + const parsedCosmosJson = JSON.parse(anyTx.toCosmosJSON()); + + expect(parsedCosmosJson).to.have.all.keys('body', 'auth_info', 'signatures'); + expect(parsedCosmosJson.body.messages.length).to.greaterThan(0); + expect(parsedCosmosJson.body).to.haveOwnProperty('memo'); + expect(parsedCosmosJson.body).to.haveOwnProperty('timeout_height'); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('signer_infos'); + expect(parsedCosmosJson.auth_info.signer_infos.length).to.greaterThan(0); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('fee'); + expect(parsedCosmosJson.auth_info.fee).to.haveOwnProperty('gas_limit'); + expect(parseInt(parsedCosmosJson.auth_info.fee.gas_limit, 10)).to.greaterThan(0); + }); + }); + }); + + context('v1 messages', function name() { + describe('appendTxBodyMessage', function () { + fuzzyDescribe('should throw Error when message is invalid', function (fuzzy) { + const { message: anyMessage } = CosmosMsgSuiteFactory.build(); + const testRunner = fuzzy(fuzzy.ObjArg(anyMessage)); + + testRunner(function (msg) { + if (msg.valid) { + return; + } + const tx = anyTransaction(); + expect(() => tx.addMessage(msg.value)).to.throw('Expected `message` to be of type `object`'); + }); + }); + + it('should append message to txBody', function () { + const { message: anyMessage } = CosmosMsgSuiteFactory.build(); + const tx = anyTransaction(); + tx.addMessage(anyMessage); + + let actualMessages = tx.getTxBody().value.messages; + expect(actualMessages.length).to.eq(1); + expect(actualMessages[0]).to.deep.eq(anyMessage); + + const { message: anotherMessage } = CosmosMsgSuiteFactory.build(); + tx.addMessage(anotherMessage); + + actualMessages = tx.getTxBody().value.messages; + expect(actualMessages.length).to.eq(2); + expect(actualMessages).to.deep.eq([anyMessage, anotherMessage]); + }); + }); + + describe('addSigner', function () { + fuzzyDescribe('should throw Error when signer is invalid', function (fuzzy) { + const anyValidTransactionSigner = TransactionSignerFactory.build(); + const testRunner = fuzzy(fuzzy.ObjArg(anyValidTransactionSigner)); + + testRunner(function (signer) { + if (signer.valid) { + return; + } + const tx = anyTransaction(); + expect(() => tx.addSigner(signer.value)).to.throw('Expected `signer` to be of type `object`'); + }); + }); + + it('should append signer to AuthInfo', function () { + const anySigner = TransactionSignerFactory.build(); + + const tx = anyTransaction(); + tx.addSigner(anySigner); + let actualSignerInfos = tx.getAuthInfo().signerInfos; + expect(actualSignerInfos.length).to.eq(1); + expect(actualSignerInfos[0].publicKey).to.deep.eq(anySigner.publicKey); + expect(actualSignerInfos[0].sequence).to.deep.eq(anySigner.accountSequence); + + const anotherSigner = TransactionSignerFactory.build(); + tx.addSigner(anotherSigner); + actualSignerInfos = tx.getAuthInfo().signerInfos; + expect(actualSignerInfos.length).to.eq(2); + expect(actualSignerInfos[1].publicKey).to.deep.eq(anotherSigner.publicKey); + expect(actualSignerInfos[1].sequence).to.deep.eq(anotherSigner.accountSequence); + }); + + it('should set a single fee `amount` to AuthInfo', function () { + const tx = anyTransaction(); + tx.setFee(cro.Coin.fromBaseUnit('10000')); + + expect(tx.getAuthInfo().fee.amount).to.have.length(1); + expect(tx.getAuthInfo().fee!.amount![0].toCosmosCoin()).to.deep.eq({ + amount: '10000', + denom: 'basetcro', + }); + }); + + it('should append fee `amount` to AuthInfo', function () { + const tx = anyTransaction(); + tx.appendFeeAmount(cro.Coin.fromBaseUnit('88888')); + tx.appendFeeAmount(cro.Coin.fromBaseUnit('99999')); + + expect(tx.getAuthInfo().fee.amount).to.have.length(2); + expect(tx.getAuthInfo().fee!.amount![0].toCosmosCoin()).to.deep.eq({ + amount: '88888', + denom: 'basetcro', + }); + expect(tx.getAuthInfo().fee!.amount![1].toCosmosCoin()).to.deep.eq({ + amount: '99999', + denom: 'basetcro', + }); + }); + + it('should append signer to signerAccountNumbers', function () { + const anySigner = TransactionSignerFactory.build(); + + const tx = anyTransaction(); + tx.addSigner(anySigner); + + let actualSignerAccountNumbers = tx.getSignerAccounts(); + expect(actualSignerAccountNumbers.length).to.eq(1); + expect(actualSignerAccountNumbers[0]).to.deep.eq({ + publicKey: anySigner.publicKey, + accountNumber: anySigner.accountNumber, + signMode: anySigner.signMode, + }); + + const anotherSigner = TransactionSignerFactory.build(); + tx.addSigner(anotherSigner); + actualSignerAccountNumbers = tx.getSignerAccounts(); + expect(actualSignerAccountNumbers.length).to.eq(2); + expect(actualSignerAccountNumbers[1]).to.deep.eq({ + publicKey: anotherSigner.publicKey, + accountNumber: anotherSigner.accountNumber, + signMode: anotherSigner.signMode, + }); + }); + }); + + describe('toSignable', function () { + it('should throw Error when no message is added', function () { + const anySigner = TransactionSignerFactory.build(); + const tx = anyTransaction(); + + tx.addSigner(anySigner); + expect(() => tx.toSignable()).to.throw('Expected message in transaction, got none'); + }); + + it('should throw Error when no signer is added', function () { + const { message: anyMessage } = CosmosMsgSuiteFactory.build(); + const tx = anyTransaction(); + + tx.addMessage(anyMessage); + + expect(() => tx.toSignable()).to.throw('Expected signer in transaction, got none'); + }); + + it('should return SignableTransactionV2', function () { + const { keyPair, message: anyMessage } = CosmosMsgSuiteFactory.build(); + const anySigner = TransactionSignerFactory.build( + {}, + { + keyPair, + }, + ); + const tx = anyTransaction(); + + tx.addMessage(anyMessage).addSigner(anySigner); + + expect(tx.toSignable()).to.be.an.instanceOf(SignableTransactionV2); + }); + }); + + describe('toCosmosJSON', function () { + it('should not throw', function () { + const anyTx = anyTransaction(); + expect(() => { + anyTx.toCosmosJSON(); + }).not.throw(); + }); + + it('should throw', function () { + const anyTx = anyTransaction(); + // @ts-ignore + anyTx.txBody = undefined; + expect(() => { + anyTx.toCosmosJSON(); + }).to.throw( + "error converting RawTransaction to Cosmos compatible JSON: TypeError: Cannot read property 'value' of undefined", + ); + }); + + it('should output correct `signer` array', function () { + const anyTx = anyTransaction(); + const { message: anyMessage } = CosmosMsgSuiteFactory.build(); + anyTx.addMessage(anyMessage); + anyTx.addSigner({ + publicKey: Bytes.fromHexString( + '03a52c32db89513a187ceb00a4520b52dec06f583f2e12afcf1da78e370a5358e6', + ), + accountNumber: new Big(1), + accountSequence: new Big(2), + }); + expect(anyTx.exportSignerAccounts()).to.eq( + `[{"publicKey":"A6UsMtuJUToYfOsApFILUt7Ab1g/LhKvzx2njjcKU1jm","accountNumber":"1","signMode":"1"}]`, + ); + }); + + it('should create correct JSON', function () { + const anyTx = anyTransaction(); + + anyTx.addMessage( + cro.bank.MsgSend.fromCosmosMsgJSON( + `{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }`, + ), + ); + + // { "body": { "messages": [{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "Ap/w6zWJiX6QCKLTt6jLM1sFJsUmBWaS6VUi7zxqqb0V" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "794129105682432" }], "fee": { "amount": [], "gas_limit": "8105066556817408", "payer": "", "granter": "" } }, "signatures": [""] } + + anyTx.addSigner({ + accountNumber: new Big(0), + accountSequence: new Big(79), + publicKey: Bytes.fromHexString( + '03a52c32db89513a187ceb00a4520b52dec06f583f2e12afcf1da78e370a5358e6', + ), + }); + + const parsedCosmosJson = JSON.parse(anyTx.toCosmosJSON()); + + expect(parsedCosmosJson).to.have.all.keys('body', 'auth_info', 'signatures'); + expect(parsedCosmosJson.body.messages.length).to.greaterThan(0); + expect(parsedCosmosJson.body).to.haveOwnProperty('memo'); + expect(parsedCosmosJson.body).to.haveOwnProperty('timeout_height'); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('signer_infos'); + expect(parsedCosmosJson.auth_info.signer_infos.length).to.greaterThan(0); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('fee'); + expect(parsedCosmosJson.auth_info.fee).to.haveOwnProperty('gas_limit'); + expect(parseInt(parsedCosmosJson.auth_info.fee.gas_limit, 10)).to.greaterThan(0); + }); + }); + }); + + describe('parseSignerAccounts', function () { + it('should throw Error when the raw data is not valid JSON', function () { + expect(() => cro.v2.RawTransactionV2.parseSignerAccounts('invalid JSON')).to.throw( + 'Invalid raw signer accounts', + ); + }); + + it('should throw Error when the raw data is not an array', function () { + expect(() => + cro.v2.RawTransactionV2.parseSignerAccounts( + '{"publicKey":"A+eBCWOq3Tv/CYQyLSafRnHG61Hf5tSBv8VGs7sbWoGN","accountNumber":"1","signMode":"1"}', + ), + ).to.throw('Expected `rawSignerAccounts` to be of type `array` but received type `Object`'); + }); + + it('should throw Error when the raw data is an array of incompatible type', function () { + expect(() => cro.v2.RawTransactionV2.parseSignerAccounts('[{"foo": "bar"}]')).to.throw( + '(array `rawSignerAccounts`) Expected property `publicKey` to be of type `string` but received type `undefined` in object `t`', + ); + }); + it('should throw Error when the `accounNumber` is an incompatible type', function () { + expect(() => + cro.v2.RawTransactionV2.parseSignerAccounts( + '[{"publicKey":"A+eBCWOq3Tv/CYQyLSafRnHG61Hf5tSBv8VGs7sbWoGN","accountNumber":"as","signMode":"1"}]', + ), + ).to.throw( + '(array `rawSignerAccounts`) Expected property string `accountNumber` to be an integer string, got `as` in object `t`', + ); + }); + it('should throw Error when the `signMode` is an invalid value', function () { + expect(() => + cro.v2.RawTransactionV2.parseSignerAccounts( + '[{"publicKey":"A+eBCWOq3Tv/CYQyLSafRnHG61Hf5tSBv8VGs7sbWoGN","accountNumber":"1","signMode":"100"}]', + ), + ).to.throw( + '(array `rawSignerAccounts`) Expected property string `signMode` to be SignMode in string, got `100` in object `t`', + ); + }); + it('should throw Error when the `pubKey` is an invalid value', function () { + expect(() => + cro.v2.RawTransactionV2.parseSignerAccounts( + '[{"publicKey":"A+eBCWOq3Tv","accountNumber":"1","signMode":"1"}]', + ), + ).to.throw( + '(array `rawSignerAccounts`) (string `publicKey`) Expected property valid base64 string of length be multiple of 4, got `"A+eBCWOq3Tv"` in object `t`', + ); + }); + + it('should work', function () { + expect( + cro.v2.RawTransactionV2.parseSignerAccounts( + '[{"publicKey":"A+eBCWOq3Tv/CYQyLSafRnHG61Hf5tSBv8VGs7sbWoGN","accountNumber":"1","signMode":"1"}]', + ), + ).to.deep.eq([ + { + publicKey: Bytes.fromBase64String('A+eBCWOq3Tv/CYQyLSafRnHG61Hf5tSBv8VGs7sbWoGN'), + accountNumber: utils.Big(1), + signMode: SIGN_MODE.DIRECT, + }, + ]); + }); + }); +}); diff --git a/lib/src/transaction/v2.raw.ts b/lib/src/transaction/v2.raw.ts new file mode 100644 index 00000000..0c6d6969 --- /dev/null +++ b/lib/src/transaction/v2.raw.ts @@ -0,0 +1,403 @@ +import ow from 'ow'; +import Big from 'big.js'; + +import { + AuthInfo as NativeAuthInfo, + TxBody as NativeTxbody, +} from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'; +import * as snakecaseKeys from 'snakecase-keys'; +import { cosmos } from '../cosmos/v1beta1/codec'; +import { AuthInfoV2, TxBody } from '../cosmos/v1beta1/types/tx'; +import { owRawSignerAccount, owRawTransactionSigner, owTimeoutHeight } from './ow.types'; +import { Bytes } from '../utils/bytes/bytes'; +import { isValidSepc256k1PublicKey } from '../utils/secp256k1'; +import { isBigInteger } from '../utils/big'; +import { Network } from '../network/network'; +import { getSignModeFromValue, SignerAccount, SIGN_MODE } from './types'; +import { cloneDeep } from '../utils/clone'; +import { CosmosMsg, owCosmosMsg } from './msg/cosmosMsg'; +import { InitConfigurations } from '../core/cro'; +import { ICoin } from '../coin/coin'; +import { owCoin } from '../coin/ow.types'; +import { getAuthInfoJson, getTxBodyJson, typeUrlToCosmosTransformer } from '../utils/txDecoder'; +import { protoEncodeAuthInfoV2 } from '../utils/protoBuf/encoder/v2.authInfo'; +import { protoEncodeTxBody } from '../utils/protoBuf/encoder/txBodyMessage'; +import { SignableTransactionV2 } from './v2.signable'; +import utils from '../utils'; + +export const rawTransactionV2 = function (config: InitConfigurations) { + return class RawTransactionV2 { + public readonly txBody: TxBody = { + typeUrl: '/cosmos.tx.v1beta1.TxBody', + value: { + messages: [], + memo: '', + timeoutHeight: '0', + }, + }; + + public readonly authInfo: AuthInfoV2 = { + signerInfos: [], + fee: { + gasLimit: new Big(200000), + }, + }; + + public readonly network: Network; + + public readonly signerAccounts: SignerAccount[] = []; + + /** + * Constructor to create a new Transaction + * @returns {RawTransactionV2} + * @throws {Error} when options is invalid + */ + public constructor() { + this.network = config.network; + } + + /** + * Add Cosmos message to transaction. The message orders will follow the add order. + * @param {CosmosMsg} message one of the supported Cosmos message + * @returns {RawTransactionV2} + * @throws {Error} when message is invalid + * @memberof RawTransactionV2 + */ + public addMessage(message: CosmosMsg): RawTransactionV2 { + ow(message, 'message', owCosmosMsg()); + + this.txBody.value.messages.push(message); + + return this; + } + + /** + * Append Cosmos MsgSend to transaction + * @param {CosmosMsg} message one of the supported Cosmos message + * @returns {RawTransactionV2} + * @throws {Error} when message is invalid + * @memberof RawTransactionV2 + */ + public appendMessage(message: CosmosMsg): RawTransactionV2 { + return this.addMessage(message); + } + + /** + * Returns the Chain-maind encoded JSON + * @memberof RawTransactionV2 + * @returns {unknown} Tx-Encoded JSON + */ + public toCosmosJSON(): string { + const txObject = { + body: Object.create({}), + authInfo: Object.create({}), + signatures: [], + }; + + try { + // Convert to native types + const authInfoBytes = protoEncodeAuthInfoV2(this.getAuthInfo()); + const txBodyBytes = protoEncodeTxBody(this.getTxBody()); + const nativeAuthInfo = NativeAuthInfo.decode(authInfoBytes.toUint8Array()); + const nativeTxBody = NativeTxbody.decode(txBodyBytes.toUint8Array()); + + // Construct JSON bodies individually + txObject.authInfo = getAuthInfoJson(nativeAuthInfo); + txObject.body = getTxBodyJson(nativeTxBody); + + // CamelCase to snake_case convertor + const stringifiedTx = JSON.stringify(snakecaseKeys.default(txObject)); + + // type_url to @type transformer for matching Cosmos JSON Format + const cosmosApiFormatTxJson = typeUrlToCosmosTransformer(stringifiedTx); + + return cosmosApiFormatTxJson; + } catch (error) { + throw new Error(`error converting RawTransaction to Cosmos compatible JSON: ${error.toString()}`); + } + } + + /** + * Export the added SignerAccounts in JSON. + * The result of this function can be imported into `SignableTransactionV2` instance + * @memberof RawTransactionV2 + */ + public exportSignerAccounts(): string { + return JSON.stringify( + this.getSignerAccounts().map((signerAccount) => { + return { + publicKey: signerAccount.publicKey.toBase64String(), + accountNumber: signerAccount.accountNumber.toString(), + signMode: signerAccount.signMode.toString(), + }; + }), + ); + } + + /** + * Parse SignerAccounts in JSON. + * The result of this function can be used to instantiate `SignableTransactionV2` + * @static + * @return {SignerAccount[]} + * @memberof RawTransactionV2 + */ + public static parseSignerAccounts(rawSignerAccounts: string): SignerAccount[] { + ow(rawSignerAccounts, 'rawSignerAccounts', ow.string); + + let signerAccounts: RawSignerAccount[]; + try { + signerAccounts = JSON.parse(rawSignerAccounts); + } catch (err) { + throw new Error(`Invalid raw signer accounts: ${err.toString()}`); + } + + ow(signerAccounts, 'rawSignerAccounts', ow.array.ofType(owRawSignerAccount())); + + return signerAccounts.map((account, i) => { + let publicKey: Bytes; + try { + publicKey = Bytes.fromBase64String(account.publicKey); + } catch (err) { + throw new Error(`Invalid signer account ${i}: invalid public key ${err.toString()}`); + } + + const parsedSignMode = parseInt(account.signMode, 10); + const signMode = getSignModeFromValue(parsedSignMode); + if (!signMode) { + throw new Error(`Invalid signer account ${i}: invalid sign mode ${account.signMode}`); + } + + return { + publicKey, + accountNumber: new utils.Big(account.accountNumber), + signMode, + }; + }); + } + + /** + * Set a memo value to the raw tx body + * @param {string} memo to be set to the raw tx body + * @returns {RawTransactionV2} + * @throws {Error} when memo is invalid + * @memberof Transaction + */ + public setMemo(memo: string): RawTransactionV2 { + ow(memo, 'memo', ow.string); + this.txBody.value.memo = memo; + + return this; + } + + /** + * Set gas limit value to tx + * @param {string} gasLimit to be set to the raw tx body, default value is 200_000 + * @returns {RawTransactionV2} + * @throws {Error} when gasLimit set is invalid + * @memberof Transaction + */ + public setGasLimit(gasLimit: string): RawTransactionV2 { + ow(gasLimit, 'gasLimit', ow.string); + try { + this.authInfo.fee.gasLimit = new Big(gasLimit); + } catch (err) { + throw new TypeError( + `Expected gasLimit value to be a base10 number represented as string, got \`${gasLimit}\``, + ); + } + + return this; + } + + /** + * Sets a `single` only fee amount to the raw tx + * @param {ICoin} fee to be set to the raw tx body + * @returns {RawTransactionV2} + * @throws {Error} when fee set is invalid + * @memberof Transaction + * @deprecated + */ + public setFee(fee: ICoin): RawTransactionV2 { + ow(fee, 'fee', owCoin()); + this.authInfo.fee.amount = [fee]; + + return this; + } + + /** + * Sets the fees to the raw tx + * @param {ICoin[]} list of fee to be set to the raw tx body + * @returns {RawTransactionV2} + * @throws {Error} when fee set is invalid + * @memberof Transaction + */ + public setFees(fees: ICoin[]): RawTransactionV2 { + ow(fees, 'fees', ow.array.ofType(owCoin())); + this.authInfo.fee.amount = fees; + + return this; + } + + /** + * Appends an `Amount` to the AuthInfo Fee Amount List + * @param {ICoin} feeAmount to be set to the raw tx body + * @returns {RawTransactionV2} + * @throws {Error} when fee set is invalid + * @memberof Transaction + */ + public appendFeeAmount(feeAmount: ICoin): RawTransactionV2 { + ow(feeAmount, 'feeAmount', owCoin()); + if (typeof this.authInfo.fee.amount === 'undefined') { + this.authInfo.fee.amount = []; + } + this.authInfo.fee.amount.push(feeAmount); + return this; + } + + /** + * Set a timeout param to tx body + * @param {string} timeoutHeight to best to the broad-casted tx + * @returns {RawTransactionV2} + * @throws {Error} when timeoutHeight is invalid + * @memberof Transaction + */ + public setTimeOutHeight(timeoutHeight: string): RawTransactionV2 { + ow(timeoutHeight, 'timeoutHeight', owTimeoutHeight); + this.txBody.value.timeoutHeight = timeoutHeight; + + return this; + } + + /** + * Add a signer to the transaction. The signer orders will follow the add order. + * @param {TransactionSigner} signer + * @param {Bytes} signer.publicKey signer public key + * @param {Big} signer.accountNumber account number of the signer address + * @param {Big} signer.accountSequence account sequence of the signer address + * @returns {RawTransactionV2} + * @throws {Error} when argument is invalid + * @memberof Transaction + */ + public addSigner(signer: TransactionSigner): RawTransactionV2 { + ow(signer, 'signer', owRawTransactionSigner); + const publicKeyResult = isValidSepc256k1PublicKey(signer.publicKey); + if (!publicKeyResult.ok) { + throw new TypeError(publicKeyResult.err('signer')); + } + + if (!isBigInteger(signer.accountNumber) && signer.accountNumber.gte(0)) { + throw new TypeError( + `Expected accountNumber to be of positive integer, got \`${signer.accountNumber}\``, + ); + } + if (!isBigInteger(signer.accountSequence) && signer.accountSequence.gte(0)) { + throw new TypeError( + `Expected accountSequence to be of positive integer, got \`${signer.accountSequence}\``, + ); + } + + let { signMode } = signer; + if (typeof signMode === 'undefined') { + signMode = SIGN_MODE.DIRECT; + } + + let cosmosSignMode: cosmos.tx.signing.v1beta1.SignMode; + switch (signMode) { + case SIGN_MODE.DIRECT: + cosmosSignMode = cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT; + break; + case SIGN_MODE.LEGACY_AMINO_JSON: + cosmosSignMode = cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON; + break; + default: + throw new Error(`Unsupported sign mode: ${signMode}`); + } + this.authInfo.signerInfos.push({ + publicKey: signer.publicKey, + // TODO: support multisig + modeInfo: { + single: { + mode: cosmosSignMode, + }, + }, + sequence: signer.accountSequence, + }); + this.signerAccounts.push({ + publicKey: signer.publicKey, + accountNumber: signer.accountNumber, + signMode, + }); + + return this; + } + + /** + * Returns signable transaction + * @returns {SignableTransactionV2} + * @throws {Error} when the transaction is incompleted + * @memberof RawTransaction + */ + public toSignable(): SignableTransactionV2 { + if (this.authInfo.signerInfos.length === 0) { + throw new Error('Expected signer in transaction, got none'); + } + if (this.txBody.value.messages.length === 0) { + throw new Error('Expected message in transaction, got none'); + } + return new SignableTransactionV2({ + rawTxJSON: this.toCosmosJSON(), + network: cloneDeep(this.network), + signerAccounts: cloneDeep(this.signerAccounts), + }); + } + + /** + * Returns TxBody + * @returns {TxBody} + * @memberof Transaction + */ + public getTxBody(): Readonly { + return this.txBody; + } + + /** + * Returns AuthInfo + * @returns {AuthInfoV2} + * @memberof Transaction + */ + public getAuthInfo(): Readonly { + return this.authInfo; + } + + /** + * Return network of the transaction + * @returns {string} + * @memberof Transaction + */ + public getNetwork(): Readonly { + return this.network; + } + + /** + * Return signer account numbers array + * @returns {SignerAccount[]} + * @memberof Transaction + */ + public getSignerAccounts(): Readonly { + return this.signerAccounts; + } + }; +}; + +export type TransactionSigner = { + publicKey: Bytes; + accountNumber: Big; + accountSequence: Big; + signMode?: SIGN_MODE; +}; + +type RawSignerAccount = { + publicKey: string; + accountNumber: string; + signMode: string; +}; diff --git a/lib/src/transaction/v2.signable.spec.ts b/lib/src/transaction/v2.signable.spec.ts new file mode 100644 index 00000000..a58a4603 --- /dev/null +++ b/lib/src/transaction/v2.signable.spec.ts @@ -0,0 +1,253 @@ +import 'mocha'; +import { expect } from 'chai'; +import { fuzzyDescribe } from '../test/mocha-fuzzy/suite'; +import { SignableTransactionParamsSuiteFactoryV2 } from './test'; +import { SignableTransactionV2 } from './v2.signable'; +import { Bytes } from '../utils/bytes/bytes'; +import { CroSDK, CroNetwork } from '../core/cro'; +import { typeUrlToMsgClassMapping, COSMOS_MSG_TYPEURL } from './common/constants/typeurl'; + +const anySignableTransaction = (): SignableTransactionV2 => { + const { params: anyParams } = SignableTransactionParamsSuiteFactoryV2.build(); + return new SignableTransactionV2(anyParams); +}; + +describe('SignableTransaction', function () { + describe('constructor', function () { + fuzzyDescribe('should throw Error when params is invalid', function (fuzzy) { + const { params: anyValidParams } = SignableTransactionParamsSuiteFactoryV2.build(); + const testRunner = fuzzy(fuzzy.ObjArg(anyValidParams)); + + testRunner(function (params) { + if (params.valid) { + return; + } + expect(() => new SignableTransactionV2(params.value)).to.throw( + 'Expected `params` to be of type `object`', + ); + }); + }); + }); + + describe('toSignDoc', function () { + fuzzyDescribe('should throw Error when index is invalid', function (fuzzy) { + const testRunner = fuzzy(fuzzy.NumberArg(0)); + + testRunner(function (index) { + if (index.valid) { + return; + } + + const anyTx = anySignableTransaction(); + expect(() => anyTx.toSignDoc(index.value)).to.throw('Expected `index` to be of type `number`'); + }); + }); + + it('should throw Error when index is out of signers size', function () { + const anyTx = anySignableTransaction(); + const outOfBoundIndex = 100; + + expect(() => anyTx.toSignDoc(outOfBoundIndex)).to.throw( + 'Expected `number `index`` to be within signer size', + ); + }); + + it('should return Bytes representation of SignDoc', function () { + const anyTx = anySignableTransaction(); + + expect(anyTx.toSignDoc(0)).to.be.an.instanceOf(Bytes); + }); + }); + + describe('toSignDocument', function () { + fuzzyDescribe('should throw Error when index is invalid', function (fuzzy) { + const testRunner = fuzzy(fuzzy.NumberArg(0)); + + testRunner(function (index) { + if (index.valid) { + return; + } + + const anyTx = anySignableTransaction(); + expect(() => anyTx.toSignDocument(index.value)).to.throw('Expected `index` to be of type `number`'); + }); + }); + + it('should throw Error when index is out of signers size', function () { + const anyTx = anySignableTransaction(); + const outOfBoundIndex = 100; + expect(() => anyTx.toSignDocument(outOfBoundIndex)).to.throw( + 'Expected `number `index`` to be within signer size', + ); + }); + + it('should return Bytes representation of SignDoc', function () { + const anyTx = anySignableTransaction(); + expect(anyTx.toSignDocument(0)).to.be.an.instanceOf(Bytes); + }); + }); + + describe('toSignDocumentHash', function () { + fuzzyDescribe('should throw Error when index is invalid', function (fuzzy) { + const testRunner = fuzzy(fuzzy.NumberArg(0)); + + testRunner(function (index) { + if (index.valid) { + return; + } + + const anyTx = anySignableTransaction(); + expect(() => anyTx.toSignDocumentHash(index.value)).to.throw('Expected `index` to be of type `number`'); + }); + }); + + it('should throw Error when index is out of signers size', function () { + const anyTx = anySignableTransaction(); + const outOfBoundIndex = 100; + + expect(() => anyTx.toSignDocumentHash(outOfBoundIndex)).to.throw( + 'Expected `number `index`` to be within signer size', + ); + }); + + it('should return Bytes representation of SignDoc', function () { + const anyTx = anySignableTransaction(); + + expect(anyTx.toSignDocumentHash(0)).to.be.an.instanceOf(Bytes); + }); + }); + + describe('setSignature', function () { + fuzzyDescribe('should throw Error when index is invalid', function (fuzzy) { + const anySignature = Bytes.fromHexString('111111'); + const testRunner = fuzzy(fuzzy.NumberArg(0), fuzzy.ObjArg(anySignature)); + + testRunner(function (index, signature) { + const anyTx = anySignableTransaction(); + if (!index.valid) { + expect(() => anyTx.setSignature(index.value, signature.value)).to.throw( + 'Expected `index` to be of type `number`', + ); + } else if (!signature.valid) { + expect(() => anyTx.setSignature(index.value, signature.value)).to.throw( + 'Expected `signature` to be of type `object`', + ); + } + }); + }); + + it('should throw Error when index is out of signers size', function () { + const { keyPair, params: anyParams } = SignableTransactionParamsSuiteFactoryV2.build(); + const anyTx = new SignableTransactionV2(anyParams); + const signature = keyPair.sign(anyTx.toSignDocumentHash(0)); + + const outOfBoundIndex = 100; + expect(() => anyTx.setSignature(outOfBoundIndex, signature)).to.throw( + 'Expected `number `index`` to be within signer size', + ); + }); + + it('should throw Error when signature is invalid', function () { + const anyTx = anySignableTransaction(); + const anyValidIndex = 0; + const invalidSignature = Bytes.fromUint8Array(new Uint8Array(64).fill(1)); + + expect(() => anyTx.setSignature(anyValidIndex, invalidSignature)).to.throw('Invalid signature'); + }); + + it('should set the signature', function () { + const { keyPair, params: anyParams } = SignableTransactionParamsSuiteFactoryV2.build(); + const anyTx = new SignableTransactionV2(anyParams); + const anyValidIndex = 0; + const signature = keyPair.sign(anyTx.toSignDocumentHash(0)); + + expect(anyTx.isIndexSigned(anyValidIndex)).to.eq(false); + + anyTx.setSignature(anyValidIndex, signature); + expect(anyTx.isIndexSigned(anyValidIndex)).to.eq(true); + }); + }); + describe('check `typeUrlToMsgClassMapping`', function () { + const croSdk = CroSDK({ network: CroNetwork.TestnetCroeseid3 }); + + [ + COSMOS_MSG_TYPEURL.MsgSend, + COSMOS_MSG_TYPEURL.distribution.MsgFundCommunityPool, + COSMOS_MSG_TYPEURL.distribution.MsgSetWithdrawAddress, + COSMOS_MSG_TYPEURL.MsgWithdrawDelegatorReward, + COSMOS_MSG_TYPEURL.MsgWithdrawValidatorCommission, + COSMOS_MSG_TYPEURL.MsgBeginRedelegate, + COSMOS_MSG_TYPEURL.MsgCreateValidator, + COSMOS_MSG_TYPEURL.MsgDelegate, + COSMOS_MSG_TYPEURL.MsgEditValidator, + COSMOS_MSG_TYPEURL.MsgUndelegate, + COSMOS_MSG_TYPEURL.MsgDeposit, + COSMOS_MSG_TYPEURL.MsgVote, + COSMOS_MSG_TYPEURL.MsgSubmitProposal, + COSMOS_MSG_TYPEURL.gov.TextProposal, + COSMOS_MSG_TYPEURL.upgrade.CancelSoftwareUpgradeProposal, + COSMOS_MSG_TYPEURL.upgrade.CommunityPoolSpendProposal, + COSMOS_MSG_TYPEURL.upgrade.ParameterChangeProposal, + COSMOS_MSG_TYPEURL.upgrade.SoftwareUpgradeProposal, + COSMOS_MSG_TYPEURL.ibc.MsgTransfer, + COSMOS_MSG_TYPEURL.ibc.MsgCreateClient, + COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient, + COSMOS_MSG_TYPEURL.ibc.MsgUpgradeClient, + COSMOS_MSG_TYPEURL.ibc.MsgSubmitMisbehaviour, + COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm, + COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry, + COSMOS_MSG_TYPEURL.nft.MsgIssueDenom, + COSMOS_MSG_TYPEURL.nft.MsgMintNFT, + COSMOS_MSG_TYPEURL.nft.MsgEditNFT, + COSMOS_MSG_TYPEURL.nft.MsgTransferNFT, + COSMOS_MSG_TYPEURL.nft.MsgBurnNFT, + ].forEach((typeUrl) => { + const classInstance = typeUrlToMsgClassMapping(croSdk, typeUrl); + expect(() => classInstance).to.not.throw(); + expect(classInstance).to.haveOwnProperty('fromCosmosMsgJSON'); + }); + + expect(() => typeUrlToMsgClassMapping(croSdk, 'unsupported_type_url')).to.throw( + 'unsupported_type_url not supported.', + ); + }); + describe('toCosmosJSON', function () { + it('should throw', function () { + const { params: anyParams } = SignableTransactionParamsSuiteFactoryV2.build(); + const anyTx = new SignableTransactionV2(anyParams); + // @ts-ignore + anyTx.txRaw.authInfoBytes = undefined; + + expect(() => { + anyTx.toCosmosJSON(); + }).to.throw('Error converting SignableTransactionV2 to Cosmos compatible JSON.'); + }); + + it('should not throw', function () { + const anyTx = anySignableTransaction(); + expect(() => { + anyTx.toCosmosJSON(); + }).not.throw(); + }); + + it('should create correct JSON', function () { + const anyTx = anySignableTransaction(); + const parsedCosmosJson = JSON.parse(anyTx.toCosmosJSON()); + // { "body": { "messages": [{ "@type": "/cosmos.bank.v1beta1. ", "amount": [{ "denom": "basetcro", "amount": "3478499933290496" }], "from_address": "tcro1x07kkkepfj2hl8etlcuqhej7jj6myqrp48y4hg", "to_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "Ap/w6zWJiX6QCKLTt6jLM1sFJsUmBWaS6VUi7zxqqb0V" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "794129105682432" }], "fee": { "amount": [], "gas_limit": "8105066556817408", "payer": "", "granter": "" } }, "signatures": [""] } + const expectedTxJSON = `{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"basetcro","amount":"1200050000000000"}],"from_address":"tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3","to_address":"tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3"}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"2"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[""]}`; + const anyTxJSONStr = anyTx.toCosmosJSON(); + expect(anyTxJSONStr).to.deep.equal(expectedTxJSON); + + expect(() => JSON.parse(anyTxJSONStr)).not.to.throw(); + + expect(parsedCosmosJson).to.have.all.keys('body', 'auth_info', 'signatures'); + expect(parsedCosmosJson.body.messages.length).to.greaterThan(0); + expect(parsedCosmosJson.body).to.haveOwnProperty('memo'); + expect(parsedCosmosJson.body).to.haveOwnProperty('timeout_height'); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('signer_infos'); + expect(parsedCosmosJson.auth_info).to.haveOwnProperty('fee'); + expect(parsedCosmosJson.auth_info.fee).to.haveOwnProperty('gas_limit'); + expect(parseInt(parsedCosmosJson.auth_info.fee.gas_limit, 10)).to.greaterThan(0); + }); + }); +}); diff --git a/lib/src/transaction/v2.signable.ts b/lib/src/transaction/v2.signable.ts new file mode 100644 index 00000000..95b6fa57 --- /dev/null +++ b/lib/src/transaction/v2.signable.ts @@ -0,0 +1,483 @@ +// Copyright © 2018–2020 IOV SAS (licensed under the Apache License, Version 2.0) +// Copyright © 2020 Confio UO (licensed under the Apache License, Version 2.0) +// Copyright © 2020 Simon Warta (licensed under the Apache License, Version 2.0) +// Modifications Copyright (c) 2018 - 2020, Foris Limited (licensed under the Apache License, Version 2.0) +import Big from 'big.js'; +import ow, { NumberPredicate } from 'ow'; +import Long from 'long'; +import secp256k1 from 'secp256k1'; + +import { + AuthInfo as NativeAuthInfo, + TxBody as NativeTxbody, +} from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'; +import * as snakecaseKeys from 'snakecase-keys'; +import { cosmos } from '../cosmos/v1beta1/codec'; +import { omitDefaults } from '../cosmos/v1beta1/adr27'; +import { SignerInfo, TxBody, TxRaw, AuthInfoV2 } from '../cosmos/v1beta1/types/tx'; +import { sha256 } from '../utils/hash'; +import { Network } from '../network/network'; +import { Bytes } from '../utils/bytes/bytes'; +import { EMPTY_SIGNATURE, SignerAccount, SIGN_MODE } from './types'; +import { owSignableTransactionParamsV2 } from './ow.types'; +import { owBytes } from '../utils/bytes/ow.types'; +import { SignedTransaction } from './signed'; +import * as legacyAmino from '../cosmos/amino'; +import { ICoin } from '../coin/coin'; +import { typeUrlToCosmosTransformer, getAuthInfoJson, getTxBodyJson, getSignaturesJson } from '../utils/txDecoder'; +import { owBig } from '../ow.types'; +import { CroSDK } from '../core/cro'; +import { CosmosTx } from '../cosmos/v1beta1/types/cosmostx'; +import { typeUrlToMsgClassMapping } from './common/constants/typeurl'; +import { protoEncodeTxBody } from '../utils/protoBuf/encoder/txBodyMessage'; +import { protoEncodeAuthInfoV2 } from '../utils/protoBuf/encoder/v2.authInfo'; +import { CosmosMsg } from './msg/cosmosMsg'; + +export const DEFAULT_GAS_LIMIT = 200_000; + +/** + * SignableTransactionV2 is a prepared transaction ready to be signed + */ +export class SignableTransactionV2 { + private txRaw: TxRaw; + + public readonly txBody: TxBody = { + typeUrl: '/cosmos.tx.v1beta1.TxBody', + value: { + messages: [], + memo: '', + timeoutHeight: '0', + }, + }; + + public readonly authInfo: AuthInfoV2 = { + signerInfos: [], + fee: { + gasLimit: new Big(DEFAULT_GAS_LIMIT), + }, + }; + + private network: Network; + + private signerAccounts: SignerAccount[] = []; + + /** + * Constructor to create a SignableTransactionV2 + * @param {SignableTransactionV2Params} params + * @returns {SignableTransactionV2} + * @throws {Error} when params is invalid or the transaction + */ + public constructor(params: SignableTransactionV2Params) { + ow(params, 'params', owSignableTransactionParamsV2); + this.network = params.network; + + const cosmosTxDecoded: CosmosTx = JSON.parse(params.rawTxJSON); + + const cosmosObj = cosmosTxDecoded; + + if (!cosmosObj.body) { + throw new Error('Missing body in Cosmos JSON'); + } + const { body } = cosmosObj; + const { memo } = body; + const timeoutHeight = body.timeout_height; + + if ( + (body.non_critical_extension_options && body.non_critical_extension_options.length > 0) || + (body.extension_options && body.extension_options.length > 0) + ) { + throw new Error( + "SignableTransactionV2 doesn't support 'nonCriticalExtensionOptions' or 'extensionOptions'", + ); + } + + if (!body.messages || body.messages.length < 1) { + throw new Error('Decoded TxBody does not have valid messages'); + } + const croSdk = CroSDK({ network: this.getNetwork() }); + + const txBody: TxBody = { + typeUrl: '/cosmos.tx.v1beta1.TxBody', + value: { + messages: [], + memo, + timeoutHeight, + }, + }; + body.messages.forEach((message) => { + const msgClassInstance = typeUrlToMsgClassMapping(croSdk, message['@type']); + const nativeMsg: CosmosMsg = msgClassInstance.fromCosmosMsgJSON(JSON.stringify(message)); + txBody.value.messages.push(nativeMsg); + }); + + if (typeof cosmosObj.auth_info === 'undefined') { + throw new Error('Decoded Tx does not have a valid `authInfo`'); + } + const cosmosAuthInfo = cosmosObj.auth_info; + const cosmosSignerInfos = cosmosAuthInfo.signer_infos; + const signerInfos: SignerInfo[] = []; + + cosmosSignerInfos.forEach((signerInfo) => { + // TODO: Support MultiSig in near future + const publicKeyObj = signerInfo.public_key as any; + if (!signerInfo.mode_info.single) { + throw new Error('SignableTransactionV2 only supports single signer mode.'); + } + + const pubKey = publicKeyObj.key; + let signMode: cosmos.tx.signing.v1beta1.SignMode; + switch (signerInfo.mode_info.single?.mode) { + case 'SIGN_MODE_DIRECT': + signMode = cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT; + break; + case 'SIGN_MODE_LEGACY_AMINO_JSON': + signMode = cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_LEGACY_AMINO_JSON; + break; + default: + throw new Error(`Unsupported sign mode: ${signerInfo.mode_info.single?.mode}`); + } + + signerInfos.push({ + publicKey: Bytes.fromBase64String(pubKey), + modeInfo: { + single: { + mode: signMode, + }, + }, + sequence: new Big(signerInfo.sequence), + }); + }); + + if (typeof cosmosAuthInfo.fee === 'undefined' || typeof cosmosAuthInfo.fee.amount === 'undefined') { + throw new Error('Decoded Tx AuthInfo does not have a valid `fee`'); + } + + const feeAmountList: ICoin[] = cosmosAuthInfo.fee.amount.map((feeAmount) => { + const feeAmountString = feeAmount.amount; + const feeAmountDenom = feeAmount.denom; + const feeAmountCoin = croSdk.v2.CoinV2.fromCustomAmountDenom(feeAmountString, feeAmountDenom); + return feeAmountCoin; + }); + + const authInfo: AuthInfoV2 = { + signerInfos, + fee: { + amount: feeAmountList || undefined, + gasLimit: new Big(cosmosAuthInfo.fee.gas_limit || DEFAULT_GAS_LIMIT), + payer: cosmosAuthInfo.fee.payer, + granter: cosmosAuthInfo.fee.granter, + }, + }; + + if (authInfo.signerInfos.length === 0) { + throw new TypeError('Expected signer in `signerInfos` of `authInfo` of `params`, got none'); + } + + this.txBody = txBody; + this.authInfo = authInfo; + + const signatures = + cosmosObj.signatures.length > 0 + ? cosmosObj.signatures.map((sigStr: string) => { + return Bytes.fromBase64String(sigStr); + }) + : authInfo.signerInfos.map(() => EMPTY_SIGNATURE); + + const bodyBytes = protoEncodeTxBody(txBody); + const authInfoBytes = protoEncodeAuthInfoV2(authInfo); + + // Initialising TxRaw + this.txRaw = { + bodyBytes, + authInfoBytes, + signatures, + }; + this.network = params.network; + + // signerAccounts[]: To keep backward compatibility we can import it explicitly as well + this.signerAccounts = params.signerAccounts || []; + } + + /** + * Imports SignerAccounts for the transaction. + * Note: It must be called before setting signature /converting to `Signed`/Setting AccountNumber + * @param signerAccounts + */ + public importSignerAccounts(signerAccounts: SignerAccount[]) { + this.signerAccounts = signerAccounts; + return this; + } + + /** + * Returns the SignDoc of the specified index before hashing + * @param {number} index index of the signer + * @returns {Bytes} + * @throws {Error} when index is invalid + * @memberof SignableTransactionV2 + */ + public toSignDocument(index: number): Bytes { + ow(index, 'index', this.owIndex()); + + const signMode = this.getSignerSignMode(index); + if (signMode === SIGN_MODE.DIRECT) { + return makeSignDoc( + this.txRaw.bodyBytes, + this.txRaw.authInfoBytes, + this.network.chainId, + this.signerAccounts[index].accountNumber, + ); + } + if (signMode === SIGN_MODE.LEGACY_AMINO_JSON) { + return makeLegacyAminoSignDoc( + legacyEncodeMsgs(this.txBody.value.messages), + legacyEncodeStdFee(this.authInfo.fee.amount, this.authInfo.fee.gasLimit), + this.network.chainId, + this.txBody.value.memo || '', + this.signerAccounts[index].accountNumber.toString(), + this.authInfo.signerInfos[index].sequence.toString(), + legacyEncodeTimeoutHeight(this.txBody.value.timeoutHeight), + ); + } + throw new Error(`Unrecognized sign mode: ${signMode}`); + } + + /** + * This function manually set the provided accountNumber at a specified index of signerAccountsList + * @param {number} index index of the signer + * @param {Big} accountNumber accountNumber to set + * @throws {Error} when index is invalid + * @memberof SignableTransactionV2 + */ + public setSignerAccountNumberAtIndex(index: number, accountNumber: Big): SignableTransactionV2 { + ow(accountNumber, 'accountNumber', owBig()); + ow(index, 'index', this.owIndex()); + + this.signerAccounts[index].accountNumber = accountNumber; + return this; + } + + /** + * Returns the SignDoc Hash of the specified index + * @param {number} index index of the signer + * @returns {Bytes} , length is 32 bytes, SHA256 hash + * @throws {Error} when index is invalid + * @memberof SignableTransactionV2 + */ + public toSignDocumentHash(index: number): Bytes { + const raw = this.toSignDocument(index); + const hash = sha256(raw); + return hash; + } + + /** + * DEPRECATED WARNING - this function will be deprecated + * Returns the SignDoc Hash of the specified index + * @param {number} index index of the signer + * @returns {Bytes} , length is 32 bytes, SHA256 hash + * @throws {Error} when index is invalid + * @memberof SignableTransactionV2 + */ + public toSignDoc(index: number): Bytes { + return this.toSignDocumentHash(index); + } + + /** + * Set signature of the specified signer index + * @param {number} index index to set the signature + * @param {Bytes} signature + * @throws {Error} when index or signature is invalid + * @memberof SignableTransactionV2 + */ + public setSignature(index: number, signature: Bytes): SignableTransactionV2 { + ow(index, 'index', this.owIndex()); + ow(signature, 'signature', owBytes()); + + const pubKey = this.signerAccounts[index].publicKey; + const signDocHash = this.toSignDocumentHash(index); + if (!secp256k1.ecdsaVerify(signature.toUint8Array(), signDocHash.toUint8Array(), pubKey.toUint8Array())) { + throw new Error('Invalid signature'); + } + + this.txRaw.signatures[index] = signature; + + return this; + } + + private getSignerSignMode(index: number): SIGN_MODE { + return this.signerAccounts[index].signMode; + } + + /** + * Returns true when the signer index is already signed + * @param {index} index + * @returns {boolean} + * @throws {Error} when index is invalid + * @memberof SignableTransactionV2 + */ + public isIndexSigned(index: number): boolean { + ow(index, 'index', this.owIndex()); + + return !this.txRaw.signatures[index].isEqual(EMPTY_SIGNATURE); + } + + private owIndex(): NumberPredicate { + return ow.number.integer.greaterThanOrEqual(0).validate((val) => ({ + validator: val < this.signerAccounts.length, + message: (label: string) => `Expected \`${label}\` to be within signer size, got \`${val}\``, + })); + } + + /** + * Returns TxRaw + * @returns {TxRaw} + * @memberof SignableTransactionV2 + */ + public getTxRaw(): Readonly { + return this.txRaw; + } + + /** + * Return network of the transaction + * @returns {string} + * @memberof Transaction + */ + public getNetwork(): Readonly { + return this.network; + } + + /** + * Return signed version of the transaction + * @returns {SignedTransaction} + * @memberof Transaction + */ + public toSigned(): SignedTransaction { + if (!this.isCompletelySigned()) { + throw new Error('Transaction is not completed signed'); + } + return new SignedTransaction(this.txRaw); + } + + /** + * Returns true when the transaction is completely signed + * @returns {boolean} + * @memberof Transaction + */ + public isCompletelySigned(): boolean { + return this.txRaw.signatures.every((signature) => !signature.isEqual(EMPTY_SIGNATURE)); + } + + /** + * Returns the Chain-maind encoded JSON containing SignerInfo + * @memberof SignableTransactionV2 + * @returns {unknown} Tx-Encoded JSON + */ + public toCosmosJSON(): string { + const txObject = { + body: Object.create({}), + authInfo: Object.create({}), + signatures: Object.create([[]]), + }; + + try { + // Convert to native types + const nativeAuthInfo = NativeAuthInfo.decode(this.txRaw.authInfoBytes.toUint8Array()); + const nativeTxBody = NativeTxbody.decode(this.txRaw.bodyBytes.toUint8Array()); + const nativeSignaturesList = this.getTxRaw().signatures.map((byteSig) => byteSig.toUint8Array()); + + // Construct JSON bodies individually + txObject.authInfo = getAuthInfoJson(nativeAuthInfo); + txObject.body = getTxBodyJson(nativeTxBody); + txObject.signatures = getSignaturesJson(nativeSignaturesList); + + // CamelCase to snake_case convertor + const stringifiedTx = JSON.stringify(snakecaseKeys.default(txObject)); + + // type_url to @type transformer for matching Cosmos JSON Format + const cosmosApiFormatTxJson = typeUrlToCosmosTransformer(stringifiedTx); + + return cosmosApiFormatTxJson; + } catch (error) { + throw new Error('Error converting SignableTransactionV2 to Cosmos compatible JSON.'); + } + } +} + +export type SignableTransactionV2Params = { + rawTxJSON: string; + signerAccounts?: SignerAccount[]; + network: Network; +}; + +/** + * Generate SignDoc binary bytes ready to be signed in direct mode + */ +const makeSignDoc = (txBodyBytes: Bytes, authInfoBytes: Bytes, chainId: string, accountNumber: Big): Bytes => { + const signDoc = omitDefaults({ + bodyBytes: txBodyBytes.toUint8Array(), + authInfoBytes: authInfoBytes.toUint8Array(), + chainId, + }); + + // Omit encoding the Long value when it's either 0, null or undefined to keep it consistent with backend encoding + // https://github.com/protobufjs/protobuf.js/issues/1138 + if (accountNumber.toNumber()) { + signDoc.accountNumber = Long.fromNumber(accountNumber.toNumber()); + } + const signDocProto = cosmos.tx.v1beta1.SignDoc.create(signDoc); + return Bytes.fromUint8Array(cosmos.tx.v1beta1.SignDoc.encode(signDocProto).finish()); +}; + +const legacyEncodeMsgs = (msgs: CosmosMsg[]): legacyAmino.Msg[] => { + return msgs.map((msg) => msg.toRawAminoMsg()); +}; + +const legacyEncodeStdFee = (feeAmountList: ICoin[] | undefined, gas: Big | undefined): legacyAmino.StdFee => { + return { + amount: feeAmountList ? feeAmountList.map((feeAmount) => feeAmount.toCosmosCoin()) : [], + gas: gas ? gas.toString() : DEFAULT_GAS_LIMIT.toString(), + }; +}; + +const legacyEncodeTimeoutHeight = (timeoutHeight: string | undefined): string | undefined => { + if (typeof timeoutHeight === 'undefined' || timeoutHeight === '0') { + return undefined; + } + + return timeoutHeight; +}; + +const makeLegacyAminoSignDoc = ( + msgs: readonly legacyAmino.Msg[], + fee: legacyAmino.StdFee, + chainId: string, + memo: string, + accountNumber: number | string, + sequence: number | string, + timeoutHeight?: string, +): Bytes => { + let encodedTimeoutHeight: string | undefined; + if (typeof timeoutHeight !== 'undefined') { + encodedTimeoutHeight = legacyAmino.Uint53.fromString(timeoutHeight.toString()).toString(); + } + + const stdSignDocBase: legacyAmino.StdSignDoc = { + chain_id: chainId, + account_number: legacyAmino.Uint53.fromString(accountNumber.toString()).toString(), + sequence: legacyAmino.Uint53.fromString(sequence.toString()).toString(), + fee, + msgs, + memo, + }; + let stdSignDoc: legacyAmino.StdSignDoc; + if (typeof timeoutHeight === 'undefined') { + stdSignDoc = { + ...stdSignDocBase, + }; + } else { + stdSignDoc = { + ...stdSignDocBase, + timeout_height: encodedTimeoutHeight, + }; + } + return Bytes.fromUint8Array(legacyAmino.toUtf8(legacyAmino.sortedJsonStringify(stdSignDoc))); +}; diff --git a/lib/src/transaction/v2.signed.spec.ts b/lib/src/transaction/v2.signed.spec.ts new file mode 100644 index 00000000..56faa47f --- /dev/null +++ b/lib/src/transaction/v2.signed.spec.ts @@ -0,0 +1,49 @@ +import 'mocha'; +import { expect } from 'chai'; +import { fuzzyDescribe } from '../test/mocha-fuzzy/suite'; +import { txRawFactoryV2 } from './test'; +import { SignedTransaction } from './signed'; +import { Bytes } from '../utils/bytes/bytes'; + +describe('SignedTransaction', function () { + describe('constructor', function () { + fuzzyDescribe('should throw Error when argument is invalid', function (fuzzy) { + const testRunner = fuzzy(fuzzy.ObjArg(txRawFactoryV2.build())); + + testRunner(function (txRaw) { + if (txRaw.valid) { + return; + } + expect(() => new SignedTransaction(txRaw.value)).to.throw('Expected `txRaw` to be of type `object`'); + }); + }); + }); + + describe('getTxHash', function () { + it('should return string', function () { + const anyTxRaw = txRawFactoryV2.build(); + + const signedTx = new SignedTransaction(anyTxRaw); + + expect(signedTx.getTxHash()).to.be.a('string'); + }); + + it('should return uppercase string', function () { + const anyTxRaw = txRawFactoryV2.build(); + + const signedTx = new SignedTransaction(anyTxRaw); + + expect(signedTx.getTxHash()).to.match(/^[A-F0-9]{64}$/); + }); + }); + + describe('encode', function () { + it('should return Bytes', function () { + const anyTxRaw = txRawFactoryV2.build(); + + const signedTx = new SignedTransaction(anyTxRaw); + + expect(signedTx.encode()).to.be.an.instanceOf(Bytes); + }); + }); +}); diff --git a/lib/src/utils/address.ts b/lib/src/utils/address.ts index 54710a38..90673b35 100644 --- a/lib/src/utils/address.ts +++ b/lib/src/utils/address.ts @@ -1,5 +1,7 @@ import bech32 from 'bech32'; import { Network } from '../network/network'; +import { Bytes } from './bytes/bytes'; +// import { toBase64 } from '@cosmjs/encoding'; export interface AddressValidationProperties { address: string; @@ -31,6 +33,26 @@ export function validateAddress(addressProps: AddressValidationProperties): bool return false; } } +export const isValidBech32Address = (addr: string): boolean => { + try { + bech32.decode(addr); + // May be maintain a whitelist Array list of possible prefixes. Such as [cosmos, cro, tcro] ..etc + return true; + } catch (error) { + return false; + } +}; + +export const assertAndReturnBech32AddressWordBytes = (addr: string): Bytes => { + try { + const { words } = bech32.decode(addr); + // May be maintain a whitelist Array list of possible prefixes. Such as [cosmos, cro, tcro] ..etc + // TODO: Revisit this when working with IBC or custom network addresses + return Bytes.fromUint8Array(new Uint8Array(bech32.fromWords(words))); + } catch (error) { + throw new Error('Invalid Bech32 address.'); + } +}; export class AddressValidator { public readonly params: AddressValidationProperties; diff --git a/lib/src/utils/protoBuf/encoder/txBodyMessage.ts b/lib/src/utils/protoBuf/encoder/txBodyMessage.ts new file mode 100644 index 00000000..1ad1673f --- /dev/null +++ b/lib/src/utils/protoBuf/encoder/txBodyMessage.ts @@ -0,0 +1,45 @@ +import Long from 'long'; +import { TxBody } from '../../../cosmos/v1beta1/types/tx'; +import { Bytes } from '../../bytes/bytes'; +import { google, cosmos } from '../../../cosmos/v1beta1/codec'; +import { Msg } from '../../../cosmos/v1beta1/types/msg'; +import { typeUrlMappings } from '../../../cosmos/v1beta1/types/typeurls'; + +/** + * Encode TxBody to protobuf binary + */ +export const protoEncodeTxBody = (txBody: TxBody): Bytes => { + const wrappedMessages = txBody.value.messages.map((message) => { + const rawMessage = message.toRawMsg(); + const messageBytes = protoEncodeTxBodyMessage(rawMessage); + return google.protobuf.Any.create({ + type_url: rawMessage.typeUrl, + value: messageBytes, + }); + }); + const txBodyProto = cosmos.tx.v1beta1.TxBody.create({ + ...txBody, + messages: wrappedMessages, + }); + + if (txBody.value.memo) { + txBodyProto.memo = txBody.value.memo; + } + + if (txBody.value.timeoutHeight && txBody.value.timeoutHeight !== '0') { + txBodyProto.timeoutHeight = Long.fromString(txBody.value.timeoutHeight, true); + } + return Bytes.fromUint8Array(cosmos.tx.v1beta1.TxBody.encode(txBodyProto).finish()); +}; + +/** + * Encode TxBody message to protobuf binary + */ +const protoEncodeTxBodyMessage = (message: Msg): Uint8Array => { + const type = typeUrlMappings[message.typeUrl]; + if (!type) { + throw new Error(`Unrecognized message type ${message.typeUrl}`); + } + const created = type.create(message.value); + return Uint8Array.from(type.encode(created).finish()); +}; diff --git a/lib/src/utils/protoBuf/encoder/v2.authInfo.ts b/lib/src/utils/protoBuf/encoder/v2.authInfo.ts new file mode 100644 index 00000000..b010d54a --- /dev/null +++ b/lib/src/utils/protoBuf/encoder/v2.authInfo.ts @@ -0,0 +1,48 @@ +import Long from 'long'; +import { AuthInfoV2 } from '../../../cosmos/v1beta1/types/tx'; +import { cosmos, google } from '../../../cosmos/v1beta1/codec'; +import { Bytes } from '../../bytes/bytes'; +import { DEFAULT_GAS_LIMIT } from '../../../transaction/v2.signable'; + +/** + * Encode AuthInfo message to protobuf binary + */ +export const protoEncodeAuthInfoV2 = (authInfo: AuthInfoV2): Bytes => { + const encodableAuthInfo: cosmos.tx.v1beta1.IAuthInfo = { + signerInfos: authInfo.signerInfos.map( + ({ publicKey, modeInfo, sequence }): cosmos.tx.v1beta1.ISignerInfo => ({ + publicKey: protoEncodePubKey(publicKey), + modeInfo, + sequence: sequence ? Long.fromString(sequence.toString()) : undefined, + }), + ), + fee: { + amount: + authInfo.fee.amount !== undefined + ? authInfo.fee.amount.map((feeAmount) => feeAmount.toCosmosCoin()) + : [], + gasLimit: protoEncodeGasLimitOrDefaultV2(authInfo), + }, + }; + return Bytes.fromUint8Array(cosmos.tx.v1beta1.AuthInfo.encode(encodableAuthInfo).finish()); +}; + +const protoEncodeGasLimitOrDefaultV2 = (authInfo: AuthInfoV2): Long.Long => { + const defaultGasLimit = Long.fromNumber(DEFAULT_GAS_LIMIT); + return authInfo.fee.gasLimit !== undefined && authInfo.fee.gasLimit !== null + ? Long.fromNumber(authInfo.fee.gasLimit.toNumber()) + : defaultGasLimit; +}; + +/** + * Encode public key to protobuf Any JS structure + */ +const protoEncodePubKey = (pubKey: Bytes): google.protobuf.IAny => { + const pubKeyProto = cosmos.crypto.secp256k1.PubKey.create({ + key: pubKey.toUint8Array(), + }); + return google.protobuf.Any.create({ + type_url: '/cosmos.crypto.secp256k1.PubKey', + value: Uint8Array.from(cosmos.crypto.secp256k1.PubKey.encode(pubKeyProto).finish()), + }); +}; diff --git a/lib/src/utils/timestamp.spec.ts b/lib/src/utils/timestamp.spec.ts new file mode 100644 index 00000000..0299533b --- /dev/null +++ b/lib/src/utils/timestamp.spec.ts @@ -0,0 +1,13 @@ +import 'mocha'; +import { expect } from 'chai'; +import Long from 'long'; +import { convertSecondsNanosToTZFormat } from './timestamp'; + +describe('convertTimestamp', function () { + it('should return correct formatted timestamp', function () { + convertSecondsNanosToTZFormat(Long.fromString('1627644878'), 10000000); + }); + it('should throw on invalid values', function () { + expect(() => convertSecondsNanosToTZFormat(Long.fromString('-1'), -1)).throw('Error converting timestamp.'); + }); +}); diff --git a/lib/src/utils/timestamp.ts b/lib/src/utils/timestamp.ts new file mode 100644 index 00000000..f1cd918e --- /dev/null +++ b/lib/src/utils/timestamp.ts @@ -0,0 +1,18 @@ +import moment from 'moment'; +import Long from 'long'; + +moment.suppressDeprecationWarnings = true; + +const convertSecondsNanosToTZFormat = (seconds: Long, nanos: number): string => { + const secondsToISO8601 = moment.unix(seconds.toNumber()).toISOString(); + const nanosToString = String(nanos); + const tsUptoMinutes = secondsToISO8601.split('.')[0]; + const finalTimestampString = `${tsUptoMinutes}.${nanosToString}Z`; + + if (moment(finalTimestampString).isValid()) { + return finalTimestampString; + } + throw new Error('Error converting timestamp.'); +}; + +export { convertSecondsNanosToTZFormat }; diff --git a/lib/src/utils/txDecoder.spec.ts b/lib/src/utils/txDecoder.spec.ts new file mode 100644 index 00000000..72fe737b --- /dev/null +++ b/lib/src/utils/txDecoder.spec.ts @@ -0,0 +1,297 @@ +/* eslint-disable */ +import 'mocha'; +import { expect } from 'chai'; +import { TxBody } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'; +import { Any } from '@cosmjs/stargate/build/codec/google/protobuf/any'; +import Long from 'long'; +import Big from 'big.js'; +import { TxDecoder } from './txDecoder'; +import { Bytes } from './bytes/bytes'; +import { Secp256k1KeyPair } from '../keypair/secp256k1'; +import { CroNetwork } from '../core/cro'; +import { SIGN_MODE } from '../transaction/types'; +import { SignableTransactionV2 } from '../transaction/v2.signable'; + +describe('TxDecoder', function () { + it('should throw on certain places', function () { + const txDecoder = new TxDecoder(); + + expect(() => { + txDecoder.fromHex( + '0A94010A91010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E6412710A2B7463726F31666D70726D30736A79366C7A396C6C7637726C746E307632617A7A7763777A766B326C73796E122B7463726F31373832676E39687A7161766563756B64617171636C76736E70636B346D747A3376777A70786C1A150A08626173657463726F120931303030303030303012690A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A210359A154BA210C489DA46626A4D631C6F8A471A2FBDA342164DD5FC4A158901F2612040A02087F180412150A100A08626173657463726F12043130303010904E1A40E812FBA1D50115CDDD534C79CDD5AD312182696CABB76F05B82B9557EE1A2842A5579B363F0A5F2E487F7228A81FBF81E125E58F264A29DA07', + ); + }).to.throw('Error decoding provided transaction hex.'); + + expect(() => { + txDecoder.fromHex(''); + }).to.throw('Received malformed transaction hex.'); + + expect(() => { + txDecoder.fromHex('INVALID_HEX'); + }).to.throw('Invalid Hex provided.'); + }); + + it('should decode correctly on empty auth_info and signatures', function () { + const txDecoder = new TxDecoder(); + + expect( + txDecoder + .fromHex( + '0a540a520a1b2f636f736d6f732e676f762e763162657461312e4d7367566f7465123308e0f64b122b7463726f3138346c7461326c7379753437767779703265387a6d746361336b35797138357036633476703318021200', + ) + .toCosmosJSON(), + ).to.equal(JSON.stringify(emptyAuthInfoTxObject)); + }); + + it('should throw on multi-signature', function () { + const txDecoder = new TxDecoder(); + const txBytes = Bytes.fromBase64String('CpQBCpEBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEnEKK3Rjcm8xMnlnd2R2ZnZndDRjNzJlMG11N2g2Z21mdjl5d2gzNHI5a2FjanISK3Rjcm8xMnlnd2R2ZnZndDRjNzJlMG11N2g2Z21mdjl5d2gzNHI5a2FjanIaFQoIYmFzZXRjcm8SCTEwMDAwMDAwMBKxAgqoAgqIAgopL2Nvc21vcy5jcnlwdG8ubXVsdGlzaWcuTGVnYWN5QW1pbm9QdWJLZXkS2gEIAxJGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQMmHiFA8uJvK1ug4G0W1/pPLiZ+Ora8MsrgRPO9ZUbAxBJGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQIXveFFPdAc68u/wp8cyiSeVxSSaieLvHDr/a6ut9gf2RJGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQILzYXwxGx61Az+IAaYhDpsTKIPgRwhIOEgePSj1Ae5vhIbEhkKBQgDEgHgEgQKAgh/EgQKAgh/EgQKAgh/EgQQwJoMGsYBCkAqnZ+kKTI2KNThqP4bi67jdF4vUItthnQjzzUbbpVrNS1L1JzRKAk8p3JAD/ZcJv5NrYH6nj/XA3BIY5aDGORRCkC+o5tK8zr8OZLuFIwias8t7v2U6u8XXrfNFL6uF3TyBSpvmW8BwCRZDFkwKosz6ryg6rObF6NCpheN0t+e7j+UCkCntQCqbypaLXA8RD0o7B/Gb5iQqD5jpOR0hd7rVQZ1xm+g6bKXS6Vd+vpNlzXmCUD1h8AxgEkKWxN5cQzL/0ZW'); + + expect(() => txDecoder.fromHex(txBytes.toHexString()).toCosmosJSON()).to.throw("Cannot read property 'length' of undefined"); + }); + + it('should throw on invalid tx body messages array', function () { + const txDecoder = new TxDecoder(); + const txDecoded = txDecoder.fromHex( + '0A94010A91010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E6412710A2B7463726F31666D70726D30736A79366C7A396C6C7637726C746E307632617A7A7763777A766B326C73796E122B7463726F31373832676E39687A7161766563756B64617171636C76736E70636B346D747A3376777A70786C1A150A08626173657463726F120931303030303030303012690A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A210359A154BA210C489DA46626A4D631C6F8A471A2FBDA342164DD5FC4A158901F2612040A02087F180412150A100A08626173657463726F12043130303010904E1A40E812FBA1D50115CDDD534C7675B838E6CE7169CDD5AD312182696CABB76F05B82B9557EE1A2842A5579B363F0A5F2E487F7228A81FBF81E125E58F264A29DA07', + ); + // @ts-ignore + txDecoded.libDecodedTxBody = TxBody.fromPartial({ + timeoutHeight: Long.fromNumber(0), + messages: [ + Any.fromPartial({ + typeUrl: '', + value: new Uint8Array(), + }), + ], + }); + expect(() => { + txDecoder.toCosmosJSON(); + }).to.throw('Missing type_url in Any'); + }); + + it('should decode and re-encode Cosmos JSON tx correctly', function () { + const signableTx = new SignableTransactionV2({ + rawTxJSON: JSON.stringify(cosmosTxObject), + network: CroNetwork.Testnet, + signerAccounts: [] + }) + signableTx.importSignerAccounts([{ accountNumber: new Big(0), publicKey: Bytes.fromBase64String('AiPJOV1BAT5kcMjSfai3WFBVT6raP+PoEmYMvfRTSoXX'), signMode: SIGN_MODE.DIRECT }]) + signableTx.setSignerAccountNumberAtIndex(0, new Big(179)); + const keyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('60300d38b56590fe22439d3eaa77d494ba9b5c93d2cec0b3639bdd51c3e3fa49'), + ); + const signature = keyPair.sign(signableTx.toSignDocumentHash(0)); + signableTx.setSignature(0, signature); + const encodedHex = signableTx.toSigned().encode().toHexString(); + const txDecoder = new TxDecoder(); + expect(txDecoder.fromHex(encodedHex).toCosmosJSON()).to.equal(JSON.stringify(cosmosTxObject)); + }); + + it('should decode and re-encode Cosmos JSON tx correctly for LEGACY MODE', function () { + const signableTx = new SignableTransactionV2({ + rawTxJSON: JSON.stringify(cosmosTxObject_Legacy), + network: CroNetwork.Testnet, + signerAccounts: [] + }) + signableTx.importSignerAccounts([{ accountNumber: new Big(0), publicKey: Bytes.fromBase64String('AiPJOV1BAT5kcMjSfai3WFBVT6raP+PoEmYMvfRTSoXX'), signMode: SIGN_MODE.LEGACY_AMINO_JSON }]) + signableTx.setSignerAccountNumberAtIndex(0, new Big(179)); + const keyPair = Secp256k1KeyPair.fromPrivKey( + Bytes.fromHexString('60300d38b56590fe22439d3eaa77d494ba9b5c93d2cec0b3639bdd51c3e3fa49'), + ); + const signature = keyPair.sign(signableTx.toSignDocumentHash(0)); + signableTx.setSignature(0, signature); + const encodedHex = signableTx.toSigned().encode().toHexString(); + const txDecoder = new TxDecoder(); + cosmosTxObject_Legacy.auth_info.fee.amount = [{ denom: 'basetcro', amount: '1000000000000' }]; + expect(txDecoder.fromHex(encodedHex).toCosmosJSON()).to.equal(JSON.stringify(cosmosTxObject_Legacy)); + }); + it('should decode the transaction correctly', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0a9b010a8c010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126c0a2b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a36383532717371733868783530122b7463726f31667a63727a61336a3466323637376a667578756c6b6733337a363835327173717338687835301a100a08626173657463726f120431303030120a616d696e6f2074657374126b0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a210223c9395d41013e6470c8d27da8b75850554faada3fe3e812660cbdf4534a85d712040a020801180112170a110a08626173657463726f1205313030303010a08d061a4031f4c489b98decb367972790747139c7706f54aafd9e5a3a5ada4f72c7b017646f1eb5cb1bdf518603d5d8991466a13c3f68844dcd9b168b5d4ca0cb5ea514bc', + ) + .toCosmosJSON(), + ).equal(JSON.stringify(cosmosTxObject)); + }); + + context('`MsgCreateValidator`', function () { + + it('should decode `MsgCreateValidator` correctly', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0ab4020ab1020a2a2f636f736d6f732e7374616b696e672e763162657461312e4d736743726561746556616c696461746f721282020a2a0a0a6869746573685465737412001a0022166869746573682e676f656c4063727970746f2e636f6d2a0012100a03302e311203302e321a04302e30311a0131222b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b63332a2f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e767232430a1d2f636f736d6f732e63727970746f2e656432353531392e5075624b657912220a20ca4c63b3e731a331e236ea6d5c81c448854a41c8f50f0828eecc0e5ecdc769333a1c0a08626173657463726f12103132303030353030303030303030303012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40f659741d05e997666313a98b545398937b6aa40d884f1f2bf5aed8a281b5118d1123d11e98db388a6cf303a2c41341b6602b685d967aebf4b74af67d767dbd45', + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", "description": { "moniker": "hiteshTest", "identity": "", "website": "", "security_contact": "hitesh.goel@crypto.com", "details": "" }, "commission": { "rate": "0.100000000000000000", "max_rate": "0.200000000000000000", "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1", "delegator_address": "tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3", "validator_address": "tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "ykxjs+cxozHiNuptXIHESIVKQcj1Dwgo7swOXs3HaTM=" }, "value": { "denom": "basetcro", "amount": "1200050000000000" } }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["9ll0HQXpl2ZjE6mLVFOYk3tqpA2ITx8r9a7YooG1EY0RI9EemNs4imzzA6LEE0G2YCtoXZZ66/S3SvZ9dn29RQ=="] })); + }); + + it('should decode `MsgCreateValidator` with no-decimal commission rates', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0ac1020abe020a2a2f636f736d6f732e7374616b696e672e763162657461312e4d736743726561746556616c696461746f72128f020a0c0a0a68697465736854657374123b0a1231303030303030303030303030303030303012123230303030303030303030303030303030301a1131303030303030303030303030303030301a0131222b7463726f313635747a63726832796c3833673871657178756567326735677a6775353779336665336b63332a2f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e767232430a1d2f636f736d6f732e63727970746f2e656432353531392e5075624b657912220a20ca4c63b3e731a331e236ea6d5c81c448854a41c8f50f0828eecc0e5ecdc769333a1c0a08626173657463726f12103132303030353030303030303030303012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40a9eed865dffb95abbc633512f17e7993d9e54678f205b8e9043112285d1965c62e75dd0ac3f50305aa35d26d3fa2ea8a4b0302e04a9cbe8fde994df114da46d5' + , + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/cosmos.staking.v1beta1.MsgCreateValidator", "description": { "moniker": "hiteshTest" }, "commission": { "rate": "0.100000000000000000", "max_rate": "0.200000000000000000", "max_change_rate": "0.010000000000000000" }, "min_self_delegation": "1", "delegator_address": "tcro165tzcrh2yl83g8qeqxueg2g5gzgu57y3fe3kc3", "validator_address": "tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr", "pubkey": { "@type": "/cosmos.crypto.ed25519.PubKey", "key": "ykxjs+cxozHiNuptXIHESIVKQcj1Dwgo7swOXs3HaTM=" }, "value": { "denom": "basetcro", "amount": "1200050000000000" } }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["qe7YZd/7lau8YzUS8X55k9nlRnjyBbjpBDESKF0ZZcYudd0Kw/UDBao10m0/ouqKSwMC4Eqcvo/emU3xFNpG1Q=="] })); + }); + }) + + context('`MsgEditValidator`', function () { + it('should decode `MsgEditValidator` correctly', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aa7010aa4010a282f636f736d6f732e7374616b696e672e763162657461312e4d73674564697456616c696461746f7212780a2a0a0a6869746573685465737412001a0022166869746573682e676f656c4063727970746f2e636f6d2a00122f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e76721a14302e3130303030303030303030303030303030302203312e3012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a4087e81b3b9706a35520778ed9099560c86b3ce8aaec3b384cc9720c89d3e044ab2601240a0d83f6a2e683e370c828b27dca8117de53eea269065c034e45e820f3', + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/cosmos.staking.v1beta1.MsgEditValidator", "description": { "moniker": "hiteshTest", "identity": "", "website": "", "security_contact": "hitesh.goel@crypto.com", "details": "" }, "validator_address": "tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr", "commission_rate": "0.100000000000000000", "min_self_delegation": "1.0" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["h+gbO5cGo1Ugd47ZCZVgyGs86KrsOzhMyXIMidPgRKsmASQKDYP2ouaD43DIKLJ9yoEX3lPuomkGXANORegg8w=="] })); + }); + it('should decode `MsgEditValidator` with no-decimal points', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aa5010aa2010a282f636f736d6f732e7374616b696e672e763162657461312e4d73674564697456616c696461746f7212760a2a0a0a6869746573685465737412001a0022166869746573682e676f656c4063727970746f2e636f6d2a00122f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e76721a123130303030303030303030303030303030302203312e3012580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40fe79a59e66813e4848d3c807ccf4a8f8b4cb91e0a4db97aa2e61dba4db2b4c9b100e4ebbc20dc7a08015a0bd6b1ef040be4a3e9584edb5f66b843d8c6b389432', + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/cosmos.staking.v1beta1.MsgEditValidator", "description": { "moniker": "hiteshTest", "identity": "", "website": "", "security_contact": "hitesh.goel@crypto.com", "details": "" }, "validator_address": "tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr", "commission_rate": "0.100000000000000000", "min_self_delegation": "1.0" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["/nmlnmaBPkhI08gHzPSo+LTLkeCk25eqLmHbpNsrTJsQDk67wg3HoIAVoL1rHvBAvko+lYTttfZrhD2MaziUMg=="] })); + }); + it('should decode `MsgEditValidator` with `null` commissionRate', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0a8c010a89010a282f636f736d6f732e7374616b696e672e763162657461312e4d73674564697456616c696461746f72125d0a2a0a0a6869746573685465737412001a0022166869746573682e676f656c4063727970746f2e636f6d2a00122f7463726f636e636c316a3770656a386b706c656d347774353070346866766e64687577356a707278787874656e767212580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a4022b05d1e95eda3a4a492d2bec1a48daa22cf618ab8e20d8a0db371c8989fcbe219376830131f16a5551bfd893f2f7c70bdffa8416e9781fe7707cc437e6cef45', + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/cosmos.staking.v1beta1.MsgEditValidator", "description": { "moniker": "hiteshTest", "identity": "", "website": "", "security_contact": "hitesh.goel@crypto.com", "details": "" }, "validator_address": "tcrocncl1j7pej8kplem4wt50p4hfvndhuw5jprxxxtenvr", "commission_rate": null, "min_self_delegation": null }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["IrBdHpXto6SkktK+waSNqiLPYYq44g2KDbNxyJify+IZN2gwEx8WpVUb/Yk/L3xwvf+oQW6Xgf53B8xDfmzvRQ=="] })); + }); + }) + + it('should decode the transaction correctly FOR CUSTOM MESSAGE PARAMS', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aaf010a94010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412740a2b7463726f3138346c7461326c7379753437767779703265387a6d746361336b357971383570366334767033122b7463726f3138746b3839646472346c6733326535387370356b66726d3065676c646c6366753430777738301a180a08626173657463726f120c39393032323733303630373512116c656761637920616d696e6f206a736f6e1880c2d72f126c0a520a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103c3d281a28592adce81bee3094f00eae26932cbc682fba239b90f47dac9fe703612040a02087f18b4820112160a100a08626173657463726f12043130303010a0c21e1a40af360b6fc4c6ee0129b16f09da17a126138cccacf2c5c67a9cd5aa79e911f4b30c069c07cbd863164dec3df102f5c622351d489354cc44a5c5f0c6e5614f5835', + ) + .toCosmosJSON(), + ).equal(JSON.stringify(nonZeroTimeoutHeight)); + }); + + it('should decode the transaction correctly FOR `MsgUpdateClient`', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aa7080aa4080a232f6962632e636f72652e636c69656e742e76312e4d7367557064617465436c69656e7412fc070a08636c69656e74496412c2070a262f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e4865616465721297070acb040a90030a04080b1000120b636f736d6f736875622d3418e9a2d702220608904e10e8072a480a20a16c45b687cff41c14f566bcf46b185e6a2aa1400b657530a2a9fe0de6f855c7122408011220133851ed2b01923ebc33d5e7bf04837af7ac4afdcd6130aa4a68791fb9b12e753220aad5b05f681ae03694bc7c96583a0259db7637617061c420e307102f5b303f023a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85542203e100a3435f7f0121710cd944379546aa2ce5f7e5d75e7463bc083dc1e2e560a4a203e100a3435f7f0121710cd944379546aa2ce5f7e5d75e7463bc083dc1e2e560a52200f2908883a105c793b74495eb7d6df2eea479ed7fc9349206a65cb0f9987a0b85a206b8a281cab99367e7568549ece0f715ab08125b2e6d635b02c5a71f015f4b54f6220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8556a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8557214cc87f56b58621811e2b5a47f38c6166e295ce36e12b50108e9a2d70210001a480a20a33f095d6a016c99c2cb3b5be268ddaf39e1b3d533ab5b3a65676595bdff750f122408011220494c5dbfc5bed9a6812e1615b9b9b823fd99c5efdf05d2854e65268ccf8c1f3f22620802121483f47d7747b0f633a6ba0df49b7dcf61f90aa1b01a0608904e10904e2240229b45ef7906e4fb9e63c938f769aeed49cf3d92be5d453eddfac00f1481450e7ec53127bcb93b7a4bf4443e37bdb3661cccc31a1ef58a1b6400a393dce22608129d010a4a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff01124a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff0118dcadc95b1a07080410eca1d702229d010a4a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff01124a0a1483f47d7747b0f633a6ba0df49b7dcf61f90aa1b012220a205b8e7d29b771f8b250edd2d50125bab007dda96a8d4525e7bdce77afd68ec7fa18d5eabd0620f9bcf4aaffffffffff0118dcadc95b1a2b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a4073919aa75f9f5e86b9d353ad5420f8b52199d600b5506c575f516e3964c86b3c5be9757f4a423492d52786657afdc2bce10a5aea7198dab1fd6d6c0d2463e521', + ) + .toCosmosJSON(), + ).equal(JSON.stringify({ "body": { "messages": [{ "@type": "/ibc.core.client.v1.MsgUpdateClient", "client_id": "clientId", "header": { "@type": "/ibc.lightclients.tendermint.v1.Header", "signed_header": { "header": { "version": { "block": "11", "app": "0" }, "chain_id": "cosmoshub-4", "height": "5624169", "time": "1970-01-01T02:46:40.1000Z", "last_block_id": { "hash": "oWxFtofP9BwU9Wa89GsYXmoqoUALZXUwoqn+Deb4Vcc=", "part_set_header": { "total": 1, "hash": "EzhR7SsBkj68M9XnvwSDevesSv3NYTCqSmh5H7mxLnU=" } }, "last_commit_hash": "qtWwX2ga4DaUvHyWWDoCWdt2N2FwYcQg4wcQL1swPwI=", "data_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", "validators_hash": "PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=", "next_validators_hash": "PhAKNDX38BIXEM2UQ3lUaqLOX35ddedGO8CD3B4uVgo=", "consensus_hash": "DykIiDoQXHk7dElet9bfLupHntf8k0kgamXLD5mHoLg=", "app_hash": "a4ooHKuZNn51aFSezg9xWrCBJbLm1jWwLFpx8BX0tU8=", "last_results_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", "evidence_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", "proposer_address": "zIf1a1hiGBHitaR/OMYWbilc424=" }, "commit": { "signatures": [{ "block_id_flag": "BLOCK_ID_FLAG_COMMIT", "validator_address": "g/R9d0ew9jOmug30m33PYfkKobA=", "timestamp": "1970-01-01T02:46:40.10000Z", "signature": "IptF73kG5PueY8k492mu7UnPPZK+XUU+3frADxSBRQ5+xTEnvLk7ekv0RD43vbNmHMzDGh71ihtkAKOT3OImCA==" }], "height": "5624169", "round": 0, "block_id": { "hash": "oz8JXWoBbJnCyztb4mjdrznhs9Uzq1s6ZWdllb3/dQ8=", "part_set_header": { "total": 1, "hash": "SUxdv8W+2aaBLhYVubm4I/2Zxe/fBdKFTmUmjM+MHz8=" } } } }, "validator_set": { "validators": [{ "address": "g/R9d0ew9jOmug30m33PYfkKobA=", "pub_key": { "ed25519": "W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=" }, "voting_power": "13595989", "proposer_priority": "-178446727" }], "proposer": { "address": "g/R9d0ew9jOmug30m33PYfkKobA=", "pub_key": { "ed25519": "W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=" }, "voting_power": "13595989", "proposer_priority": "-178446727" }, "total_voting_power": "192042716" }, "trusted_height": { "revision_number": "4", "revision_height": "5624044" }, "trusted_validators": { "validators": [{ "address": "g/R9d0ew9jOmug30m33PYfkKobA=", "pub_key": { "ed25519": "W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=" }, "voting_power": "13595989", "proposer_priority": "-178446727" }], "proposer": { "address": "g/R9d0ew9jOmug30m33PYfkKobA=", "pub_key": { "ed25519": "W459Kbdx+LJQ7dLVASW6sAfdqWqNRSXnvc53r9aOx/o=" }, "voting_power": "13595989", "proposer_priority": "-178446727" }, "total_voting_power": "192042716" } }, "signer": "tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["c5Gap1+fXoa501OtVCD4tSGZ1gC1UGxXX1FuOWTIazxb6XV/SkI0ktUnhmV6/cK84Qpa6nGY2rH9bWwNJGPlIQ=="] })); + }); + it('should decode the transaction correctly FOR `MsgCreateClient`', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0ab4020ab1020a232f6962632e636f72652e636c69656e742e76312e4d7367437265617465436c69656e741289020aa0010a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e74537461746512710a12746573746e65742d63726f65736569642d311204080110011a06086410a08d062206086410a08d062a06086410a08d063204086410643a040864106442280a0d08051005180520022a0300010212110a02010210011800200a2a03000102300518904e20904e4a036962635000580012370a2e2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436f6e73656e737573537461746512051a030102031a2b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40d4414a8cc77c85b9afcc53b76b4aaec7b793973c19f7a2a5b2c35c3d9fd80a0c51e11e77d42a190479e0a99ba02c7b957d5aec76afc9129835c178e19d42d237', + ) + .toCosmosJSON(), + ).equal(JSON.stringify({ "body": { "messages": [{ "@type": "/ibc.core.client.v1.MsgCreateClient", "client_state": { "@type": "/ibc.lightclients.tendermint.v1.ClientState", "proof_specs": [{ "leaf_spec": { "hash": "BITCOIN", "prehash_key": "BITCOIN", "prehash_value": "BITCOIN", "length": "VAR_RLP", "prefix": "AAEC" }, "inner_spec": { "child_order": [1, 2], "child_size": 1, "min_prefix_length": 0, "max_prefix_length": 10, "empty_child": null, "hash": "BITCOIN" }, "max_depth": 10000, "min_depth": 10000 }], "upgrade_path": ["ibc"], "chain_id": "testnet-croeseid-1", "trust_level": { "numerator": "1", "denominator": "1" }, "trusting_period": "100s", "unbonding_period": "100s", "max_clock_drift": "100s", "frozen_height": { "revision_number": "100", "revision_height": "100" }, "latest_height": { "revision_number": "100", "revision_height": "100" }, "allow_update_after_expiry": false, "allow_update_after_misbehaviour": false }, "consensus_state": { "@type": "/ibc.lightclients.tendermint.v1.ConsensusState", "next_validators_hash": "010203" }, "signer": "tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["1EFKjMd8hbmvzFO3a0qux7eTlzwZ96KlssNcPZ/YCgxR4R531CoZBHngqZugLHuVfVrsdq/JEpg1wXjhnULSNw=="] })); + }); + it('should decode the transaction correctly FOR `MsgConnectionOpenConfirm`', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aa4020aa1020a302f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e436f6e6669726d12ec010a0c636f6e6e656374696f6e2d3012a5010aea040ae7040a1a636f6e6e656374696f6e732f636f6e6e656374696f6e2d31303912610a1030372d74656e6465726d696e742d333912230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f524445524544180322260a0f30372d74656e6465726d696e742d30120c636f6e6e656374696f6e2d301a050a036962631a0e0801180120012a060002e6b1ae05222c080112280204e6b1ae052096d7f01a07080410eca1d702222b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40d229e4846fa7efaaa1574ac5bda529cc60f43bfbf621fbca66e099bcb3af34e4090f929b8d2ccaa871595a9e6dd5a3fe521717dc5bc510c5e7e9be8dfc7bfc35', + ) + .toCosmosJSON(), + ).equal(JSON.stringify({ "body": { "messages": [{ "@type": "/ibc.core.connection.v1.MsgConnectionOpenConfirm", "connection_id": "connection-0", "proof_ack": "CuoECucEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJhChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgDIiYKDzA3LXRlbmRlcm1pbnQtMBIMY29ubmVjdGlvbi0wGgUKA2liYxoOCAEYASABKgYAAuaxrgUiLAgBEigCBOaxrgUgltfw", "proof_height": { "revision_number": "4", "revision_height": "5624044" }, "signer": "tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["0inkhG+n76qhV0rFvaUpzGD0O/v2IfvKZuCZvLOvNOQJD5KbjSzKqHFZWp5t1aP+UhcX3FvFEMXn6b6N/Hv8NQ=="] })); + }); + it('should decode `MsgConnectionOpenTry` correctly', function () { + const txDecoder = new TxDecoder(); + expect( + txDecoder + .fromHex( + '0aa7170aa4170a2c2f6962632e636f72652e636f6e6e656374696f6e2e76312e4d7367436f6e6e656374696f6e4f70656e54727912f3160a0f30372d74656e6465726d696e742d3012001a0022290a1030372d74656e6465726d696e742d3339120e636f6e6e656374696f6e2d3130391a050a03696263280032210a0131120c4f524445524f524445524544120e4f52444552554e4f5244455245443a07080410ec98d70242b7060adc040ad9040a1a636f6e6e656374696f6e732f636f6e6e656374696f6e2d31303912530a1030372d74656e6465726d696e742d333912230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f524445524544180122180a0f30372d74656e6465726d696e742d301a050a036962631a0e0801180120012a060002d4b1ae05222c080112280204d4b1ae052096d7f0fdba34083b5898d347edfbfbbf1f968c471391f69cfe408f6bb0de743120222c080112280406d4b1ae05201f31bea2a2993df8b6bcd4b872255b71bfd833fb37c607c0e4b1fe6cd0d04ae920222c08011228060ad4b1ae052056618c26ac2faea333d1af7a21464c87df120ec0869a5bed6cabc0318853506120222c08011228081ad4b1ae0520cbcc6c857ab02218811af71be0f36ae4b22a9ced0e5076a28e485046a47b8eaa20222e080112070a26d4b1ae05201a21208b508c514e677c7f8e2eef7484eca3f4074c761e2e2e6e73b4144124b09b46d4222e080112070c58d4b1ae05201a2120a15b43e7827ea0c76bda049eb8af99d2704baeed8350bd671c266846aabd7dbe222d080112290e9c01d4b1ae0520bd6697f9c3d6330a0288543943d7aca3e0d5e1de5f1fb092a6af24d8a939f2aa20222f0801120810a602d4b1ae05201a21201106cd57f27f0f0e4d5b24c9ad69313e5ef3f0d6e58c79c8f80818e6341385bd222f0801120812de03d4b1ae05201a2120b7b204d60777389fa960aa53584a316f3074a5e98677afe79b9cd0c212609f62222d0801122916860cd4b1ae052027ff652d2c5831b7e5aa5eb00607d86409fcf379d1a59a93c197f077b9e6ead9200ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf244ae2070a87060a84060a24636c69656e74732f30372d74656e6465726d696e742d33392f636c69656e74537461746512c2010a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651292010a1a63727970746f2d6f72672d636861696e2d6d61696e6e65742d311204080110031a040880ea4922050880d493012a0308d80432003a05080110d74142190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a1075706772616465644942435374617465500158011a0e0801180120012a060002d4b1ae05222e080112070204d4b1ae05201a212021afa31f920ad80cc97dbc2d50930e8d1faf040e3d0d4c82d9c61a1c18cbf98c222c080112280408d4b1ae05209a7fb7f61f5e58d46262d327fe5f597cacab4515676e13858cf761ea91321d8020222e080112070610d4b1ae05201a2120e140aad320cab4acceecf4aa8c19a9ee76d401895cbf0db41fa4fb9d138ac48f222c080112280820d4b1ae0520f1d4c8cf0fd548dfc4908fd230fd1b438eb9727b172279bef1e2165dbe29280520222e080112070a2ad4b1ae05201a212019b0655aa367603d3360b41f4bc237b5010e049d2e06af546d887d17004c7374222e080112070c66d4b1ae05201a21200a9250a2fd891c0392530325d02db55ebeb42b24d892e953c44d7690d3cca8b6222d080112290eae01d4b1ae052061c211a10f3343cda38ffe3b508937880cd12a52ea748c4a6134c617c69d0ed320222d0801122910ea01d4b1ae0520e6f0c13c29cc4fbc0f941f1ab737ab4962ab6656949ccb91575a78661908643420222d0801122912ea02d4b1ae0520f18ad71aae009d201acf938be932c63b98d65eed2266db0c11e91f68f18c543f20222d0801122914a808d4b1ae052055a5492d665f23e1c1917938cff166ca217eb10a09b0c7729ffbf872e069566b20222f0801120816860cd4b1ae05201a21206b96c95da8f21f092c33a78391c23d1692167a841e5f8450f2578c43c9ce80f80ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf2452af070ad4050ad1050a2f636c69656e74732f30372d74656e6465726d696e742d33392f636f6e73656e7375735374617465732f312d383430371286010a2e2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436f6e73656e737573537461746512540a0c0893d8f2820610fe8edac60312220a202f91b0403dcac16a7e3c565e43c473d29ba3c49bdc1e7f4115dddcc0e160dbde1a2015d4a1bd346a1c32898a55ee9e4095e035f19b0fabbd98c7f3798948f564929e1a0e0801180120012a060002d4b1ae05222e080112070204d4b1ae05201a2120390e107da915f545496db87c621174feb7add0af41b18e2289a3c08c05faad5c222c080112280408d4b1ae0520cf12973db134c9f7acf0702199dc16b589c16601b91c639dbf61ab8dbead02f820222c080112280610d4b1ae052066f93e42fb9c9d9232aefb47b065fc61c42de229f88701679d0e21be3ff193d220222c080112280820d4b1ae0520f1d4c8cf0fd548dfc4908fd230fd1b438eb9727b172279bef1e2165dbe29280520222e080112070a2ad4b1ae05201a212019b0655aa367603d3360b41f4bc237b5010e049d2e06af546d887d17004c7374222e080112070c66d4b1ae05201a21200a9250a2fd891c0392530325d02db55ebeb42b24d892e953c44d7690d3cca8b6222d080112290eae01d4b1ae052061c211a10f3343cda38ffe3b508937880cd12a52ea748c4a6134c617c69d0ed320222d0801122910ea01d4b1ae0520e6f0c13c29cc4fbc0f941f1ab737ab4962ab6656949ccb91575a78661908643420222d0801122912ea02d4b1ae0520f18ad71aae009d201acf938be932c63b98d65eed2266db0c11e91f68f18c543f20222d0801122914a808d4b1ae052055a5492d665f23e1c1917938cff166ca217eb10a09b0c7729ffbf872e069566b20222f0801120816860cd4b1ae05201a21206b96c95da8f21f092c33a78391c23d1692167a841e5f8450f2578c43c9ce80f80ad5010ad2010a036962631220b9fe976fb3ce9220c113cedbd7a8e33654aa14b0ac6d52bd342c86fcdf8ebe7d1a090801180120012a0100222708011201011a20f956de7f0419af4109cc1974e1f137230abd2b8cb9f527775eecca1a88170f222225080112210105a5a5a4e19e08f87ae92010ca023a1a92629c6710ae1cbb28efc6e539aacf3e222508011221016c8defde2f514dfc0f414c1f216ee93cd8cbc36c7fb4362f9cd66431ed97e822222708011201011a20049597477e69780d27290c5a446e45d8ead38eab143dcfa559737b0819d5cf245a05080110d741622b7463726f313573667570643236737036716633376c6c3571367875663333306b37646639746e767271687412580a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103fd0d560b6c4aa1ca16721d039a192867c3457e19dad553edb98e7ba88b159c2712040a0208011802120410c09a0c1a40e8c37cdb1be95db31bd759e610619ec538f54c8873e6e2efc4f26fa52388a79976606e23f9329b8aaadb4c472bb2da36c58bd9a4101cad0bd36049cd59672529', + ) + .toCosmosJSON(), + ).to.deep.equal(JSON.stringify({ "body": { "messages": [{ "@type": "/ibc.core.connection.v1.MsgConnectionOpenTry", "counterparty_versions": [{ "features": ["ORDERORDERED", "ORDERUNORDERED"], "identifier": "1" }], "client_id": "07-tendermint-0", "previous_connection_id": "", "client_state": {}, "counterparty": { "client_id": "07-tendermint-39", "connection_id": "connection-109", "prefix": { "key_prefix": "aWJj" } }, "delay_period": "0", "proof_height": { "revision_number": "4", "revision_height": "5622892" }, "proof_init": "CtwECtkEChpjb25uZWN0aW9ucy9jb25uZWN0aW9uLTEwORJTChAwNy10ZW5kZXJtaW50LTM5EiMKATESDU9SREVSX09SREVSRUQSD09SREVSX1VOT1JERVJFRBgBIhgKDzA3LXRlbmRlcm1pbnQtMBoFCgNpYmMaDggBGAEgASoGAALUsa4FIiwIARIoAgTUsa4FIJbX8P26NAg7WJjTR+37+78floxHE5H2nP5Aj2uw3nQxICIsCAESKAQG1LGuBSAfMb6iopk9+La81LhyJVtxv9gz+zfGB8Dksf5s0NBK6SAiLAgBEigGCtSxrgUgVmGMJqwvrqMz0a96IUZMh98SDsCGmlvtbKvAMYhTUGEgIiwIARIoCBrUsa4FIMvMbIV6sCIYgRr3G+DzauSyKpztDlB2oo5IUEake46qICIuCAESBwom1LGuBSAaISCLUIxRTmd8f44u73SE7KP0B0x2Hi4ubnO0FEEksJtG1CIuCAESBwxY1LGuBSAaISChW0Pngn6gx2vaBJ64r5nScEuu7YNQvWccJmhGqr19viItCAESKQ6cAdSxrgUgvWaX+cPWMwoCiFQ5Q9eso+DV4d5fH7CSpq8k2Kk58qogIi8IARIIEKYC1LGuBSAaISARBs1X8n8PDk1bJMmtaTE+XvPw1uWMecj4CBjmNBOFvSIvCAESCBLeA9SxrgUgGiEgt7IE1gd3OJ+pYKpTWEoxbzB0pemGd6/nm5zQwhJgn2IiLQgBEikWhgzUsa4FICf/ZS0sWDG35apesAYH2GQJ/PN50aWak8GX8He55urZIArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", "proof_client": "CocGCoQGCiRjbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY2xpZW50U3RhdGUSwgEKKy9pYmMubGlnaHRjbGllbnRzLnRlbmRlcm1pbnQudjEuQ2xpZW50U3RhdGUSkgEKGmNyeXB0by1vcmctY2hhaW4tbWFpbm5ldC0xEgQIARADGgQIgOpJIgUIgNSTASoDCNgEMgA6BQgBENdBQhkKCQgBGAEgASoBABIMCgIAARAhGAQgDDABQhkKCQgBGAEgASoBABIMCgIAARAgGAEgATABSgd1cGdyYWRlShB1cGdyYWRlZElCQ1N0YXRlUAFYARoOCAEYASABKgYAAtSxrgUiLggBEgcCBNSxrgUgGiEgIa+jH5IK2AzJfbwtUJMOjR+vBA49DUyC2cYaHBjL+YwiLAgBEigECNSxrgUgmn+39h9eWNRiYtMn/l9ZfKyrRRVnbhOFjPdh6pEyHYAgIi4IARIHBhDUsa4FIBohIOFAqtMgyrSszuz0qowZqe521AGJXL8NtB+k+50TisSPIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", "proof_consensus": "CtQFCtEFCi9jbGllbnRzLzA3LXRlbmRlcm1pbnQtMzkvY29uc2Vuc3VzU3RhdGVzLzEtODQwNxKGAQouL2liYy5saWdodGNsaWVudHMudGVuZGVybWludC52MS5Db25zZW5zdXNTdGF0ZRJUCgwIk9jyggYQ/o7axgMSIgogL5GwQD3KwWp+PFZeQ8Rz0pujxJvcHn9BFd3cwOFg294aIBXUob00ahwyiYpV7p5AleA18ZsPq72Yx/N5iUj1ZJKeGg4IARgBIAEqBgAC1LGuBSIuCAESBwIE1LGuBSAaISA5DhB9qRX1RUltuHxiEXT+t63Qr0GxjiKJo8CMBfqtXCIsCAESKAQI1LGuBSDPEpc9sTTJ96zwcCGZ3Ba1icFmAbkcY52/YauNvq0C+CAiLAgBEigGENSxrgUgZvk+QvucnZIyrvtHsGX8YcQt4in4hwFnnQ4hvj/xk9IgIiwIARIoCCDUsa4FIPHUyM8P1UjfxJCP0jD9G0OOuXJ7FyJ5vvHiFl2+KSgFICIuCAESBwoq1LGuBSAaISAZsGVao2dgPTNgtB9Lwje1AQ4EnS4Gr1RtiH0XAExzdCIuCAESBwxm1LGuBSAaISAKklCi/YkcA5JTAyXQLbVevrQrJNiS6VPETXaQ08yotiItCAESKQ6uAdSxrgUgYcIRoQ8zQ82jj/47UIk3iAzRKlLqdIxKYTTGF8adDtMgIi0IARIpEOoB1LGuBSDm8ME8KcxPvA+UHxq3N6tJYqtmVpScy5FXWnhmGQhkNCAiLQgBEikS6gLUsa4FIPGK1xquAJ0gGs+Ti+kyxjuY1l7tImbbDBHpH2jxjFQ/ICItCAESKRSoCNSxrgUgVaVJLWZfI+HBkXk4z/FmyiF+sQoJsMdyn/v4cuBpVmsgIi8IARIIFoYM1LGuBSAaISBrlsldqPIfCSwzp4ORwj0WkhZ6hB5fhFDyV4xDyc6A+ArVAQrSAQoDaWJjEiC5/pdvs86SIMETztvXqOM2VKoUsKxtUr00LIb8346+fRoJCAEYASABKgEAIicIARIBARog+VbefwQZr0EJzBl04fE3Iwq9K4y59Sd3XuzKGogXDyIiJQgBEiEBBaWlpOGeCPh66SAQygI6GpJinGcQrhy7KO/G5Tmqzz4iJQgBEiEBbI3v3i9RTfwPQUwfIW7pPNjLw2x/tDYvnNZkMe2X6CIiJwgBEgEBGiAElZdHfml4DScpDFpEbkXY6tOOqxQ9z6VZc3sIGdXPJA==", "consensus_height": { "revision_number": "1", "revision_height": "8407" }, "signer": "tcro15sfupd26sp6qf37ll5q6xuf330k7df9tnvrqht" }], "memo": "", "timeout_height": "0", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A/0NVgtsSqHKFnIdA5oZKGfDRX4Z2tVT7bmOe6iLFZwn" }, "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, "sequence": "2" }], "fee": { "amount": [], "gas_limit": "200000", "payer": "", "granter": "" } }, "signatures": ["6MN82xvpXbMb11nmEGGexTj1TIhz5uLvxPJvpSOIp5l2YG4j+TKbiqrbTEcrsto2xYvZpBAcrQvTYEnNWWclKQ=="] })); + }); +}); + +let cosmosTxObject = { + body: { + messages: [ + { + '@type': '/cosmos.bank.v1beta1.MsgSend', + amount: [{ denom: 'basetcro', amount: '1000' }], + from_address: 'tcro1fzcrza3j4f2677jfuxulkg33z6852qsqs8hx50', + to_address: 'tcro1fzcrza3j4f2677jfuxulkg33z6852qsqs8hx50', + }, + ], + memo: 'amino test', + timeout_height: '0', + extension_options: [], + non_critical_extension_options: [], + }, + auth_info: { + signer_infos: [ + { + public_key: { + '@type': '/cosmos.crypto.secp256k1.PubKey', + key: 'AiPJOV1BAT5kcMjSfai3WFBVT6raP+PoEmYMvfRTSoXX', + }, + mode_info: { single: { mode: 'SIGN_MODE_DIRECT' } }, + sequence: '1', + }, + ], + fee: { amount: [{ denom: 'basetcro', amount: '10000' }], gas_limit: '100000', payer: '', granter: '' }, + }, + signatures: ['MfTEibmN7LNnlyeQdHE5x3BvVKr9nlo6WtpPcsewF2RvHrXLG99RhgPV2JkUZqE8P2iETc2bFotdTKDLXqUUvA=='], +}; + +let cosmosTxObject_Legacy = JSON.parse(JSON.stringify(cosmosTxObject)); +cosmosTxObject_Legacy.auth_info.signer_infos[0].mode_info.single.mode = 'SIGN_MODE_LEGACY_AMINO_JSON'; +cosmosTxObject_Legacy.auth_info.fee.amount = [{ denom: 'basetcro', amount: '1000000000000' }]; +cosmosTxObject_Legacy.signatures[0] = + 'xYN+yNCrRPCMZG1NsxAY93RmNnl7GpxnkZfz7MGoc9lXKHZiRd8WDVEqnGChTfvsBzU/2om+AGSYrJy/JyPc/w=='; + +let cosmosTxObject_UNRECOGNIZED = JSON.parse(JSON.stringify(cosmosTxObject)); +cosmosTxObject_UNRECOGNIZED.auth_info.signer_infos[0].mode_info.single.mode = 'UNRECOGNIZED'; + +let emptyAuthInfoTxObject = { + body: { + messages: [ + { + '@type': '/cosmos.gov.v1beta1.MsgVote', + proposal_id: "1244000", + voter: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', + option: 2, + }, + ], + memo: '', + timeout_height: '0', + extension_options: [], + non_critical_extension_options: [], + }, + auth_info: { signer_infos: [] }, + signatures: [], +}; + +const nonZeroTimeoutHeight = { "body": { "messages": [{ "@type": "/cosmos.bank.v1beta1.MsgSend", "amount": [{ "denom": "basetcro", "amount": "990227306075" }], "from_address": "tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3", "to_address": "tcro18tk89ddr4lg32e58sp5kfrm0egldlcfu40ww80" }], "memo": "legacy amino json", "timeout_height": "100000000", "extension_options": [], "non_critical_extension_options": [] }, "auth_info": { "signer_infos": [{ "public_key": { "@type": "/cosmos.crypto.secp256k1.PubKey", "key": "A8PSgaKFkq3Ogb7jCU8A6uJpMsvGgvuiObkPR9rJ/nA2" }, "mode_info": { "single": { "mode": "SIGN_MODE_LEGACY_AMINO_JSON" } }, "sequence": "16692" }], "fee": { "amount": [{ "denom": "basetcro", "amount": "1000" }], "gas_limit": "500000", "payer": "", "granter": "" } }, "signatures": ["rzYLb8TG7gEpsW8J2hehJhOMzKzyxcZ6nNWqeekR9LMMBpwHy9hjFk3sPfEC9cYiNR1Ik1TMRKXF8MblYU9YNQ=="] }; + +let multipleFeeAmountsTx = JSON.parse(JSON.stringify(cosmosTxObject)); +multipleFeeAmountsTx.auth_info.fee.amount = [ + { denom: 'tcro', amount: '10000' }, + { denom: 'tcro', amount: '10000' }, +]; diff --git a/lib/src/utils/txDecoder.ts b/lib/src/utils/txDecoder.ts index 21dbcc7c..527cedeb 100644 --- a/lib/src/utils/txDecoder.ts +++ b/lib/src/utils/txDecoder.ts @@ -1,11 +1,17 @@ import { Registry } from '@cosmjs/proto-signing'; import { toBase64, fromBase64 } from '@cosmjs/encoding'; import { AuthInfo, TxBody, SignerInfo, Tx } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'; - import * as snakecaseKeys from 'snakecase-keys'; -import { cosmos } from '../cosmos/v1beta1/codec/generated/codecimpl'; +import Long from 'long'; +import Big from 'big.js'; +import { cosmos, ics23, tendermintV2 } from '../cosmos/v1beta1/codec/generated/codecimpl'; import { Bytes } from './bytes/bytes'; import { typeUrlMappings } from '../cosmos/v1beta1/types/typeurls'; +import { COSMOS_MSG_TYPEURL } from '../transaction/common/constants/typeurl'; +import { convertSecondsNanosToTZFormat } from './timestamp'; + +const cosmJSRegistry = new Registry(Object.entries(typeUrlMappings)); +const DISPLAY_DIVISION_STRING = '1000000000000000000'; export class TxDecoder { private libDecodedTxBody!: TxBody; @@ -14,8 +20,6 @@ export class TxDecoder { private libDecodedSignatures!: Uint8Array[]; - private readonly cosmJSRegistry = new Registry(Object.entries(typeUrlMappings)); - /** * Creates TxDecoder instance * @constructor @@ -26,8 +30,8 @@ export class TxDecoder { this.libDecodedSignatures = Object.create([]); } - private isValidHex = (h: string) => { - const re = /[0-9A-Fa-f]/g; + private assertHex = (h: string) => { + const re = /^[a-fA-F0-9]+$/; if (!re.test(h)) { throw new TypeError('Invalid Hex provided.'); } @@ -42,9 +46,9 @@ export class TxDecoder { if (!txHex) { throw new TypeError(`Received malformed transaction hex.`); } + this.assertHex(txHex); const sanitisedTxHex = Bytes.clean0x(txHex); try { - this.isValidHex(sanitisedTxHex); const encodedTxBytes = Bytes.fromHexString(sanitisedTxHex).toUint8Array(); const libDecodedTx = Tx.decode(encodedTxBytes); this.libDecodedSignatures = libDecodedTx.signatures; @@ -52,7 +56,6 @@ export class TxDecoder { // Deep decoding for TxBody below this.libDecodedTxBody = libDecodedTx.body!; - return this; } catch (error) { throw new TypeError(`Error decoding provided transaction hex.`); @@ -66,84 +69,551 @@ export class TxDecoder { */ public toCosmosJSON() { const txObject = { - tx: { - body: Object.create({}), - authInfo: Object.create({}), - signatures: Object.create([[]]), - }, + body: Object.create({}), + authInfo: Object.create({}), + signatures: Object.create([[]]), }; - txObject.tx.body = this.getTxBodyJson(this.libDecodedTxBody); - txObject.tx.signatures = this.getSignaturesJson(this.libDecodedSignatures); - txObject.tx.authInfo = this.getAuthInfoJson(this.libDecodedAuthInfo); + txObject.body = getTxBodyJson(this.libDecodedTxBody); + txObject.signatures = getSignaturesJson(this.libDecodedSignatures); + txObject.authInfo = getAuthInfoJson(this.libDecodedAuthInfo); const stringifiedTx = JSON.stringify(snakecaseKeys.default(txObject)); - const cosmosApiFormatTxJson = this.typeUrlTransformer(stringifiedTx); + const cosmosApiFormatTxJson = typeUrlToCosmosTransformer(stringifiedTx); return cosmosApiFormatTxJson; } +} +export const getSignerInfoJson = (signerInfo: SignerInfo) => { + const stringifiedSignerInfo = JSON.stringify(SignerInfo.toJSON(signerInfo) as any); + const libParsedSignerInfo = JSON.parse(stringifiedSignerInfo); + const decodedPubkey: cosmos.crypto.ed25519.PubKey | cosmos.crypto.secp256k1.PubKey = cosmJSRegistry.decode({ + typeUrl: libParsedSignerInfo.publicKey?.typeUrl!, + value: fromBase64(libParsedSignerInfo.publicKey?.value!), + }); + + const obj = { ...libParsedSignerInfo }; + obj.publicKey = { typeUrl: libParsedSignerInfo.publicKey?.typeUrl!, key: toBase64(decodedPubkey.key) }; - private getTxBodyJson(txBody: TxBody) { - const txBodyStringified = JSON.stringify(TxBody.toJSON(txBody)); + return obj; +}; - const parsedTxBody = JSON.parse(txBodyStringified); - const obj = { ...parsedTxBody }; - obj.messages = txBody.messages.map(({ typeUrl, value }) => { - if (!typeUrl) { - throw new Error('Missing type_url in Any'); +export const getSignaturesJson = (signaturesArray: Uint8Array[]): string[] => { + let signatures: string[] = []; + // Adding Signatures array to final object + if (signaturesArray) { + signatures = signaturesArray.map((e) => toBase64(typeof e !== typeof undefined ? e : new Uint8Array())); + } + return signatures; +}; + +export const getTxBodyJson = (txBody: TxBody) => { + const txBodyStringified = JSON.stringify(TxBody.toJSON(txBody)); + const parsedTxBody = JSON.parse(txBodyStringified); + const obj = { ...parsedTxBody }; + obj.messages = txBody.messages.map(({ typeUrl, value }) => { + return decodeAnyType(typeUrl, value); + }); + return obj; +}; + +function decodeAnyType(typeUrl: string, value: Uint8Array) { + if (!typeUrl) { + throw new Error('Missing type_url in Any'); + } + if (!value) { + throw new Error('Missing value in Any'); + } + const decodedParams = cosmJSRegistry.decode({ typeUrl, value }); + handleCustomTypes(decodedParams); + const finalDecodedParams = handleSpecialParams(decodedParams, typeUrl); + return { typeUrl, ...finalDecodedParams }; +} + +function handleSpecialParams(decodedParams: any, typeUrl: string) { + // handle all `MsgSubmitProposal` related messages + const clonedDecodedParams = { ...decodedParams }; + if (decodedParams.content && Object.keys(decodedParams.content).length !== 0) { + clonedDecodedParams.content = decodeAnyType(decodedParams.content.type_url, decodedParams.content.value); + } + + // handle `MsgCreateValidator` + if (typeUrl === COSMOS_MSG_TYPEURL.MsgCreateValidator) { + clonedDecodedParams.pubkey = decodeAnyType(decodedParams.pubkey.type_url, decodedParams.pubkey.value); + clonedDecodedParams.pubkey.key = Bytes.fromUint8Array(clonedDecodedParams.pubkey.key).toBase64String(); + + // Check if the `commission` object values are represented already in `float` + /*eslint-disable */ + for (const key in decodedParams.commission) { + const rateString = decodedParams.commission[key]; + const splitRateByDecimal = rateString.split('.'); + + // if `string` has `NO` decimal place + if (splitRateByDecimal.length === 1) { + const rateToBig = new Big(rateString); + clonedDecodedParams.commission[key] = rateToBig.div(new Big(DISPLAY_DIVISION_STRING)).toFixed(18); } - if (!value) { - throw new Error('Missing value in Any'); + // If `string` has `ONE` decimal place + else if (splitRateByDecimal.length === 2) { + const rateToBig = new Big(rateString); + clonedDecodedParams.commission[key] = rateToBig.toFixed(18); } - const decodedParams = this.cosmJSRegistry.decode({ typeUrl, value }); - return { typeUrl, ...decodedParams }; - }); - return obj; + } } - private getSignaturesJson = (signaturesArray: Uint8Array[]): string[] => { - let signatures: string[] = []; - // Adding Signatures array to final object - if (signaturesArray) { - signatures = signaturesArray.map((e) => toBase64(typeof e !== typeof undefined ? e : new Uint8Array())); + // handle `MsgEditValidator` + if (typeUrl === COSMOS_MSG_TYPEURL.MsgEditValidator) { + if (decodedParams.commissionRate === "" || typeof decodedParams.commissionRate === "undefined") { + clonedDecodedParams.commissionRate = null; + } else { + const rateString = decodedParams.commissionRate; + const splitRateByDecimal = rateString.split('.'); + + // if `string` has `NO` decimal place + if (splitRateByDecimal.length === 1) { + const rateToBig = new Big(rateString); + clonedDecodedParams.commissionRate = rateToBig.div(new Big(DISPLAY_DIVISION_STRING)).toFixed(18); + } + // If `string` has `ONE` decimal place + else if (splitRateByDecimal.length === 2) { + const rateToBig = new Big(rateString); + clonedDecodedParams.commissionRate = rateToBig.toFixed(18); + } } - return signatures; - }; - private getAuthInfoJson(authInfo: AuthInfo) { - const authInfoStringified = JSON.stringify(AuthInfo.toJSON(authInfo)); + // use `null` in case minSelfDelegation is undefined + if (decodedParams.minSelfDelegation === "" || typeof decodedParams.minSelfDelegation === "undefined") { + clonedDecodedParams.minSelfDelegation = null; + } - const libParsedAuthInfo = JSON.parse(authInfoStringified); - const obj = { ...libParsedAuthInfo }; + } + /* eslint-enable */ - if (authInfo.signerInfos) { - obj.signerInfos = authInfo.signerInfos.map((e) => - typeof e !== typeof undefined ? this.getSignerInfoJson(e) : undefined, + if (typeUrl === COSMOS_MSG_TYPEURL.ibc.MsgCreateClient) { + // if clientState = `undefined` or `null` + if (decodedParams.clientState && Object.keys(decodedParams.clientState).length > 0) { + clonedDecodedParams.clientState = decodeAnyType( + decodedParams.clientState.type_url, + decodedParams.clientState.value, ); - } else { - obj.signerInfos = []; + + // handle trusting_period + if ( + clonedDecodedParams.clientState.trustingPeriod && + clonedDecodedParams.clientState.trustingPeriod.seconds + ) { + clonedDecodedParams.clientState.trustingPeriod = `${clonedDecodedParams.clientState.trustingPeriod.seconds}s`; + } + // handle unbonding_period + if ( + clonedDecodedParams.clientState.unbondingPeriod && + clonedDecodedParams.clientState.unbondingPeriod.seconds + ) { + clonedDecodedParams.clientState.unbondingPeriod = `${clonedDecodedParams.clientState.unbondingPeriod.seconds}s`; + } + // handle max_clock_drift + if ( + clonedDecodedParams.clientState.maxClockDrift && + clonedDecodedParams.clientState.maxClockDrift.seconds + ) { + clonedDecodedParams.clientState.maxClockDrift = `${clonedDecodedParams.clientState.maxClockDrift.seconds}s`; + } + + // handle proofSpecs + if (clonedDecodedParams.clientState.proofSpecs && clonedDecodedParams.clientState.proofSpecs.length > 0) { + clonedDecodedParams.clientState.proofSpecs = clonedDecodedParams.clientState.proofSpecs.map( + (proofSpec: any) => { + // handle `leafSpec` + if (proofSpec.leafSpec) { + if (proofSpec.leafSpec.hash) { + /* eslint-disable */ + proofSpec.leafSpec.hash = getHashOpStringFromValue(proofSpec.leafSpec.hash); + /* eslint-enable */ + } + if (proofSpec.leafSpec.prehashKey) { + /* eslint-disable */ + proofSpec.leafSpec.prehashKey = getHashOpStringFromValue(proofSpec.leafSpec.prehashKey); + /* eslint-enable */ + } + if (proofSpec.leafSpec.prehashValue) { + /* eslint-disable */ + proofSpec.leafSpec.prehashValue = getHashOpStringFromValue( + proofSpec.leafSpec.prehashValue, + ); + /* eslint-enable */ + } + if (proofSpec.leafSpec.length) { + /* eslint-disable */ + proofSpec.leafSpec.length = getLengthOpStringFromValue(proofSpec.leafSpec.length); + /* eslint-enable */ + } + if (proofSpec.leafSpec.prefix) { + /* eslint-disable */ + proofSpec.leafSpec.prefix = Bytes.fromUint8Array( + proofSpec.leafSpec.prefix, + ).toBase64String(); + /* eslint-enable */ + } + } + + // handle `innerSpec` + if (proofSpec.innerSpec) { + /* eslint-disable */ + proofSpec.innerSpec.emptyChild = null; // should be Bytes.fromUint8Array(proofSpec.innerSpec.emptyChild).toBase64String(); + /* eslint-enable */ + + if (proofSpec.innerSpec.hash) { + /* eslint-disable */ + proofSpec.innerSpec.hash = getHashOpStringFromValue(proofSpec.innerSpec.hash); + /* eslint-enable */ + } + } + + return proofSpec; + }, + ); + } } - return obj; + // if consensusState = `undefined` or `null` + if (decodedParams.consensusState && Object.keys(decodedParams.consensusState).length > 0) { + clonedDecodedParams.consensusState = decodeAnyType( + decodedParams.consensusState.type_url, + decodedParams.consensusState.value, + ); + + if (clonedDecodedParams.consensusState.nextValidatorsHash) { + // Below is a valid Tx Hash hence using .toHexString + clonedDecodedParams.consensusState.nextValidatorsHash = Bytes.fromUint8Array( + clonedDecodedParams.consensusState.nextValidatorsHash, + ).toHexString(); + } + } } - private getSignerInfoJson(signerInfo: SignerInfo) { - const stringifiedSignerInfo = JSON.stringify(SignerInfo.toJSON(signerInfo) as any); - const libParsedSignerInfo = JSON.parse(stringifiedSignerInfo); - const decodedPubkey: cosmos.crypto.ed25519.PubKey | cosmos.crypto.secp256k1.PubKey = this.cosmJSRegistry.decode( - { - typeUrl: libParsedSignerInfo.publicKey?.typeUrl!, - value: fromBase64(libParsedSignerInfo.publicKey?.value!), - }, - ); + if (typeUrl === COSMOS_MSG_TYPEURL.ibc.MsgUpdateClient) { + if (decodedParams.header && Object.keys(decodedParams.header).length > 0) { + clonedDecodedParams.header = decodeAnyType(decodedParams.header.type_url, decodedParams.header.value); + + if (clonedDecodedParams.header.signedHeader) { + const { signedHeader } = clonedDecodedParams.header; + + /** handle signed_header.header params */ + if (signedHeader.header) { + // handle signed_header.header.`time` + if (signedHeader.header.time) { + clonedDecodedParams.header.signedHeader.header.time = convertSecondsNanosToTZFormat( + Long.fromString(signedHeader.header.time.seconds), + signedHeader.header.time.nanos, + ); + } - const obj = { ...libParsedSignerInfo }; - obj.publicKey = { typeUrl: libParsedSignerInfo.publicKey?.typeUrl!, key: toBase64(decodedPubkey.key) }; + // handle signed_header.header.lastBlockId.hash + if (signedHeader.header.lastBlockId.hash) { + clonedDecodedParams.header.signedHeader.header.lastBlockId.hash = Bytes.fromUint8Array( + signedHeader.header.lastBlockId.hash, + ).toBase64String(); + } + // handle signed_header.header.lastBlockId.part_set_header.hash + if (signedHeader.header.lastBlockId.partSetHeader.hash) { + clonedDecodedParams.header.signedHeader.header.lastBlockId.partSetHeader.hash = Bytes.fromUint8Array( + signedHeader.header.lastBlockId.partSetHeader.hash, + ).toBase64String(); + } + // handle signed_header.header.last_commit_hash + if (signedHeader.header.lastCommitHash) { + clonedDecodedParams.header.signedHeader.header.lastCommitHash = Bytes.fromUint8Array( + signedHeader.header.lastCommitHash, + ).toBase64String(); + } + // handle signed_header.header.data_hash + if (signedHeader.header.dataHash) { + clonedDecodedParams.header.signedHeader.header.dataHash = Bytes.fromUint8Array( + signedHeader.header.dataHash, + ).toBase64String(); + } + // handle signed_header.header.validators_hash + if (signedHeader.header.validatorsHash) { + clonedDecodedParams.header.signedHeader.header.validatorsHash = Bytes.fromUint8Array( + signedHeader.header.validatorsHash, + ).toBase64String(); + } + // handle signed_header.header.next_validators_hash + if (signedHeader.header.nextValidatorsHash) { + clonedDecodedParams.header.signedHeader.header.nextValidatorsHash = Bytes.fromUint8Array( + signedHeader.header.nextValidatorsHash, + ).toBase64String(); + } + // handle signed_header.header.consensus_hash + if (signedHeader.header.consensusHash) { + clonedDecodedParams.header.signedHeader.header.consensusHash = Bytes.fromUint8Array( + signedHeader.header.consensusHash, + ).toBase64String(); + } + // handle signed_header.header.app_hash + if (signedHeader.header.appHash) { + clonedDecodedParams.header.signedHeader.header.appHash = Bytes.fromUint8Array( + signedHeader.header.appHash, + ).toBase64String(); + } + // handle signed_header.header.last_results_hash + if (signedHeader.header.lastResultsHash) { + clonedDecodedParams.header.signedHeader.header.lastResultsHash = Bytes.fromUint8Array( + signedHeader.header.lastResultsHash, + ).toBase64String(); + } + // handle signed_header.header.evidence_hash + if (signedHeader.header.evidenceHash) { + clonedDecodedParams.header.signedHeader.header.evidenceHash = Bytes.fromUint8Array( + signedHeader.header.evidenceHash, + ).toBase64String(); + } + // handle signed_header.header.proposer_address + if (signedHeader.header.proposerAddress) { + clonedDecodedParams.header.signedHeader.header.proposerAddress = Bytes.fromUint8Array( + signedHeader.header.proposerAddress, + ).toBase64String(); + } + } - return obj; + /* eslint-disable */ + /** handle signed_header.`commit` params */ + if (signedHeader.commit) { + if (signedHeader.commit.signatures && signedHeader.commit.signatures.length > 0) { + signedHeader.commit.signatures = signedHeader.commit.signatures.map((signatureObj: any) => { + // handle signed_header.commit.signatures[].block_id_flag + if (signatureObj.blockIdFlag) { + signatureObj.blockIdFlag = getBlockIdFlagStringFromValue(signatureObj.blockIdFlag); + } + // handle signed_header.commit.signatures[].validator_address + if (signatureObj.validatorAddress) { + signatureObj.validatorAddress = Bytes.fromUint8Array( + signatureObj.validatorAddress, + ).toBase64String(); + } + // handle signed_header.commit.signatures[].timestamp + if (signatureObj.timestamp) { + signatureObj.timestamp = convertSecondsNanosToTZFormat( + Long.fromString(signatureObj.timestamp.seconds), + signatureObj.timestamp.nanos, + ); + } + // handle signed_header.commit.signatures[].signature + if (signatureObj.signature) { + signatureObj.signature = Bytes.fromUint8Array(signatureObj.signature).toBase64String(); + } + return signatureObj; + }); + } + + // handle signedHeader.commit.blockId + if (signedHeader.commit.blockId) { + // handle signed_header.commit.block_id.hash + if (signedHeader.commit.blockId.hash) { + clonedDecodedParams.header.signedHeader.commit.blockId.hash = Bytes.fromUint8Array( + clonedDecodedParams.header.signedHeader.commit.blockId.hash, + ).toBase64String(); + } + + // handle signed_header.commit.block_id.part_set_header.hash + if ( + signedHeader.commit.blockId.partSetHeader && + signedHeader.commit.blockId.partSetHeader.hash + ) { + clonedDecodedParams.header.signedHeader.commit.blockId.partSetHeader.hash = Bytes.fromUint8Array( + clonedDecodedParams.header.signedHeader.commit.blockId.partSetHeader.hash, + ).toBase64String(); + } + } + } + } + + if (clonedDecodedParams.header.validatorSet && clonedDecodedParams.header.validatorSet) { + const { validatorSet } = clonedDecodedParams.header; + + // handle validatorSet.validators[] + if (validatorSet.validators && validatorSet.validators.length > 0) { + validatorSet.validators = validatorSet.validators.map((validator: any) => { + // validator_set.validators[].address + if (validator.address) { + validator.address = Bytes.fromUint8Array(validator.address).toBase64String(); + } + + // validator_set.validators[].pub_key.ed25519 + if (validator.pubKey) { + // ed25519 + if (validator.pubKey.ed25519) { + validator.pubKey.ed25519 = Bytes.fromUint8Array( + validator.pubKey.ed25519, + ).toBase64String(); + } + + // secpk256 + if (validator.pubKey.secpk256) { + validator.pubKey.secpk256 = Bytes.fromUint8Array( + validator.pubKey.secpk256, + ).toBase64String(); + } + } + return validator; + }); + } + + if (validatorSet.proposer) { + // validator_set.proposer.address + if (validatorSet.proposer.address) { + clonedDecodedParams.header.validatorSet.proposer.address = Bytes.fromUint8Array( + clonedDecodedParams.header.validatorSet.proposer.address, + ).toBase64String(); + } + + // validator_set.proposer.pub_key.ed25519 + if (validatorSet.proposer.pubKey) { + // ed25519 + if (validatorSet.proposer.pubKey.ed25519) { + clonedDecodedParams.header.validatorSet.proposer.pubKey.ed25519 = Bytes.fromUint8Array( + validatorSet.proposer.pubKey.ed25519, + ).toBase64String(); + } + } + } + } + + if (clonedDecodedParams.header.trustedValidators) { + const { trustedValidators } = clonedDecodedParams.header; + if (trustedValidators.validators && trustedValidators.validators.length > 0) { + trustedValidators.validators = trustedValidators.validators.map((validator: any) => { + // trusted_validators.validators[].address + if (validator.address) { + validator.address = Bytes.fromUint8Array(validator.address).toBase64String(); + } + + // trusted_validators.validators[].pub_key.ed25519 + if (validator.pubKey) { + // ed25519 + if (validator.pubKey.ed25519) { + validator.pubKey.ed25519 = Bytes.fromUint8Array( + validator.pubKey.ed25519, + ).toBase64String(); + } + + // secpk256 + if (validator.pubKey.secpk256) { + validator.pubKey.secpk256 = Bytes.fromUint8Array( + validator.pubKey.secpk256, + ).toBase64String(); + } + } + return validator; + }); + } + // trusted_validators.proposer.address + if (trustedValidators.proposer.address) { + clonedDecodedParams.header.trustedValidators.proposer.address = Bytes.fromUint8Array( + trustedValidators.proposer.address, + ).toBase64String(); + } + + if (trustedValidators.proposer.pubKey) { + // trusted_validators.proposer.pub_key.ed25519 + if (trustedValidators.proposer.pubKey.ed25519) { + clonedDecodedParams.header.trustedValidators.proposer.pubKey.ed25519 = Bytes.fromUint8Array( + trustedValidators.proposer.pubKey.ed25519, + ).toBase64String(); + } + } + } + /* eslint-enable */ + } } - // replace `type_url` with `@type` to match CosmosSDK tx format - private typeUrlTransformer = (str: string) => str.replace(/type_url/g, '@type'); + if (typeUrl === COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenConfirm) { + if (decodedParams.proofAck) { + clonedDecodedParams.proofAck = Bytes.fromUint8Array(decodedParams.proofAck).toBase64String(); + } + } + + if (typeUrl === COSMOS_MSG_TYPEURL.ibc.connection.MsgConnectionOpenTry) { + // todo: handle `clientState` + + // counterparty.prefix.keyPrefix + if (decodedParams.counterparty.prefix && decodedParams.counterparty.prefix.keyPrefix) { + clonedDecodedParams.counterparty.prefix.keyPrefix = Bytes.fromUint8Array( + decodedParams.counterparty.prefix.keyPrefix, + ).toBase64String(); + } + + // proof_init + if (decodedParams.proofInit) { + clonedDecodedParams.proofInit = Bytes.fromUint8Array(decodedParams.proofInit).toBase64String(); + } + // proof_client + if (decodedParams.proofClient) { + clonedDecodedParams.proofClient = Bytes.fromUint8Array(decodedParams.proofClient).toBase64String(); + } + // proof_consensus + if (decodedParams.proofConsensus) { + clonedDecodedParams.proofConsensus = Bytes.fromUint8Array(decodedParams.proofConsensus).toBase64String(); + } + } + return clonedDecodedParams; } + +const getHashOpStringFromValue = (targetValue: number): string | null => { + const mayBeHashOp = Object.values(ics23.HashOp).find((v) => v === targetValue) as ics23.HashOp | undefined; + if (mayBeHashOp) { + return ics23.HashOp[mayBeHashOp] || null; + } + return null; +}; + +const getLengthOpStringFromValue = (targetValue: number): string | null => { + const mayBeLengthOp = Object.values(ics23.LengthOp).find((v) => v === targetValue) as ics23.LengthOp | undefined; + if (mayBeLengthOp) { + return ics23.LengthOp[mayBeLengthOp] || null; + } + return null; +}; + +const getBlockIdFlagStringFromValue = (targetValue: string): string | null => { + const mayBeBlockIdFlag = Object.values(tendermintV2.types.BlockIDFlag).find((v) => v === targetValue) as + | tendermintV2.types.BlockIDFlag + | undefined; + if (mayBeBlockIdFlag) { + return tendermintV2.types.BlockIDFlag[mayBeBlockIdFlag] || null; + } + return null; +}; + +export const getAuthInfoJson = (authInfo: AuthInfo) => { + const authInfoStringified = JSON.stringify(AuthInfo.toJSON(authInfo)); + + const libParsedAuthInfo = JSON.parse(authInfoStringified); + const obj = { ...libParsedAuthInfo }; + + if (authInfo.signerInfos) { + obj.signerInfos = authInfo.signerInfos.map((e) => + typeof e !== typeof undefined ? getSignerInfoJson(e) : undefined, + ); + } else { + obj.signerInfos = []; + } + + return obj; +}; + +// transforms `type_url` to `@type` to match GoLang's TxDecoder JSON output +export const typeUrlToCosmosTransformer = (str: string) => str.replace(/type_url/g, '@type'); + +const handleCustomTypes = (obj: any) => { + Object.keys(obj).forEach((k) => { + if (typeof obj[k] === 'object' && obj[k] !== null) { + if (obj[k] instanceof Long) { + // Recursively keeping same object + obj[k] = obj[k].toString(10); // eslint-disable-line no-param-reassign + } + handleCustomTypes(obj[k]); + } + }); +}; diff --git a/lib/src/utils/txDecoding.spec.ts b/lib/src/utils/txDecoding.spec.ts deleted file mode 100644 index 40e06e79..00000000 --- a/lib/src/utils/txDecoding.spec.ts +++ /dev/null @@ -1,126 +0,0 @@ -import 'mocha'; -import { expect } from 'chai'; -import { TxBody } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'; -import { Any } from '@cosmjs/stargate/build/codec/google/protobuf/any'; -import Long from 'long'; -import { TxDecoder } from './txDecoder'; - -describe('TxDecoder', function () { - it('should throw on certain places', function () { - const txDecoder = new TxDecoder(); - - expect(() => { - txDecoder.fromHex( - '0A94010A91010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E6412710A2B7463726F31666D70726D30736A79366C7A396C6C7637726C746E307632617A7A7763777A766B326C73796E122B7463726F31373832676E39687A7161766563756B64617171636C76736E70636B346D747A3376777A70786C1A150A08626173657463726F120931303030303030303012690A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A210359A154BA210C489DA46626A4D631C6F8A471A2FBDA342164DD5FC4A158901F2612040A02087F180412150A100A08626173657463726F12043130303010904E1A40E812FBA1D50115CDDD534C7675B838E6CE7169CDD5AD312182696CABB76F05B82B9557EE1A2842A5579B363F0A5F2E487F7228A81FBF81E125E58F264A29DA07RRTTGG', - ); - }).to.throw('Error decoding provided transaction hex.'); - - expect(() => { - txDecoder.fromHex(''); - }).to.throw('Received malformed transaction hex.'); - }); - it('should decode correctly on empty auth_info and signatures', function () { - const txDecoder = new TxDecoder(); - - expect( - txDecoder - .fromHex( - '0a540a520a1b2f636f736d6f732e676f762e763162657461312e4d7367566f7465123308e0f64b122b7463726f3138346c7461326c7379753437767779703265387a6d746361336b35797138357036633476703318021200', - ) - .toCosmosJSON(), - ).to.equal( - JSON.stringify({ - tx: { - body: { - messages: [ - { - '@type': '/cosmos.gov.v1beta1.MsgVote', - proposal_id: { low: 1244000, high: 0, unsigned: true }, - voter: 'tcro184lta2lsyu47vwyp2e8zmtca3k5yq85p6c4vp3', - option: 2, - }, - ], - memo: '', - timeout_height: '0', - extension_options: [], - non_critical_extension_options: [], - }, - auth_info: { signer_infos: [] }, - signatures: [], - }, - }), - ); - }); - - it('should throw on empty messages array', function () { - const txDecoder = new TxDecoder(); - const txDecoded = txDecoder.fromHex( - '0A94010A91010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E6412710A2B7463726F31666D70726D30736A79366C7A396C6C7637726C746E307632617A7A7763777A766B326C73796E122B7463726F31373832676E39687A7161766563756B64617171636C76736E70636B346D747A3376777A70786C1A150A08626173657463726F120931303030303030303012690A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A210359A154BA210C489DA46626A4D631C6F8A471A2FBDA342164DD5FC4A158901F2612040A02087F180412150A100A08626173657463726F12043130303010904E1A40E812FBA1D50115CDDD534C7675B838E6CE7169CDD5AD312182696CABB76F05B82B9557EE1A2842A5579B363F0A5F2E487F7228A81FBF81E125E58F264A29DA07', - ); - // @ts-ignore - txDecoded.libDecodedTxBody = TxBody.fromPartial({ - timeoutHeight: Long.fromNumber(0), - messages: [ - Any.fromPartial({ - typeUrl: '', - value: new Uint8Array(), - }), - ], - }); - - expect(() => { - txDecoder.toCosmosJSON(); - }).to.throw('Missing type_url in Any'); - }); - - it('should decode the transaction correctly', function () { - const txDecoder = new TxDecoder(); - expect( - txDecoder - .fromHex( - '0A94010A91010A1C2F636F736D6F732E62616E6B2E763162657461312E4D736753656E6412710A2B7463726F31666D70726D30736A79366C7A396C6C7637726C746E307632617A7A7763777A766B326C73796E122B7463726F31373832676E39687A7161766563756B64617171636C76736E70636B346D747A3376777A70786C1A150A08626173657463726F120931303030303030303012690A500A460A1F2F636F736D6F732E63727970746F2E736563703235366B312E5075624B657912230A210359A154BA210C489DA46626A4D631C6F8A471A2FBDA342164DD5FC4A158901F2612040A02087F180412150A100A08626173657463726F12043130303010904E1A40E812FBA1D50115CDDD534C7675B838E6CE7169CDD5AD312182696CABB76F05B82B9557EE1A2842A5579B363F0A5F2E487F7228A81FBF81E125E58F264A29DA07', - ) - .toCosmosJSON(), - ).equal( - JSON.stringify({ - tx: { - body: { - messages: [ - { - '@type': '/cosmos.bank.v1beta1.MsgSend', - amount: [{ denom: 'basetcro', amount: '100000000' }], - from_address: 'tcro1fmprm0sjy6lz9llv7rltn0v2azzwcwzvk2lsyn', - to_address: 'tcro1782gn9hzqavecukdaqqclvsnpck4mtz3vwzpxl', - }, - ], - memo: '', - timeout_height: '0', - extension_options: [], - non_critical_extension_options: [], - }, - auth_info: { - signer_infos: [ - { - public_key: { - '@type': '/cosmos.crypto.secp256k1.PubKey', - key: 'A1mhVLohDEidpGYmpNYxxvikcaL72jQhZN1fxKFYkB8m', - }, - mode_info: { single: { mode: 'SIGN_MODE_LEGACY_AMINO_JSON' } }, - sequence: '4', - }, - ], - fee: { - amount: [{ denom: 'basetcro', amount: '1000' }], - gas_limit: '10000', - payer: '', - granter: '', - }, - }, - signatures: [ - '6BL7odUBFc3dU0x2dbg45s5xac3VrTEhgmlsq7dvBbgrlVfuGihCpVebNj8KXy5If3IoqB+/geEl5Y8mSinaBw==', - ], - }, - }), - ); - }); -}); diff --git a/package-lock.json b/package-lock.json index 831e2b5b..66f73b1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@crypto-org-chain/chain-jslib", - "version": "0.0.20", + "version": "0.0.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@crypto-org-chain/chain-jslib", - "version": "0.0.20", + "version": "0.0.22", "license": "Apache-2.0", "dependencies": { "@cosmjs/amino": "0.25.0-alpha.2", @@ -24,6 +24,7 @@ "create-hash": "1.2.0", "lodash": "4.17.21", "long": "4.0.0", + "moment": "2.29.1", "ow": "0.17.0", "protobufjs": "6.10.1", "randombytes": "2.1.0", @@ -1015,7 +1016,6 @@ "version": "11.1.0", "resolved": "https://registry.npmjs.org/@types/nock/-/nock-11.1.0.tgz", "integrity": "sha512-jI/ewavBQ7X5178262JQR0ewicPAcJhXS/iFaNJl0VHLfyosZ/kwSrsa6VNQNSO8i9d8SqdRgOtZSOKJ/+iNMw==", - "deprecated": "This is a stub types definition. nock provides its own type definitions, so you do not need this installed.", "dev": true, "dependencies": { "nock": "*" @@ -1912,6 +1912,7 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.1.2", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -3192,9 +3193,6 @@ }, "engines": { "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" } }, "node_modules/globby": { @@ -3278,6 +3276,7 @@ "minimist": "^1.2.5", "neo-async": "^2.6.0", "source-map": "^0.6.1", + "uglify-js": "^3.1.4", "wordwrap": "^1.0.0" }, "bin": { @@ -3744,10 +3743,7 @@ "node_modules/isomorphic-ws": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", - "peerDependencies": { - "ws": "*" - } + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" }, "node_modules/istanbul-lib-coverage": { "version": "3.0.0", @@ -4150,9 +4146,6 @@ "integrity": "sha512-+WA2/1sPmDj1dlvvJmB5G6JKfY9dpn7EVBUL06+y6PoljPkh+6V1QihwxNkbcGxCRjt2b0F9K0taiCuo7MbdFQ==", "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/marked": { @@ -4418,6 +4411,14 @@ "node": ">=8" } }, + "node_modules/moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -10068,8 +10069,7 @@ "isomorphic-ws": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", - "requires": {} + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" }, "istanbul-lib-coverage": { "version": "3.0.0", @@ -10614,6 +10614,11 @@ } } }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 2399cc41..ad985fa4 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,10 @@ "test:watch": "nodemon", "test": "NODE_ENV=test mocha --timeout 10000 --require ./node_modules/ts-node/register --exit --color --recursive 'lib/src/**/*.spec.ts'", "test:e2e": "NODE_ENV=test mocha --timeout 30000 --require ./node_modules/ts-node/register --exit --color ./lib/e2e/**/*.spec.ts", + "test:e2e:tx-decoder": "NODE_ENV=test mocha --timeout 0 --require ./node_modules/ts-node/register --exit --color ./lib/e2e/tx-decoder/*.ts", + "test:e2e:offline-signing": "NODE_ENV=test mocha --timeout 0 --require ./node_modules/ts-node/register --exit --color ./lib/e2e/offline-signing/*.ts", "preget-proto": "rm -rf proto", - "get-proto": "REF=v0.42.4 ./lib/src/cosmos/v1beta1/scripts/get-proto.sh", + "get-proto": "COSMOS_REF=v0.42.4 ICS23_REF=v0.6.3 CHAIN_MAIN_REF=v2.1.1 ./lib/src/cosmos/v1beta1/scripts/get-proto.sh", "predefine-proto": "./lib/src/cosmos/v1beta1/scripts/predefine-proto.sh", "define-proto": "./lib/src/cosmos/v1beta1/scripts/define-proto.sh", "postdefine-proto": "./lib/src/cosmos/v1beta1/scripts/postdefine-proto.sh", @@ -58,6 +60,7 @@ "create-hash": "1.2.0", "lodash": "4.17.21", "long": "4.0.0", + "moment": "2.29.1", "ow": "0.17.0", "protobufjs": "6.10.1", "randombytes": "2.1.0",