@injectivelabs/wallet-core 1.19.17 → 1.19.19

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, skipPoll, privateKey, feePayerSig, accountNumber }) {
376
+ async broadcastWithFeePayerSig({ tx, 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"));
@@ -393,8 +393,10 @@ var MsgBroadcaster = class {
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
395
  const txResponse = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
396
- skipPoll,
397
- txTimeout: txTimeoutInBlocks
396
+ txTimeout: txTimeoutInBlocks,
397
+ onBroadcast: () => {
398
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
399
+ }
398
400
  });
399
401
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
400
402
  if (txResponse.code !== 0) throw new __injectivelabs_exceptions.TransactionException(/* @__PURE__ */ new Error(`Transaction failed - ${txResponse.rawLog} - ${txResponse.txHash}`), {
@@ -496,9 +498,10 @@ var MsgBroadcaster = class {
496
498
  txTimeout: txTimeoutInBlocks,
497
499
  address: tx.injectiveAddress
498
500
  });
501
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
502
+ const confirmedTx = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
499
503
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
- if (tx.skipPoll) return response;
501
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
504
+ return confirmedTx;
502
505
  }
503
506
  /**
504
507
  * Prepare/sign/broadcast transaction using
@@ -588,9 +591,10 @@ var MsgBroadcaster = class {
588
591
  txTimeout: txTimeoutInBlocks,
589
592
  address: tx.injectiveAddress
590
593
  });
594
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
595
+ const confirmedTx = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
591
596
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
- if (tx.skipPoll) return response;
593
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
597
+ return confirmedTx;
594
598
  }
595
599
  /**
596
600
  * Prepare/sign/broadcast transaction using
@@ -632,18 +636,10 @@ var MsgBroadcaster = class {
632
636
  try {
633
637
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
634
638
  const response = await broadcast();
639
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
640
+ const confirmedTx = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
635
641
  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
- };
646
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
642
+ return confirmedTx;
647
643
  } catch (e) {
648
644
  const error = e;
649
645
  if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
@@ -728,9 +724,10 @@ var MsgBroadcaster = class {
728
724
  address: tx.injectiveAddress,
729
725
  txTimeout: txTimeoutInBlocks
730
726
  });
727
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
728
+ const confirmedTx$1 = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
731
729
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
- if (tx.skipPoll) return response$1;
733
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
730
+ return confirmedTx$1;
734
731
  }
735
732
  const directSignResponse = await walletStrategy.signCosmosTransaction({
736
733
  txRaw,
@@ -745,9 +742,10 @@ var MsgBroadcaster = class {
745
742
  txTimeout: txTimeoutInBlocks,
746
743
  address: tx.injectiveAddress
747
744
  });
745
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
746
+ const confirmedTx = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
748
747
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
- if (tx.skipPoll) return response;
750
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
748
+ return confirmedTx;
751
749
  }
752
750
  /**
753
751
  * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
@@ -820,13 +818,16 @@ var MsgBroadcaster = class {
820
818
  /** Broadcast the transaction */
821
819
  const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, {
822
820
  txTimeout: txTimeoutInBlocks,
823
- skipPoll: tx.skipPoll
821
+ onBroadcast: () => {
822
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
823
+ }
824
824
  });
825
825
  if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
826
826
  code: __injectivelabs_exceptions.UnspecifiedErrorCode,
827
827
  contextCode: response.code,
828
828
  contextModule: response.codespace
829
829
  });
830
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
830
831
  return response;
831
832
  }
832
833
  /**
@@ -930,19 +931,11 @@ var MsgBroadcaster = class {
930
931
  try {
931
932
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastStart);
932
933
  const response = await broadcast();
933
- walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
934
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastSynced);
934
935
  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
- };
945
- return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
936
+ const confirmedTx = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
937
+ walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionBroadcastEnd);
938
+ return confirmedTx;
946
939
  } catch (e) {
947
940
  const error = e;
948
941
  if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
@@ -80,8 +80,6 @@ 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;
85
83
  gas?: {
86
84
  gasPrice?: string;
87
85
  gas?: number; /** gas limit */
@@ -180,13 +178,11 @@ declare class MsgBroadcaster {
180
178
  */
181
179
  broadcastWithFeePayerSig({
182
180
  tx,
183
- skipPoll,
184
181
  privateKey,
185
182
  feePayerSig,
186
183
  accountNumber
187
184
  }: {
188
185
  privateKey: string;
189
- skipPoll?: boolean;
190
186
  feePayerSig: string;
191
187
  accountNumber: number;
192
188
  tx: Uint8Array | string;
@@ -80,8 +80,6 @@ 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;
85
83
  gas?: {
86
84
  gasPrice?: string;
87
85
  gas?: number; /** gas limit */
@@ -180,13 +178,11 @@ declare class MsgBroadcaster {
180
178
  */
181
179
  broadcastWithFeePayerSig({
182
180
  tx,
183
- skipPoll,
184
181
  privateKey,
185
182
  feePayerSig,
186
183
  accountNumber
187
184
  }: {
188
185
  privateKey: string;
189
- skipPoll?: boolean;
190
186
  feePayerSig: string;
191
187
  accountNumber: number;
192
188
  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, skipPoll, privateKey, feePayerSig, accountNumber }) {
376
+ async broadcastWithFeePayerSig({ tx, 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"));
@@ -393,8 +393,10 @@ var MsgBroadcaster = class {
393
393
  txRaw.signatures = [takerSig, feePayerSig.startsWith("0x") ? hexToUint8Array(feePayerSig.slice(2)) : base64ToUint8Array(feePayerSig)];
394
394
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
395
395
  const txResponse = await new TxGrpcApi(endpoints.grpc).broadcast(txRaw, {
396
- skipPoll,
397
- txTimeout: txTimeoutInBlocks
396
+ txTimeout: txTimeoutInBlocks,
397
+ onBroadcast: () => {
398
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
399
+ }
398
400
  });
399
401
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
400
402
  if (txResponse.code !== 0) throw new TransactionException(/* @__PURE__ */ new Error(`Transaction failed - ${txResponse.rawLog} - ${txResponse.txHash}`), {
@@ -496,9 +498,10 @@ var MsgBroadcaster = class {
496
498
  txTimeout: txTimeoutInBlocks,
497
499
  address: tx.injectiveAddress
498
500
  });
501
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
502
+ const confirmedTx = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
499
503
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
500
- if (tx.skipPoll) return response;
501
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
504
+ return confirmedTx;
502
505
  }
503
506
  /**
504
507
  * Prepare/sign/broadcast transaction using
@@ -588,9 +591,10 @@ var MsgBroadcaster = class {
588
591
  txTimeout: txTimeoutInBlocks,
589
592
  address: tx.injectiveAddress
590
593
  });
594
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
595
+ const confirmedTx = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
591
596
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
592
- if (tx.skipPoll) return response;
593
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
597
+ return confirmedTx;
594
598
  }
595
599
  /**
596
600
  * Prepare/sign/broadcast transaction using
@@ -632,18 +636,10 @@ var MsgBroadcaster = class {
632
636
  try {
633
637
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
634
638
  const response = await broadcast();
639
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
640
+ const confirmedTx = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
635
641
  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
- };
646
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
642
+ return confirmedTx;
647
643
  } catch (e) {
648
644
  const error = e;
649
645
  if (isThrownException(error)) {
@@ -728,9 +724,10 @@ var MsgBroadcaster = class {
728
724
  address: tx.injectiveAddress,
729
725
  txTimeout: txTimeoutInBlocks
730
726
  });
727
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
728
+ const confirmedTx$1 = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
731
729
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
732
- if (tx.skipPoll) return response$1;
733
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
730
+ return confirmedTx$1;
734
731
  }
735
732
  const directSignResponse = await walletStrategy.signCosmosTransaction({
736
733
  txRaw,
@@ -745,9 +742,10 @@ var MsgBroadcaster = class {
745
742
  txTimeout: txTimeoutInBlocks,
746
743
  address: tx.injectiveAddress
747
744
  });
745
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
746
+ const confirmedTx = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
748
747
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
749
- if (tx.skipPoll) return response;
750
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
748
+ return confirmedTx;
751
749
  }
752
750
  /**
753
751
  * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
@@ -820,13 +818,16 @@ var MsgBroadcaster = class {
820
818
  /** Broadcast the transaction */
821
819
  const response = await new TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, {
822
820
  txTimeout: txTimeoutInBlocks,
823
- skipPoll: tx.skipPoll
821
+ onBroadcast: () => {
822
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
823
+ }
824
824
  });
825
825
  if (response.code !== 0) throw new TransactionException(new Error(response.rawLog), {
826
826
  code: UnspecifiedErrorCode,
827
827
  contextCode: response.code,
828
828
  contextModule: response.codespace
829
829
  });
830
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
830
831
  return response;
831
832
  }
832
833
  /**
@@ -930,19 +931,11 @@ var MsgBroadcaster = class {
930
931
  try {
931
932
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
932
933
  const response = await broadcast();
933
- walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
934
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastSynced);
934
935
  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
- };
945
- return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
936
+ const confirmedTx = await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
937
+ walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
938
+ return confirmedTx;
946
939
  } catch (e) {
947
940
  const error = e;
948
941
  if (isThrownException(error)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.19.17",
3
+ "version": "1.19.19",
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.17",
48
- "@injectivelabs/ts-types": "1.19.17",
49
- "@injectivelabs/networks": "1.19.17",
50
- "@injectivelabs/utils": "1.19.17",
51
- "@injectivelabs/wallet-base": "1.19.17",
52
- "@injectivelabs/sdk-ts": "1.19.17"
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"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"