@injectivelabs/wallet-core 1.16.13-alpha.0 → 1.16.13-alpha.2

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.
@@ -72,9 +72,18 @@ class MsgBroadcaster {
72
72
  if (!(0, wallet_base_1.isEvmBrowserWallet)(walletStrategy.wallet)) {
73
73
  return this.evmChainId;
74
74
  }
75
- const mainnetEvmIds = [ts_types_1.EvmChainId.Mainnet, ts_types_1.EvmChainId.MainnetEvm];
76
- const testnetEvmIds = [ts_types_1.EvmChainId.Sepolia, ts_types_1.EvmChainId.TestnetEvm];
77
- const devnetEvmIds = [ts_types_1.EvmChainId.Sepolia, ts_types_1.EvmChainId.DevnetEvm];
75
+ const mainnetEvmIds = [
76
+ ts_types_1.EvmChainId.Mainnet,
77
+ ts_types_1.EvmChainId.MainnetEvm,
78
+ ];
79
+ const testnetEvmIds = [
80
+ ts_types_1.EvmChainId.Sepolia,
81
+ ts_types_1.EvmChainId.TestnetEvm,
82
+ ];
83
+ const devnetEvmIds = [
84
+ ts_types_1.EvmChainId.Sepolia,
85
+ ts_types_1.EvmChainId.DevnetEvm,
86
+ ];
78
87
  try {
79
88
  const chainId = await walletStrategy.getEthereumChainId();
80
89
  if (!chainId) {
@@ -213,7 +222,7 @@ class MsgBroadcaster {
213
222
  }
214
223
  /** Account Details * */
215
224
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
216
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
225
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
217
226
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
218
227
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
219
228
  /**
@@ -305,7 +314,7 @@ class MsgBroadcaster {
305
314
  }
306
315
  /** Account Details * */
307
316
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
308
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
317
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
309
318
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
310
319
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
311
320
  /**
@@ -404,9 +413,7 @@ class MsgBroadcaster {
404
413
  if (txTimeoutOnFeeDelegation) {
405
414
  const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
406
415
  const latestHeight = latestBlock.header.height;
407
- timeoutHeight = new utils_1.BigNumberInBase(latestHeight)
408
- .plus(txTimeout)
409
- .toNumber();
416
+ timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout).toNumber();
410
417
  }
411
418
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationStart);
412
419
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -479,7 +486,7 @@ class MsgBroadcaster {
479
486
  }
480
487
  }
481
488
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
482
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
489
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
483
490
  const signMode = (0, wallet_base_1.isCosmosAminoOnlyWallet)(walletStrategy.wallet)
484
491
  ? sdk_ts_1.SIGN_EIP712
485
492
  : sdk_ts_1.SIGN_DIRECT;
@@ -569,7 +576,7 @@ class MsgBroadcaster {
569
576
  }
570
577
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
571
578
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
572
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
579
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
573
580
  const pubKey = await walletStrategy.getPubKey();
574
581
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
575
582
  /** EIP712 for signing on Ethereum wallets */
@@ -668,7 +675,7 @@ class MsgBroadcaster {
668
675
  }
669
676
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
670
677
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
671
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
678
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
672
679
  const pubKey = await walletStrategy.getPubKey();
673
680
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
674
681
  /** Prepare the Transaction * */
@@ -773,7 +780,7 @@ class MsgBroadcaster {
773
780
  if (typeof args === 'string') {
774
781
  return (0, utils_1.getStdFee)({
775
782
  ...(baseFee && {
776
- gasPrice: new utils_1.BigNumberInBase(baseFee).toFixed(),
783
+ gasPrice: (0, utils_1.toBigNumber)(baseFee).toFixed(),
777
784
  }),
778
785
  gas: args,
779
786
  });
@@ -781,7 +788,7 @@ class MsgBroadcaster {
781
788
  return (0, utils_1.getStdFee)({
782
789
  ...args,
783
790
  ...(baseFee && {
784
- gasPrice: new utils_1.BigNumberInBase(baseFee).toFixed(),
791
+ gasPrice: (0, utils_1.toBigNumber)(baseFee).toFixed(),
785
792
  }),
786
793
  });
787
794
  }
@@ -811,7 +818,7 @@ class MsgBroadcaster {
811
818
  const stdGasFee = {
812
819
  ...(await this.getStdFeeWithDynamicBaseFee({
813
820
  ...(0, utils_1.getStdFee)(args.fee),
814
- gas: new utils_1.BigNumberInBase(result.gasInfo.gasUsed)
821
+ gas: (0, utils_1.toBigNumber)(result.gasInfo.gasUsed)
815
822
  .times(this.gasBufferCoefficient)
816
823
  .toFixed(),
817
824
  })),
@@ -42,7 +42,7 @@ export declare const WalletStrategyEmitterEventType: {
42
42
  readonly TransactionPreparationEnd: "transaction-preparation-end";
43
43
  readonly TransactionPreparationStart: "transaction-preparation-start";
44
44
  };
45
- export type WalletStrategyEmitterEventType = typeof WalletStrategyEmitterEventType[keyof typeof WalletStrategyEmitterEventType];
45
+ export type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
46
46
  export type WalletStrategyEmitterEvents = {
47
47
  [WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
48
48
  [WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
@@ -1,9 +1,9 @@
1
1
  import { EvmChainId } from '@injectivelabs/ts-types';
2
2
  import { isTestnet, isMainnet, getNetworkInfo, getNetworkEndpoints, } from '@injectivelabs/networks';
3
- import { sleep, getStdFee, BigNumberInBase, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
3
+ import { sleep, getStdFee, toBigNumber, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
4
4
  import { WalletException, GeneralException, isThrownException, UnspecifiedErrorCode, ChainCosmosErrorCode, TransactionException, TransactionChainErrorModule, } from '@injectivelabs/exceptions';
5
5
  import { Wallet, isCosmosWallet, WalletDeviceType, isEvmBrowserWallet, isEip712V2OnlyWallet, createEip712StdSignDoc, isCosmosAminoOnlyWallet, getEthereumSignerAddress, getInjectiveSignerAddress, } from '@injectivelabs/wallet-base';
6
- import { TxGrpcApi, hexToBuff, PublicKey, SIGN_DIRECT, hexToBase64, ofacWallets, SIGN_EIP712, SIGN_EIP712_V2, ChainGrpcAuthApi, createTxRawEIP712, createTransaction, ChainGrpcTxFeesApi, getAminoStdSignDoc, getEip712TypedData, createWeb3Extension, getEip712TypedDataV2, IndexerGrpcWeb3GwApi, ChainGrpcTendermintApi, getGasPriceBasedOnMessage, createTxRawFromSigResponse, recoverTypedSignaturePubKey, createTransactionWithSigners } from '@injectivelabs/sdk-ts';
6
+ import { TxGrpcApi, hexToBuff, PublicKey, SIGN_DIRECT, hexToBase64, ofacWallets, SIGN_EIP712, SIGN_EIP712_V2, ChainGrpcAuthApi, createTxRawEIP712, createTransaction, ChainGrpcTxFeesApi, getAminoStdSignDoc, getEip712TypedData, createWeb3Extension, getEip712TypedDataV2, IndexerGrpcWeb3GwApi, ChainGrpcTendermintApi, getGasPriceBasedOnMessage, createTxRawFromSigResponse, recoverTypedSignaturePubKey, createTransactionWithSigners, } from '@injectivelabs/sdk-ts';
7
7
  import { checkIfTxRunOutOfGas } from '../utils/index.js';
8
8
  import { WalletStrategyEmitterEventType } from './types.js';
9
9
  const getEthereumWalletPubKey = async ({ pubKey, eip712TypedData, signature, }) => {
@@ -69,9 +69,18 @@ export class MsgBroadcaster {
69
69
  if (!isEvmBrowserWallet(walletStrategy.wallet)) {
70
70
  return this.evmChainId;
71
71
  }
72
- const mainnetEvmIds = [EvmChainId.Mainnet, EvmChainId.MainnetEvm];
73
- const testnetEvmIds = [EvmChainId.Sepolia, EvmChainId.TestnetEvm];
74
- const devnetEvmIds = [EvmChainId.Sepolia, EvmChainId.DevnetEvm];
72
+ const mainnetEvmIds = [
73
+ EvmChainId.Mainnet,
74
+ EvmChainId.MainnetEvm,
75
+ ];
76
+ const testnetEvmIds = [
77
+ EvmChainId.Sepolia,
78
+ EvmChainId.TestnetEvm,
79
+ ];
80
+ const devnetEvmIds = [
81
+ EvmChainId.Sepolia,
82
+ EvmChainId.DevnetEvm,
83
+ ];
75
84
  try {
76
85
  const chainId = await walletStrategy.getEthereumChainId();
77
86
  if (!chainId) {
@@ -210,7 +219,7 @@ export class MsgBroadcaster {
210
219
  }
211
220
  /** Account Details * */
212
221
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
213
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
222
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
214
223
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
215
224
  let stdFee = getStdFee({ ...tx.gas, gas });
216
225
  /**
@@ -302,7 +311,7 @@ export class MsgBroadcaster {
302
311
  }
303
312
  /** Account Details * */
304
313
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
305
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
314
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
306
315
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
307
316
  let stdFee = getStdFee({ ...tx.gas, gas });
308
317
  /**
@@ -401,9 +410,7 @@ export class MsgBroadcaster {
401
410
  if (txTimeoutOnFeeDelegation) {
402
411
  const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
403
412
  const latestHeight = latestBlock.header.height;
404
- timeoutHeight = new BigNumberInBase(latestHeight)
405
- .plus(txTimeout)
406
- .toNumber();
413
+ timeoutHeight = toBigNumber(latestHeight).plus(txTimeout).toNumber();
407
414
  }
408
415
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
409
416
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -476,7 +483,7 @@ export class MsgBroadcaster {
476
483
  }
477
484
  }
478
485
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
479
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
486
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
480
487
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet)
481
488
  ? SIGN_EIP712
482
489
  : SIGN_DIRECT;
@@ -566,7 +573,7 @@ export class MsgBroadcaster {
566
573
  }
567
574
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
568
575
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
569
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
576
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
570
577
  const pubKey = await walletStrategy.getPubKey();
571
578
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
572
579
  /** EIP712 for signing on Ethereum wallets */
@@ -665,7 +672,7 @@ export class MsgBroadcaster {
665
672
  }
666
673
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
667
674
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
668
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
675
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
669
676
  const pubKey = await walletStrategy.getPubKey();
670
677
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
671
678
  /** Prepare the Transaction * */
@@ -770,7 +777,7 @@ export class MsgBroadcaster {
770
777
  if (typeof args === 'string') {
771
778
  return getStdFee({
772
779
  ...(baseFee && {
773
- gasPrice: new BigNumberInBase(baseFee).toFixed(),
780
+ gasPrice: toBigNumber(baseFee).toFixed(),
774
781
  }),
775
782
  gas: args,
776
783
  });
@@ -778,7 +785,7 @@ export class MsgBroadcaster {
778
785
  return getStdFee({
779
786
  ...args,
780
787
  ...(baseFee && {
781
- gasPrice: new BigNumberInBase(baseFee).toFixed(),
788
+ gasPrice: toBigNumber(baseFee).toFixed(),
782
789
  }),
783
790
  });
784
791
  }
@@ -808,7 +815,7 @@ export class MsgBroadcaster {
808
815
  const stdGasFee = {
809
816
  ...(await this.getStdFeeWithDynamicBaseFee({
810
817
  ...getStdFee(args.fee),
811
- gas: new BigNumberInBase(result.gasInfo.gasUsed)
818
+ gas: toBigNumber(result.gasInfo.gasUsed)
812
819
  .times(this.gasBufferCoefficient)
813
820
  .toFixed(),
814
821
  })),
@@ -42,7 +42,7 @@ export declare const WalletStrategyEmitterEventType: {
42
42
  readonly TransactionPreparationEnd: "transaction-preparation-end";
43
43
  readonly TransactionPreparationStart: "transaction-preparation-start";
44
44
  };
45
- export type WalletStrategyEmitterEventType = typeof WalletStrategyEmitterEventType[keyof typeof WalletStrategyEmitterEventType];
45
+ export type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
46
46
  export type WalletStrategyEmitterEvents = {
47
47
  [WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
48
48
  [WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { GeneralException, WalletException } from '@injectivelabs/exceptions';
3
- import { Wallet, isEvmWallet, isCosmosWallet } from '@injectivelabs/wallet-base';
4
- import { WalletStrategyEmitterEventType, } from '../broadcaster/types.js';
3
+ import { Wallet, isEvmWallet, isCosmosWallet, } from '@injectivelabs/wallet-base';
4
+ import { WalletStrategyEmitterEventType } from '../broadcaster/types.js';
5
5
  const getInitialWallet = (args) => {
6
6
  if (args.wallet) {
7
7
  return args.wallet;
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.16.13-alpha.0",
4
+ "version": "1.16.13-alpha.2",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -56,17 +56,17 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.13-alpha.0",
60
- "@injectivelabs/networks": "1.16.13-alpha.0",
61
- "@injectivelabs/sdk-ts": "1.16.13-alpha.0",
62
- "@injectivelabs/ts-types": "1.16.13-alpha.0",
63
- "@injectivelabs/utils": "1.16.13-alpha.0",
64
- "@injectivelabs/wallet-base": "1.16.13-alpha.0",
59
+ "@injectivelabs/exceptions": "1.16.13-alpha.2",
60
+ "@injectivelabs/networks": "1.16.13-alpha.2",
61
+ "@injectivelabs/sdk-ts": "1.16.13-alpha.2",
62
+ "@injectivelabs/ts-types": "1.16.13-alpha.2",
63
+ "@injectivelabs/utils": "1.16.13-alpha.2",
64
+ "@injectivelabs/wallet-base": "1.16.13-alpha.2",
65
65
  "@keplr-wallet/types": "^0.12.159",
66
66
  "eventemitter3": "^5.0.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "shx": "^0.3.3"
70
70
  },
71
- "gitHead": "bb71ac9147c0a2f0946ea0c316caf094fbbe2f2c"
71
+ "gitHead": "c60f210698d2ee266855a6bb7342d0147964bad4"
72
72
  }