@injectivelabs/wallet-core 1.16.17 → 1.16.19

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.
@@ -214,7 +214,7 @@ class MsgBroadcaster {
214
214
  * @returns transaction hash
215
215
  */
216
216
  async broadcastEip712(tx) {
217
- const { chainId, txTimeout, endpoints, walletStrategy } = this;
217
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
218
218
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
219
219
  const evmChainId = await this.getEvmChainId();
220
220
  if (!evmChainId) {
@@ -222,7 +222,7 @@ class MsgBroadcaster {
222
222
  }
223
223
  /** Account Details * */
224
224
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
225
- const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
225
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
226
226
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
227
227
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
228
228
  /**
@@ -290,11 +290,11 @@ class MsgBroadcaster {
290
290
  const response = await walletStrategy.sendTransaction(txRawEip712, {
291
291
  chainId,
292
292
  endpoints,
293
- txTimeout,
293
+ txTimeout: txTimeoutInBlocks,
294
294
  address: tx.injectiveAddress,
295
295
  });
296
296
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
297
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
297
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
298
298
  }
299
299
  /**
300
300
  * Prepare/sign/broadcast transaction using
@@ -306,7 +306,7 @@ class MsgBroadcaster {
306
306
  * @returns transaction hash
307
307
  */
308
308
  async broadcastEip712V2(tx) {
309
- const { chainId, endpoints, txTimeout, walletStrategy } = this;
309
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
310
310
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
311
311
  const evmChainId = await this.getEvmChainId();
312
312
  if (!evmChainId) {
@@ -314,7 +314,7 @@ class MsgBroadcaster {
314
314
  }
315
315
  /** Account Details * */
316
316
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
317
- const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
317
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
318
318
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
319
319
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
320
320
  /**
@@ -384,11 +384,11 @@ class MsgBroadcaster {
384
384
  const response = await walletStrategy.sendTransaction(txRawEip712, {
385
385
  chainId,
386
386
  endpoints,
387
- txTimeout,
387
+ txTimeout: txTimeoutInBlocks,
388
388
  address: tx.injectiveAddress,
389
389
  });
390
390
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
391
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
391
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
392
392
  }
393
393
  /**
394
394
  * Prepare/sign/broadcast transaction using
@@ -398,7 +398,7 @@ class MsgBroadcaster {
398
398
  * @returns transaction hash
399
399
  */
400
400
  async broadcastEip712WithFeeDelegation(tx) {
401
- const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
401
+ const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks, } = this;
402
402
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
403
403
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
404
404
  const evmChainId = await this.getEvmChainId();
@@ -413,7 +413,9 @@ class MsgBroadcaster {
413
413
  if (txTimeoutOnFeeDelegation) {
414
414
  const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
415
415
  const latestHeight = latestBlock.header.height;
416
- timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout).toNumber();
416
+ timeoutHeight = (0, utils_1.toBigNumber)(latestHeight)
417
+ .plus(txTimeoutInBlocks)
418
+ .toNumber();
417
419
  }
418
420
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationStart);
419
421
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -437,7 +439,7 @@ class MsgBroadcaster {
437
439
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastStart);
438
440
  const response = await broadcast();
439
441
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
440
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
442
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
441
443
  }
442
444
  catch (e) {
443
445
  const error = e;
@@ -472,7 +474,7 @@ class MsgBroadcaster {
472
474
  * @returns transaction hash
473
475
  */
474
476
  async broadcastDirectSign(tx) {
475
- const { walletStrategy, txTimeout, endpoints, chainId } = this;
477
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
476
478
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
477
479
  /**
478
480
  * When using Ledger with Keplr/Leap we have
@@ -486,7 +488,7 @@ class MsgBroadcaster {
486
488
  }
487
489
  }
488
490
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
489
- const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
491
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
490
492
  const signMode = (0, wallet_base_1.isCosmosAminoOnlyWallet)(walletStrategy.wallet)
491
493
  ? sdk_ts_1.SIGN_EIP712
492
494
  : sdk_ts_1.SIGN_DIRECT;
@@ -529,11 +531,11 @@ class MsgBroadcaster {
529
531
  const response = await walletStrategy.sendTransaction(txRaw, {
530
532
  chainId,
531
533
  endpoints,
532
- txTimeout,
533
534
  address: tx.injectiveAddress,
535
+ txTimeout: txTimeoutInBlocks,
534
536
  });
535
537
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
536
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
538
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
537
539
  }
538
540
  const directSignResponse = (await walletStrategy.signCosmosTransaction({
539
541
  txRaw,
@@ -545,11 +547,11 @@ class MsgBroadcaster {
545
547
  const response = await walletStrategy.sendTransaction(directSignResponse, {
546
548
  chainId,
547
549
  endpoints,
548
- txTimeout,
550
+ txTimeout: txTimeoutInBlocks,
549
551
  address: tx.injectiveAddress,
550
552
  });
551
553
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
552
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
554
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
553
555
  }
554
556
  /**
555
557
  * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
@@ -558,7 +560,7 @@ class MsgBroadcaster {
558
560
  * @param tx the transaction that needs to be broadcasted
559
561
  */
560
562
  async experimentalBroadcastWalletThroughLedger(tx) {
561
- const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
563
+ const { chainId, endpoints, evmChainId, simulateTx, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
562
564
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
563
565
  /**
564
566
  * We can only use this method
@@ -576,7 +578,7 @@ class MsgBroadcaster {
576
578
  }
577
579
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
578
580
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
579
- const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
581
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
580
582
  const pubKey = await walletStrategy.getPubKey();
581
583
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
582
584
  /** EIP712 for signing on Ethereum wallets */
@@ -631,7 +633,7 @@ class MsgBroadcaster {
631
633
  const signatureBuff = Buffer.from(aminoSignResponse.signature.signature, 'base64');
632
634
  txRawEip712.signatures = [signatureBuff];
633
635
  /** Broadcast the transaction */
634
- const response = await new sdk_ts_1.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout });
636
+ const response = await new sdk_ts_1.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
635
637
  if (response.code !== 0) {
636
638
  throw new exceptions_1.TransactionException(new Error(response.rawLog), {
637
639
  code: exceptions_1.UnspecifiedErrorCode,
@@ -649,7 +651,7 @@ class MsgBroadcaster {
649
651
  * @returns transaction hash
650
652
  */
651
653
  async broadcastDirectSignWithFeeDelegation(tx) {
652
- const { options, chainId, txTimeout, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
654
+ const { options, chainId, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks, } = this;
653
655
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
654
656
  /**
655
657
  * We can only use this method when Keplr is connected
@@ -675,7 +677,9 @@ class MsgBroadcaster {
675
677
  }
676
678
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
677
679
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
678
- const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
680
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation
681
+ ? txTimeoutInBlocks
682
+ : utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
679
683
  const pubKey = await walletStrategy.getPubKey();
680
684
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
681
685
  /** Prepare the Transaction * */
@@ -731,7 +735,7 @@ class MsgBroadcaster {
731
735
  if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) {
732
736
  cosmosWallet.enableGasCheck(chainId);
733
737
  }
734
- return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
738
+ return await new sdk_ts_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * utils_1.DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
735
739
  }
736
740
  catch (e) {
737
741
  const error = e;
@@ -1,6 +1,6 @@
1
1
  import { EvmChainId } from '@injectivelabs/ts-types';
2
2
  import { isTestnet, isMainnet, getNetworkInfo, getNetworkEndpoints, } from '@injectivelabs/networks';
3
- import { sleep, getStdFee, toBigNumber, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
3
+ import { sleep, getStdFee, toBigNumber, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, } from '@injectivelabs/utils';
4
4
  import { WalletException, GeneralException, isThrownException, UnspecifiedErrorCode, ChainCosmosErrorCode, TransactionException, TransactionChainErrorModule, } from '@injectivelabs/exceptions';
5
5
  import { Wallet, isCosmosWallet, WalletDeviceType, isEvmBrowserWallet, isEip712V2OnlyWallet, createEip712StdSignDoc, isCosmosAminoOnlyWallet, getEthereumSignerAddress, getInjectiveSignerAddress, } from '@injectivelabs/wallet-base';
6
6
  import { TxGrpcApi, hexToBuff, PublicKey, SIGN_DIRECT, hexToBase64, ofacWallets, SIGN_EIP712, SIGN_EIP712_V2, ChainGrpcAuthApi, createTxRawEIP712, createTransaction, ChainGrpcTxFeesApi, getAminoStdSignDoc, getEip712TypedData, createWeb3Extension, getEip712TypedDataV2, IndexerGrpcWeb3GwApi, ChainGrpcTendermintApi, getGasPriceBasedOnMessage, createTxRawFromSigResponse, recoverTypedSignaturePubKey, createTransactionWithSigners, } from '@injectivelabs/sdk-ts';
@@ -211,7 +211,7 @@ export class MsgBroadcaster {
211
211
  * @returns transaction hash
212
212
  */
213
213
  async broadcastEip712(tx) {
214
- const { chainId, txTimeout, endpoints, walletStrategy } = this;
214
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
215
215
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
216
216
  const evmChainId = await this.getEvmChainId();
217
217
  if (!evmChainId) {
@@ -219,7 +219,7 @@ export class MsgBroadcaster {
219
219
  }
220
220
  /** Account Details * */
221
221
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
222
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
222
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
223
223
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
224
224
  let stdFee = getStdFee({ ...tx.gas, gas });
225
225
  /**
@@ -287,11 +287,11 @@ export class MsgBroadcaster {
287
287
  const response = await walletStrategy.sendTransaction(txRawEip712, {
288
288
  chainId,
289
289
  endpoints,
290
- txTimeout,
290
+ txTimeout: txTimeoutInBlocks,
291
291
  address: tx.injectiveAddress,
292
292
  });
293
293
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
294
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
294
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
295
295
  }
296
296
  /**
297
297
  * Prepare/sign/broadcast transaction using
@@ -303,7 +303,7 @@ export class MsgBroadcaster {
303
303
  * @returns transaction hash
304
304
  */
305
305
  async broadcastEip712V2(tx) {
306
- const { chainId, endpoints, txTimeout, walletStrategy } = this;
306
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
307
307
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
308
308
  const evmChainId = await this.getEvmChainId();
309
309
  if (!evmChainId) {
@@ -311,7 +311,7 @@ export class MsgBroadcaster {
311
311
  }
312
312
  /** Account Details * */
313
313
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
314
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
314
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
315
315
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
316
316
  let stdFee = getStdFee({ ...tx.gas, gas });
317
317
  /**
@@ -381,11 +381,11 @@ export class MsgBroadcaster {
381
381
  const response = await walletStrategy.sendTransaction(txRawEip712, {
382
382
  chainId,
383
383
  endpoints,
384
- txTimeout,
384
+ txTimeout: txTimeoutInBlocks,
385
385
  address: tx.injectiveAddress,
386
386
  });
387
387
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
388
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
388
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
389
389
  }
390
390
  /**
391
391
  * Prepare/sign/broadcast transaction using
@@ -395,7 +395,7 @@ export class MsgBroadcaster {
395
395
  * @returns transaction hash
396
396
  */
397
397
  async broadcastEip712WithFeeDelegation(tx) {
398
- const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
398
+ const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks, } = this;
399
399
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
400
400
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
401
401
  const evmChainId = await this.getEvmChainId();
@@ -410,7 +410,9 @@ export class MsgBroadcaster {
410
410
  if (txTimeoutOnFeeDelegation) {
411
411
  const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
412
412
  const latestHeight = latestBlock.header.height;
413
- timeoutHeight = toBigNumber(latestHeight).plus(txTimeout).toNumber();
413
+ timeoutHeight = toBigNumber(latestHeight)
414
+ .plus(txTimeoutInBlocks)
415
+ .toNumber();
414
416
  }
415
417
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
416
418
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -434,7 +436,7 @@ export class MsgBroadcaster {
434
436
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
435
437
  const response = await broadcast();
436
438
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
437
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
439
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
438
440
  }
439
441
  catch (e) {
440
442
  const error = e;
@@ -469,7 +471,7 @@ export class MsgBroadcaster {
469
471
  * @returns transaction hash
470
472
  */
471
473
  async broadcastDirectSign(tx) {
472
- const { walletStrategy, txTimeout, endpoints, chainId } = this;
474
+ const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
473
475
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
474
476
  /**
475
477
  * When using Ledger with Keplr/Leap we have
@@ -483,7 +485,7 @@ export class MsgBroadcaster {
483
485
  }
484
486
  }
485
487
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
486
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
488
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
487
489
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet)
488
490
  ? SIGN_EIP712
489
491
  : SIGN_DIRECT;
@@ -526,11 +528,11 @@ export class MsgBroadcaster {
526
528
  const response = await walletStrategy.sendTransaction(txRaw, {
527
529
  chainId,
528
530
  endpoints,
529
- txTimeout,
530
531
  address: tx.injectiveAddress,
532
+ txTimeout: txTimeoutInBlocks,
531
533
  });
532
534
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
533
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
535
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
534
536
  }
535
537
  const directSignResponse = (await walletStrategy.signCosmosTransaction({
536
538
  txRaw,
@@ -542,11 +544,11 @@ export class MsgBroadcaster {
542
544
  const response = await walletStrategy.sendTransaction(directSignResponse, {
543
545
  chainId,
544
546
  endpoints,
545
- txTimeout,
547
+ txTimeout: txTimeoutInBlocks,
546
548
  address: tx.injectiveAddress,
547
549
  });
548
550
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
549
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
551
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
550
552
  }
551
553
  /**
552
554
  * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
@@ -555,7 +557,7 @@ export class MsgBroadcaster {
555
557
  * @param tx the transaction that needs to be broadcasted
556
558
  */
557
559
  async experimentalBroadcastWalletThroughLedger(tx) {
558
- const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
560
+ const { chainId, endpoints, evmChainId, simulateTx, walletStrategy, txTimeout: txTimeoutInBlocks, } = this;
559
561
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
560
562
  /**
561
563
  * We can only use this method
@@ -573,7 +575,7 @@ export class MsgBroadcaster {
573
575
  }
574
576
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
575
577
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
576
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
578
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
577
579
  const pubKey = await walletStrategy.getPubKey();
578
580
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
579
581
  /** EIP712 for signing on Ethereum wallets */
@@ -628,7 +630,7 @@ export class MsgBroadcaster {
628
630
  const signatureBuff = Buffer.from(aminoSignResponse.signature.signature, 'base64');
629
631
  txRawEip712.signatures = [signatureBuff];
630
632
  /** Broadcast the transaction */
631
- const response = await new TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout });
633
+ const response = await new TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
632
634
  if (response.code !== 0) {
633
635
  throw new TransactionException(new Error(response.rawLog), {
634
636
  code: UnspecifiedErrorCode,
@@ -646,7 +648,7 @@ export class MsgBroadcaster {
646
648
  * @returns transaction hash
647
649
  */
648
650
  async broadcastDirectSignWithFeeDelegation(tx) {
649
- const { options, chainId, txTimeout, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
651
+ const { options, chainId, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks, } = this;
650
652
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
651
653
  /**
652
654
  * We can only use this method when Keplr is connected
@@ -672,7 +674,9 @@ export class MsgBroadcaster {
672
674
  }
673
675
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
674
676
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
675
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
677
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutOnFeeDelegation
678
+ ? txTimeoutInBlocks
679
+ : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
676
680
  const pubKey = await walletStrategy.getPubKey();
677
681
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
678
682
  /** Prepare the Transaction * */
@@ -728,7 +732,7 @@ export class MsgBroadcaster {
728
732
  if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) {
729
733
  cosmosWallet.enableGasCheck(chainId);
730
734
  }
731
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
735
+ return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1000);
732
736
  }
733
737
  catch (e) {
734
738
  const error = e;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
3
  "description": "Core wallet strategy",
4
- "version": "1.16.17",
4
+ "version": "1.16.19",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,17 +56,17 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.17",
60
- "@injectivelabs/networks": "1.16.17",
61
- "@injectivelabs/sdk-ts": "1.16.17",
62
- "@injectivelabs/ts-types": "1.16.17",
63
- "@injectivelabs/utils": "1.16.17",
64
- "@injectivelabs/wallet-base": "1.16.17",
59
+ "@injectivelabs/exceptions": "1.16.19",
60
+ "@injectivelabs/networks": "1.16.19",
61
+ "@injectivelabs/sdk-ts": "1.16.19",
62
+ "@injectivelabs/ts-types": "1.16.19",
63
+ "@injectivelabs/utils": "1.16.19",
64
+ "@injectivelabs/wallet-base": "1.16.19",
65
65
  "@keplr-wallet/types": "^0.12.159",
66
66
  "eventemitter3": "^5.0.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "shx": "^0.3.3"
70
70
  },
71
- "gitHead": "c99ac11b35e7a212f6a1f82cbf35540d6d053062"
71
+ "gitHead": "48a6522a9317958b108a4373c4b8412b10136859"
72
72
  }