@xchainjs/xchain-thorchain 0.27.4 → 0.27.5

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/lib/client.d.ts CHANGED
@@ -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
@@ -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
@@ -10268,7 +10277,7 @@ class Client extends BaseXChainClient {
10268
10277
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10269
10278
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10270
10279
  */
10271
- deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
10280
+ deposit({ walletIndex = 0, asset = AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10272
10281
  var _a, _b, _c, _d;
10273
10282
  return __awaiter(this, void 0, void 0, function* () {
10274
10283
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10314,7 +10323,7 @@ class Client extends BaseXChainClient {
10314
10323
  txBody: depositTxBody,
10315
10324
  signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
10316
10325
  gasLimit: long_1.fromString(gasLimit.toFixed(0)),
10317
- sequence: account.sequence || long_1.ZERO,
10326
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10318
10327
  });
10319
10328
  const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
10320
10329
  if (!txHash)
@@ -10331,7 +10340,7 @@ class Client extends BaseXChainClient {
10331
10340
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10332
10341
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10333
10342
  */
10334
- transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10343
+ transfer({ walletIndex = 0, asset = AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10335
10344
  var _a, _b, _c, _d;
10336
10345
  return __awaiter(this, void 0, void 0, function* () {
10337
10346
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10373,7 +10382,7 @@ class Client extends BaseXChainClient {
10373
10382
  txBody: txBody,
10374
10383
  gasLimit: long_1.fromString(gasLimit.toString()),
10375
10384
  signerPubkey: cosmosclient.codec.instanceToProtoAny(signerPubkey),
10376
- sequence: account.sequence || long_1.ZERO,
10385
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10377
10386
  });
10378
10387
  const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
10379
10388
  if (!txHash)
@@ -10462,4 +10471,4 @@ const msgNativeTxFromJson = (value) => {
10462
10471
  return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
10463
10472
  };
10464
10473
 
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 };
10474
+ 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
@@ -9942,7 +9942,16 @@ const getExplorerTxUrl = ({ urls, network, txID, }) => {
9942
9942
  case xchainClient.Network.Testnet:
9943
9943
  return `${url}?network=testnet`;
9944
9944
  }
9945
- };
9945
+ };
9946
+ const getAccount = (address, client) => {
9947
+ const accAddress = core.cosmosclient.AccAddress.fromString(address);
9948
+ return client.getAccount(accAddress);
9949
+ };
9950
+ const getSequence = (address, client) => __awaiter(void 0, void 0, void 0, function* () {
9951
+ var _e;
9952
+ const { sequence } = yield getAccount(address, client);
9953
+ return (_e = sequence === null || sequence === void 0 ? void 0 : sequence.toNumber()) !== null && _e !== void 0 ? _e : null;
9954
+ });
9946
9955
 
9947
9956
  /**
9948
9957
  * Custom Thorchain Client
@@ -10276,7 +10285,7 @@ class Client extends xchainClient.BaseXChainClient {
10276
10285
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10277
10286
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10278
10287
  */
10279
- deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), }) {
10288
+ deposit({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, memo, gasLimit = new bignumber(DEPOSIT_GAS_LIMIT_VALUE), sequence, }) {
10280
10289
  var _a, _b, _c, _d;
10281
10290
  return __awaiter(this, void 0, void 0, function* () {
10282
10291
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10322,7 +10331,7 @@ class Client extends xchainClient.BaseXChainClient {
10322
10331
  txBody: depositTxBody,
10323
10332
  signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
10324
10333
  gasLimit: long_1.fromString(gasLimit.toFixed(0)),
10325
- sequence: account.sequence || long_1.ZERO,
10334
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10326
10335
  });
10327
10336
  const txHash = yield this.getCosmosClient().signAndBroadcast(txBuilder, privKey, accountNumber);
10328
10337
  if (!txHash)
@@ -10339,7 +10348,7 @@ class Client extends xchainClient.BaseXChainClient {
10339
10348
  * @throws {"insufficient funds"} Thrown if the wallet has insufficient funds.
10340
10349
  * @throws {"Invalid transaction hash"} Thrown by missing tx hash
10341
10350
  */
10342
- transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), }) {
10351
+ transfer({ walletIndex = 0, asset = xchainUtil.AssetRuneNative, amount, recipient, memo, gasLimit = new bignumber(DEFAULT_GAS_LIMIT_VALUE), sequence, }) {
10343
10352
  var _a, _b, _c, _d;
10344
10353
  return __awaiter(this, void 0, void 0, function* () {
10345
10354
  const balances = yield this.getBalance(this.getAddress(walletIndex));
@@ -10381,7 +10390,7 @@ class Client extends xchainClient.BaseXChainClient {
10381
10390
  txBody: txBody,
10382
10391
  gasLimit: long_1.fromString(gasLimit.toString()),
10383
10392
  signerPubkey: core.cosmosclient.codec.instanceToProtoAny(signerPubkey),
10384
- sequence: account.sequence || long_1.ZERO,
10393
+ sequence: sequence ? long_1.fromNumber(sequence) : account.sequence || long_1.ZERO,
10385
10394
  });
10386
10395
  const txHash = yield this.cosmosClient.signAndBroadcast(txBuilder, privKey, accountNumber);
10387
10396
  if (!txHash)
@@ -10482,6 +10491,7 @@ exports.buildDepositTx = buildDepositTx;
10482
10491
  exports.buildTransferTx = buildTransferTx;
10483
10492
  exports.buildUnsignedTx = buildUnsignedTx;
10484
10493
  exports.defaultExplorerUrls = defaultExplorerUrls;
10494
+ exports.getAccount = getAccount;
10485
10495
  exports.getBalance = getBalance;
10486
10496
  exports.getChainId = getChainId;
10487
10497
  exports.getDefaultFees = getDefaultFees;
@@ -10492,6 +10502,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
10492
10502
  exports.getExplorerTxUrl = getExplorerTxUrl;
10493
10503
  exports.getExplorerUrl = getExplorerUrl;
10494
10504
  exports.getPrefix = getPrefix;
10505
+ exports.getSequence = getSequence;
10495
10506
  exports.getTxType = getTxType;
10496
10507
  exports.isBroadcastSuccess = isBroadcastSuccess;
10497
10508
  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 & {
package/lib/util.d.ts CHANGED
@@ -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<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.5",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",