@injectivelabs/wallet-core 1.18.20 → 1.18.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.
@@ -773,7 +773,7 @@ var MsgBroadcaster = class {
773
773
  */
774
774
  async broadcastDirectSignWithFeeDelegation(tx) {
775
775
  var _tx$gas7;
776
- const { options, chainId, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
776
+ const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
777
777
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
778
778
  /**
779
779
  * We can only use this method when Keplr is connected
@@ -787,8 +787,35 @@ var MsgBroadcaster = class {
787
787
  const feePayerPubKey = await this.fetchFeePayerPubKey(options.feePayerPubKey);
788
788
  const feePayerPublicKey = __injectivelabs_sdk_ts_core_accounts.PublicKey.fromBase64(feePayerPubKey);
789
789
  const feePayer = feePayerPublicKey.toAddress().address;
790
+ const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
791
+ if (httpHeaders) transactionApi.setMetadata(httpHeaders);
792
+ const fetchAccountBlockDetails = async () => {
793
+ try {
794
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
795
+ return {
796
+ baseAccount: baseAccount$1,
797
+ latestHeight: latestHeight$1
798
+ };
799
+ } catch (e) {
800
+ const error = e;
801
+ if ((0, __injectivelabs_exceptions.isThrownException)(error) && error.message.toLowerCase().includes(`account ${tx.injectiveAddress} not found`)) {
802
+ await transactionApi.prepareCosmosTxRequest({
803
+ address: tx.injectiveAddress,
804
+ message: msgs.map((msg) => msg.toWeb3Gw()),
805
+ memo: tx.memo,
806
+ estimateGas: simulateTx
807
+ });
808
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
809
+ return {
810
+ baseAccount: baseAccount$1,
811
+ latestHeight: latestHeight$1
812
+ };
813
+ }
814
+ throw e;
815
+ }
816
+ };
790
817
  /** Account Details * */
791
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
818
+ const { baseAccount, latestHeight } = await fetchAccountBlockDetails();
792
819
  const chainGrpcAuthApi = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
793
820
  if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
794
821
  const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
@@ -826,8 +853,6 @@ var MsgBroadcaster = class {
826
853
  accountNumber: baseAccount.accountNumber
827
854
  });
828
855
  walletStrategy.emit(__injectivelabs_wallet_base.WalletStrategyEmitterEventType.TransactionPreparationEnd);
829
- const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
830
- if (httpHeaders) transactionApi.setMetadata(httpHeaders);
831
856
  const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
832
857
  address: tx.injectiveAddress,
833
858
  txRaw: (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(directSignResponse),
package/dist/esm/index.js CHANGED
@@ -773,7 +773,7 @@ var MsgBroadcaster = class {
773
773
  */
774
774
  async broadcastDirectSignWithFeeDelegation(tx) {
775
775
  var _tx$gas7;
776
- const { options, chainId, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
776
+ const { options, chainId, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, txTimeout: txTimeoutInBlocks } = this;
777
777
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
778
778
  /**
779
779
  * We can only use this method when Keplr is connected
@@ -787,8 +787,35 @@ var MsgBroadcaster = class {
787
787
  const feePayerPubKey = await this.fetchFeePayerPubKey(options.feePayerPubKey);
788
788
  const feePayerPublicKey = PublicKey.fromBase64(feePayerPubKey);
789
789
  const feePayer = feePayerPublicKey.toAddress().address;
790
+ const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
791
+ if (httpHeaders) transactionApi.setMetadata(httpHeaders);
792
+ const fetchAccountBlockDetails = async () => {
793
+ try {
794
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
795
+ return {
796
+ baseAccount: baseAccount$1,
797
+ latestHeight: latestHeight$1
798
+ };
799
+ } catch (e) {
800
+ const error = e;
801
+ if (isThrownException(error) && error.message.toLowerCase().includes(`account ${tx.injectiveAddress} not found`)) {
802
+ await transactionApi.prepareCosmosTxRequest({
803
+ address: tx.injectiveAddress,
804
+ message: msgs.map((msg) => msg.toWeb3Gw()),
805
+ memo: tx.memo,
806
+ estimateGas: simulateTx
807
+ });
808
+ const { baseAccount: baseAccount$1, latestHeight: latestHeight$1 } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
809
+ return {
810
+ baseAccount: baseAccount$1,
811
+ latestHeight: latestHeight$1
812
+ };
813
+ }
814
+ throw e;
815
+ }
816
+ };
790
817
  /** Account Details * */
791
- const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
818
+ const { baseAccount, latestHeight } = await fetchAccountBlockDetails();
792
819
  const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc);
793
820
  if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
794
821
  const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
@@ -826,8 +853,6 @@ var MsgBroadcaster = class {
826
853
  accountNumber: baseAccount.accountNumber
827
854
  });
828
855
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
829
- const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
830
- if (httpHeaders) transactionApi.setMetadata(httpHeaders);
831
856
  const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
832
857
  address: tx.injectiveAddress,
833
858
  txRaw: createTxRawFromSigResponse(directSignResponse),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.18.20",
3
+ "version": "1.18.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.18.20",
48
- "@injectivelabs/networks": "1.18.20",
49
- "@injectivelabs/sdk-ts": "1.18.20",
50
- "@injectivelabs/ts-types": "1.18.20",
51
- "@injectivelabs/utils": "1.18.20",
52
- "@injectivelabs/wallet-base": "1.18.20"
47
+ "@injectivelabs/exceptions": "1.18.21",
48
+ "@injectivelabs/networks": "1.18.21",
49
+ "@injectivelabs/ts-types": "1.18.21",
50
+ "@injectivelabs/utils": "1.18.21",
51
+ "@injectivelabs/sdk-ts": "1.18.21",
52
+ "@injectivelabs/wallet-base": "1.18.21"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"