@injectivelabs/wallet-core 1.20.61 → 1.20.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,12 @@ export const msgBroadcaster = new MsgBroadcaster({ ...broadcasterArgs, walletStr
41
41
 
42
42
  Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
43
43
 
44
+ ### Fixed gas
45
+
46
+ With `useFixedGas: true` and no explicit gas limit, `MsgBroadcaster` applies a fixed 1.2 multiplier to message presets for Cosmos wallet strategies, including `Wallet.PrivateKeyCosmos`. EVM wallet presets, explicit gas overrides, and fallback gas limits are unchanged. `gasBufferCoefficient` controls the buffer for simulated gas only.
47
+
48
+ This correction is scoped to wallet-core's `MsgBroadcaster`. The SDK's `MsgBroadcasterWithPk` retains unbuffered presets for both DirectSign and EIP-712 fee delegation. For example, the same `MsgWithdrawV2` uses 384,000 gas through `MsgBroadcaster` with `Wallet.PrivateKeyCosmos`, and 320,000 through `MsgBroadcasterWithPk`.
49
+
44
50
  ---
45
51
 
46
52
  ## 📜 Contribution
@@ -77,7 +77,8 @@ var MsgBroadcaster = class {
77
77
  msgs,
78
78
  gas,
79
79
  simulateTx: this.simulateTx,
80
- useFixedGas: this.useFixedGas
80
+ useFixedGas: this.useFixedGas,
81
+ fixedGasBufferCoefficient: (0, __injectivelabs_wallet_base.isCosmosWallet)(this.walletStrategy.wallet) ? 1.2 : 1
81
82
  });
82
83
  }
83
84
  async getEvmChainId() {
@@ -120,10 +121,7 @@ var MsgBroadcaster = class {
120
121
  try {
121
122
  return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : (0, __injectivelabs_wallet_base.isEip712V2OnlyWallet)(walletStrategy.wallet) ? await this.broadcastEip712V2(txWithAddresses) : await this.broadcastEip712(txWithAddresses);
122
123
  } catch (e) {
123
- const error = e;
124
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
125
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
126
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
124
+ return this.handleBroadcastError(e, tx);
127
125
  }
128
126
  }
129
127
  /**
@@ -145,10 +143,7 @@ var MsgBroadcaster = class {
145
143
  try {
146
144
  return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : await this.broadcastEip712V2(txWithAddresses);
147
145
  } catch (e) {
148
- const error = e;
149
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
150
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
151
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
146
+ return this.handleBroadcastError(e, tx);
152
147
  }
153
148
  }
154
149
  /**
@@ -169,10 +164,7 @@ var MsgBroadcaster = class {
169
164
  try {
170
165
  return (0, __injectivelabs_wallet_base.isCosmosWallet)(walletStrategy.wallet) ? await this.broadcastDirectSignWithFeeDelegation(txWithAddresses) : await this.broadcastEip712WithFeeDelegation(txWithAddresses);
171
166
  } catch (e) {
172
- const error = e;
173
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
174
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
175
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
167
+ return this.handleBroadcastError(e, tx);
176
168
  }
177
169
  }
178
170
  /**
@@ -228,12 +220,18 @@ var MsgBroadcaster = class {
228
220
  });
229
221
  return txResponse;
230
222
  } catch (e) {
231
- const error = e;
232
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
233
- if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
234
- throw new __injectivelabs_exceptions.TransactionException(new Error(error));
223
+ return this.handleBroadcastError(e, { txInclusion });
235
224
  }
236
225
  }
226
+ handleBroadcastError(error, tx) {
227
+ if (error instanceof __injectivelabs_sdk_ts_core_tx.TxObservationAbortError || (0, __injectivelabs_utils.isAbortError)(error) && (0, __injectivelabs_sdk_ts_core_tx.getTxObservationSignals)(this.resolveTxInclusionOptions(tx)).some((signal) => signal === null || signal === void 0 ? void 0 : signal.aborted)) {
228
+ this.walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionCancelled, error);
229
+ throw error;
230
+ }
231
+ this.walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionFail);
232
+ if ((0, __injectivelabs_exceptions.isThrownException)(error)) throw error;
233
+ throw new __injectivelabs_exceptions.TransactionException(new Error(error));
234
+ }
237
235
  /**
238
236
  * Prepare/sign/broadcast transaction using
239
237
  * Ethereum native wallets on the client side.
@@ -1116,11 +1114,11 @@ var MsgBroadcaster = class {
1116
1114
  return client;
1117
1115
  }
1118
1116
  async waitForTxInclusion({ tx, txHash, timeout }) {
1119
- return this.createTxGrpcApi().waitForTxInclusion({
1117
+ return (0, __injectivelabs_sdk_ts_core_tx.observeTx)(txHash, () => this.createTxGrpcApi().waitForTxInclusion({
1120
1118
  txHash,
1121
1119
  timeout,
1122
1120
  options: this.resolveTxInclusionOptions(tx)
1123
- });
1121
+ }));
1124
1122
  }
1125
1123
  async prepareTxInclusionWaiter({ tx, timeout, txRawOrSignResponse }) {
1126
1124
  const txRaw = (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(txRawOrSignResponse);
@@ -1137,7 +1135,7 @@ var MsgBroadcaster = class {
1137
1135
  timeout,
1138
1136
  txHash: responseTxHash
1139
1137
  });
1140
- const confirmedTx = await inclusionWaiter.wait(responseTxHash);
1138
+ const confirmedTx = await (0, __injectivelabs_sdk_ts_core_tx.observeTx)(responseTxHash, () => inclusionWaiter.wait(responseTxHash));
1141
1139
  if (!confirmedTx) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
1142
1140
  return confirmedTx;
1143
1141
  }
@@ -1,4 +1,4 @@
1
- const require_broadcaster = require('./broadcaster-B2w12U0i.cjs');
1
+ const require_broadcaster = require('./broadcaster-B0iDYqb7.cjs');
2
2
  require('./defineProperty-CImP5zIM.cjs');
3
3
 
4
4
  exports.MsgBroadcaster = require_broadcaster.MsgBroadcaster;
@@ -1,3 +1,3 @@
1
1
  import "./BaseWalletStrategy-CD9sBzZB.cjs";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-CHR5Ye7m.cjs";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-TB1ybJUD.cjs";
3
3
  export { MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster };
@@ -38,6 +38,7 @@ interface MsgBroadcasterOptions {
38
38
  txInclusion?: TxClientInclusionOptions;
39
39
  walletStrategy: BaseWalletStrategy;
40
40
  useDynamicBaseFee?: boolean;
41
+ /** Buffers automatic message presets by 1.2 for Cosmos wallet strategies. */
41
42
  useFixedGas?: boolean;
42
43
  txTimeoutOnFeeDelegation?: boolean;
43
44
  gasBufferCoefficient?: number;
@@ -134,6 +135,7 @@ declare class MsgBroadcaster {
134
135
  txInclusion?: TxClientInclusionOptions;
135
136
  txTimeoutInBlocks?: number;
136
137
  }): Promise<TxResponse>;
138
+ private handleBroadcastError;
137
139
  /**
138
140
  * Prepare/sign/broadcast transaction using
139
141
  * Ethereum native wallets on the client side.
@@ -1,4 +1,4 @@
1
- const require_broadcaster = require('./broadcaster-B2w12U0i.cjs');
1
+ const require_broadcaster = require('./broadcaster-B0iDYqb7.cjs');
2
2
  require('./defineProperty-CImP5zIM.cjs');
3
3
  const require_strategy = require('./strategy-BxKznCI0.cjs');
4
4
 
@@ -1,5 +1,5 @@
1
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-CHR5Ye7m.cjs";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-TB1ybJUD.cjs";
3
3
  import "./index-DLoAMD9J.cjs";
4
4
 
5
5
  //#region src/utils/tx.d.ts
@@ -6,9 +6,9 @@ import { base64ToUint8Array, getGasOptionsBasedOnMessage, hexToBase64, hexToBuff
6
6
  import { IndexerGrpcWeb3GwApi } from "@injectivelabs/sdk-ts/client/indexer";
7
7
  import { getNetworkEndpoints, getNetworkInfo, isMainnet, isTestnet } from "@injectivelabs/networks";
8
8
  import { ChainGrpcAuthApi, ChainGrpcTendermintApi, ChainGrpcTxFeesApi } from "@injectivelabs/sdk-ts/client/chain";
9
- import { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_GAS_PRICE, getStdFee, sleep, toBigNumber } from "@injectivelabs/utils";
9
+ import { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_GAS_PRICE, getStdFee, isAbortError, sleep, toBigNumber } from "@injectivelabs/utils";
10
10
  import { Wallet, WalletDeviceType, WalletStrategyEmitterEventType, createEip712StdSignDoc, getEthereumSignerAddress, getInjectiveSignerAddress, isCosmosAminoOnlyWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet } from "@injectivelabs/wallet-base";
11
- import { CosmosTxV1Beta1TxPb, SIGN_DIRECT, SIGN_EIP712, SIGN_EIP712_V2, TxClient, TxGrpcApi, createTransaction, createTransactionWithSigners, createTxRawEIP712, createTxRawFromSigResponse, createWeb3Extension, getAminoStdSignDoc, getEip712TypedData, getEip712TypedDataV2 } from "@injectivelabs/sdk-ts/core/tx";
11
+ import { CosmosTxV1Beta1TxPb, SIGN_DIRECT, SIGN_EIP712, SIGN_EIP712_V2, TxClient, TxGrpcApi, TxObservationAbortError, createTransaction, createTransactionWithSigners, createTxRawEIP712, createTxRawFromSigResponse, createWeb3Extension, getAminoStdSignDoc, getEip712TypedData, getEip712TypedDataV2, getTxObservationSignals, observeTx } from "@injectivelabs/sdk-ts/core/tx";
12
12
 
13
13
  //#region src/utils/tx.ts
14
14
  const checkIfTxRunOutOfGas = (e) => {
@@ -77,7 +77,8 @@ var MsgBroadcaster = class {
77
77
  msgs,
78
78
  gas,
79
79
  simulateTx: this.simulateTx,
80
- useFixedGas: this.useFixedGas
80
+ useFixedGas: this.useFixedGas,
81
+ fixedGasBufferCoefficient: isCosmosWallet(this.walletStrategy.wallet) ? 1.2 : 1
81
82
  });
82
83
  }
83
84
  async getEvmChainId() {
@@ -120,10 +121,7 @@ var MsgBroadcaster = class {
120
121
  try {
121
122
  return isCosmosWallet(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : isEip712V2OnlyWallet(walletStrategy.wallet) ? await this.broadcastEip712V2(txWithAddresses) : await this.broadcastEip712(txWithAddresses);
122
123
  } catch (e) {
123
- const error = e;
124
- walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
125
- if (isThrownException(error)) throw error;
126
- throw new TransactionException(new Error(error));
124
+ return this.handleBroadcastError(e, tx);
127
125
  }
128
126
  }
129
127
  /**
@@ -145,10 +143,7 @@ var MsgBroadcaster = class {
145
143
  try {
146
144
  return isCosmosWallet(walletStrategy.wallet) ? await this.broadcastDirectSign(txWithAddresses) : await this.broadcastEip712V2(txWithAddresses);
147
145
  } catch (e) {
148
- const error = e;
149
- walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
150
- if (isThrownException(error)) throw error;
151
- throw new TransactionException(new Error(error));
146
+ return this.handleBroadcastError(e, tx);
152
147
  }
153
148
  }
154
149
  /**
@@ -169,10 +164,7 @@ var MsgBroadcaster = class {
169
164
  try {
170
165
  return isCosmosWallet(walletStrategy.wallet) ? await this.broadcastDirectSignWithFeeDelegation(txWithAddresses) : await this.broadcastEip712WithFeeDelegation(txWithAddresses);
171
166
  } catch (e) {
172
- const error = e;
173
- walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
174
- if (isThrownException(error)) throw error;
175
- throw new TransactionException(new Error(error));
167
+ return this.handleBroadcastError(e, tx);
176
168
  }
177
169
  }
178
170
  /**
@@ -228,12 +220,18 @@ var MsgBroadcaster = class {
228
220
  });
229
221
  return txResponse;
230
222
  } catch (e) {
231
- const error = e;
232
- walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
233
- if (isThrownException(error)) throw error;
234
- throw new TransactionException(new Error(error));
223
+ return this.handleBroadcastError(e, { txInclusion });
235
224
  }
236
225
  }
226
+ handleBroadcastError(error, tx) {
227
+ if (error instanceof TxObservationAbortError || isAbortError(error) && getTxObservationSignals(this.resolveTxInclusionOptions(tx)).some((signal) => signal === null || signal === void 0 ? void 0 : signal.aborted)) {
228
+ this.walletStrategy.emit(WalletStrategyEmitterEventType.TransactionCancelled, error);
229
+ throw error;
230
+ }
231
+ this.walletStrategy.emit(WalletStrategyEmitterEventType.TransactionFail);
232
+ if (isThrownException(error)) throw error;
233
+ throw new TransactionException(new Error(error));
234
+ }
237
235
  /**
238
236
  * Prepare/sign/broadcast transaction using
239
237
  * Ethereum native wallets on the client side.
@@ -1116,11 +1114,11 @@ var MsgBroadcaster = class {
1116
1114
  return client;
1117
1115
  }
1118
1116
  async waitForTxInclusion({ tx, txHash, timeout }) {
1119
- return this.createTxGrpcApi().waitForTxInclusion({
1117
+ return observeTx(txHash, () => this.createTxGrpcApi().waitForTxInclusion({
1120
1118
  txHash,
1121
1119
  timeout,
1122
1120
  options: this.resolveTxInclusionOptions(tx)
1123
- });
1121
+ }));
1124
1122
  }
1125
1123
  async prepareTxInclusionWaiter({ tx, timeout, txRawOrSignResponse }) {
1126
1124
  const txRaw = createTxRawFromSigResponse(txRawOrSignResponse);
@@ -1137,7 +1135,7 @@ var MsgBroadcaster = class {
1137
1135
  timeout,
1138
1136
  txHash: responseTxHash
1139
1137
  });
1140
- const confirmedTx = await inclusionWaiter.wait(responseTxHash);
1138
+ const confirmedTx = await observeTx(responseTxHash, () => inclusionWaiter.wait(responseTxHash));
1141
1139
  if (!confirmedTx) throw new TransactionException(/* @__PURE__ */ new Error(`The transaction with ${responseTxHash} is not found`));
1142
1140
  return confirmedTx;
1143
1141
  }
@@ -1,3 +1,3 @@
1
1
  import "./BaseWalletStrategy-2HVN2oeB.js";
2
- import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-70XLhK_X.js";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-B1XSJ1Zx.js";
3
3
  export { MsgBroadcaster, MsgBroadcasterOptions, MsgBroadcasterTxOptions, MsgBroadcasterTxOptionsWithAddresses, Web3Broadcaster };
@@ -1,4 +1,4 @@
1
- import { n as MsgBroadcaster, t as Web3Broadcaster } from "./broadcaster-iB5heVHH.js";
1
+ import { n as MsgBroadcaster, t as Web3Broadcaster } from "./broadcaster-DO14o8eB.js";
2
2
  import "./defineProperty-D4YE9KXX.js";
3
3
 
4
4
  export { MsgBroadcaster, Web3Broadcaster };
@@ -38,6 +38,7 @@ interface MsgBroadcasterOptions {
38
38
  txInclusion?: TxClientInclusionOptions;
39
39
  walletStrategy: BaseWalletStrategy;
40
40
  useDynamicBaseFee?: boolean;
41
+ /** Buffers automatic message presets by 1.2 for Cosmos wallet strategies. */
41
42
  useFixedGas?: boolean;
42
43
  txTimeoutOnFeeDelegation?: boolean;
43
44
  gasBufferCoefficient?: number;
@@ -134,6 +135,7 @@ declare class MsgBroadcaster {
134
135
  txInclusion?: TxClientInclusionOptions;
135
136
  txTimeoutInBlocks?: number;
136
137
  }): Promise<TxResponse>;
138
+ private handleBroadcastError;
137
139
  /**
138
140
  * Prepare/sign/broadcast transaction using
139
141
  * Ethereum native wallets on the client side.
@@ -1,5 +1,5 @@
1
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-70XLhK_X.js";
2
+ import { a as MsgBroadcasterTxOptionsWithAddresses, i as MsgBroadcasterTxOptions, n as MsgBroadcaster, r as MsgBroadcasterOptions, t as Web3Broadcaster } from "./index-B1XSJ1Zx.js";
3
3
  import "./index-DRYular4.js";
4
4
 
5
5
  //#region src/utils/tx.d.ts
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as MsgBroadcaster, r as checkIfTxRunOutOfGas, t as Web3Broadcaster } from "./broadcaster-iB5heVHH.js";
1
+ import { n as MsgBroadcaster, r as checkIfTxRunOutOfGas, t as Web3Broadcaster } from "./broadcaster-DO14o8eB.js";
2
2
  import "./defineProperty-D4YE9KXX.js";
3
3
  import { t as BaseWalletStrategy } from "./strategy-Co4vD1wN.js";
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.20.61",
3
+ "version": "1.20.63",
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.61",
88
- "@injectivelabs/networks": "1.20.61",
89
- "@injectivelabs/utils": "1.20.61",
90
- "@injectivelabs/ts-types": "1.20.61",
91
- "@injectivelabs/sdk-ts": "1.20.61",
92
- "@injectivelabs/wallet-base": "1.20.61"
87
+ "@injectivelabs/exceptions": "1.20.63",
88
+ "@injectivelabs/networks": "1.20.63",
89
+ "@injectivelabs/utils": "1.20.63",
90
+ "@injectivelabs/ts-types": "1.20.63",
91
+ "@injectivelabs/wallet-base": "1.20.63",
92
+ "@injectivelabs/sdk-ts": "1.20.63"
93
93
  },
94
94
  "publishConfig": {
95
95
  "access": "public"