@xchainjs/xchain-thorchain 0.27.4 → 0.27.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,14 +16,13 @@ yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @
16
16
 
17
17
  Important note: Make sure to install same version of `@cosmos-client/core` as `xchain-thorchain` is using (currently `@cosmos-client/core@0.45.1` ). In other case things might break.
18
18
 
19
-
20
19
  ## Documentation
21
20
 
22
21
  ### [`xchain thorchain`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/)
22
+
23
23
  [`How xchain-thorchain works`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/how-it-works.html)\
24
24
  [`How to use xchain-thorchain`](http://docs.xchainjs.org/xchain-client/xchain-thorchain/how-to-use.html)
25
25
 
26
-
27
26
  For more examples check out tests in `./__tests__/client.test.ts`
28
27
 
29
28
  ## Service Providers
@@ -56,5 +55,25 @@ In order for this library to de/serialize proto3 structures, you can use the fol
56
55
  yarn run pbts src/types/proto/MsgCompiled.js -o src/types/proto/MsgCompiled.d.ts
57
56
  ```
58
57
 
59
- Alternatively, you can run the convenience script: `genMsgs.sh`, which will overwrite the proto/js files in types/proto. This should only be done and checked in if changes were made to the upstream Msg in the THORNode repo.
58
+ Alternatively, you can run the convenience script: `genMsgs.sh`, which will overwrite the proto/js files in types/proto. This should only be done and checked in if changes were made to the upstream Msg in the THORNode repo.
59
+
60
+ ### Setting Headers for Nine Realms endpoints
61
+
62
+ If you plan on using the publically accessible endpoints provided by Nine Realms(listed below), ensure that you add a valid 'x-client-id' to all requests
63
+
64
+ - https://midgard.ninerealms.com
65
+ - https://haskoin.ninerealms.com (BTC/BCH/LTC)
66
+ - https://thornode.ninerealms.com
67
+
68
+ Example
69
+
70
+ ```typescript
71
+ import cosmosclient from '@cosmos-client/core'
72
+ import axios from 'axios'
73
+ import { register9Rheader } from '@xchainjs/xchain-util'
74
+
75
+ register9Rheader(axios)
76
+ register9Rheader(cosmosclient.config.globalAxios)
77
+ ```
60
78
 
79
+ For a complete example please see this [test](https://github.com/xchainjs/xchainjs-lib/blob/master/packages/xchain-thorchain-amm/__e2e__/wallet.e2e.ts)
package/lib/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { cosmosclient, proto } from '@cosmos-client/core';
1
+ import cosmosclient from '@cosmos-client/core';
2
2
  import { Balance, BaseXChainClient, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
3
3
  import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
4
4
  import { Address, Asset } from '@xchainjs/xchain-util';
@@ -33,7 +33,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
33
33
  *
34
34
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
35
35
  */
36
- constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, customRequestHeaders, }: XChainClientParams & ThorchainClientParams);
36
+ constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
37
37
  /**
38
38
  * Set/update the current network.
39
39
  *
@@ -115,7 +115,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
115
115
  * @throws {"Phrase not set"}
116
116
  * Throws an error if phrase has not been set before
117
117
  * */
118
- getPrivateKey(index?: number): proto.cosmos.crypto.secp256k1.PrivKey;
118
+ getPrivateKey(index?: number): cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
119
119
  /**
120
120
  * Get public key
121
121
  *
@@ -185,7 +185,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
185
185
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
186
186
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
187
187
  */
188
- deposit({ walletIndex, asset, amount, memo, gasLimit, }: DepositParam): Promise<TxHash>;
188
+ deposit({ walletIndex, asset, amount, memo, gasLimit, sequence, }: DepositParam): Promise<TxHash>;
189
189
  /**
190
190
  * Transfer balances with MsgSend
191
191
  *
@@ -195,8 +195,9 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
195
195
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
196
196
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
197
197
  */
198
- transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, }: TxParams & {
198
+ transfer({ walletIndex, asset, amount, recipient, memo, gasLimit, sequence, }: TxParams & {
199
199
  gasLimit?: BigNumber;
200
+ sequence?: number;
200
201
  }): Promise<TxHash>;
201
202
  /**
202
203
  * Transfer without broadcast balances with MsgSend
package/lib/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { cosmosclient, proto, rest } from '@cosmos-client/core';
1
+ import cosmosclient from '@cosmos-client/core';
2
2
  import { Network, TxType, singleFee, FeeType, BaseXChainClient } from '@xchainjs/xchain-client';
3
3
  import { CosmosSDKClient } from '@xchainjs/xchain-cosmos';
4
4
  import { isAssetRuneNative, isSynthAsset, assetToString, AssetRuneNative, assetFromString, baseAmount, assetToBase, assetAmount, Chain } from '@xchainjs/xchain-util';
@@ -9764,13 +9764,13 @@ const getChainId = (nodeUrl) => __awaiter(void 0, void 0, void 0, function* () {
9764
9764
  * @returns
9765
9765
  */
9766
9766
  const buildUnsignedTx = ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }) => {
9767
- const authInfo = new proto.cosmos.tx.v1beta1.AuthInfo({
9767
+ const authInfo = new cosmosclient.proto.cosmos.tx.v1beta1.AuthInfo({
9768
9768
  signer_infos: [
9769
9769
  {
9770
9770
  public_key: signerPubkey,
9771
9771
  mode_info: {
9772
9772
  single: {
9773
- mode: proto.cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
9773
+ mode: cosmosclient.proto.cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
9774
9774
  },
9775
9775
  },
9776
9776
  sequence: sequence,
@@ -9801,7 +9801,7 @@ const getEstimatedGas = ({ cosmosSDKClient, txBody, privKey, accountNumber, acco
9801
9801
  });
9802
9802
  const signDocBytes = txBuilder.signDocBytes(accountNumber);
9803
9803
  txBuilder.addSignature(privKey.sign(signDocBytes));
9804
- const resp = yield rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
9804
+ const resp = yield cosmosclient.rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
9805
9805
  const estimatedGas = (_d = (_c = (_b = resp.data) === null || _b === void 0 ? void 0 : _b.gas_info) === null || _c === void 0 ? void 0 : _c.gas_used) !== null && _d !== void 0 ? _d : null;
9806
9806
  if (!estimatedGas) {
9807
9807
  throw new Error('Could not get data of estimated gas');
@@ -9832,7 +9832,7 @@ const buildDepositTx = ({ msgNativeTx, nodeUrl, chainId, }) => __awaiter(void 0,
9832
9832
  signer: signerDecoded.data,
9833
9833
  };
9834
9834
  const depositMsg = MsgCompiled.types.MsgDeposit.fromObject(msgDepositObj);
9835
- return new proto.cosmos.tx.v1beta1.TxBody({
9835
+ return new cosmosclient.proto.cosmos.tx.v1beta1.TxBody({
9836
9836
  messages: [cosmosclient.codec.instanceToProtoAny(depositMsg)],
9837
9837
  memo: msgNativeTx.memo,
9838
9838
  });
@@ -9866,7 +9866,7 @@ const buildTransferTx = ({ fromAddress, toAddress, assetAmount, assetDenom, memo
9866
9866
  ],
9867
9867
  };
9868
9868
  const transferMsg = MsgCompiled.types.MsgSend.fromObject(transferObj);
9869
- return new proto.cosmos.tx.v1beta1.TxBody({
9869
+ return new cosmosclient.proto.cosmos.tx.v1beta1.TxBody({
9870
9870
  messages: [cosmosclient.codec.instanceToProtoAny(transferMsg)],
9871
9871
  memo,
9872
9872
  });
@@ -9934,7 +9934,16 @@ const getExplorerTxUrl = ({ urls, network, txID, }) => {
9934
9934
  case Network.Testnet:
9935
9935
  return `${url}?network=testnet`;
9936
9936
  }
9937
- };
9937
+ };
9938
+ const getAccount = (address, client) => {
9939
+ const accAddress = cosmosclient.AccAddress.fromString(address);
9940
+ return client.getAccount(accAddress);
9941
+ };
9942
+ const getSequence = (address, client) => __awaiter(void 0, void 0, void 0, function* () {
9943
+ var _e;
9944
+ const { sequence } = yield getAccount(address, client);
9945
+ return (_e = sequence === null || sequence === void 0 ? void 0 : sequence.toNumber()) !== null && _e !== void 0 ? _e : null;
9946
+ });
9938
9947
 
9939
9948
  /**
9940
9949
  * Custom Thorchain Client
@@ -9971,8 +9980,8 @@ class Client extends BaseXChainClient {
9971
9980
  [Network.Mainnet]: 'thorchain-mainnet-v1',
9972
9981
  [Network.Stagenet]: 'thorchain-stagenet-v2',
9973
9982
  [Network.Testnet]: 'deprecated',
9974
- }, customRequestHeaders = {}, }) {
9975
- super(Chain.Cosmos, { network, rootDerivationPaths, phrase, customRequestHeaders });
9983
+ }, }) {
9984
+ super(Chain.Cosmos, { network, rootDerivationPaths, phrase });
9976
9985
  /**
9977
9986
  * Get transaction history of a given address with pagination options.
9978
9987
  * By default it will return the transaction history of the current wallet.
@@ -10029,14 +10038,10 @@ class Client extends BaseXChainClient {
10029
10038
  this.chainIds = chainIds;
10030
10039
  registerSendCodecs();
10031
10040
  registerDepositCodecs();
10032
- if (this.clientUrl[Network.Mainnet].node.includes('ninerealms.com') && !this.customRequestHeaders['x-client-id']) {
10033
- this.customRequestHeaders['x-client-id'] = 'xchainjs-client';
10034
- }
10035
10041
  this.cosmosClient = new CosmosSDKClient({
10036
10042
  server: this.getClientUrl().node,
10037
10043
  chainId: this.getChainId(network),
10038
10044
  prefix: getPrefix(network),
10039
- headers: this.customRequestHeaders,
10040
10045
  });
10041
10046
  }
10042
10047
  /**
@@ -10268,7 +10273,7 @@ class Client extends BaseXChainClient {
10268
10273
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10269
10274
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10270
10275
  */
10271
- deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
10276
+ deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10272
10277
  var _a, _b, _c, _d;
10273
10278
  return __awaiter(this, void 0, void 0, function* () {
10274
10279
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10314,7 +10319,7 @@ class Client extends BaseXChainClient {
10314
10319
  txBody: depositTxBody,
10315
10320
  signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
10316
10321
  gasLimit: long_1.fromString(gasLimit.toFixed(0)),
10317
- sequence: account.sequence || long_1.ZERO,
10322
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10318
10323
  });
10319
10324
  const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
10320
10325
  if (!txHash)
@@ -10331,7 +10336,7 @@ class Client extends BaseXChainClient {
10331
10336
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10332
10337
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10333
10338
  */
10334
- transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10339
+ transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10335
10340
  var _a, _b, _c, _d;
10336
10341
  return __awaiter(this, void 0, void 0, function* () {
10337
10342
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10373,7 +10378,7 @@ class Client extends BaseXChainClient {
10373
10378
  txBody: txBody,
10374
10379
  gasLimit: long_1.fromString(gasLimit.toString()),
10375
10380
  signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
10376
- sequence: account.sequence || long_1.ZERO,
10381
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10377
10382
  });
10378
10383
  const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
10379
10384
  if (!txHash)
@@ -10462,4 +10467,4 @@ const msgNativeTxFromJson = (value) => {
10462
10467
  return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
10463
10468
  };
10464
10469
 
10465
- export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
10470
+ export { Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_TX_COUNT, MsgNativeTx, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@cosmos-client/core');
5
+ var cosmosclient = require('@cosmos-client/core');
6
6
  var xchainClient = require('@xchainjs/xchain-client');
7
7
  var xchainCosmos = require('@xchainjs/xchain-cosmos');
8
8
  var xchainUtil = require('@xchainjs/xchain-util');
@@ -11,6 +11,7 @@ var bech32Buffer = require('bech32-buffer');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
14
+ var cosmosclient__default = /*#__PURE__*/_interopDefaultLegacy(cosmosclient);
14
15
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
15
16
 
16
17
  /*! *****************************************************************************
@@ -9688,13 +9689,13 @@ const getPrefix = (network) => {
9688
9689
  * Register type for encoding `MsgDeposit` messages
9689
9690
  */
9690
9691
  const registerDepositCodecs = () => {
9691
- core.cosmosclient.codec.register('/types.MsgDeposit', MsgCompiled.types.MsgDeposit);
9692
+ cosmosclient__default['default'].codec.register('/types.MsgDeposit', MsgCompiled.types.MsgDeposit);
9692
9693
  };
9693
9694
  /**
9694
9695
  * Register type for encoding `MsgSend` messages
9695
9696
  */
9696
9697
  const registerSendCodecs = () => {
9697
- core.cosmosclient.codec.register('/types.MsgSend', MsgCompiled.types.MsgSend);
9698
+ cosmosclient__default['default'].codec.register('/types.MsgSend', MsgCompiled.types.MsgSend);
9698
9699
  };
9699
9700
  /**
9700
9701
  * Parse transaction data from event logs
@@ -9772,13 +9773,13 @@ const getChainId = (nodeUrl) => __awaiter(void 0, void 0, void 0, function* () {
9772
9773
  * @returns
9773
9774
  */
9774
9775
  const buildUnsignedTx = ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }) => {
9775
- const authInfo = new core.proto.cosmos.tx.v1beta1.AuthInfo({
9776
+ const authInfo = new cosmosclient__default['default'].proto.cosmos.tx.v1beta1.AuthInfo({
9776
9777
  signer_infos: [
9777
9778
  {
9778
9779
  public_key: signerPubkey,
9779
9780
  mode_info: {
9780
9781
  single: {
9781
- mode: core.proto.cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
9782
+ mode: cosmosclient__default['default'].proto.cosmos.tx.signing.v1beta1.SignMode.SIGN_MODE_DIRECT,
9782
9783
  },
9783
9784
  },
9784
9785
  sequence: sequence,
@@ -9789,7 +9790,7 @@ const buildUnsignedTx = ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit,
9789
9790
  gas_limit: gasLimit || null,
9790
9791
  },
9791
9792
  });
9792
- return new core.cosmosclient.TxBuilder(cosmosSdk, txBody, authInfo);
9793
+ return new cosmosclient__default['default'].TxBuilder(cosmosSdk, txBody, authInfo);
9793
9794
  };
9794
9795
  /**
9795
9796
  * Estimates usage of gas
@@ -9804,12 +9805,12 @@ const getEstimatedGas = ({ cosmosSDKClient, txBody, privKey, accountNumber, acco
9804
9805
  const txBuilder = buildUnsignedTx({
9805
9806
  cosmosSdk: cosmosSDKClient.sdk,
9806
9807
  txBody: txBody,
9807
- signerPubkey: core.cosmosclient.codec.instanceToProtoAny(pubKey),
9808
+ signerPubkey: cosmosclient__default['default'].codec.instanceToProtoAny(pubKey),
9808
9809
  sequence: accountSequence,
9809
9810
  });
9810
9811
  const signDocBytes = txBuilder.signDocBytes(accountNumber);
9811
9812
  txBuilder.addSignature(privKey.sign(signDocBytes));
9812
- const resp = yield core.rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
9813
+ const resp = yield cosmosclient__default['default'].rest.tx.simulate(cosmosSDKClient.sdk, { tx_bytes: txBuilder.txBytes() });
9813
9814
  const estimatedGas = (_d = (_c = (_b = resp.data) === null || _b === void 0 ? void 0 : _b.gas_info) === null || _c === void 0 ? void 0 : _c.gas_used) !== null && _d !== void 0 ? _d : null;
9814
9815
  if (!estimatedGas) {
9815
9816
  throw new Error('Could not get data of estimated gas');
@@ -9840,8 +9841,8 @@ const buildDepositTx = ({ msgNativeTx, nodeUrl, chainId, }) => __awaiter(void 0,
9840
9841
  signer: signerDecoded.data,
9841
9842
  };
9842
9843
  const depositMsg = MsgCompiled.types.MsgDeposit.fromObject(msgDepositObj);
9843
- return new core.proto.cosmos.tx.v1beta1.TxBody({
9844
- messages: [core.cosmosclient.codec.instanceToProtoAny(depositMsg)],
9844
+ return new cosmosclient__default['default'].proto.cosmos.tx.v1beta1.TxBody({
9845
+ messages: [cosmosclient__default['default'].codec.instanceToProtoAny(depositMsg)],
9845
9846
  memo: msgNativeTx.memo,
9846
9847
  });
9847
9848
  });
@@ -9874,8 +9875,8 @@ const buildTransferTx = ({ fromAddress, toAddress, assetAmount, assetDenom, memo
9874
9875
  ],
9875
9876
  };
9876
9877
  const transferMsg = MsgCompiled.types.MsgSend.fromObject(transferObj);
9877
- return new core.proto.cosmos.tx.v1beta1.TxBody({
9878
- messages: [core.cosmosclient.codec.instanceToProtoAny(transferMsg)],
9878
+ return new cosmosclient__default['default'].proto.cosmos.tx.v1beta1.TxBody({
9879
+ messages: [cosmosclient__default['default'].codec.instanceToProtoAny(transferMsg)],
9879
9880
  memo,
9880
9881
  });
9881
9882
  });
@@ -9942,7 +9943,16 @@ const getExplorerTxUrl = ({ urls, network, txID, }) => {
9942
9943
  case xchainClient.Network.Testnet:
9943
9944
  return `${url}?network=testnet`;
9944
9945
  }
9945
- };
9946
+ };
9947
+ const getAccount = (address, client) => {
9948
+ const accAddress = cosmosclient__default['default'].AccAddress.fromString(address);
9949
+ return client.getAccount(accAddress);
9950
+ };
9951
+ const getSequence = (address, client) => __awaiter(void 0, void 0, void 0, function* () {
9952
+ var _e;
9953
+ const { sequence } = yield getAccount(address, client);
9954
+ return (_e = sequence === null || sequence === void 0 ? void 0 : sequence.toNumber()) !== null && _e !== void 0 ? _e : null;
9955
+ });
9946
9956
 
9947
9957
  /**
9948
9958
  * Custom Thorchain Client
@@ -9979,8 +9989,8 @@ class Client extends xchainClient.BaseXChainClient {
9979
9989
  [xchainClient.Network.Mainnet]: 'thorchain-mainnet-v1',
9980
9990
  [xchainClient.Network.Stagenet]: 'thorchain-stagenet-v2',
9981
9991
  [xchainClient.Network.Testnet]: 'deprecated',
9982
- }, customRequestHeaders = {}, }) {
9983
- super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase, customRequestHeaders });
9992
+ }, }) {
9993
+ super(xchainUtil.Chain.Cosmos, { network, rootDerivationPaths, phrase });
9984
9994
  /**
9985
9995
  * Get transaction history of a given address with pagination options.
9986
9996
  * By default it will return the transaction history of the current wallet.
@@ -10037,14 +10047,10 @@ class Client extends xchainClient.BaseXChainClient {
10037
10047
  this.chainIds = chainIds;
10038
10048
  registerSendCodecs();
10039
10049
  registerDepositCodecs();
10040
- if (this.clientUrl[xchainClient.Network.Mainnet].node.includes('ninerealms.com') && !this.customRequestHeaders['x-client-id']) {
10041
- this.customRequestHeaders['x-client-id'] = 'xchainjs-client';
10042
- }
10043
10050
  this.cosmosClient = new xchainCosmos.CosmosSDKClient({
10044
10051
  server: this.getClientUrl().node,
10045
10052
  chainId: this.getChainId(network),
10046
10053
  prefix: getPrefix(network),
10047
- headers: this.customRequestHeaders,
10048
10054
  });
10049
10055
  }
10050
10056
  /**
@@ -10276,7 +10282,7 @@ class Client extends xchainClient.BaseXChainClient {
10276
10282
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10277
10283
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10278
10284
  */
10279
- deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
10285
+ deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10280
10286
  var _a, _b, _c, _d;
10281
10287
  return __awaiter(this, void 0, void 0, function* () {
10282
10288
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10298,7 +10304,7 @@ class Client extends xchainClient.BaseXChainClient {
10298
10304
  const privKey = this.getPrivateKey(walletIndex);
10299
10305
  const signerPubkey = privKey.pubKey();
10300
10306
  const fromAddress = this.getAddress(walletIndex);
10301
- const fromAddressAcc = core.cosmosclient.AccAddress.fromString(fromAddress);
10307
+ const fromAddressAcc = cosmosclient__default['default'].AccAddress.fromString(fromAddress);
10302
10308
  const depositTxBody = yield buildDepositTx({
10303
10309
  msgNativeTx: {
10304
10310
  memo: memo,
@@ -10320,9 +10326,9 @@ class Client extends xchainClient.BaseXChainClient {
10320
10326
  const txBuilder = buildUnsignedTx({
10321
10327
  cosmosSdk: this.getCosmosClient().sdk,
10322
10328
  txBody: depositTxBody,
10323
- signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
10329
+ signerPubkey: cosmosclient__default['default'].codec.instanceToProtoAny(signerPubkey),
10324
10330
  gasLimit: long_1.fromString(gasLimit.toFixed(0)),
10325
- sequence: account.sequence || long_1.ZERO,
10331
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10326
10332
  });
10327
10333
  const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
10328
10334
  if (!txHash)
@@ -10339,7 +10345,7 @@ class Client extends xchainClient.BaseXChainClient {
10339
10345
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10340
10346
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10341
10347
  */
10342
- transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10348
+ transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10343
10349
  var _a, _b, _c, _d;
10344
10350
  return __awaiter(this, void 0, void 0, function* () {
10345
10351
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10361,7 +10367,7 @@ class Client extends xchainClient.BaseXChainClient {
10361
10367
  const privKey = this.getPrivateKey(walletIndex);
10362
10368
  const from = this.getAddress(walletIndex);
10363
10369
  const signerPubkey = privKey.pubKey();
10364
- const accAddress = core.cosmosclient.AccAddress.fromString(from);
10370
+ const accAddress = cosmosclient__default['default'].AccAddress.fromString(from);
10365
10371
  const denom = getDenom(asset);
10366
10372
  const txBody = yield buildTransferTx({
10367
10373
  fromAddress: from,
@@ -10380,8 +10386,8 @@ class Client extends xchainClient.BaseXChainClient {
10380
10386
  cosmosSdk: this.getCosmosClient().sdk,
10381
10387
  txBody: txBody,
10382
10388
  gasLimit: long_1.fromString(gasLimit.toString()),
10383
- signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
10384
- sequence: account.sequence || long_1.ZERO,
10389
+ signerPubkey: cosmosclient__default['default'].codec.instanceToProtoAny(signerPubkey),
10390
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10385
10391
  });
10386
10392
  const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
10387
10393
  if (!txHash)
@@ -10424,7 +10430,7 @@ class Client extends xchainClient.BaseXChainClient {
10424
10430
  cosmosSdk: this.getCosmosClient().sdk,
10425
10431
  txBody: txBody,
10426
10432
  gasLimit: long_1.fromString(gasLimit.toFixed(0)),
10427
- signerPubkey: core.cosmosclient.codec.instanceToProtoAny(privKey.pubKey()),
10433
+ signerPubkey: cosmosclient__default['default'].codec.instanceToProtoAny(privKey.pubKey()),
10428
10434
  sequence: fromSequence,
10429
10435
  });
10430
10436
  const signDocBytes = txBuilder.signDocBytes(fromAccountNumber);
@@ -10467,7 +10473,7 @@ class MsgNativeTx {
10467
10473
  * @returns {MsgNativeTx}
10468
10474
  */
10469
10475
  const msgNativeTxFromJson = (value) => {
10470
- return new MsgNativeTx(value.coins, value.memo, core.cosmosclient.AccAddress.fromString(value.signer));
10476
+ return new MsgNativeTx(value.coins, value.memo, cosmosclient__default['default'].AccAddress.fromString(value.signer));
10471
10477
  };
10472
10478
 
10473
10479
  exports.Client = Client;
@@ -10482,6 +10488,7 @@ exports.buildDepositTx = buildDepositTx;
10482
10488
  exports.buildTransferTx = buildTransferTx;
10483
10489
  exports.buildUnsignedTx = buildUnsignedTx;
10484
10490
  exports.defaultExplorerUrls = defaultExplorerUrls;
10491
+ exports.getAccount = getAccount;
10485
10492
  exports.getBalance = getBalance;
10486
10493
  exports.getChainId = getChainId;
10487
10494
  exports.getDefaultFees = getDefaultFees;
@@ -10492,6 +10499,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
10492
10499
  exports.getExplorerTxUrl = getExplorerTxUrl;
10493
10500
  exports.getExplorerUrl = getExplorerUrl;
10494
10501
  exports.getPrefix = getPrefix;
10502
+ exports.getSequence = getSequence;
10495
10503
  exports.getTxType = getTxType;
10496
10504
  exports.isBroadcastSuccess = isBroadcastSuccess;
10497
10505
  exports.msgNativeTxFromJson = msgNativeTxFromJson;
@@ -26,6 +26,7 @@ export declare type DepositParam = {
26
26
  amount: BaseAmount;
27
27
  memo: string;
28
28
  gasLimit?: BigNumber;
29
+ sequence?: number;
29
30
  };
30
31
  export declare type TxData = Pick<Tx, 'from' | 'to' | 'type'>;
31
32
  export declare type TxOfflineParams = TxParams & {
@@ -1,4 +1,4 @@
1
- import { cosmosclient, proto } from '@cosmos-client/core';
1
+ import cosmosclient from '@cosmos-client/core';
2
2
  import { Asset } from '@xchainjs/xchain-util';
3
3
  export declare type MsgCoin = {
4
4
  asset: Asset;
@@ -31,7 +31,7 @@ export declare type ThorchainDepositResponse = AminoWrapping<{
31
31
  memo: string;
32
32
  signer: string;
33
33
  }>[];
34
- fee: proto.cosmos.tx.v1beta1.Fee;
34
+ fee: cosmosclient.proto.cosmos.tx.v1beta1.Fee;
35
35
  signatures: string[];
36
36
  memo: string;
37
37
  timeout_height: string;
package/lib/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { cosmosclient, proto } from '@cosmos-client/core';
1
+ import cosmosclient from '@cosmos-client/core';
2
2
  import { Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
3
3
  import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
4
4
  import { Address, Asset, BaseAmount } from '@xchainjs/xchain-util';
@@ -87,8 +87,8 @@ export declare const getChainId: (nodeUrl: string) => Promise<ChainId>;
87
87
  */
88
88
  export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }: {
89
89
  cosmosSdk: cosmosclient.CosmosSDK;
90
- txBody: proto.cosmos.tx.v1beta1.TxBody;
91
- signerPubkey: proto.google.protobuf.Any;
90
+ txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
91
+ signerPubkey: cosmosclient.proto.google.protobuf.Any;
92
92
  sequence: Long;
93
93
  gasLimit?: Long.Long | undefined;
94
94
  }) => cosmosclient.TxBuilder;
@@ -101,8 +101,8 @@ export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequen
101
101
  */
102
102
  export declare const getEstimatedGas: ({ cosmosSDKClient, txBody, privKey, accountNumber, accountSequence, multiplier, }: {
103
103
  cosmosSDKClient: CosmosSDKClient;
104
- txBody: proto.cosmos.tx.v1beta1.TxBody;
105
- privKey: proto.cosmos.crypto.secp256k1.PrivKey;
104
+ txBody: cosmosclient.proto.cosmos.tx.v1beta1.TxBody;
105
+ privKey: cosmosclient.proto.cosmos.crypto.secp256k1.PrivKey;
106
106
  accountNumber: Long;
107
107
  accountSequence: Long;
108
108
  multiplier?: number | undefined;
@@ -122,7 +122,7 @@ export declare const buildDepositTx: ({ msgNativeTx, nodeUrl, chainId, }: {
122
122
  msgNativeTx: MsgNativeTx;
123
123
  nodeUrl: string;
124
124
  chainId: ChainId;
125
- }) => Promise<proto.cosmos.tx.v1beta1.TxBody>;
125
+ }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
126
126
  /**
127
127
  * Structure a MsgSend
128
128
  *
@@ -142,7 +142,7 @@ export declare const buildTransferTx: ({ fromAddress, toAddress, assetAmount, as
142
142
  memo?: string | undefined;
143
143
  nodeUrl: string;
144
144
  chainId: ChainId;
145
- }) => Promise<proto.cosmos.tx.v1beta1.TxBody>;
145
+ }) => Promise<cosmosclient.proto.cosmos.tx.v1beta1.TxBody>;
146
146
  /**
147
147
  * Get the balance of a given address.
148
148
  *
@@ -191,3 +191,5 @@ export declare const getExplorerTxUrl: ({ urls, network, txID, }: {
191
191
  network: Network;
192
192
  txID: TxHash;
193
193
  }) => string;
194
+ export declare const getAccount: (address: string, client: CosmosSDKClient) => Promise<cosmosclient.proto.cosmos.auth.v1beta1.IBaseAccount>;
195
+ export declare const getSequence: (address: string, client: CosmosSDKClient) => Promise<number | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.27.4",
3
+ "version": "0.27.6",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -34,10 +34,10 @@
34
34
  "generate:ThorchainMsgs": "./genMsgs.sh"
35
35
  },
36
36
  "devDependencies": {
37
- "@cosmos-client/core": "0.45.13",
37
+ "@cosmos-client/core": "0.46.1",
38
38
  "@types/big.js": "^6.0.0",
39
39
  "@xchainjs/xchain-client": "^0.13.3",
40
- "@xchainjs/xchain-cosmos": "^0.20.4",
40
+ "@xchainjs/xchain-cosmos": "^0.20.5",
41
41
  "@xchainjs/xchain-crypto": "^0.2.6",
42
42
  "@xchainjs/xchain-util": "^0.11.0",
43
43
  "axios": "^0.25.0",
@@ -48,9 +48,9 @@
48
48
  "access": "public"
49
49
  },
50
50
  "peerDependencies": {
51
- "@cosmos-client/core": "0.45.13",
51
+ "@cosmos-client/core": "0.46.1",
52
52
  "@xchainjs/xchain-client": "^0.13.3",
53
- "@xchainjs/xchain-cosmos": "^0.20.4",
53
+ "@xchainjs/xchain-cosmos": "^0.20.5",
54
54
  "@xchainjs/xchain-crypto": "^0.2.6",
55
55
  "@xchainjs/xchain-util": "^0.11.0",
56
56
  "axios": "^0.25.0",