@injectivelabs/wallet-core 1.15.2 → 1.15.3

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.
@@ -27,6 +27,7 @@ export declare class MsgBroadcaster {
27
27
  timeout: number;
28
28
  };
29
29
  };
30
+ httpHeaders?: Record<string, string>;
30
31
  constructor(options: MsgBroadcasterOptions);
31
32
  setOptions(options: Partial<MsgBroadcasterOptions>): void;
32
33
  /**
@@ -129,4 +130,5 @@ export declare class MsgBroadcaster {
129
130
  */
130
131
  private simulateTxWithSigners;
131
132
  private retryOnException;
133
+ private fetchAccountAndBlockDetails;
132
134
  }
@@ -38,6 +38,7 @@ class MsgBroadcaster {
38
38
  ethereumChainId;
39
39
  gasBufferCoefficient = 1.2;
40
40
  retriesOnError = defaultRetriesConfig();
41
+ httpHeaders;
41
42
  constructor(options) {
42
43
  const networkInfo = (0, networks_1.getNetworkInfo)(options.network);
43
44
  this.options = options;
@@ -54,6 +55,7 @@ class MsgBroadcaster {
54
55
  options.ethereumChainId || networkInfo.ethereumChainId;
55
56
  this.endpoints = options.endpoints || (0, networks_1.getNetworkEndpoints)(options.network);
56
57
  this.walletStrategy = options.walletStrategy;
58
+ this.httpHeaders = options.httpHeaders;
57
59
  }
58
60
  setOptions(options) {
59
61
  this.simulateTx = options.simulateTx || this.simulateTx;
@@ -170,11 +172,7 @@ class MsgBroadcaster {
170
172
  throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
171
173
  }
172
174
  /** Account Details * */
173
- const accountDetails = await new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
174
- const { baseAccount } = accountDetails;
175
- /** Block Details */
176
- const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
177
- const latestHeight = latestBlock.header.height;
175
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
178
176
  const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
179
177
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
180
178
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
@@ -254,17 +252,13 @@ class MsgBroadcaster {
254
252
  * @returns transaction hash
255
253
  */
256
254
  async broadcastEip712V2(tx) {
257
- const { walletStrategy, chainId, txTimeout, endpoints, ethereumChainId } = this;
255
+ const { chainId, endpoints, txTimeout, walletStrategy, ethereumChainId } = this;
258
256
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
259
257
  if (!ethereumChainId) {
260
258
  throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
261
259
  }
262
260
  /** Account Details * */
263
- const accountDetails = await new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
264
- const { baseAccount } = accountDetails;
265
- /** Block Details */
266
- const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
267
- const latestHeight = latestBlock.header.height;
261
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
268
262
  const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
269
263
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
270
264
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
@@ -341,13 +335,16 @@ class MsgBroadcaster {
341
335
  * @returns transaction hash
342
336
  */
343
337
  async broadcastEip712WithFeeDelegation(tx) {
344
- const { txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
338
+ const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
345
339
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
346
340
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
347
341
  if (!ethereumChainId) {
348
342
  throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
349
343
  }
350
344
  const transactionApi = new sdk_ts_1.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
345
+ if (httpHeaders) {
346
+ transactionApi.setMetadata(httpHeaders);
347
+ }
351
348
  let timeoutHeight = undefined;
352
349
  if (txTimeoutOnFeeDelegation) {
353
350
  const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
@@ -422,12 +419,7 @@ class MsgBroadcaster {
422
419
  return this.experimentalBroadcastWalletThroughLedger(tx);
423
420
  }
424
421
  }
425
- /** Account Details * */
426
- const accountDetails = await new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
427
- const { baseAccount } = accountDetails;
428
- /** Block Details */
429
- const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
430
- const latestHeight = latestBlock.header.height;
422
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
431
423
  const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
432
424
  const signMode = (0, wallet_base_1.isCosmosAminoOnlyWallet)(walletStrategy.wallet)
433
425
  ? sdk_ts_1.SIGN_EIP712
@@ -509,12 +501,7 @@ class MsgBroadcaster {
509
501
  throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
510
502
  }
511
503
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
512
- /** Account Details * */
513
- const accountDetails = await new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
514
- const { baseAccount } = accountDetails;
515
- /** Block Details */
516
- const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
517
- const latestHeight = latestBlock.header.height;
504
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
518
505
  const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
519
506
  const pubKey = await walletStrategy.getPubKey();
520
507
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
@@ -588,7 +575,7 @@ class MsgBroadcaster {
588
575
  * @returns transaction hash
589
576
  */
590
577
  async broadcastDirectSignWithFeeDelegation(tx) {
591
- const { options, chainId, txTimeout, endpoints, walletStrategy, txTimeoutOnFeeDelegation, } = this;
578
+ const { options, chainId, txTimeout, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
592
579
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
593
580
  /**
594
581
  * We can only use this method when Keplr is connected
@@ -607,14 +594,13 @@ class MsgBroadcaster {
607
594
  const feePayerPublicKey = sdk_ts_1.PublicKey.fromBase64(feePayerPubKey);
608
595
  const feePayer = feePayerPublicKey.toAddress().address;
609
596
  /** Account Details * */
597
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
610
598
  const chainGrpcAuthApi = new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc);
611
- const accountDetails = await chainGrpcAuthApi.fetchAccount(tx.injectiveAddress);
599
+ if (httpHeaders) {
600
+ chainGrpcAuthApi.setMetadata(httpHeaders);
601
+ }
612
602
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
613
- const { baseAccount } = accountDetails;
614
603
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
615
- /** Block Details */
616
- const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
617
- const latestHeight = latestBlock.header.height;
618
604
  const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
619
605
  const pubKey = await walletStrategy.getPubKey();
620
606
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
@@ -649,6 +635,9 @@ class MsgBroadcaster {
649
635
  accountNumber: baseAccount.accountNumber,
650
636
  }));
651
637
  const transactionApi = new sdk_ts_1.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
638
+ if (httpHeaders) {
639
+ transactionApi.setMetadata(httpHeaders);
640
+ }
652
641
  const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
653
642
  address: tx.injectiveAddress,
654
643
  txRaw: (0, sdk_ts_1.createTxRawFromSigResponse)(directSignResponse),
@@ -684,8 +673,11 @@ class MsgBroadcaster {
684
673
  if (existingFeePayerPubKey) {
685
674
  return existingFeePayerPubKey;
686
675
  }
687
- const { endpoints } = this;
676
+ const { endpoints, httpHeaders } = this;
688
677
  const transactionApi = new sdk_ts_1.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
678
+ if (httpHeaders) {
679
+ transactionApi.setMetadata(httpHeaders);
680
+ }
689
681
  const response = await transactionApi.fetchFeePayer();
690
682
  if (!response.feePayerPubKey) {
691
683
  throw new exceptions_1.GeneralException(new Error('Please provide a feePayerPubKey'));
@@ -739,19 +731,27 @@ class MsgBroadcaster {
739
731
  * Create TxRaw and simulate it
740
732
  */
741
733
  async simulateTxRaw(txRaw) {
742
- const { endpoints } = this;
734
+ const { endpoints, httpHeaders } = this;
743
735
  txRaw.signatures = [new Uint8Array(0)];
744
- const simulationResponse = await new sdk_ts_1.TxGrpcApi(endpoints.grpc).simulate(txRaw);
736
+ const client = new sdk_ts_1.TxGrpcApi(endpoints.grpc);
737
+ if (httpHeaders) {
738
+ client.setMetadata(httpHeaders);
739
+ }
740
+ const simulationResponse = await client.simulate(txRaw);
745
741
  return simulationResponse;
746
742
  }
747
743
  /**
748
744
  * Create TxRaw and simulate it
749
745
  */
750
746
  async simulateTxWithSigners(args) {
751
- const { endpoints } = this;
747
+ const { endpoints, httpHeaders } = this;
752
748
  const { txRaw } = (0, sdk_ts_1.createTransactionWithSigners)(args);
753
749
  txRaw.signatures = Array(Array.isArray(args.signers) ? args.signers.length : 1).fill(new Uint8Array(0));
754
- const simulationResponse = await new sdk_ts_1.TxGrpcApi(endpoints.grpc).simulate(txRaw);
750
+ const client = new sdk_ts_1.TxGrpcApi(endpoints.grpc);
751
+ if (httpHeaders) {
752
+ client.setMetadata(httpHeaders);
753
+ }
754
+ const simulationResponse = await client.simulate(txRaw);
755
755
  return simulationResponse;
756
756
  }
757
757
  async retryOnException(exception, retryLogic) {
@@ -778,5 +778,23 @@ class MsgBroadcaster {
778
778
  throw e;
779
779
  }
780
780
  }
781
+ async fetchAccountAndBlockDetails(address) {
782
+ const { endpoints, httpHeaders } = this;
783
+ const chainClient = new sdk_ts_1.ChainGrpcAuthApi(endpoints.grpc);
784
+ const tendermintClient = new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc);
785
+ if (httpHeaders) {
786
+ chainClient.setMetadata(httpHeaders);
787
+ tendermintClient.setMetadata(httpHeaders);
788
+ }
789
+ const accountDetails = await chainClient.fetchAccount(address);
790
+ const { baseAccount } = accountDetails;
791
+ const latestBlock = await tendermintClient.fetchLatestBlock();
792
+ const latestHeight = latestBlock.header.height;
793
+ return {
794
+ baseAccount,
795
+ latestHeight,
796
+ accountDetails,
797
+ };
798
+ }
781
799
  }
782
800
  exports.MsgBroadcaster = MsgBroadcaster;
@@ -29,4 +29,5 @@ export interface MsgBroadcasterOptions {
29
29
  txTimeout?: number;
30
30
  walletStrategy: BaseWalletStrategy;
31
31
  gasBufferCoefficient?: number;
32
+ httpHeaders?: Record<string, string>;
32
33
  }
@@ -27,6 +27,7 @@ export declare class MsgBroadcaster {
27
27
  timeout: number;
28
28
  };
29
29
  };
30
+ httpHeaders?: Record<string, string>;
30
31
  constructor(options: MsgBroadcasterOptions);
31
32
  setOptions(options: Partial<MsgBroadcasterOptions>): void;
32
33
  /**
@@ -129,4 +130,5 @@ export declare class MsgBroadcaster {
129
130
  */
130
131
  private simulateTxWithSigners;
131
132
  private retryOnException;
133
+ private fetchAccountAndBlockDetails;
132
134
  }
@@ -35,6 +35,7 @@ export class MsgBroadcaster {
35
35
  ethereumChainId;
36
36
  gasBufferCoefficient = 1.2;
37
37
  retriesOnError = defaultRetriesConfig();
38
+ httpHeaders;
38
39
  constructor(options) {
39
40
  const networkInfo = getNetworkInfo(options.network);
40
41
  this.options = options;
@@ -51,6 +52,7 @@ export class MsgBroadcaster {
51
52
  options.ethereumChainId || networkInfo.ethereumChainId;
52
53
  this.endpoints = options.endpoints || getNetworkEndpoints(options.network);
53
54
  this.walletStrategy = options.walletStrategy;
55
+ this.httpHeaders = options.httpHeaders;
54
56
  }
55
57
  setOptions(options) {
56
58
  this.simulateTx = options.simulateTx || this.simulateTx;
@@ -167,11 +169,7 @@ export class MsgBroadcaster {
167
169
  throw new GeneralException(new Error('Please provide ethereumChainId'));
168
170
  }
169
171
  /** Account Details * */
170
- const accountDetails = await new ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
171
- const { baseAccount } = accountDetails;
172
- /** Block Details */
173
- const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
174
- const latestHeight = latestBlock.header.height;
172
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
175
173
  const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
176
174
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
177
175
  let stdFee = getStdFee({ ...tx.gas, gas });
@@ -251,17 +249,13 @@ export class MsgBroadcaster {
251
249
  * @returns transaction hash
252
250
  */
253
251
  async broadcastEip712V2(tx) {
254
- const { walletStrategy, chainId, txTimeout, endpoints, ethereumChainId } = this;
252
+ const { chainId, endpoints, txTimeout, walletStrategy, ethereumChainId } = this;
255
253
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
256
254
  if (!ethereumChainId) {
257
255
  throw new GeneralException(new Error('Please provide ethereumChainId'));
258
256
  }
259
257
  /** Account Details * */
260
- const accountDetails = await new ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
261
- const { baseAccount } = accountDetails;
262
- /** Block Details */
263
- const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
264
- const latestHeight = latestBlock.header.height;
258
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
265
259
  const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
266
260
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
267
261
  let stdFee = getStdFee({ ...tx.gas, gas });
@@ -338,13 +332,16 @@ export class MsgBroadcaster {
338
332
  * @returns transaction hash
339
333
  */
340
334
  async broadcastEip712WithFeeDelegation(tx) {
341
- const { txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
335
+ const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
342
336
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
343
337
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
344
338
  if (!ethereumChainId) {
345
339
  throw new GeneralException(new Error('Please provide ethereumChainId'));
346
340
  }
347
341
  const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
342
+ if (httpHeaders) {
343
+ transactionApi.setMetadata(httpHeaders);
344
+ }
348
345
  let timeoutHeight = undefined;
349
346
  if (txTimeoutOnFeeDelegation) {
350
347
  const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
@@ -419,12 +416,7 @@ export class MsgBroadcaster {
419
416
  return this.experimentalBroadcastWalletThroughLedger(tx);
420
417
  }
421
418
  }
422
- /** Account Details * */
423
- const accountDetails = await new ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
424
- const { baseAccount } = accountDetails;
425
- /** Block Details */
426
- const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
427
- const latestHeight = latestBlock.header.height;
419
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
428
420
  const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
429
421
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet)
430
422
  ? SIGN_EIP712
@@ -506,12 +498,7 @@ export class MsgBroadcaster {
506
498
  throw new GeneralException(new Error('Please provide ethereumChainId'));
507
499
  }
508
500
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
509
- /** Account Details * */
510
- const accountDetails = await new ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
511
- const { baseAccount } = accountDetails;
512
- /** Block Details */
513
- const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
514
- const latestHeight = latestBlock.header.height;
501
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
515
502
  const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
516
503
  const pubKey = await walletStrategy.getPubKey();
517
504
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
@@ -585,7 +572,7 @@ export class MsgBroadcaster {
585
572
  * @returns transaction hash
586
573
  */
587
574
  async broadcastDirectSignWithFeeDelegation(tx) {
588
- const { options, chainId, txTimeout, endpoints, walletStrategy, txTimeoutOnFeeDelegation, } = this;
575
+ const { options, chainId, txTimeout, endpoints, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
589
576
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
590
577
  /**
591
578
  * We can only use this method when Keplr is connected
@@ -604,14 +591,13 @@ export class MsgBroadcaster {
604
591
  const feePayerPublicKey = PublicKey.fromBase64(feePayerPubKey);
605
592
  const feePayer = feePayerPublicKey.toAddress().address;
606
593
  /** Account Details * */
594
+ const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
607
595
  const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc);
608
- const accountDetails = await chainGrpcAuthApi.fetchAccount(tx.injectiveAddress);
596
+ if (httpHeaders) {
597
+ chainGrpcAuthApi.setMetadata(httpHeaders);
598
+ }
609
599
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
610
- const { baseAccount } = accountDetails;
611
600
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
612
- /** Block Details */
613
- const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
614
- const latestHeight = latestBlock.header.height;
615
601
  const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
616
602
  const pubKey = await walletStrategy.getPubKey();
617
603
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
@@ -646,6 +632,9 @@ export class MsgBroadcaster {
646
632
  accountNumber: baseAccount.accountNumber,
647
633
  }));
648
634
  const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
635
+ if (httpHeaders) {
636
+ transactionApi.setMetadata(httpHeaders);
637
+ }
649
638
  const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
650
639
  address: tx.injectiveAddress,
651
640
  txRaw: createTxRawFromSigResponse(directSignResponse),
@@ -681,8 +670,11 @@ export class MsgBroadcaster {
681
670
  if (existingFeePayerPubKey) {
682
671
  return existingFeePayerPubKey;
683
672
  }
684
- const { endpoints } = this;
673
+ const { endpoints, httpHeaders } = this;
685
674
  const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
675
+ if (httpHeaders) {
676
+ transactionApi.setMetadata(httpHeaders);
677
+ }
686
678
  const response = await transactionApi.fetchFeePayer();
687
679
  if (!response.feePayerPubKey) {
688
680
  throw new GeneralException(new Error('Please provide a feePayerPubKey'));
@@ -736,19 +728,27 @@ export class MsgBroadcaster {
736
728
  * Create TxRaw and simulate it
737
729
  */
738
730
  async simulateTxRaw(txRaw) {
739
- const { endpoints } = this;
731
+ const { endpoints, httpHeaders } = this;
740
732
  txRaw.signatures = [new Uint8Array(0)];
741
- const simulationResponse = await new TxGrpcApi(endpoints.grpc).simulate(txRaw);
733
+ const client = new TxGrpcApi(endpoints.grpc);
734
+ if (httpHeaders) {
735
+ client.setMetadata(httpHeaders);
736
+ }
737
+ const simulationResponse = await client.simulate(txRaw);
742
738
  return simulationResponse;
743
739
  }
744
740
  /**
745
741
  * Create TxRaw and simulate it
746
742
  */
747
743
  async simulateTxWithSigners(args) {
748
- const { endpoints } = this;
744
+ const { endpoints, httpHeaders } = this;
749
745
  const { txRaw } = createTransactionWithSigners(args);
750
746
  txRaw.signatures = Array(Array.isArray(args.signers) ? args.signers.length : 1).fill(new Uint8Array(0));
751
- const simulationResponse = await new TxGrpcApi(endpoints.grpc).simulate(txRaw);
747
+ const client = new TxGrpcApi(endpoints.grpc);
748
+ if (httpHeaders) {
749
+ client.setMetadata(httpHeaders);
750
+ }
751
+ const simulationResponse = await client.simulate(txRaw);
752
752
  return simulationResponse;
753
753
  }
754
754
  async retryOnException(exception, retryLogic) {
@@ -775,4 +775,22 @@ export class MsgBroadcaster {
775
775
  throw e;
776
776
  }
777
777
  }
778
+ async fetchAccountAndBlockDetails(address) {
779
+ const { endpoints, httpHeaders } = this;
780
+ const chainClient = new ChainGrpcAuthApi(endpoints.grpc);
781
+ const tendermintClient = new ChainGrpcTendermintApi(endpoints.grpc);
782
+ if (httpHeaders) {
783
+ chainClient.setMetadata(httpHeaders);
784
+ tendermintClient.setMetadata(httpHeaders);
785
+ }
786
+ const accountDetails = await chainClient.fetchAccount(address);
787
+ const { baseAccount } = accountDetails;
788
+ const latestBlock = await tendermintClient.fetchLatestBlock();
789
+ const latestHeight = latestBlock.header.height;
790
+ return {
791
+ baseAccount,
792
+ latestHeight,
793
+ accountDetails,
794
+ };
795
+ }
778
796
  }
@@ -29,4 +29,5 @@ export interface MsgBroadcasterOptions {
29
29
  txTimeout?: number;
30
30
  walletStrategy: BaseWalletStrategy;
31
31
  gasBufferCoefficient?: number;
32
+ httpHeaders?: Record<string, string>;
32
33
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
3
  "description": "Core wallet strategy",
4
- "version": "1.15.2",
4
+ "version": "1.15.3",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -58,14 +58,14 @@
58
58
  "dependencies": {
59
59
  "@injectivelabs/exceptions": "^1.15.1",
60
60
  "@injectivelabs/networks": "^1.15.2",
61
- "@injectivelabs/sdk-ts": "^1.15.2",
61
+ "@injectivelabs/sdk-ts": "^1.15.3",
62
62
  "@injectivelabs/ts-types": "^1.15.2",
63
63
  "@injectivelabs/utils": "^1.15.2",
64
- "@injectivelabs/wallet-base": "^1.15.2",
64
+ "@injectivelabs/wallet-base": "^1.15.3",
65
65
  "@keplr-wallet/types": "^0.12.159"
66
66
  },
67
67
  "devDependencies": {
68
68
  "shx": "^0.3.3"
69
69
  },
70
- "gitHead": "64a57f3115b63114124d0d1fb61f75e520905499"
70
+ "gitHead": "ba67fdc10cfb9ef4f98e753681fb1f3a42f266d8"
71
71
  }