@injectivelabs/wallet-core 1.16.38-alpha.1 → 1.16.38-alpha.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.
@@ -1,10 +1,15 @@
1
1
  let __injectivelabs_exceptions = require("@injectivelabs/exceptions");
2
2
  let eventemitter3 = require("eventemitter3");
3
3
  let __injectivelabs_wallet_base = require("@injectivelabs/wallet-base");
4
+ let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
4
5
  let __injectivelabs_ts_types = require("@injectivelabs/ts-types");
6
+ let __injectivelabs_sdk_ts_core_accounts = require("@injectivelabs/sdk-ts/core/accounts");
7
+ let __injectivelabs_sdk_ts_client_indexer = require("@injectivelabs/sdk-ts/client/indexer");
5
8
  let __injectivelabs_networks = require("@injectivelabs/networks");
9
+ let __injectivelabs_sdk_ts_client_chain = require("@injectivelabs/sdk-ts/client/chain");
6
10
  let __injectivelabs_utils = require("@injectivelabs/utils");
7
- let __injectivelabs_sdk_ts = require("@injectivelabs/sdk-ts");
11
+ let __injectivelabs_sdk_ts_utils = require("@injectivelabs/sdk-ts/utils");
12
+ let __injectivelabs_sdk_ts_core_tx = require("@injectivelabs/sdk-ts/core/tx");
8
13
 
9
14
  //#region src/utils/tx.ts
10
15
  const checkIfTxRunOutOfGas = (e) => {
@@ -99,7 +104,7 @@ var BaseWalletStrategy = class {
99
104
  getWallet() {
100
105
  return this.wallet;
101
106
  }
102
- setWallet(wallet) {
107
+ async setWallet(wallet) {
103
108
  this.wallet = wallet;
104
109
  this.getStrategy();
105
110
  }
@@ -215,7 +220,7 @@ var BaseWalletStrategy = class {
215
220
  //#region src/broadcaster/MsgBroadcaster.ts
216
221
  const getEthereumWalletPubKey = async ({ pubKey, eip712TypedData, signature }) => {
217
222
  if (pubKey) return pubKey;
218
- return (0, __injectivelabs_sdk_ts.hexToBase64)(await (0, __injectivelabs_sdk_ts.recoverTypedSignaturePubKey)(eip712TypedData, signature));
223
+ return (0, __injectivelabs_sdk_ts_utils.hexToBase64)(await (0, __injectivelabs_sdk_ts_utils.recoverTypedSignaturePubKey)(eip712TypedData, signature));
219
224
  };
220
225
  const defaultRetriesConfig = () => ({ [`${__injectivelabs_exceptions.TransactionChainErrorModule.CosmosSdk}-${__injectivelabs_exceptions.ChainCosmosErrorCode.ErrMempoolIsFull}`]: {
221
226
  retries: 0,
@@ -374,7 +379,7 @@ var MsgBroadcaster = class {
374
379
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight.toString()).plus(txTimeoutInBlocks);
375
380
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
376
381
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
377
- const gas = (((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.gas) || (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs)).toString();
382
+ const gas = (((_tx$gas = tx.gas) === null || _tx$gas === void 0 ? void 0 : _tx$gas.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
378
383
  let stdFee = (0, __injectivelabs_utils.getStdFee)({
379
384
  ...tx.gas,
380
385
  gas
@@ -388,7 +393,7 @@ var MsgBroadcaster = class {
388
393
  else {
389
394
  const { stdFee: simulatedStdFee } = await this.getTxWithSignersAndStdFee({
390
395
  chainId,
391
- signMode: __injectivelabs_sdk_ts.SIGN_EIP712,
396
+ signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
392
397
  memo: tx.memo,
393
398
  message: msgs,
394
399
  timeoutHeight: timeoutHeight.toNumber(),
@@ -402,7 +407,7 @@ var MsgBroadcaster = class {
402
407
  stdFee = simulatedStdFee;
403
408
  }
404
409
  /** EIP712 for signing on Ethereum wallets */
405
- const eip712TypedData = (0, __injectivelabs_sdk_ts.getEip712TypedData)({
410
+ const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
406
411
  msgs,
407
412
  fee: stdFee,
408
413
  tx: {
@@ -422,10 +427,10 @@ var MsgBroadcaster = class {
422
427
  signature
423
428
  });
424
429
  /** Preparing the transaction for client broadcasting */
425
- const { txRaw } = (0, __injectivelabs_sdk_ts.createTransaction)({
430
+ const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
426
431
  message: msgs,
427
432
  memo: tx.memo,
428
- signMode: __injectivelabs_sdk_ts.SIGN_EIP712,
433
+ signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
429
434
  fee: stdFee,
430
435
  pubKey: pubKeyOrSignatureDerivedPubKey,
431
436
  sequence: baseAccount.sequence,
@@ -433,9 +438,9 @@ var MsgBroadcaster = class {
433
438
  accountNumber: baseAccount.accountNumber,
434
439
  chainId
435
440
  });
436
- const txRawEip712 = (0, __injectivelabs_sdk_ts.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts.createWeb3Extension)({ evmChainId }));
441
+ const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
437
442
  /** Append Signatures */
438
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts.hexToBuff)(signature)];
443
+ txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
439
444
  const response = await walletStrategy.sendTransaction(txRawEip712, {
440
445
  chainId,
441
446
  endpoints,
@@ -443,7 +448,7 @@ var MsgBroadcaster = class {
443
448
  address: tx.injectiveAddress
444
449
  });
445
450
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
446
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
451
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
447
452
  }
448
453
  /**
449
454
  * Prepare/sign/broadcast transaction using
@@ -465,7 +470,7 @@ var MsgBroadcaster = class {
465
470
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
466
471
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
467
472
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
468
- const gas = (((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.gas) || (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs)).toString();
473
+ const gas = (((_tx$gas2 = tx.gas) === null || _tx$gas2 === void 0 ? void 0 : _tx$gas2.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
469
474
  let stdFee = (0, __injectivelabs_utils.getStdFee)({
470
475
  ...tx.gas,
471
476
  gas
@@ -479,7 +484,7 @@ var MsgBroadcaster = class {
479
484
  else {
480
485
  const { stdFee: simulatedStdFee } = await this.getTxWithSignersAndStdFee({
481
486
  chainId,
482
- signMode: __injectivelabs_sdk_ts.SIGN_EIP712_V2,
487
+ signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712_V2,
483
488
  memo: tx.memo,
484
489
  message: msgs,
485
490
  timeoutHeight: timeoutHeight.toNumber(),
@@ -494,7 +499,7 @@ var MsgBroadcaster = class {
494
499
  }
495
500
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
496
501
  /** EIP712 for signing on Ethereum wallets */
497
- const eip712TypedData = (0, __injectivelabs_sdk_ts.getEip712TypedDataV2)({
502
+ const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedDataV2)({
498
503
  msgs,
499
504
  fee: stdFee,
500
505
  tx: {
@@ -515,10 +520,10 @@ var MsgBroadcaster = class {
515
520
  signature
516
521
  });
517
522
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
518
- const { txRaw } = (0, __injectivelabs_sdk_ts.createTransaction)({
523
+ const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
519
524
  message: msgs,
520
525
  memo: tx.memo,
521
- signMode: __injectivelabs_sdk_ts.SIGN_EIP712_V2,
526
+ signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712_V2,
522
527
  fee: stdFee,
523
528
  pubKey: pubKeyOrSignatureDerivedPubKey,
524
529
  sequence: baseAccount.sequence,
@@ -526,9 +531,9 @@ var MsgBroadcaster = class {
526
531
  accountNumber: baseAccount.accountNumber,
527
532
  chainId
528
533
  });
529
- const txRawEip712 = (0, __injectivelabs_sdk_ts.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts.createWeb3Extension)({ evmChainId }));
534
+ const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
530
535
  /** Append Signatures */
531
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts.hexToBuff)(signature)];
536
+ txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.hexToBuff)(signature)];
532
537
  const response = await walletStrategy.sendTransaction(txRawEip712, {
533
538
  chainId,
534
539
  endpoints,
@@ -536,7 +541,7 @@ var MsgBroadcaster = class {
536
541
  address: tx.injectiveAddress
537
542
  });
538
543
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
539
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
544
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
540
545
  }
541
546
  /**
542
547
  * Prepare/sign/broadcast transaction using
@@ -551,12 +556,12 @@ var MsgBroadcaster = class {
551
556
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
552
557
  const evmChainId = await this.getEvmChainId();
553
558
  if (!evmChainId) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide evmChainId"));
554
- const transactionApi = new __injectivelabs_sdk_ts.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
559
+ const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
555
560
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
556
561
  const txTimeoutTimeInSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS;
557
562
  const txTimeoutTimeInMilliSeconds = txTimeoutTimeInSeconds * 1e3;
558
563
  let timeoutHeight = void 0;
559
- if (txTimeoutOnFeeDelegation) timeoutHeight = (0, __injectivelabs_utils.toBigNumber)((await new __injectivelabs_sdk_ts.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
564
+ if (txTimeoutOnFeeDelegation) timeoutHeight = (0, __injectivelabs_utils.toBigNumber)((await new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock()).header.height.toString()).plus(txTimeoutInBlocks).toNumber();
560
565
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
561
566
  const prepareTxResponse = await transactionApi.prepareTxRequest({
562
567
  timeoutHeight,
@@ -564,7 +569,7 @@ var MsgBroadcaster = class {
564
569
  message: web3Msgs,
565
570
  address: tx.ethereumAddress,
566
571
  chainId: evmChainId,
567
- gasLimit: (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs),
572
+ gasLimit: (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs),
568
573
  estimateGas: simulateTx
569
574
  });
570
575
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
@@ -579,7 +584,7 @@ var MsgBroadcaster = class {
579
584
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
580
585
  const response = await broadcast();
581
586
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
582
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
587
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
583
588
  } catch (e) {
584
589
  const error = e;
585
590
  if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
@@ -590,7 +595,7 @@ var MsgBroadcaster = class {
590
595
  * to just broadcast the transaction twice
591
596
  **/
592
597
  if (walletStrategy.wallet === __injectivelabs_wallet_base.Wallet.PrivateKey && checkIfTxRunOutOfGas(exception)) {
593
- const { baseAccount } = await new __injectivelabs_sdk_ts.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
598
+ const { baseAccount } = await new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc).fetchAccount(tx.injectiveAddress);
594
599
  /** We only do it on the first account tx fail */
595
600
  if (baseAccount.sequence > 1) throw e;
596
601
  return await this.broadcastEip712WithFeeDelegation(tx);
@@ -621,9 +626,9 @@ var MsgBroadcaster = class {
621
626
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
622
627
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
623
628
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
624
- const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts.SIGN_EIP712 : __injectivelabs_sdk_ts.SIGN_DIRECT;
629
+ const signMode = (0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet) ? __injectivelabs_sdk_ts_core_tx.SIGN_EIP712 : __injectivelabs_sdk_ts_core_tx.SIGN_DIRECT;
625
630
  const pubKey = await walletStrategy.getPubKey(tx.injectiveAddress);
626
- const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs)).toString();
631
+ const gas = (((_tx$gas3 = tx.gas) === null || _tx$gas3 === void 0 ? void 0 : _tx$gas3.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
627
632
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
628
633
  /** Prepare the Transaction * */
629
634
  const { txRaw } = await this.getTxWithSignersAndStdFee({
@@ -646,7 +651,7 @@ var MsgBroadcaster = class {
646
651
  /** Ledger using Cosmos app only allows signing amino docs */
647
652
  if ((0, __injectivelabs_wallet_base.isCosmosAminoOnlyWallet)(walletStrategy.wallet)) {
648
653
  var _tx$gas4;
649
- const aminoSignDoc = (0, __injectivelabs_sdk_ts.getAminoStdSignDoc)({
654
+ const aminoSignDoc = (0, __injectivelabs_sdk_ts_core_tx.getAminoStdSignDoc)({
650
655
  ...tx,
651
656
  ...baseAccount,
652
657
  msgs,
@@ -654,7 +659,7 @@ var MsgBroadcaster = class {
654
659
  gas: gas || ((_tx$gas4 = tx.gas) === null || _tx$gas4 === void 0 || (_tx$gas4 = _tx$gas4.gas) === null || _tx$gas4 === void 0 ? void 0 : _tx$gas4.toString()),
655
660
  timeoutHeight: timeoutHeight.toFixed()
656
661
  });
657
- txRaw.signatures = [(0, __injectivelabs_sdk_ts.base64ToUint8Array)((await walletStrategy.signAminoCosmosTransaction({
662
+ txRaw.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)((await walletStrategy.signAminoCosmosTransaction({
658
663
  signDoc: aminoSignDoc,
659
664
  address: tx.injectiveAddress
660
665
  })).signature.signature)];
@@ -666,7 +671,7 @@ var MsgBroadcaster = class {
666
671
  txTimeout: txTimeoutInBlocks
667
672
  });
668
673
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
669
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
674
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response$1.txHash, txTimeoutTimeInMilliSeconds);
670
675
  }
671
676
  const directSignResponse = await walletStrategy.signCosmosTransaction({
672
677
  txRaw,
@@ -682,7 +687,7 @@ var MsgBroadcaster = class {
682
687
  address: tx.injectiveAddress
683
688
  });
684
689
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
685
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
690
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
686
691
  }
687
692
  /**
688
693
  * We use this method only when we want to broadcast a transaction using Ledger on Keplr/Leap for Injective
@@ -706,9 +711,9 @@ var MsgBroadcaster = class {
706
711
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
707
712
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutInBlocks);
708
713
  const pubKey = await walletStrategy.getPubKey();
709
- const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs)).toString();
714
+ const gas = (((_tx$gas5 = tx.gas) === null || _tx$gas5 === void 0 ? void 0 : _tx$gas5.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
710
715
  /** EIP712 for signing on Ethereum wallets */
711
- const eip712TypedData = (0, __injectivelabs_sdk_ts.getEip712TypedData)({
716
+ const eip712TypedData = (0, __injectivelabs_sdk_ts_core_tx.getEip712TypedData)({
712
717
  msgs,
713
718
  fee: await this.getStdFeeWithDynamicBaseFee({
714
719
  ...tx.gas,
@@ -739,22 +744,22 @@ var MsgBroadcaster = class {
739
744
  * get as a response in case the user changed the fee/memo
740
745
  * on the Keplr popup
741
746
  */
742
- const { txRaw } = (0, __injectivelabs_sdk_ts.createTransaction)({
747
+ const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransaction)({
743
748
  pubKey,
744
749
  message: msgs,
745
750
  memo: aminoSignResponse.signed.memo,
746
- signMode: __injectivelabs_sdk_ts.SIGN_EIP712,
751
+ signMode: __injectivelabs_sdk_ts_core_tx.SIGN_EIP712,
747
752
  fee: aminoSignResponse.signed.fee,
748
753
  sequence: parseInt(aminoSignResponse.signed.sequence, 10),
749
754
  timeoutHeight: parseInt(aminoSignResponse.signed.timeout_height, 10),
750
755
  accountNumber: parseInt(aminoSignResponse.signed.account_number, 10),
751
756
  chainId
752
757
  });
753
- const txRawEip712 = (0, __injectivelabs_sdk_ts.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts.createWeb3Extension)({ evmChainId }));
758
+ const txRawEip712 = (0, __injectivelabs_sdk_ts_core_tx.createTxRawEIP712)(txRaw, (0, __injectivelabs_sdk_ts_core_tx.createWeb3Extension)({ evmChainId }));
754
759
  if (simulateTx) await this.simulateTxRaw(txRawEip712);
755
- txRawEip712.signatures = [(0, __injectivelabs_sdk_ts.base64ToUint8Array)(aminoSignResponse.signature.signature)];
760
+ txRawEip712.signatures = [(0, __injectivelabs_sdk_ts_utils.base64ToUint8Array)(aminoSignResponse.signature.signature)];
756
761
  /** Broadcast the transaction */
757
- const response = await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
762
+ const response = await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).broadcast(txRawEip712, { txTimeout: txTimeoutInBlocks });
758
763
  if (response.code !== 0) throw new __injectivelabs_exceptions.TransactionException(new Error(response.rawLog), {
759
764
  code: __injectivelabs_exceptions.UnspecifiedErrorCode,
760
765
  contextCode: response.code,
@@ -783,17 +788,17 @@ var MsgBroadcaster = class {
783
788
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
784
789
  const canDisableCosmosGasCheck = [__injectivelabs_wallet_base.Wallet.Keplr, __injectivelabs_wallet_base.Wallet.OWallet].includes(walletStrategy.wallet);
785
790
  const feePayerPubKey = await this.fetchFeePayerPubKey(options.feePayerPubKey);
786
- const feePayerPublicKey = __injectivelabs_sdk_ts.PublicKey.fromBase64(feePayerPubKey);
791
+ const feePayerPublicKey = __injectivelabs_sdk_ts_core_accounts.PublicKey.fromBase64(feePayerPubKey);
787
792
  const feePayer = feePayerPublicKey.toAddress().address;
788
793
  /** Account Details * */
789
794
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
790
- const chainGrpcAuthApi = new __injectivelabs_sdk_ts.ChainGrpcAuthApi(endpoints.grpc);
795
+ const chainGrpcAuthApi = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
791
796
  if (httpHeaders) chainGrpcAuthApi.setMetadata(httpHeaders);
792
797
  const { baseAccount: feePayerBaseAccount } = await chainGrpcAuthApi.fetchAccount(feePayer);
793
798
  const timeoutHeight = (0, __injectivelabs_utils.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeoutInBlocks : __injectivelabs_utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
794
799
  const txTimeoutTimeInMilliSeconds = txTimeoutInBlocks * __injectivelabs_utils.DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3;
795
800
  const pubKey = await walletStrategy.getPubKey();
796
- const gas = (((_tx$gas7 = tx.gas) === null || _tx$gas7 === void 0 ? void 0 : _tx$gas7.gas) || (0, __injectivelabs_sdk_ts.getGasPriceBasedOnMessage)(msgs)).toString();
801
+ const gas = (((_tx$gas7 = tx.gas) === null || _tx$gas7 === void 0 ? void 0 : _tx$gas7.gas) || (0, __injectivelabs_sdk_ts_utils.getGasPriceBasedOnMessage)(msgs)).toString();
797
802
  /** Prepare the Transaction * */
798
803
  const { txRaw } = await this.getTxWithSignersAndStdFee({
799
804
  chainId,
@@ -824,11 +829,11 @@ var MsgBroadcaster = class {
824
829
  accountNumber: baseAccount.accountNumber
825
830
  });
826
831
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
827
- const transactionApi = new __injectivelabs_sdk_ts.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
832
+ const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
828
833
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
829
834
  const broadcast = async () => await transactionApi.broadcastCosmosTxRequest({
830
835
  address: tx.injectiveAddress,
831
- txRaw: (0, __injectivelabs_sdk_ts.createTxRawFromSigResponse)(directSignResponse),
836
+ txRaw: (0, __injectivelabs_sdk_ts_core_tx.createTxRawFromSigResponse)(directSignResponse),
832
837
  signature: directSignResponse.signature.signature,
833
838
  pubKey: directSignResponse.signature.pub_key || {
834
839
  value: pubKey,
@@ -840,7 +845,7 @@ var MsgBroadcaster = class {
840
845
  const response = await broadcast();
841
846
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastEnd);
842
847
  if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) cosmosWallet.enableGasCheck(chainId);
843
- return await new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
848
+ return await new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash, txTimeoutTimeInMilliSeconds);
844
849
  } catch (e) {
845
850
  const error = e;
846
851
  if ((0, __injectivelabs_exceptions.isThrownException)(error)) {
@@ -858,15 +863,15 @@ var MsgBroadcaster = class {
858
863
  async fetchFeePayerPubKey(existingFeePayerPubKey) {
859
864
  if (existingFeePayerPubKey) return existingFeePayerPubKey;
860
865
  const { endpoints, httpHeaders } = this;
861
- const transactionApi = new __injectivelabs_sdk_ts.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
866
+ const transactionApi = new __injectivelabs_sdk_ts_client_indexer.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
862
867
  if (httpHeaders) transactionApi.setMetadata(httpHeaders);
863
868
  const response = await transactionApi.fetchFeePayer();
864
869
  if (!response.feePayerPubKey) throw new __injectivelabs_exceptions.GeneralException(/* @__PURE__ */ new Error("Please provide a feePayerPubKey"));
865
- if (response.feePayerPubKey.key.startsWith("0x") || response.feePayerPubKey.key.length === 66) return (0, __injectivelabs_sdk_ts.uint8ArrayToBase64)((0, __injectivelabs_sdk_ts.hexToUint8Array)(response.feePayerPubKey.key));
870
+ if (response.feePayerPubKey.key.startsWith("0x") || response.feePayerPubKey.key.length === 66) return (0, __injectivelabs_sdk_ts_utils.uint8ArrayToBase64)((0, __injectivelabs_sdk_ts_utils.hexToUint8Array)(response.feePayerPubKey.key));
866
871
  return response.feePayerPubKey.key;
867
872
  }
868
873
  async getStdFeeWithDynamicBaseFee(args) {
869
- const client = new __injectivelabs_sdk_ts.ChainGrpcTxFeesApi(this.endpoints.grpc);
874
+ const client = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTxFeesApi(this.endpoints.grpc);
870
875
  let baseFee = __injectivelabs_utils.DEFAULT_GAS_PRICE;
871
876
  try {
872
877
  const response = await client.fetchEipBaseFee();
@@ -894,12 +899,12 @@ var MsgBroadcaster = class {
894
899
  var _result$gasInfo;
895
900
  const { simulateTx } = this;
896
901
  if (!simulateTx) return {
897
- ...(0, __injectivelabs_sdk_ts.createTransactionWithSigners)(args),
902
+ ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args),
898
903
  stdFee: await this.getStdFeeWithDynamicBaseFee(args.fee)
899
904
  };
900
905
  const result = await this.simulateTxWithSigners(args);
901
906
  if (!((_result$gasInfo = result.gasInfo) === null || _result$gasInfo === void 0 ? void 0 : _result$gasInfo.gasUsed)) return {
902
- ...(0, __injectivelabs_sdk_ts.createTransactionWithSigners)(args),
907
+ ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args),
903
908
  stdFee: await this.getStdFeeWithDynamicBaseFee(args.fee)
904
909
  };
905
910
  const stdGasFee = { ...await this.getStdFeeWithDynamicBaseFee({
@@ -907,7 +912,7 @@ var MsgBroadcaster = class {
907
912
  gas: (0, __injectivelabs_utils.toBigNumber)(result.gasInfo.gasUsed).times(this.gasBufferCoefficient).toFixed()
908
913
  }) };
909
914
  return {
910
- ...(0, __injectivelabs_sdk_ts.createTransactionWithSigners)({
915
+ ...(0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)({
911
916
  ...args,
912
917
  fee: stdGasFee
913
918
  }),
@@ -920,7 +925,7 @@ var MsgBroadcaster = class {
920
925
  async simulateTxRaw(txRaw) {
921
926
  const { endpoints, httpHeaders } = this;
922
927
  txRaw.signatures = [new Uint8Array(0)];
923
- const client = new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc);
928
+ const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc);
924
929
  if (httpHeaders) client.setMetadata(httpHeaders);
925
930
  return await client.simulate(txRaw);
926
931
  }
@@ -929,9 +934,9 @@ var MsgBroadcaster = class {
929
934
  */
930
935
  async simulateTxWithSigners(args) {
931
936
  const { endpoints, httpHeaders } = this;
932
- const { txRaw } = (0, __injectivelabs_sdk_ts.createTransactionWithSigners)(args);
937
+ const { txRaw } = (0, __injectivelabs_sdk_ts_core_tx.createTransactionWithSigners)(args);
933
938
  txRaw.signatures = Array(Array.isArray(args.signers) ? args.signers.length : 1).fill(new Uint8Array(0));
934
- const client = new __injectivelabs_sdk_ts.TxGrpcApi(endpoints.grpc);
939
+ const client = new __injectivelabs_sdk_ts_core_tx.TxGrpcApi(endpoints.grpc);
935
940
  if (httpHeaders) client.setMetadata(httpHeaders);
936
941
  return await client.simulate(txRaw);
937
942
  }
@@ -956,8 +961,8 @@ var MsgBroadcaster = class {
956
961
  }
957
962
  async fetchAccountAndBlockDetails(address) {
958
963
  const { endpoints, httpHeaders } = this;
959
- const chainClient = new __injectivelabs_sdk_ts.ChainGrpcAuthApi(endpoints.grpc);
960
- const tendermintClient = new __injectivelabs_sdk_ts.ChainGrpcTendermintApi(endpoints.grpc);
964
+ const chainClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcAuthApi(endpoints.grpc);
965
+ const tendermintClient = new __injectivelabs_sdk_ts_client_chain.ChainGrpcTendermintApi(endpoints.grpc);
961
966
  if (httpHeaders) {
962
967
  chainClient.setMetadata(httpHeaders);
963
968
  tendermintClient.setMetadata(httpHeaders);
@@ -2,8 +2,10 @@ import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction,
2
2
  import { StdSignDoc } from "@keplr-wallet/types";
3
3
  import { OfflineSigner } from "@cosmjs/proto-signing";
4
4
  import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
5
- import { AminoSignResponse, DirectSignResponse, Msgs, TxRaw, TxResponse } from "@injectivelabs/sdk-ts";
5
+ import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
6
+ import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
6
7
  import { EventEmitter } from "eventemitter3";
8
+ import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
7
9
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
8
10
 
9
11
  //#region src/utils/tx.d.ts
@@ -75,7 +77,7 @@ declare class BaseWalletStrategy implements WalletStrategy {
75
77
  emit: WalletStrategyEmitter['emit'];
76
78
  constructor(args: WalletStrategyArguments);
77
79
  getWallet(): Wallet;
78
- setWallet(wallet: Wallet): void;
80
+ setWallet(wallet: Wallet): Promise<void>;
79
81
  setMetadata(metadata?: WalletMetadata): void;
80
82
  getStrategy(): ConcreteWalletStrategy;
81
83
  getAddresses(args?: unknown): Promise<AccountAddress[]>;
@@ -2,9 +2,11 @@ import { EventEmitter } from "eventemitter3";
2
2
  import { ConcreteStrategiesArg, ConcreteWalletStrategy, CosmosWalletAbstraction, Eip1193Provider, SendTransactionOptions, Wallet, WalletDeviceType, WalletMetadata, WalletStrategy, WalletStrategyArguments, onAccountChangeCallback, onChainIdChangeCallback } from "@injectivelabs/wallet-base";
3
3
  import { AccountAddress, ChainId, EvmChainId } from "@injectivelabs/ts-types";
4
4
  import { Network, NetworkEndpoints } from "@injectivelabs/networks";
5
- import { AminoSignResponse, DirectSignResponse, Msgs, TxRaw, TxResponse } from "@injectivelabs/sdk-ts";
5
+ import { TxResponse } from "@injectivelabs/sdk-ts/core/tx";
6
6
  import { StdSignDoc } from "@keplr-wallet/types";
7
7
  import { OfflineSigner } from "@cosmjs/proto-signing";
8
+ import { AminoSignResponse, DirectSignResponse, TxRaw } from "@injectivelabs/sdk-ts/types";
9
+ import { Msgs } from "@injectivelabs/sdk-ts/core/modules";
8
10
 
9
11
  //#region src/utils/tx.d.ts
10
12
  declare const checkIfTxRunOutOfGas: (e: unknown) => boolean;
@@ -75,7 +77,7 @@ declare class BaseWalletStrategy implements WalletStrategy {
75
77
  emit: WalletStrategyEmitter['emit'];
76
78
  constructor(args: WalletStrategyArguments);
77
79
  getWallet(): Wallet;
78
- setWallet(wallet: Wallet): void;
80
+ setWallet(wallet: Wallet): Promise<void>;
79
81
  setMetadata(metadata?: WalletMetadata): void;
80
82
  getStrategy(): ConcreteWalletStrategy;
81
83
  getAddresses(args?: unknown): Promise<AccountAddress[]>;
package/dist/esm/index.js CHANGED
@@ -1,10 +1,15 @@
1
1
  import { ChainCosmosErrorCode, GeneralException, TransactionChainErrorModule, TransactionException, UnspecifiedErrorCode, WalletException, Web3Exception, isThrownException } from "@injectivelabs/exceptions";
2
2
  import { EventEmitter } from "eventemitter3";
3
3
  import { Wallet, WalletDeviceType, createEip712StdSignDoc, getEthereumSignerAddress, getInjectiveSignerAddress, isCosmosAminoOnlyWallet, isCosmosWallet, isEip712V2OnlyWallet, isEvmBrowserWallet, isEvmWallet } from "@injectivelabs/wallet-base";
4
+ import { ofacWallets } from "@injectivelabs/sdk-ts";
4
5
  import { EvmChainId } from "@injectivelabs/ts-types";
6
+ import { PublicKey } from "@injectivelabs/sdk-ts/core/accounts";
7
+ import { IndexerGrpcWeb3GwApi } from "@injectivelabs/sdk-ts/client/indexer";
5
8
  import { getNetworkEndpoints, getNetworkInfo, isMainnet, isTestnet } from "@injectivelabs/networks";
9
+ import { ChainGrpcAuthApi, ChainGrpcTendermintApi, ChainGrpcTxFeesApi } from "@injectivelabs/sdk-ts/client/chain";
6
10
  import { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_GAS_PRICE, getStdFee, sleep, toBigNumber } from "@injectivelabs/utils";
7
- import { ChainGrpcAuthApi, ChainGrpcTendermintApi, ChainGrpcTxFeesApi, IndexerGrpcWeb3GwApi, PublicKey, SIGN_DIRECT, SIGN_EIP712, SIGN_EIP712_V2, TxGrpcApi, base64ToUint8Array, createTransaction, createTransactionWithSigners, createTxRawEIP712, createTxRawFromSigResponse, createWeb3Extension, getAminoStdSignDoc, getEip712TypedData, getEip712TypedDataV2, getGasPriceBasedOnMessage, hexToBase64, hexToBuff, hexToUint8Array, ofacWallets, recoverTypedSignaturePubKey, uint8ArrayToBase64 } from "@injectivelabs/sdk-ts";
11
+ import { base64ToUint8Array, getGasPriceBasedOnMessage, hexToBase64, hexToBuff, hexToUint8Array, recoverTypedSignaturePubKey, uint8ArrayToBase64 } from "@injectivelabs/sdk-ts/utils";
12
+ import { SIGN_DIRECT, SIGN_EIP712, SIGN_EIP712_V2, TxGrpcApi, createTransaction, createTransactionWithSigners, createTxRawEIP712, createTxRawFromSigResponse, createWeb3Extension, getAminoStdSignDoc, getEip712TypedData, getEip712TypedDataV2 } from "@injectivelabs/sdk-ts/core/tx";
8
13
 
9
14
  //#region src/utils/tx.ts
10
15
  const checkIfTxRunOutOfGas = (e) => {
@@ -99,7 +104,7 @@ var BaseWalletStrategy = class {
99
104
  getWallet() {
100
105
  return this.wallet;
101
106
  }
102
- setWallet(wallet) {
107
+ async setWallet(wallet) {
103
108
  this.wallet = wallet;
104
109
  this.getStrategy();
105
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-core",
3
- "version": "1.16.38-alpha.1",
3
+ "version": "1.16.38-alpha.3",
4
4
  "description": "Core wallet strategy",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,6 +37,22 @@
37
37
  "files": [
38
38
  "dist"
39
39
  ],
40
+ "dependencies": {
41
+ "@keplr-wallet/types": "^0.12.159",
42
+ "eventemitter3": "^5.0.1",
43
+ "@injectivelabs/networks": "1.16.38-alpha.1",
44
+ "@injectivelabs/exceptions": "1.16.38-alpha.2",
45
+ "@injectivelabs/ts-types": "1.16.38-alpha.1",
46
+ "@injectivelabs/sdk-ts": "1.16.38-alpha.3",
47
+ "@injectivelabs/utils": "1.16.38-alpha.2",
48
+ "@injectivelabs/wallet-base": "1.16.38-alpha.3"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "_moduleAliases": {
54
+ "~wallet-core": "dist"
55
+ },
40
56
  "scripts": {
41
57
  "build": "pnpm type-check && tsdown",
42
58
  "build:fast": "tsdown",
@@ -51,22 +67,5 @@
51
67
  "dev": "ts-node -r tsconfig-paths/register src/index.ts",
52
68
  "start": "node dist/index.js",
53
69
  "lint": "eslint . --ext .ts,.js"
54
- },
55
- "dependencies": {
56
- "@injectivelabs/exceptions": "1.16.38-alpha.0",
57
- "@injectivelabs/networks": "1.16.38-alpha.0",
58
- "@injectivelabs/sdk-ts": "1.16.38-alpha.1",
59
- "@injectivelabs/ts-types": "1.16.38-alpha.0",
60
- "@injectivelabs/utils": "1.16.38-alpha.0",
61
- "@injectivelabs/wallet-base": "1.16.38-alpha.1",
62
- "@keplr-wallet/types": "catalog:",
63
- "eventemitter3": "^5.0.1"
64
- },
65
- "publishConfig": {
66
- "access": "public"
67
- },
68
- "_moduleAliases": {
69
- "~wallet-core": "dist"
70
- },
71
- "gitHead": "35dab975c20dbf43d52a85fb161cf810c46d8f6f"
72
- }
70
+ }
71
+ }