@injectivelabs/wallet-core 1.20.14 → 1.20.16

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.
@@ -1,6 +1,6 @@
1
1
  import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
2
2
  import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
3
- import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base/light";
3
+ import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base/runtime-light";
4
4
  import { StdSignDoc } from "@keplr-wallet/types";
5
5
  import { OfflineSigner } from "@cosmjs/proto-signing";
6
6
  import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
@@ -41,6 +41,7 @@ var MsgBroadcaster = class {
41
41
  require_defineProperty._defineProperty(this, "chainId", void 0);
42
42
  require_defineProperty._defineProperty(this, "txTimeout", __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
43
43
  require_defineProperty._defineProperty(this, "simulateTx", true);
44
+ require_defineProperty._defineProperty(this, "useDynamicBaseFee", false);
44
45
  require_defineProperty._defineProperty(this, "txTimeoutOnFeeDelegation", false);
45
46
  require_defineProperty._defineProperty(this, "evmChainId", void 0);
46
47
  require_defineProperty._defineProperty(this, "gasBufferCoefficient", 1.2);
@@ -50,6 +51,7 @@ var MsgBroadcaster = class {
50
51
  const networkInfo = (0, __injectivelabs_networks.getNetworkInfo)(options.network);
51
52
  this.options = options;
52
53
  this.simulateTx = options.simulateTx !== void 0 ? options.simulateTx : true;
54
+ this.useDynamicBaseFee = options.useDynamicBaseFee !== void 0 ? options.useDynamicBaseFee : false;
53
55
  this.txTimeout = options.txTimeout || __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT;
54
56
  this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation !== void 0 ? options.txTimeoutOnFeeDelegation : true;
55
57
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
@@ -61,10 +63,11 @@ var MsgBroadcaster = class {
61
63
  this.txInclusion = options.txInclusion;
62
64
  }
63
65
  setOptions(options) {
64
- this.simulateTx = options.simulateTx || this.simulateTx;
65
- this.txTimeout = options.txTimeout || this.txTimeout;
66
- this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation || this.txTimeoutOnFeeDelegation;
67
- this.txInclusion = options.txInclusion || this.txInclusion;
66
+ this.simulateTx = options.simulateTx !== void 0 ? options.simulateTx : this.simulateTx;
67
+ this.useDynamicBaseFee = options.useDynamicBaseFee !== void 0 ? options.useDynamicBaseFee : this.useDynamicBaseFee;
68
+ this.txTimeout = options.txTimeout !== void 0 ? options.txTimeout : this.txTimeout;
69
+ this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation !== void 0 ? options.txTimeoutOnFeeDelegation : this.txTimeoutOnFeeDelegation;
70
+ this.txInclusion = options.txInclusion !== void 0 ? options.txInclusion : this.txInclusion;
68
71
  }
69
72
  async getEvmChainId() {
70
73
  const { walletStrategy } = this;
@@ -234,9 +237,18 @@ var MsgBroadcaster = class {
234
237
  const { chainId, endpoints, walletStrategy } = this;
235
238
  const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
236
239
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
237
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
240
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails({
241
+ latestHeight: tx.latestHeight,
242
+ timeoutHeight: tx.timeoutHeight,
243
+ address: tx.injectiveAddress,
244
+ existingAccountDetails: tx.accountDetails
245
+ })]);
238
246
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
239
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight.toString()).plus(txTimeoutInBlocks);
247
+ const timeoutHeight = this.resolveTimeoutHeight({
248
+ tx,
249
+ latestHeight,
250
+ txTimeoutInBlocks
251
+ });
240
252
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
241
253
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
242
254
  const gas = (((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
@@ -345,9 +357,18 @@ var MsgBroadcaster = class {
345
357
  const { chainId, endpoints, walletStrategy } = this;
346
358
  const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
347
359
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
348
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
360
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails({
361
+ latestHeight: tx.latestHeight,
362
+ timeoutHeight: tx.timeoutHeight,
363
+ address: tx.injectiveAddress,
364
+ existingAccountDetails: tx.accountDetails
365
+ })]);
349
366
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
350
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
367
+ const timeoutHeight = this.resolveTimeoutHeight({
368
+ tx,
369
+ latestHeight,
370
+ txTimeoutInBlocks
371
+ });
351
372
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
352
373
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
353
374
  const gas = (((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
@@ -462,11 +483,22 @@ var MsgBroadcaster = class {
462
483
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
463
484
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
464
485
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
465
- let timeoutHeight = void 0;
466
- if (txTimeoutOnFeeDelegation) timeoutHeight = (0, __injectivelabs_utils.toBigNumber)((await new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
486
+ let timeoutHeight = this.resolveOptionalTimeoutHeight({
487
+ tx,
488
+ latestHeight: tx.latestHeight,
489
+ txTimeoutInBlocks
490
+ });
491
+ if (timeoutHeight === void 0 && txTimeoutOnFeeDelegation) {
492
+ const latestHeight = (await new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString();
493
+ timeoutHeight = this.resolveTimeoutHeight({
494
+ tx,
495
+ latestHeight,
496
+ txTimeoutInBlocks
497
+ });
498
+ }
467
499
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationStart);
468
500
  const prepareTxResponse = await transactionApi.prepareTxRequest({
469
- timeoutHeight,
501
+ timeoutHeight: timeoutHeight === null || timeoutHeight === void 0 ? void 0 : timeoutHeight.toNumber(),
470
502
  memo: tx.memo,
471
503
  message: web3Msgs,
472
504
  address: tx.ethereumAddress,
@@ -532,8 +564,17 @@ var MsgBroadcaster = class {
532
564
  if ([__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.Leap].includes(walletStrategy.getWallet())) {
533
565
  if (await walletStrategy.getWalletDeviceType() === __injectivelabs_wallet_base.WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
534
566
  }
535
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
536
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
567
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails({
568
+ latestHeight: tx.latestHeight,
569
+ timeoutHeight: tx.timeoutHeight,
570
+ address: tx.injectiveAddress,
571
+ existingAccountDetails: tx.accountDetails
572
+ }), walletStrategy.getPubKey(tx.injectiveAddress)]);
573
+ const timeoutHeight = this.resolveTimeoutHeight({
574
+ tx,
575
+ latestHeight,
576
+ txTimeoutInBlocks
577
+ });
537
578
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
538
579
  const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
539
580
  const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
@@ -659,8 +700,17 @@ var MsgBroadcaster = class {
659
700
  }
660
701
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
661
702
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
662
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
663
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
703
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails({
704
+ latestHeight: tx.latestHeight,
705
+ timeoutHeight: tx.timeoutHeight,
706
+ address: tx.injectiveAddress,
707
+ existingAccountDetails: tx.accountDetails
708
+ }), walletStrategy.getPubKey()]);
709
+ const timeoutHeight = this.resolveTimeoutHeight({
710
+ tx,
711
+ latestHeight,
712
+ txTimeoutInBlocks
713
+ });
664
714
  const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
665
715
  /** EIP712 for signing on Ethereum wallets */
666
716
  const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
@@ -751,7 +801,12 @@ var MsgBroadcaster = class {
751
801
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
752
802
  const fetchAccountBlockDetails = async () => {
753
803
  try {
754
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
804
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails({
805
+ latestHeight: tx.latestHeight,
806
+ timeoutHeight: tx.timeoutHeight,
807
+ address: tx.injectiveAddress,
808
+ existingAccountDetails: tx.accountDetails
809
+ });
755
810
  return {
756
811
  baseAccount: baseAccount$1,
757
812
  latestHeight: latestHeight$1
@@ -765,7 +820,11 @@ var MsgBroadcaster = class {
765
820
  memo: tx.memo,
766
821
  estimateGas: simulateTx
767
822
  });
768
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
823
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails({
824
+ latestHeight: tx.latestHeight,
825
+ timeoutHeight: tx.timeoutHeight,
826
+ address: tx.injectiveAddress
827
+ });
769
828
  return {
770
829
  baseAccount: baseAccount$1,
771
830
  latestHeight: latestHeight$1
@@ -774,14 +833,21 @@ var MsgBroadcaster = class {
774
833
  throw e;
775
834
  }
776
835
  };
777
- /** Account Details * */
778
- const { baseAccount, latestHeight } = await fetchAccountBlockDetails();
779
836
  const chainGrpcAuthApi = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
780
837
  if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
781
- const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
782
- const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeoutInBlocks : __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
838
+ const [accountBlockDetails, feePayerAccountDetails, pubKey] = await Promise.all([
839
+ fetchAccountBlockDetails(),
840
+ chainGrpcAuthApi.fetchAccount(feePayer),
841
+ walletStrategy.getPubKey()
842
+ ]);
843
+ const { baseAccount, latestHeight } = accountBlockDetails;
844
+ const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
845
+ const timeoutHeight = this.resolveTimeoutHeight({
846
+ tx,
847
+ latestHeight,
848
+ txTimeoutInBlocks: txTimeoutOnFeeDelegation ? txTimeoutInBlocks : __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT
849
+ });
783
850
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
784
- const pubKey = await walletStrategy.getPubKey();
785
851
  const gas = (((_tx$gas7 = tx.gas) === null || _tx$gas7 === void 0 ? void 0 : _tx$gas7.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
786
852
  /** Prepare the Transaction * */
787
853
  const { txRaw } = await this.getTxWithSignersAndStdFee({
@@ -872,7 +938,9 @@ var MsgBroadcaster = class {
872
938
  return response.feePayerPubKey.key;
873
939
  }
874
940
  async getStdFeeWithDynamicBaseFee(args) {
875
- const client = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTxFeesApi(this.endpoints.grpc);
941
+ const { endpoints, useDynamicBaseFee } = this;
942
+ if (!useDynamicBaseFee) return (0, __injectivelabs_utils.getStdFee)(args);
943
+ const client = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTxFeesApi(endpoints.grpc);
876
944
  let baseFee = __injectivelabs_utils.DEFAULT_GAS_PRICE;
877
945
  try {
878
946
  const response = await client.fetchEipBaseFee();
@@ -960,23 +1028,52 @@ var MsgBroadcaster = class {
960
1028
  throw e;
961
1029
  }
962
1030
  }
963
- async fetchAccountAndBlockDetails(address, existingAccountDetails) {
1031
+ async fetchAccountAndBlockDetails({ address, latestHeight, timeoutHeight, existingAccountDetails }) {
964
1032
  const { endpoints, httpHeaders } = this;
965
- const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
966
- if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
967
- if (existingAccountDetails) return {
968
- baseAccount: existingAccountDetails,
969
- latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
970
- };
1033
+ const shouldFetchLatestHeight = latestHeight === void 0 && timeoutHeight === void 0;
1034
+ if (existingAccountDetails) {
1035
+ if (!shouldFetchLatestHeight) return {
1036
+ latestHeight: latestHeight === null || latestHeight === void 0 ? void 0 : latestHeight.toString(),
1037
+ baseAccount: existingAccountDetails
1038
+ };
1039
+ const tendermintClient$1 = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
1040
+ if (httpHeaders) tendermintClient$1.setMetadata(httpHeaders);
1041
+ return {
1042
+ baseAccount: existingAccountDetails,
1043
+ latestHeight: (await tendermintClient$1.fetchLatestBlock()).header.height.toString()
1044
+ };
1045
+ }
971
1046
  const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
972
1047
  if (httpHeaders) chainClient.setMetadata(httpHeaders);
1048
+ if (!shouldFetchLatestHeight) {
1049
+ const accountDetails$1 = await chainClient.fetchAccount(address);
1050
+ return {
1051
+ latestHeight: latestHeight === null || latestHeight === void 0 ? void 0 : latestHeight.toString(),
1052
+ baseAccount: accountDetails$1.baseAccount
1053
+ };
1054
+ }
1055
+ const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
1056
+ if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
973
1057
  const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
974
- const { baseAccount } = accountDetails;
975
1058
  return {
976
- baseAccount,
1059
+ baseAccount: accountDetails.baseAccount,
977
1060
  latestHeight: latestBlock.header.height.toString()
978
1061
  };
979
1062
  }
1063
+ resolveOptionalTimeoutHeight({ tx, latestHeight, txTimeoutInBlocks }) {
1064
+ if (tx.timeoutHeight !== void 0) return (0, __injectivelabs_utils.toBigNumber)(tx.timeoutHeight);
1065
+ if (latestHeight === void 0) return;
1066
+ return (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
1067
+ }
1068
+ resolveTimeoutHeight({ tx, latestHeight, txTimeoutInBlocks }) {
1069
+ const timeoutHeight = this.resolveOptionalTimeoutHeight({
1070
+ tx,
1071
+ latestHeight,
1072
+ txTimeoutInBlocks
1073
+ });
1074
+ if (!timeoutHeight) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide latestHeight or timeoutHeight"));
1075
+ return timeoutHeight;
1076
+ }
980
1077
  resolveTimeoutInBlocks(override) {
981
1078
  return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
982
1079
  }
@@ -1,4 +1,4 @@
1
- const require_broadcaster = require('./broadcaster-CuStNJ2g.cjs');
1
+ const require_broadcaster = require('./broadcaster-DTwN2Hve.cjs');
2
2
  require('./defineProperty-CImP5zIM.cjs');
3
3
 
4
4
  exports.MsgBroadcaster = require_broadcaster.MsgBroadcaster;
@@ -1,3 +1,3 @@
1
- import "./BaseWalletStrategy-Bvs5nQRI.cjs";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-aQCoSOFW.cjs";
1
+ import "./BaseWalletStrategy-CD9sBzZB.cjs";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-DIurlb8S.cjs";
3
3
  export { MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster };
@@ -1,4 +1,4 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-Bvs5nQRI.cjs";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-CD9sBzZB.cjs";
2
2
  import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
3
3
  import { ChainId, EvmChainId } from "@injectivelabs/ts-types";
4
4
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
@@ -12,6 +12,8 @@ interface MsgBroadcasterTxOptions {
12
12
  ethereumAddress?: string;
13
13
  injectiveAddress?: string;
14
14
  accountDetails?: AuthBaseAccount;
15
+ latestHeight?: number | string;
16
+ timeoutHeight?: number | string;
15
17
  txTimeoutInBlocks?: number;
16
18
  txInclusion?: TxClientInclusionOptions;
17
19
  gas?: {
@@ -27,15 +29,16 @@ interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
27
29
  }
28
30
  interface MsgBroadcasterOptions {
29
31
  network: Network;
30
- endpoints?: NetworkEndpoints;
31
32
  chainId?: ChainId;
33
+ txTimeout?: number;
34
+ simulateTx?: boolean;
32
35
  evmChainId?: EvmChainId;
33
36
  feePayerPubKey?: string;
34
- simulateTx?: boolean;
35
- txTimeoutOnFeeDelegation?: boolean;
36
- txTimeout?: number;
37
+ endpoints?: NetworkEndpoints;
37
38
  txInclusion?: TxClientInclusionOptions;
38
39
  walletStrategy: BaseWalletStrategy;
40
+ useDynamicBaseFee?: boolean;
41
+ txTimeoutOnFeeDelegation?: boolean;
39
42
  gasBufferCoefficient?: number;
40
43
  httpHeaders?: Record<string, string>;
41
44
  }
@@ -55,6 +58,7 @@ declare class MsgBroadcaster {
55
58
  chainId: ChainId;
56
59
  txTimeout: number;
57
60
  simulateTx: boolean;
61
+ useDynamicBaseFee: boolean;
58
62
  txTimeoutOnFeeDelegation: boolean;
59
63
  evmChainId?: EvmChainId;
60
64
  gasBufferCoefficient: number;
@@ -204,6 +208,8 @@ declare class MsgBroadcaster {
204
208
  private simulateTxWithSigners;
205
209
  private retryOnException;
206
210
  private fetchAccountAndBlockDetails;
211
+ private resolveOptionalTimeoutHeight;
212
+ private resolveTimeoutHeight;
207
213
  private resolveTimeoutInBlocks;
208
214
  private resolveTxInclusionOptions;
209
215
  private createTxGrpcApi;
@@ -1,6 +1,6 @@
1
- const require_broadcaster = require('./broadcaster-CuStNJ2g.cjs');
1
+ const require_broadcaster = require('./broadcaster-DTwN2Hve.cjs');
2
2
  require('./defineProperty-CImP5zIM.cjs');
3
- const require_strategy = require('./strategy-D8mmr647.cjs');
3
+ const require_strategy = require('./strategy-BxKznCI0.cjs');
4
4
 
5
5
  exports.BaseWalletStrategy = require_strategy.BaseWalletStrategy;
6
6
  exports.MsgBroadcaster = require_broadcaster.MsgBroadcaster;
@@ -1,5 +1,5 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-Bvs5nQRI.cjs";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-aQCoSOFW.cjs";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-CD9sBzZB.cjs";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-DIurlb8S.cjs";
3
3
  import "./index-DLoAMD9J.cjs";
4
4
 
5
5
  //#region src/utils/tx.d.ts
@@ -1,15 +1,15 @@
1
1
  const require_defineProperty = require('./defineProperty-CImP5zIM.cjs');
2
2
  let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
3
3
  let eventemitter3 = require("eventemitter3");
4
- let __injectivelabs_wallet_base_light = require("@injectivelabs/wallet-base/light");
4
+ let __injectivelabs_wallet_base_runtime_light = require("@injectivelabs/wallet-base/runtime-light");
5
5
 
6
6
  //#region src/strategy/BaseWalletStrategy.ts
7
7
  const getInitialWallet = (args) => {
8
8
  if (args.wallet) return args.wallet;
9
9
  const keys = Object.keys(args.strategies || {});
10
- if (keys.length === 0) return __injectivelabs_wallet_base_light.Wallet.Metamask;
11
- if (keys.includes(__injectivelabs_wallet_base_light.Wallet.Metamask) && args.evmOptions) return __injectivelabs_wallet_base_light.Wallet.Metamask;
12
- if (keys.includes(__injectivelabs_wallet_base_light.Wallet.Keplr) && !args.evmOptions) return __injectivelabs_wallet_base_light.Wallet.Keplr;
10
+ if (keys.length === 0) return __injectivelabs_wallet_base_runtime_light.Wallet.Metamask;
11
+ if (keys.includes(__injectivelabs_wallet_base_runtime_light.Wallet.Metamask) && args.evmOptions) return __injectivelabs_wallet_base_runtime_light.Wallet.Metamask;
12
+ if (keys.includes(__injectivelabs_wallet_base_runtime_light.Wallet.Keplr) && !args.evmOptions) return __injectivelabs_wallet_base_runtime_light.Wallet.Keplr;
13
13
  return keys[0];
14
14
  };
15
15
  var BaseWalletStrategy = class {
@@ -101,33 +101,33 @@ var BaseWalletStrategy = class {
101
101
  return this.getStrategy().sendEvmTransaction(tx, options);
102
102
  }
103
103
  async signEip712TypedData(eip712TypedData, address, options = {}) {
104
- if ((0, __injectivelabs_wallet_base_light.isCosmosWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Ethereum Transaction using ${this.wallet}`));
104
+ if ((0, __injectivelabs_wallet_base_runtime_light.isCosmosWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Ethereum Transaction using ${this.wallet}`));
105
105
  /** Phantom wallet needs enabling before signing */
106
- if (this.wallet === __injectivelabs_wallet_base_light.Wallet.Phantom) await this.enable();
107
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSignStart);
106
+ if (this.wallet === __injectivelabs_wallet_base_runtime_light.Wallet.Phantom) await this.enable();
107
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSignStart);
108
108
  const response = await this.getStrategy().signEip712TypedData(eip712TypedData, address, options);
109
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSigned);
109
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSigned);
110
110
  return response;
111
111
  }
112
112
  async signAminoCosmosTransaction(transaction) {
113
- if ((0, __injectivelabs_wallet_base_light.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
114
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSignStart);
113
+ if ((0, __injectivelabs_wallet_base_runtime_light.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
114
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSignStart);
115
115
  const response = await this.getStrategy().signAminoCosmosTransaction(transaction);
116
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSigned);
116
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSigned);
117
117
  return response;
118
118
  }
119
119
  async signCosmosTransaction(transaction) {
120
- if ((0, __injectivelabs_wallet_base_light.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
121
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSignStart);
120
+ if ((0, __injectivelabs_wallet_base_runtime_light.isEvmWallet)(this.wallet)) throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error(`You can't sign Cosmos Transaction using ${this.wallet}`));
121
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSignStart);
122
122
  const response = await this.getStrategy().signCosmosTransaction(transaction);
123
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSigned);
123
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSigned);
124
124
  return response;
125
125
  }
126
126
  async signArbitrary(signer, data) {
127
127
  if (this.getStrategy().signArbitrary) {
128
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSignStart);
128
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSignStart);
129
129
  const response = await this.getStrategy().signArbitrary(signer, data);
130
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.TransactionSigned);
130
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.TransactionSigned);
131
131
  return response;
132
132
  }
133
133
  }
@@ -140,7 +140,7 @@ var BaseWalletStrategy = class {
140
140
  async disconnect() {
141
141
  if (this.getStrategy().disconnect) {
142
142
  await this.getStrategy().disconnect();
143
- this.emit(__injectivelabs_wallet_base_light.WalletStrategyEmitterEventType.WalletStrategyDisconnect);
143
+ this.emit(__injectivelabs_wallet_base_runtime_light.WalletStrategyEmitterEventType.WalletStrategyDisconnect);
144
144
  }
145
145
  }
146
146
  getCosmosWallet(chainId) {
@@ -1,4 +1,4 @@
1
1
  require('./defineProperty-CImP5zIM.cjs');
2
- const require_strategy = require('./strategy-D8mmr647.cjs');
2
+ const require_strategy = require('./strategy-BxKznCI0.cjs');
3
3
 
4
4
  exports.BaseWalletStrategy = require_strategy.BaseWalletStrategy;
@@ -1,3 +1,3 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-Bvs5nQRI.cjs";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-CD9sBzZB.cjs";
2
2
  import "./index-DLoAMD9J.cjs";
3
3
  export { BaseWalletStrategy };
@@ -1,4 +1,4 @@
1
- import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base/light";
1
+ import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, WalletStrategyEmitter, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base/runtime-light";
2
2
  import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
3
3
  import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
4
4
  import { StdSignDoc } from "@keplr-wallet/types";
@@ -41,6 +41,7 @@ var MsgBroadcaster = class {
41
41
  _defineProperty(this, "chainId", void 0);
42
42
  _defineProperty(this, "txTimeout", DEFAULT_BLOCK_TIMEOUT_HEIGHT);
43
43
  _defineProperty(this, "simulateTx", true);
44
+ _defineProperty(this, "useDynamicBaseFee", false);
44
45
  _defineProperty(this, "txTimeoutOnFeeDelegation", false);
45
46
  _defineProperty(this, "evmChainId", void 0);
46
47
  _defineProperty(this, "gasBufferCoefficient", 1.2);
@@ -50,6 +51,7 @@ var MsgBroadcaster = class {
50
51
  const networkInfo = getNetworkInfo(options.network);
51
52
  this.options = options;
52
53
  this.simulateTx = options.simulateTx !== void 0 ? options.simulateTx : true;
54
+ this.useDynamicBaseFee = options.useDynamicBaseFee !== void 0 ? options.useDynamicBaseFee : false;
53
55
  this.txTimeout = options.txTimeout || DEFAULT_BLOCK_TIMEOUT_HEIGHT;
54
56
  this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation !== void 0 ? options.txTimeoutOnFeeDelegation : true;
55
57
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
@@ -61,10 +63,11 @@ var MsgBroadcaster = class {
61
63
  this.txInclusion = options.txInclusion;
62
64
  }
63
65
  setOptions(options) {
64
- this.simulateTx = options.simulateTx || this.simulateTx;
65
- this.txTimeout = options.txTimeout || this.txTimeout;
66
- this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation || this.txTimeoutOnFeeDelegation;
67
- this.txInclusion = options.txInclusion || this.txInclusion;
66
+ this.simulateTx = options.simulateTx !== void 0 ? options.simulateTx : this.simulateTx;
67
+ this.useDynamicBaseFee = options.useDynamicBaseFee !== void 0 ? options.useDynamicBaseFee : this.useDynamicBaseFee;
68
+ this.txTimeout = options.txTimeout !== void 0 ? options.txTimeout : this.txTimeout;
69
+ this.txTimeoutOnFeeDelegation = options.txTimeoutOnFeeDelegation !== void 0 ? options.txTimeoutOnFeeDelegation : this.txTimeoutOnFeeDelegation;
70
+ this.txInclusion = options.txInclusion !== void 0 ? options.txInclusion : this.txInclusion;
68
71
  }
69
72
  async getEvmChainId() {
70
73
  const { walletStrategy } = this;
@@ -234,9 +237,18 @@ var MsgBroadcaster = class {
234
237
  const { chainId, endpoints, walletStrategy } = this;
235
238
  const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
236
239
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
237
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
240
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails({
241
+ latestHeight: tx.latestHeight,
242
+ timeoutHeight: tx.timeoutHeight,
243
+ address: tx.injectiveAddress,
244
+ existingAccountDetails: tx.accountDetails
245
+ })]);
238
246
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
239
- const timeoutHeight = toBigNumber(latestHeight.toString()).plus(txTimeoutInBlocks);
247
+ const timeoutHeight = this.resolveTimeoutHeight({
248
+ tx,
249
+ latestHeight,
250
+ txTimeoutInBlocks
251
+ });
240
252
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
241
253
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
242
254
  const gas = (((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.gas) || getGasPriceBasedOnMessage(msgs)).toString();
@@ -345,9 +357,18 @@ var MsgBroadcaster = class {
345
357
  const { chainId, endpoints, walletStrategy } = this;
346
358
  const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
347
359
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
348
- const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
360
+ const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails({
361
+ latestHeight: tx.latestHeight,
362
+ timeoutHeight: tx.timeoutHeight,
363
+ address: tx.injectiveAddress,
364
+ existingAccountDetails: tx.accountDetails
365
+ })]);
349
366
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
350
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
367
+ const timeoutHeight = this.resolveTimeoutHeight({
368
+ tx,
369
+ latestHeight,
370
+ txTimeoutInBlocks
371
+ });
351
372
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
352
373
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
353
374
  const gas = (((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.gas) || getGasPriceBasedOnMessage(msgs)).toString();
@@ -462,11 +483,22 @@ var MsgBroadcaster = class {
462
483
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
463
484
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS;
464
485
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
465
- let timeoutHeight = void 0;
466
- if (txTimeoutOnFeeDelegation) timeoutHeight = toBigNumber((await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
486
+ let timeoutHeight = this.resolveOptionalTimeoutHeight({
487
+ tx,
488
+ latestHeight: tx.latestHeight,
489
+ txTimeoutInBlocks
490
+ });
491
+ if (timeoutHeight === void 0 && txTimeoutOnFeeDelegation) {
492
+ const latestHeight = (await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString();
493
+ timeoutHeight = this.resolveTimeoutHeight({
494
+ tx,
495
+ latestHeight,
496
+ txTimeoutInBlocks
497
+ });
498
+ }
467
499
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
468
500
  const prepareTxResponse = await transactionApi.prepareTxRequest({
469
- timeoutHeight,
501
+ timeoutHeight: timeoutHeight === null || timeoutHeight === void 0 ? void 0 : timeoutHeight.toNumber(),
470
502
  memo: tx.memo,
471
503
  message: web3Msgs,
472
504
  address: tx.ethereumAddress,
@@ -532,8 +564,17 @@ var MsgBroadcaster = class {
532
564
  if ([Wallet.Keplr, Wallet.Leap].includes(walletStrategy.getWallet())) {
533
565
  if (await walletStrategy.getWalletDeviceType() === WalletDeviceType.Hardware) return this.experimentalBroadcastWalletThroughLedger(tx);
534
566
  }
535
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey(tx.injectiveAddress)]);
536
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
567
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails({
568
+ latestHeight: tx.latestHeight,
569
+ timeoutHeight: tx.timeoutHeight,
570
+ address: tx.injectiveAddress,
571
+ existingAccountDetails: tx.accountDetails
572
+ }), walletStrategy.getPubKey(tx.injectiveAddress)]);
573
+ const timeoutHeight = this.resolveTimeoutHeight({
574
+ tx,
575
+ latestHeight,
576
+ txTimeoutInBlocks
577
+ });
537
578
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
538
579
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet) ? SIGN_EIP712 : SIGN_DIRECT;
539
580
  const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || getGasPriceBasedOnMessage(msgs)).toString();
@@ -659,8 +700,17 @@ var MsgBroadcaster = class {
659
700
  }
660
701
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
661
702
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
662
- const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails), walletStrategy.getPubKey()]);
663
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutInBlocks);
703
+ const [{ baseAccount, latestHeight }, pubKey] = await Promise.all([this.fetchAccountAndBlockDetails({
704
+ latestHeight: tx.latestHeight,
705
+ timeoutHeight: tx.timeoutHeight,
706
+ address: tx.injectiveAddress,
707
+ existingAccountDetails: tx.accountDetails
708
+ }), walletStrategy.getPubKey()]);
709
+ const timeoutHeight = this.resolveTimeoutHeight({
710
+ tx,
711
+ latestHeight,
712
+ txTimeoutInBlocks
713
+ });
664
714
  const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || getGasPriceBasedOnMessage(msgs)).toString();
665
715
  /** EIP712 for signing on Ethereum wallets */
666
716
  const eip712TypedData = getEip712TypedData({
@@ -751,7 +801,12 @@ var MsgBroadcaster = class {
751
801
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
752
802
  const fetchAccountBlockDetails = async () => {
753
803
  try {
754
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails);
804
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails({
805
+ latestHeight: tx.latestHeight,
806
+ timeoutHeight: tx.timeoutHeight,
807
+ address: tx.injectiveAddress,
808
+ existingAccountDetails: tx.accountDetails
809
+ });
755
810
  return {
756
811
  baseAccount: baseAccount$1,
757
812
  latestHeight: latestHeight$1
@@ -765,7 +820,11 @@ var MsgBroadcaster = class {
765
820
  memo: tx.memo,
766
821
  estimateGas: simulateTx
767
822
  });
768
- const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
823
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails({
824
+ latestHeight: tx.latestHeight,
825
+ timeoutHeight: tx.timeoutHeight,
826
+ address: tx.injectiveAddress
827
+ });
769
828
  return {
770
829
  baseAccount: baseAccount$1,
771
830
  latestHeight: latestHeight$1
@@ -774,14 +833,21 @@ var MsgBroadcaster = class {
774
833
  throw e;
775
834
  }
776
835
  };
777
- /** Account Details * */
778
- const { baseAccount, latestHeight } = await fetchAccountBlockDetails();
779
836
  const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc);
780
837
  if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
781
- const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
782
- const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeoutInBlocks : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
838
+ const [accountBlockDetails, feePayerAccountDetails, pubKey] = await Promise.all([
839
+ fetchAccountBlockDetails(),
840
+ chainGrpcAuthApi.fetchAccount(feePayer),
841
+ walletStrategy.getPubKey()
842
+ ]);
843
+ const { baseAccount, latestHeight } = accountBlockDetails;
844
+ const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
845
+ const timeoutHeight = this.resolveTimeoutHeight({
846
+ tx,
847
+ latestHeight,
848
+ txTimeoutInBlocks: txTimeoutOnFeeDelegation ? txTimeoutInBlocks : DEFAULT_BLOCK_TIMEOUT_HEIGHT
849
+ });
783
850
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
784
- const pubKey = await walletStrategy.getPubKey();
785
851
  const gas = (((_tx$gas7 = tx.gas) === null || _tx$gas7 === void 0 ? void 0 : _tx$gas7.gas) || getGasPriceBasedOnMessage(msgs)).toString();
786
852
  /** Prepare the Transaction * */
787
853
  const { txRaw } = await this.getTxWithSignersAndStdFee({
@@ -872,7 +938,9 @@ var MsgBroadcaster = class {
872
938
  return response.feePayerPubKey.key;
873
939
  }
874
940
  async getStdFeeWithDynamicBaseFee(args) {
875
- const client = new ChainGrpcTxFeesApi(this.endpoints.grpc);
941
+ const { endpoints, useDynamicBaseFee } = this;
942
+ if (!useDynamicBaseFee) return getStdFee(args);
943
+ const client = new ChainGrpcTxFeesApi(endpoints.grpc);
876
944
  let baseFee = DEFAULT_GAS_PRICE;
877
945
  try {
878
946
  const response = await client.fetchEipBaseFee();
@@ -960,23 +1028,52 @@ var MsgBroadcaster = class {
960
1028
  throw e;
961
1029
  }
962
1030
  }
963
- async fetchAccountAndBlockDetails(address, existingAccountDetails) {
1031
+ async fetchAccountAndBlockDetails({ address, latestHeight, timeoutHeight, existingAccountDetails }) {
964
1032
  const { endpoints, httpHeaders } = this;
965
- const tendermintClient = new ChainGrpcTendermintApi(endpoints.grpc);
966
- if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
967
- if (existingAccountDetails) return {
968
- baseAccount: existingAccountDetails,
969
- latestHeight: (await tendermintClient.fetchLatestBlock()).header.height.toString()
970
- };
1033
+ const shouldFetchLatestHeight = latestHeight === void 0 && timeoutHeight === void 0;
1034
+ if (existingAccountDetails) {
1035
+ if (!shouldFetchLatestHeight) return {
1036
+ latestHeight: latestHeight === null || latestHeight === void 0 ? void 0 : latestHeight.toString(),
1037
+ baseAccount: existingAccountDetails
1038
+ };
1039
+ const tendermintClient$1 = new ChainGrpcTendermintApi(endpoints.grpc);
1040
+ if (httpHeaders) tendermintClient$1.setMetadata(httpHeaders);
1041
+ return {
1042
+ baseAccount: existingAccountDetails,
1043
+ latestHeight: (await tendermintClient$1.fetchLatestBlock()).header.height.toString()
1044
+ };
1045
+ }
971
1046
  const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
972
1047
  if (httpHeaders) chainClient.setMetadata(httpHeaders);
1048
+ if (!shouldFetchLatestHeight) {
1049
+ const accountDetails$1 = await chainClient.fetchAccount(address);
1050
+ return {
1051
+ latestHeight: latestHeight === null || latestHeight === void 0 ? void 0 : latestHeight.toString(),
1052
+ baseAccount: accountDetails$1.baseAccount
1053
+ };
1054
+ }
1055
+ const tendermintClient = new ChainGrpcTendermintApi(endpoints.grpc);
1056
+ if (httpHeaders) tendermintClient.setMetadata(httpHeaders);
973
1057
  const [accountDetails, latestBlock] = await Promise.all([chainClient.fetchAccount(address), tendermintClient.fetchLatestBlock()]);
974
- const { baseAccount } = accountDetails;
975
1058
  return {
976
- baseAccount,
1059
+ baseAccount: accountDetails.baseAccount,
977
1060
  latestHeight: latestBlock.header.height.toString()
978
1061
  };
979
1062
  }
1063
+ resolveOptionalTimeoutHeight({ tx, latestHeight, txTimeoutInBlocks }) {
1064
+ if (tx.timeoutHeight !== void 0) return toBigNumber(tx.timeoutHeight);
1065
+ if (latestHeight === void 0) return;
1066
+ return toBigNumber(latestHeight).plus(txTimeoutInBlocks);
1067
+ }
1068
+ resolveTimeoutHeight({ tx, latestHeight, txTimeoutInBlocks }) {
1069
+ const timeoutHeight = this.resolveOptionalTimeoutHeight({
1070
+ tx,
1071
+ latestHeight,
1072
+ txTimeoutInBlocks
1073
+ });
1074
+ if (!timeoutHeight) throw new GeneralException(/* @__PURE__ */ new Error("Please provide latestHeight or timeoutHeight"));
1075
+ return timeoutHeight;
1076
+ }
980
1077
  resolveTimeoutInBlocks(override) {
981
1078
  return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
982
1079
  }
@@ -1,3 +1,3 @@
1
- import "./BaseWalletStrategy-D2xNJmzo.js";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-D2pR5txS.js";
1
+ import "./BaseWalletStrategy-2HVN2oeB.js";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-mLvMuoGv.js";
3
3
  export { MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster };
@@ -1,4 +1,4 @@
1
- import { n as MsgBroadcaster, t as Web3Broadcaster } from "./broadcaster-ZH8xuuQH.js";
1
+ import { n as MsgBroadcaster, t as Web3Broadcaster } from "./broadcaster-DzLAEG3E.js";
2
2
  import "./defineProperty-D4YE9KXX.js";
3
3
 
4
4
  export { MsgBroadcaster, Web3Broadcaster };
@@ -1,4 +1,4 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-D2xNJmzo.js";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-2HVN2oeB.js";
2
2
  import { ChainId, EvmChainId } from "@injectivelabs/ts-types";
3
3
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
4
4
  import { AuthBaseAccount } from "@injectivelabs/sdk-ts/client/chain";
@@ -12,6 +12,8 @@ interface MsgBroadcasterTxOptions {
12
12
  ethereumAddress?: string;
13
13
  injectiveAddress?: string;
14
14
  accountDetails?: AuthBaseAccount;
15
+ latestHeight?: number | string;
16
+ timeoutHeight?: number | string;
15
17
  txTimeoutInBlocks?: number;
16
18
  txInclusion?: TxClientInclusionOptions;
17
19
  gas?: {
@@ -27,15 +29,16 @@ interface MsgBroadcasterTxOptionsWithAddresses extends MsgBroadcasterTxOptions {
27
29
  }
28
30
  interface MsgBroadcasterOptions {
29
31
  network: Network;
30
- endpoints?: NetworkEndpoints;
31
32
  chainId?: ChainId;
33
+ txTimeout?: number;
34
+ simulateTx?: boolean;
32
35
  evmChainId?: EvmChainId;
33
36
  feePayerPubKey?: string;
34
- simulateTx?: boolean;
35
- txTimeoutOnFeeDelegation?: boolean;
36
- txTimeout?: number;
37
+ endpoints?: NetworkEndpoints;
37
38
  txInclusion?: TxClientInclusionOptions;
38
39
  walletStrategy: BaseWalletStrategy;
40
+ useDynamicBaseFee?: boolean;
41
+ txTimeoutOnFeeDelegation?: boolean;
39
42
  gasBufferCoefficient?: number;
40
43
  httpHeaders?: Record<string, string>;
41
44
  }
@@ -55,6 +58,7 @@ declare class MsgBroadcaster {
55
58
  chainId: ChainId;
56
59
  txTimeout: number;
57
60
  simulateTx: boolean;
61
+ useDynamicBaseFee: boolean;
58
62
  txTimeoutOnFeeDelegation: boolean;
59
63
  evmChainId?: EvmChainId;
60
64
  gasBufferCoefficient: number;
@@ -204,6 +208,8 @@ declare class MsgBroadcaster {
204
208
  private simulateTxWithSigners;
205
209
  private retryOnException;
206
210
  private fetchAccountAndBlockDetails;
211
+ private resolveOptionalTimeoutHeight;
212
+ private resolveTimeoutHeight;
207
213
  private resolveTimeoutInBlocks;
208
214
  private resolveTxInclusionOptions;
209
215
  private createTxGrpcApi;
@@ -1,5 +1,5 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-D2xNJmzo.js";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-D2pR5txS.js";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-2HVN2oeB.js";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-mLvMuoGv.js";
3
3
  import "./index-DRYular4.js";
4
4
 
5
5
  //#region src/utils/tx.d.ts
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as MsgBroadcaster, r as checkIfTxRunOutOfGas, t as Web3Broadcaster } from "./broadcaster-ZH8xuuQH.js";
1
+ import { n as MsgBroadcaster, r as checkIfTxRunOutOfGas, t as Web3Broadcaster } from "./broadcaster-DzLAEG3E.js";
2
2
  import "./defineProperty-D4YE9KXX.js";
3
- import { t as BaseWalletStrategy } from "./strategy-DU-V-GfI.js";
3
+ import { t as BaseWalletStrategy } from "./strategy-Co4vD1wN.js";
4
4
 
5
5
  export { BaseWalletStrategy, MsgBroadcaster, Web3Broadcaster, checkIfTxRunOutOfGas };
@@ -1,7 +1,7 @@
1
1
  import { t as _defineProperty } from "./defineProperty-D4YE9KXX.js";
2
2
  import { GeneralException, WalletException } from "@injectivelabs/exceptions";
3
3
  import { EventEmitter } from "eventemitter3";
4
- import { Wallet, WalletStrategyEmitterEventType, isCosmosWallet, isEvmWallet } from "@injectivelabs/wallet-base/light";
4
+ import { Wallet, WalletStrategyEmitterEventType, isCosmosWallet, isEvmWallet } from "@injectivelabs/wallet-base/runtime-light";
5
5
 
6
6
  //#region src/strategy/BaseWalletStrategy.ts
7
7
  const getInitialWallet = (args) => {
@@ -1,3 +1,3 @@
1
- import { t as BaseWalletStrategy } from "./BaseWalletStrategy-D2xNJmzo.js";
1
+ import { t as BaseWalletStrategy } from "./BaseWalletStrategy-2HVN2oeB.js";
2
2
  import "./index-DRYular4.js";
3
3
  export { BaseWalletStrategy };
@@ -1,4 +1,4 @@
1
1
  import "./defineProperty-D4YE9KXX.js";
2
- import { t as BaseWalletStrategy } from "./strategy-DU-V-GfI.js";
2
+ import { t as BaseWalletStrategy } from "./strategy-Co4vD1wN.js";
3
3
 
4
4
  export { BaseWalletStrategy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.20.14",
3
+ "version": "1.20.16",
4
4
  "description": "Core wallet strategy",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -84,12 +84,12 @@
84
84
  "dependencies": {
85
85
  "@keplr-wallet/types": "^0.12.296",
86
86
  "eventemitter3": "^5.0.1",
87
- "@injectivelabs/exceptions": "1.20.14",
88
- "@injectivelabs/networks": "1.20.14",
89
- "@injectivelabs/sdk-ts": "1.20.14",
90
- "@injectivelabs/wallet-base": "1.20.14",
91
- "@injectivelabs/ts-types": "1.20.14",
92
- "@injectivelabs/utils": "1.20.14"
87
+ "@injectivelabs/exceptions": "1.20.16",
88
+ "@injectivelabs/networks": "1.20.16",
89
+ "@injectivelabs/ts-types": "1.20.16",
90
+ "@injectivelabs/sdk-ts": "1.20.16",
91
+ "@injectivelabs/utils": "1.20.16",
92
+ "@injectivelabs/wallet-base": "1.20.16"
93
93
  },
94
94
  "publishConfig": {
95
95
  "access": "public"