@injectivelabs/wallet-core 1.19.16 → 1.19.18

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,
@@ -494,6 +497,7 @@ var MsgBroadcaster = class {
494
497
  address: tx.injectiveAddress
495
498
  });
496
499
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
+ if (tx.skipPoll) return response;
497
501
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
498
502
  }
499
503
  /**
@@ -585,6 +589,7 @@ var MsgBroadcaster = class {
585
589
  address: tx.injectiveAddress
586
590
  });
587
591
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
+ if (tx.skipPoll) return response;
588
593
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
589
594
  }
590
595
  /**
@@ -628,6 +633,16 @@ var MsgBroadcaster = class {
628
633
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
629
634
  const response = await broadcast();
630
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
+ };
631
646
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
632
647
  } catch (e) {
633
648
  const error = e;
@@ -714,6 +729,7 @@ var MsgBroadcaster = class {
714
729
  txTimeout: txTimeoutInBlocks
715
730
  });
716
731
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
+ if (tx.skipPoll) return response$1;
717
733
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
718
734
  }
719
735
  const directSignResponse = await walletStrategy.signCosmosTransaction({
@@ -730,6 +746,7 @@ var MsgBroadcaster = class {
730
746
  address: tx.injectiveAddress
731
747
  });
732
748
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
+ if (tx.skipPoll) return response;
733
750
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
734
751
  }
735
752
  /**
@@ -801,7 +818,10 @@ var MsgBroadcaster = class {
801
818
  if (simulateTx) await this.simulateTxRaw(txRawEip712);
802
819
  txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(aminoSignResponse.signature.signature)];
803
820
  /** Broadcast the transaction */
804
- 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
+ });
805
825
  if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
806
826
  code: __injectivelabs_exceptions.UnspecifiedErrorCode,
807
827
  contextCode: response.code,
@@ -912,6 +932,16 @@ var MsgBroadcaster = class {
912
932
  const response = await broadcast();
913
933
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
914
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
+ };
915
945
  return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
916
946
  } catch (e) {
917
947
  const error = e;
@@ -80,6 +80,8 @@ interface MsgBroadcasterTxOptions {
80
80
  injectiveAddress?: string;
81
81
  msgs: Msgs | Msgs[];
82
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;
83
85
  gas?: {
84
86
  gasPrice?: string;
85
87
  gas?: number; /** gas limit */
@@ -178,11 +180,13 @@ declare class MsgBroadcaster {
178
180
  */
179
181
  broadcastWithFeePayerSig({
180
182
  tx,
183
+ skipPoll,
181
184
  privateKey,
182
185
  feePayerSig,
183
186
  accountNumber
184
187
  }: {
185
188
  privateKey: string;
189
+ skipPoll?: boolean;
186
190
  feePayerSig: string;
187
191
  accountNumber: number;
188
192
  tx: Uint8Array | string;
@@ -80,6 +80,8 @@ interface MsgBroadcasterTxOptions {
80
80
  injectiveAddress?: string;
81
81
  msgs: Msgs | Msgs[];
82
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;
83
85
  gas?: {
84
86
  gasPrice?: string;
85
87
  gas?: number; /** gas limit */
@@ -178,11 +180,13 @@ declare class MsgBroadcaster {
178
180
  */
179
181
  broadcastWithFeePayerSig({
180
182
  tx,
183
+ skipPoll,
181
184
  privateKey,
182
185
  feePayerSig,
183
186
  accountNumber
184
187
  }: {
185
188
  privateKey: string;
189
+ skipPoll?: boolean;
186
190
  feePayerSig: string;
187
191
  accountNumber: number;
188
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,
@@ -494,6 +497,7 @@ var MsgBroadcaster = class {
494
497
  address: tx.injectiveAddress
495
498
  });
496
499
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
+ if (tx.skipPoll) return response;
497
501
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
498
502
  }
499
503
  /**
@@ -585,6 +589,7 @@ var MsgBroadcaster = class {
585
589
  address: tx.injectiveAddress
586
590
  });
587
591
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
+ if (tx.skipPoll) return response;
588
593
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
589
594
  }
590
595
  /**
@@ -628,6 +633,16 @@ var MsgBroadcaster = class {
628
633
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
629
634
  const response = await broadcast();
630
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
+ };
631
646
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
632
647
  } catch (e) {
633
648
  const error = e;
@@ -714,6 +729,7 @@ var MsgBroadcaster = class {
714
729
  txTimeout: txTimeoutInBlocks
715
730
  });
716
731
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
+ if (tx.skipPoll) return response$1;
717
733
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
718
734
  }
719
735
  const directSignResponse = await walletStrategy.signCosmosTransaction({
@@ -730,6 +746,7 @@ var MsgBroadcaster = class {
730
746
  address: tx.injectiveAddress
731
747
  });
732
748
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
+ if (tx.skipPoll) return response;
733
750
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
734
751
  }
735
752
  /**
@@ -801,7 +818,10 @@ var MsgBroadcaster = class {
801
818
  if (simulateTx) await this.simulateTxRaw(txRawEip712);
802
819
  txRawEip712.signatures = [base64ToUint8Array(aminoSignResponse.signature.signature)];
803
820
  /** Broadcast the transaction */
804
- 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
+ });
805
825
  if (response.code !== 0) throw new TransactionException(new Error(response.rawLog), {
806
826
  code: UnspecifiedErrorCode,
807
827
  contextCode: response.code,
@@ -912,6 +932,16 @@ var MsgBroadcaster = class {
912
932
  const response = await broadcast();
913
933
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
914
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
+ };
915
945
  return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
916
946
  } catch (e) {
917
947
  const error = e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.19.16",
3
+ "version": "1.19.18",
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.16",
48
- "@injectivelabs/sdk-ts": "1.19.16",
49
- "@injectivelabs/networks": "1.19.16",
50
- "@injectivelabs/ts-types": "1.19.16",
51
- "@injectivelabs/utils": "1.19.16",
52
- "@injectivelabs/wallet-base": "1.19.16"
47
+ "@injectivelabs/exceptions": "1.19.18",
48
+ "@injectivelabs/utils": "1.19.18",
49
+ "@injectivelabs/sdk-ts": "1.19.18",
50
+ "@injectivelabs/networks": "1.19.18",
51
+ "@injectivelabs/wallet-base": "1.19.18",
52
+ "@injectivelabs/ts-types": "1.19.18"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"