@injectivelabs/wallet-core 1.19.15 → 1.19.17

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.
@@ -373,7 +373,7 @@ var MsgBroadcaster = class {
373
373
  * @param privateKey Taker (autosign) private key — hex, with or without `0x`
374
374
  * @returns transaction response with txHash
375
375
  */
376
- async broadcastWithFeePayerSig({ tx, privateKey, feePayerSig, accountNumber }) {
376
+ async broadcastWithFeePayerSig({ tx, skipPoll, privateKey, feePayerSig, accountNumber }) {
377
377
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
378
378
  const pk = __injectivelabs_sdk_ts_core_accounts.PrivateKey.fromHex(privateKey);
379
379
  if (__injectivelabs_sdk_ts_utils.ofacList.includes(pk.toHex().toLowerCase())) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
@@ -392,7 +392,10 @@ var MsgBroadcaster = class {
392
392
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
393
393
  txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? (0, __injectivelabs_sdk_ts_utils.hexToUint8Array)(feePayerSig.slice(2)) : (0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(feePayerSig)];
394
394
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
395
- const txResponse = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRaw, { txTimeout: txTimeoutInBlocks });
395
+ const txResponse = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
396
+ skipPoll,
397
+ txTimeout: txTimeoutInBlocks
398
+ });
396
399
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
397
400
  if (txResponse.code !== 0) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`Transaction failed - ${txResponse.rawLog} - ${txResponse.txHash}`), {
398
401
  code: __injectivelabs_exceptions.UnspecifiedErrorCode,
@@ -420,10 +423,8 @@ var MsgBroadcaster = class {
420
423
  var _tx$gas, _baseAccount$pubKey;
421
424
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
422
425
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
423
- const evmChainId = await this.getEvmChainId();
426
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
424
427
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
425
- /** Account Details * */
426
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
427
428
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight.toString()).plus(txTimeoutInBlocks);
428
429
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
429
430
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
@@ -496,6 +497,7 @@ var MsgBroadcaster = class {
496
497
  address: tx.injectiveAddress
497
498
  });
498
499
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
+ if (tx.skipPoll) return response;
499
501
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
500
502
  }
501
503
  /**
@@ -511,10 +513,8 @@ var MsgBroadcaster = class {
511
513
  var _tx$gas2, _baseAccount$pubKey2;
512
514
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
513
515
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
514
- const evmChainId = await this.getEvmChainId();
516
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
515
517
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
516
- /** Account Details * */
517
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
518
518
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
519
519
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
520
520
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
@@ -589,6 +589,7 @@ var MsgBroadcaster = class {
589
589
  address: tx.injectiveAddress
590
590
  });
591
591
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
+ if (tx.skipPoll) return response;
592
593
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
593
594
  }
594
595
  /**
@@ -632,6 +633,16 @@ var MsgBroadcaster = class {
632
633
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
633
634
  const response = await broadcast();
634
635
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
636
+ if (tx.skipPoll) return {
637
+ txHash: response.txHash,
638
+ height: Number(response.height),
639
+ codespace: response.codespace,
640
+ code: response.code,
641
+ rawLog: response.rawLog,
642
+ timestamp: response.timestamp,
643
+ gasWanted: 0,
644
+ gasUsed: 0
645
+ };
635
646
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
636
647
  } catch (e) {
637
648
  const error = e;
@@ -671,11 +682,10 @@ var MsgBroadcaster = class {
671
682
  if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Leap].includes(walletStrategy.getWallet())) {
672
683
  if (await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
673
684
  }
674
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
685
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
675
686
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
676
687
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
677
688
  const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
678
- const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
679
689
  const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
680
690
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
681
691
  /** Prepare the Transaction * */
@@ -719,6 +729,7 @@ var MsgBroadcaster = class {
719
729
  txTimeout: txTimeoutInBlocks
720
730
  });
721
731
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
+ if (tx.skipPoll) return response$1;
722
733
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
723
734
  }
724
735
  const directSignResponse = await walletStrategy.signCosmosTransaction({
@@ -735,6 +746,7 @@ var MsgBroadcaster = class {
735
746
  address: tx.injectiveAddress
736
747
  });
737
748
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
+ if (tx.skipPoll) return response;
738
750
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
739
751
  }
740
752
  /**
@@ -756,9 +768,8 @@ var MsgBroadcaster = class {
756
768
  }
757
769
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
758
770
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
759
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
771
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
760
772
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
761
- const pubKey = await walletStrategy.getPubKey();
762
773
  const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
763
774
  /** EIP712 for signing on Ethereum wallets */
764
775
  const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
@@ -807,7 +818,10 @@ var MsgBroadcaster = class {
807
818
  if (simulateTx) await this.simulateTxRaw(txRawEip712);
808
819
  txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(aminoSignResponse.signature.signature)];
809
820
  /** Broadcast the transaction */
810
- const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
821
+ const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, {
822
+ txTimeout: txTimeoutInBlocks,
823
+ skipPoll: tx.skipPoll
824
+ });
811
825
  if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
812
826
  code: __injectivelabs_exceptions.UnspecifiedErrorCode,
813
827
  contextCode: response.code,
@@ -842,7 +856,7 @@ var MsgBroadcaster = class {
842
856
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
843
857
  const fetchAccountBlockDetails = async () => {
844
858
  try {
845
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
859
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
846
860
  return {
847
861
  baseAccount: baseAccount$1,
848
862
  latestHeight: latestHeight$1
@@ -918,6 +932,16 @@ var MsgBroadcaster = class {
918
932
  const response = await broadcast();
919
933
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
920
934
  if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
935
+ if (tx.skipPoll) return {
936
+ txHash: response.txHash,
937
+ height: Number(response.height),
938
+ codespace: response.codespace,
939
+ code: response.code,
940
+ rawLog: response.rawLog,
941
+ timestamp: response.timestamp,
942
+ gasWanted: 0,
943
+ gasUsed: 0
944
+ };
921
945
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
922
946
  } catch (e) {
923
947
  const error = e;
@@ -1032,20 +1056,21 @@ var MsgBroadcaster = class {
1032
1056
  throw e;
1033
1057
  }
1034
1058
  }
1035
- async fetchAccountAndBlockDetails(address) {
1059
+ async fetchAccountAndBlockDetails(address, existingAccountDetails) {
1036
1060
  const { endpoints, httpHeaders } = this;
1037
- const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
1038
1061
  const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
1039
- if (httpHeaders) {
1040
- chainClient.setMetadata(httpHeaders);
1041
- tendermintClient.setMetadata(httpHeaders);
1042
- }
1043
- const accountDetails = await chainClient.fetchAccount(address);
1062
+ if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
1063
+ if (existingAccountDetails) return {
1064
+ baseAccount: existingAccountDetails,
1065
+ latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
1066
+ };
1067
+ const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
1068
+ if (httpHeaders) chainClient.setMetadata(httpHeaders);
1069
+ const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
1044
1070
  const { baseAccount } = accountDetails;
1045
1071
  return {
1046
1072
  baseAccount,
1047
- latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString(),
1048
- accountDetails
1073
+ latestHeight: latestBlock.header.height.toString()
1049
1074
  };
1050
1075
  }
1051
1076
  };
@@ -6,6 +6,7 @@ import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
6
6
  import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
7
7
  import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
8
8
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
9
+ import { AuthBaseAccount } from "@injectivelabs/sdk-ts/client/chain";
9
10
 
10
11
  //#region src/utils/tx.d.ts
11
12
  declare const checkIfTxRunOutOfGas: (e: unknown) => boolean;
@@ -78,6 +79,9 @@ interface MsgBroadcasterTxOptions {
78
79
  ethereumAddress?: string;
79
80
  injectiveAddress?: string;
80
81
  msgs: Msgs | Msgs[];
82
+ accountDetails?: AuthBaseAccount;
83
+ /** Return txHash immediately without polling for block inclusion. Note: gasWanted/gasUsed will be 0 in fee-delegation paths. */
84
+ skipPoll?: boolean;
81
85
  gas?: {
82
86
  gasPrice?: string;
83
87
  gas?: number; /** gas limit */
@@ -176,11 +180,13 @@ declare class MsgBroadcaster {
176
180
  */
177
181
  broadcastWithFeePayerSig({
178
182
  tx,
183
+ skipPoll,
179
184
  privateKey,
180
185
  feePayerSig,
181
186
  accountNumber
182
187
  }: {
183
188
  privateKey: string;
189
+ skipPoll?: boolean;
184
190
  feePayerSig: string;
185
191
  accountNumber: number;
186
192
  tx: Uint8Array | string;
@@ -1,6 +1,7 @@
1
1
  import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
2
2
  import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
3
3
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
4
+ import { AuthBaseAccount } from "@injectivelabs/sdk-ts/client/chain";
4
5
  import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
5
6
  import { StdSignDoc } from "@keplr-wallet/types";
6
7
  import { OfflineSigner } from "@cosmjs/proto-signing";
@@ -78,6 +79,9 @@ interface MsgBroadcasterTxOptions {
78
79
  ethereumAddress?: string;
79
80
  injectiveAddress?: string;
80
81
  msgs: Msgs | Msgs[];
82
+ accountDetails?: AuthBaseAccount;
83
+ /** Return txHash immediately without polling for block inclusion. Note: gasWanted/gasUsed will be 0 in fee-delegation paths. */
84
+ skipPoll?: boolean;
81
85
  gas?: {
82
86
  gasPrice?: string;
83
87
  gas?: number; /** gas limit */
@@ -176,11 +180,13 @@ declare class MsgBroadcaster {
176
180
  */
177
181
  broadcastWithFeePayerSig({
178
182
  tx,
183
+ skipPoll,
179
184
  privateKey,
180
185
  feePayerSig,
181
186
  accountNumber
182
187
  }: {
183
188
  privateKey: string;
189
+ skipPoll?: boolean;
184
190
  feePayerSig: string;
185
191
  accountNumber: number;
186
192
  tx: Uint8Array | string;
package/dist/esm/index.js CHANGED
@@ -373,7 +373,7 @@ var MsgBroadcaster = class {
373
373
  * @param privateKey Taker (autosign) private key — hex, with or without `0x`
374
374
  * @returns transaction response with txHash
375
375
  */
376
- async broadcastWithFeePayerSig({ tx, privateKey, feePayerSig, accountNumber }) {
376
+ async broadcastWithFeePayerSig({ tx, skipPoll, privateKey, feePayerSig, accountNumber }) {
377
377
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
378
378
  const pk = PrivateKey.fromHex(privateKey);
379
379
  if (ofacList.includes(pk.toHex().toLowerCase())) throw new GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
@@ -392,7 +392,10 @@ var MsgBroadcaster = class {
392
392
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
393
393
  txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? hexToUint8Array(feePayerSig.slice(2)) : base64ToUint8Array(feePayerSig)];
394
394
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
395
- const txResponse = await new TxGrpcApi(endpoints.grpc).broadcast(txRaw, { txTimeout: txTimeoutInBlocks });
395
+ const txResponse = await new TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
396
+ skipPoll,
397
+ txTimeout: txTimeoutInBlocks
398
+ });
396
399
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
397
400
  if (txResponse.code !== 0) throw new TransactionException(/* @__PURE__ */ new Error(`Transaction failed - ${txResponse.rawLog} - ${txResponse.txHash}`), {
398
401
  code: UnspecifiedErrorCode,
@@ -420,10 +423,8 @@ var MsgBroadcaster = class {
420
423
  var _tx$gas, _baseAccount$pubKey;
421
424
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
422
425
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
423
- const evmChainId = await this.getEvmChainId();
426
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
424
427
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
425
- /** Account Details * */
426
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
427
428
  const timeoutHeight = toBigNumber(latestHeight.toString()).plus(txTimeoutInBlocks);
428
429
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
429
430
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
@@ -496,6 +497,7 @@ var MsgBroadcaster = class {
496
497
  address: tx.injectiveAddress
497
498
  });
498
499
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
+ if (tx.skipPoll) return response;
499
501
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
500
502
  }
501
503
  /**
@@ -511,10 +513,8 @@ var MsgBroadcaster = class {
511
513
  var _tx$gas2, _baseAccount$pubKey2;
512
514
  const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
513
515
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
514
- const evmChainId = await this.getEvmChainId();
516
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
515
517
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
516
- /** Account Details * */
517
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
518
518
  const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
519
519
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
520
520
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
@@ -589,6 +589,7 @@ var MsgBroadcaster = class {
589
589
  address: tx.injectiveAddress
590
590
  });
591
591
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
+ if (tx.skipPoll) return response;
592
593
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
593
594
  }
594
595
  /**
@@ -632,6 +633,16 @@ var MsgBroadcaster = class {
632
633
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
633
634
  const response = await broadcast();
634
635
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
636
+ if (tx.skipPoll) return {
637
+ txHash: response.txHash,
638
+ height: Number(response.height),
639
+ codespace: response.codespace,
640
+ code: response.code,
641
+ rawLog: response.rawLog,
642
+ timestamp: response.timestamp,
643
+ gasWanted: 0,
644
+ gasUsed: 0
645
+ };
635
646
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
636
647
  } catch (e) {
637
648
  const error = e;
@@ -671,11 +682,10 @@ var MsgBroadcaster = class {
671
682
  if ([Wallet.Keplr, Wallet.Leap].includes(walletStrategy.getWallet())) {
672
683
  if (await walletStrategy.getWalletDeviceType() === WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
673
684
  }
674
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
685
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
675
686
  const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
676
687
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
677
688
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet) ? SIGN_EIP712 : SIGN_DIRECT;
678
- const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
679
689
  const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || getGasPriceBasedOnMessage(msgs)).toString();
680
690
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
681
691
  /** Prepare the Transaction * */
@@ -719,6 +729,7 @@ var MsgBroadcaster = class {
719
729
  txTimeout: txTimeoutInBlocks
720
730
  });
721
731
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
+ if (tx.skipPoll) return response$1;
722
733
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
723
734
  }
724
735
  const directSignResponse = await walletStrategy.signCosmosTransaction({
@@ -735,6 +746,7 @@ var MsgBroadcaster = class {
735
746
  address: tx.injectiveAddress
736
747
  });
737
748
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
+ if (tx.skipPoll) return response;
738
750
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
739
751
  }
740
752
  /**
@@ -756,9 +768,8 @@ var MsgBroadcaster = class {
756
768
  }
757
769
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
758
770
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
759
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
771
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
760
772
  const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
761
- const pubKey = await walletStrategy.getPubKey();
762
773
  const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || getGasPriceBasedOnMessage(msgs)).toString();
763
774
  /** EIP712 for signing on Ethereum wallets */
764
775
  const eip712TypedData = getEip712TypedData({
@@ -807,7 +818,10 @@ var MsgBroadcaster = class {
807
818
  if (simulateTx) await this.simulateTxRaw(txRawEip712);
808
819
  txRawEip712.signatures = [base64ToUint8Array(aminoSignResponse.signature.signature)];
809
820
  /** Broadcast the transaction */
810
- const response = await new TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
821
+ const response = await new TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, {
822
+ txTimeout: txTimeoutInBlocks,
823
+ skipPoll: tx.skipPoll
824
+ });
811
825
  if (response.code !== 0) throw new TransactionException(new Error(response.rawLog), {
812
826
  code: UnspecifiedErrorCode,
813
827
  contextCode: response.code,
@@ -842,7 +856,7 @@ var MsgBroadcaster = class {
842
856
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
843
857
  const fetchAccountBlockDetails = async () => {
844
858
  try {
845
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
859
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
846
860
  return {
847
861
  baseAccount: baseAccount$1,
848
862
  latestHeight: latestHeight$1
@@ -918,6 +932,16 @@ var MsgBroadcaster = class {
918
932
  const response = await broadcast();
919
933
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
920
934
  if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
935
+ if (tx.skipPoll) return {
936
+ txHash: response.txHash,
937
+ height: Number(response.height),
938
+ codespace: response.codespace,
939
+ code: response.code,
940
+ rawLog: response.rawLog,
941
+ timestamp: response.timestamp,
942
+ gasWanted: 0,
943
+ gasUsed: 0
944
+ };
921
945
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
922
946
  } catch (e) {
923
947
  const error = e;
@@ -1032,20 +1056,21 @@ var MsgBroadcaster = class {
1032
1056
  throw e;
1033
1057
  }
1034
1058
  }
1035
- async fetchAccountAndBlockDetails(address) {
1059
+ async fetchAccountAndBlockDetails(address, existingAccountDetails) {
1036
1060
  const { endpoints, httpHeaders } = this;
1037
- const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
1038
1061
  const tendermintClient = new ChainGrpcTendermintApi(endpoints.grpc);
1039
- if (httpHeaders) {
1040
- chainClient.setMetadata(httpHeaders);
1041
- tendermintClient.setMetadata(httpHeaders);
1042
- }
1043
- const accountDetails = await chainClient.fetchAccount(address);
1062
+ if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
1063
+ if (existingAccountDetails) return {
1064
+ baseAccount: existingAccountDetails,
1065
+ latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
1066
+ };
1067
+ const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
1068
+ if (httpHeaders) chainClient.setMetadata(httpHeaders);
1069
+ const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
1044
1070
  const { baseAccount } = accountDetails;
1045
1071
  return {
1046
1072
  baseAccount,
1047
- latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString(),
1048
- accountDetails
1073
+ latestHeight: latestBlock.header.height.toString()
1049
1074
  };
1050
1075
  }
1051
1076
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.19.15",
3
+ "version": "1.19.17",
4
4
  "description": "Core wallet strategy",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -44,12 +44,12 @@
44
44
  "dependencies": {
45
45
  "@keplr-wallet/types": "^0.12.296",
46
46
  "eventemitter3": "^5.0.1",
47
- "@injectivelabs/exceptions": "1.19.15",
48
- "@injectivelabs/networks": "1.19.15",
49
- "@injectivelabs/sdk-ts": "1.19.15",
50
- "@injectivelabs/utils": "1.19.15",
51
- "@injectivelabs/ts-types": "1.19.15",
52
- "@injectivelabs/wallet-base": "1.19.15"
47
+ "@injectivelabs/exceptions": "1.19.17",
48
+ "@injectivelabs/ts-types": "1.19.17",
49
+ "@injectivelabs/networks": "1.19.17",
50
+ "@injectivelabs/utils": "1.19.17",
51
+ "@injectivelabs/wallet-base": "1.19.17",
52
+ "@injectivelabs/sdk-ts": "1.19.17"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"