@injectivelabs/wallet-core 1.19.19 → 1.19.21

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,8 +373,9 @@ 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 }) {
377
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
376
+ async broadcastWithFeePayerSig({ tx, privateKey, feePayerSig, accountNumber, txTimeoutInBlocks: txTimeoutInBlocksParam }) {
377
+ const { chainId, endpoints, walletStrategy } = this;
378
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(txTimeoutInBlocksParam);
378
379
  const pk = __injectivelabs_sdk_ts_core_accounts.PrivateKey.fromHex(privateKey);
379
380
  if (__injectivelabs_sdk_ts_utils.ofacList.includes(pk.toHex().toLowerCase())) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
380
381
  const txBytes = typeof tx === "string" ? (0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(tx) : tx;
@@ -412,6 +413,9 @@ var MsgBroadcaster = class {
412
413
  throw new __injectivelabs_exceptions.TransactionException(new Error(error));
413
414
  }
414
415
  }
416
+ resolveTimeoutInBlocks(override) {
417
+ return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
418
+ }
415
419
  /**
416
420
  * Prepare/sign/broadcast transaction using
417
421
  * Ethereum native wallets on the client side.
@@ -423,7 +427,8 @@ var MsgBroadcaster = class {
423
427
  */
424
428
  async broadcastEip712(tx) {
425
429
  var _tx$gas, _baseAccount$pubKey;
426
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
430
+ const { chainId, endpoints, walletStrategy } = this;
431
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
427
432
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
428
433
  const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
429
434
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
@@ -514,7 +519,8 @@ var MsgBroadcaster = class {
514
519
  */
515
520
  async broadcastEip712V2(tx) {
516
521
  var _tx$gas2, _baseAccount$pubKey2;
517
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
522
+ const { chainId, endpoints, walletStrategy } = this;
523
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
518
524
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
519
525
  const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
520
526
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
@@ -604,7 +610,8 @@ var MsgBroadcaster = class {
604
610
  * @returns transaction hash
605
611
  */
606
612
  async broadcastEip712WithFeeDelegation(tx) {
607
- const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
613
+ const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
614
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
608
615
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
609
616
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
610
617
  const evmChainId = await this.getEvmChainId();
@@ -669,7 +676,8 @@ var MsgBroadcaster = class {
669
676
  */
670
677
  async broadcastDirectSign(tx) {
671
678
  var _tx$gas3;
672
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
679
+ const { chainId, endpoints, walletStrategy } = this;
680
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
673
681
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
674
682
  /**
675
683
  * When using Ledger with Keplr/Leap we have
@@ -755,7 +763,8 @@ var MsgBroadcaster = class {
755
763
  */
756
764
  async experimentalBroadcastWalletThroughLedger(tx) {
757
765
  var _tx$gas5, _tx$gas6;
758
- const { chainId, endpoints, evmChainId, simulateTx, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
766
+ const { chainId, endpoints, evmChainId, simulateTx, walletStrategy } = this;
767
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
759
768
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
760
769
  /**
761
770
  * We can only use this method
@@ -839,7 +848,8 @@ var MsgBroadcaster = class {
839
848
  */
840
849
  async broadcastDirectSignWithFeeDelegation(tx) {
841
850
  var _tx$gas7;
842
- const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
851
+ const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
852
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
843
853
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
844
854
  /**
845
855
  * We can only use this method when Keplr is connected
@@ -76,10 +76,11 @@ declare class BaseWalletStrategy implements WalletStrategy {
76
76
  //#region src/broadcaster/types.d.ts
77
77
  interface MsgBroadcasterTxOptions {
78
78
  memo?: string;
79
+ msgs: Msgs | Msgs[];
79
80
  ethereumAddress?: string;
80
81
  injectiveAddress?: string;
81
- msgs: Msgs | Msgs[];
82
82
  accountDetails?: AuthBaseAccount;
83
+ txTimeoutInBlocks?: number;
83
84
  gas?: {
84
85
  gasPrice?: string;
85
86
  gas?: number; /** gas limit */
@@ -180,13 +181,16 @@ declare class MsgBroadcaster {
180
181
  tx,
181
182
  privateKey,
182
183
  feePayerSig,
183
- accountNumber
184
+ accountNumber,
185
+ txTimeoutInBlocks: txTimeoutInBlocksParam
184
186
  }: {
185
187
  privateKey: string;
186
188
  feePayerSig: string;
187
189
  accountNumber: number;
188
190
  tx: Uint8Array | string;
191
+ txTimeoutInBlocks?: number;
189
192
  }): Promise<TxResponse>;
193
+ private resolveTimeoutInBlocks;
190
194
  /**
191
195
  * Prepare/sign/broadcast transaction using
192
196
  * Ethereum native wallets on the client side.
@@ -76,10 +76,11 @@ declare class BaseWalletStrategy implements WalletStrategy {
76
76
  //#region src/broadcaster/types.d.ts
77
77
  interface MsgBroadcasterTxOptions {
78
78
  memo?: string;
79
+ msgs: Msgs | Msgs[];
79
80
  ethereumAddress?: string;
80
81
  injectiveAddress?: string;
81
- msgs: Msgs | Msgs[];
82
82
  accountDetails?: AuthBaseAccount;
83
+ txTimeoutInBlocks?: number;
83
84
  gas?: {
84
85
  gasPrice?: string;
85
86
  gas?: number; /** gas limit */
@@ -180,13 +181,16 @@ declare class MsgBroadcaster {
180
181
  tx,
181
182
  privateKey,
182
183
  feePayerSig,
183
- accountNumber
184
+ accountNumber,
185
+ txTimeoutInBlocks: txTimeoutInBlocksParam
184
186
  }: {
185
187
  privateKey: string;
186
188
  feePayerSig: string;
187
189
  accountNumber: number;
188
190
  tx: Uint8Array | string;
191
+ txTimeoutInBlocks?: number;
189
192
  }): Promise<TxResponse>;
193
+ private resolveTimeoutInBlocks;
190
194
  /**
191
195
  * Prepare/sign/broadcast transaction using
192
196
  * Ethereum native wallets on the client side.
package/dist/esm/index.js CHANGED
@@ -373,8 +373,9 @@ 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 }) {
377
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
376
+ async broadcastWithFeePayerSig({ tx, privateKey, feePayerSig, accountNumber, txTimeoutInBlocks: txTimeoutInBlocksParam }) {
377
+ const { chainId, endpoints, walletStrategy } = this;
378
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(txTimeoutInBlocksParam);
378
379
  const pk = PrivateKey.fromHex(privateKey);
379
380
  if (ofacList.includes(pk.toHex().toLowerCase())) throw new GeneralException(/* @__PURE__ */ new Error("You cannot execute this transaction"));
380
381
  const txBytes = typeof tx === "string" ? base64ToUint8Array(tx) : tx;
@@ -412,6 +413,9 @@ var MsgBroadcaster = class {
412
413
  throw new TransactionException(new Error(error));
413
414
  }
414
415
  }
416
+ resolveTimeoutInBlocks(override) {
417
+ return typeof override === "number" && Number.isInteger(override) && override > 0 ? override : this.txTimeout;
418
+ }
415
419
  /**
416
420
  * Prepare/sign/broadcast transaction using
417
421
  * Ethereum native wallets on the client side.
@@ -423,7 +427,8 @@ var MsgBroadcaster = class {
423
427
  */
424
428
  async broadcastEip712(tx) {
425
429
  var _tx$gas, _baseAccount$pubKey;
426
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
430
+ const { chainId, endpoints, walletStrategy } = this;
431
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
427
432
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
428
433
  const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
429
434
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
@@ -514,7 +519,8 @@ var MsgBroadcaster = class {
514
519
  */
515
520
  async broadcastEip712V2(tx) {
516
521
  var _tx$gas2, _baseAccount$pubKey2;
517
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
522
+ const { chainId, endpoints, walletStrategy } = this;
523
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
518
524
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
519
525
  const [evmChainId, { baseAccount, latestHeight }] = await Promise.all([this.getEvmChainId(), this.fetchAccountAndBlockDetails(tx.injectiveAddress, tx.accountDetails)]);
520
526
  if (!evmChainId) throw new GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
@@ -604,7 +610,8 @@ var MsgBroadcaster = class {
604
610
  * @returns transaction hash
605
611
  */
606
612
  async broadcastEip712WithFeeDelegation(tx) {
607
- const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
613
+ const { endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
614
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
608
615
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
609
616
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
610
617
  const evmChainId = await this.getEvmChainId();
@@ -669,7 +676,8 @@ var MsgBroadcaster = class {
669
676
  */
670
677
  async broadcastDirectSign(tx) {
671
678
  var _tx$gas3;
672
- const { chainId, endpoints, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
679
+ const { chainId, endpoints, walletStrategy } = this;
680
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
673
681
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
674
682
  /**
675
683
  * When using Ledger with Keplr/Leap we have
@@ -755,7 +763,8 @@ var MsgBroadcaster = class {
755
763
  */
756
764
  async experimentalBroadcastWalletThroughLedger(tx) {
757
765
  var _tx$gas5, _tx$gas6;
758
- const { chainId, endpoints, evmChainId, simulateTx, walletStrategy, txTimeout: txTimeoutInBlocks } = this;
766
+ const { chainId, endpoints, evmChainId, simulateTx, walletStrategy } = this;
767
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
759
768
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
760
769
  /**
761
770
  * We can only use this method
@@ -839,7 +848,8 @@ var MsgBroadcaster = class {
839
848
  */
840
849
  async broadcastDirectSignWithFeeDelegation(tx) {
841
850
  var _tx$gas7;
842
- const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
851
+ const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation } = this;
852
+ const txTimeoutInBlocks = this.resolveTimeoutInBlocks(tx.txTimeoutInBlocks);
843
853
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
844
854
  /**
845
855
  * We can only use this method when Keplr is connected
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.19.19",
3
+ "version": "1.19.21",
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.19",
48
- "@injectivelabs/networks": "1.19.19",
49
- "@injectivelabs/sdk-ts": "1.19.19",
50
- "@injectivelabs/utils": "1.19.19",
51
- "@injectivelabs/wallet-base": "1.19.19",
52
- "@injectivelabs/ts-types": "1.19.19"
47
+ "@injectivelabs/networks": "1.19.21",
48
+ "@injectivelabs/exceptions": "1.19.21",
49
+ "@injectivelabs/ts-types": "1.19.21",
50
+ "@injectivelabs/sdk-ts": "1.19.21",
51
+ "@injectivelabs/utils": "1.19.21",
52
+ "@injectivelabs/wallet-base": "1.19.21"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"