@injectivelabs/wallet-core 1.16.12 → 1.16.13-alpha.1

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,8 +1,9 @@
1
- import { TxResponse } from '@injectivelabs/sdk-ts';
2
- import { NetworkEndpoints } from '@injectivelabs/networks';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
- import { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
5
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import { EvmChainId } from '@injectivelabs/ts-types';
2
+ import type { NetworkEndpoints } from '@injectivelabs/networks';
3
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
+ import type { ChainId as ChainIdType, EvmChainId as EvmChainIdType } from '@injectivelabs/ts-types';
5
+ import type { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
6
+ import type { TxResponse } from '@injectivelabs/sdk-ts';
6
7
  /**
7
8
  * This class is used to broadcast transactions
8
9
  * using the WalletStrategy as a handler
@@ -14,14 +15,14 @@ export declare class MsgBroadcaster {
14
15
  options: MsgBroadcasterOptions;
15
16
  walletStrategy: BaseWalletStrategy;
16
17
  endpoints: NetworkEndpoints;
17
- chainId: ChainId;
18
+ chainId: ChainIdType;
18
19
  txTimeout: number;
19
20
  simulateTx: boolean;
20
21
  txTimeoutOnFeeDelegation: boolean;
21
- evmChainId?: EvmChainId;
22
+ evmChainId?: EvmChainIdType;
22
23
  gasBufferCoefficient: number;
23
24
  retriesOnError: {
24
- "sdk-20": {
25
+ [x: string]: {
25
26
  retries: number;
26
27
  maxRetries: number;
27
28
  timeout: number;
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MsgBroadcaster = void 0;
4
- const sdk_ts_1 = require("@injectivelabs/sdk-ts");
4
+ const ts_types_1 = require("@injectivelabs/ts-types");
5
+ const networks_1 = require("@injectivelabs/networks");
5
6
  const utils_1 = require("@injectivelabs/utils");
6
7
  const exceptions_1 = require("@injectivelabs/exceptions");
7
- const networks_1 = require("@injectivelabs/networks");
8
- const ts_types_1 = require("@injectivelabs/ts-types");
9
- const types_js_1 = require("./types.js");
10
- const index_js_1 = require("../utils/index.js");
11
8
  const wallet_base_1 = require("@injectivelabs/wallet-base");
12
- const getEthereumWalletPubKey = ({ pubKey, eip712TypedData, signature, }) => {
9
+ const sdk_ts_1 = require("@injectivelabs/sdk-ts");
10
+ const index_js_1 = require("../utils/index.js");
11
+ const types_js_1 = require("./types.js");
12
+ const getEthereumWalletPubKey = async ({ pubKey, eip712TypedData, signature, }) => {
13
13
  if (pubKey) {
14
14
  return pubKey;
15
15
  }
16
- return (0, sdk_ts_1.hexToBase64)((0, sdk_ts_1.recoverTypedSignaturePubKey)(eip712TypedData, signature));
16
+ const recoveredPubKey = await (0, sdk_ts_1.recoverTypedSignaturePubKey)(
17
+ // TODO: fix type
18
+ eip712TypedData, signature);
19
+ return (0, sdk_ts_1.hexToBase64)(recoveredPubKey);
17
20
  };
18
21
  const defaultRetriesConfig = () => ({
19
22
  [`${exceptions_1.TransactionChainErrorModule.CosmosSdk}-${exceptions_1.ChainCosmosErrorCode.ErrMempoolIsFull}`]: {
@@ -69,9 +72,18 @@ class MsgBroadcaster {
69
72
  if (!(0, wallet_base_1.isEvmBrowserWallet)(walletStrategy.wallet)) {
70
73
  return this.evmChainId;
71
74
  }
72
- const mainnetEvmIds = [ts_types_1.EvmChainId.Mainnet, ts_types_1.EvmChainId.MainnetEvm];
73
- const testnetEvmIds = [ts_types_1.EvmChainId.Sepolia, ts_types_1.EvmChainId.TestnetEvm];
74
- 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
+ ];
75
87
  try {
76
88
  const chainId = await walletStrategy.getEthereumChainId();
77
89
  if (!chainId) {
@@ -210,7 +222,7 @@ class MsgBroadcaster {
210
222
  }
211
223
  /** Account Details * */
212
224
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
213
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
225
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
214
226
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
215
227
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
216
228
  /**
@@ -252,7 +264,7 @@ class MsgBroadcaster {
252
264
  });
253
265
  /** Signing on Ethereum */
254
266
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
255
- const pubKeyOrSignatureDerivedPubKey = getEthereumWalletPubKey({
267
+ const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
256
268
  pubKey: baseAccount.pubKey?.key,
257
269
  eip712TypedData,
258
270
  signature,
@@ -302,7 +314,7 @@ class MsgBroadcaster {
302
314
  }
303
315
  /** Account Details * */
304
316
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
305
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
317
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
306
318
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
307
319
  let stdFee = (0, utils_1.getStdFee)({ ...tx.gas, gas });
308
320
  /**
@@ -346,7 +358,7 @@ class MsgBroadcaster {
346
358
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationEnd);
347
359
  /** Signing on Ethereum */
348
360
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
349
- const pubKeyOrSignatureDerivedPubKey = getEthereumWalletPubKey({
361
+ const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
350
362
  pubKey: baseAccount.pubKey?.key,
351
363
  eip712TypedData,
352
364
  signature,
@@ -401,9 +413,7 @@ class MsgBroadcaster {
401
413
  if (txTimeoutOnFeeDelegation) {
402
414
  const latestBlock = await new sdk_ts_1.ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
403
415
  const latestHeight = latestBlock.header.height;
404
- timeoutHeight = new utils_1.BigNumberInBase(latestHeight)
405
- .plus(txTimeout)
406
- .toNumber();
416
+ timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout).toNumber();
407
417
  }
408
418
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationStart);
409
419
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -476,7 +486,7 @@ class MsgBroadcaster {
476
486
  }
477
487
  }
478
488
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
479
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
489
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
480
490
  const signMode = (0, wallet_base_1.isCosmosAminoOnlyWallet)(walletStrategy.wallet)
481
491
  ? sdk_ts_1.SIGN_EIP712
482
492
  : sdk_ts_1.SIGN_DIRECT;
@@ -566,7 +576,7 @@ class MsgBroadcaster {
566
576
  }
567
577
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
568
578
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
569
- const timeoutHeight = new utils_1.BigNumberInBase(latestHeight).plus(txTimeout);
579
+ const timeoutHeight = (0, utils_1.toBigNumber)(latestHeight).plus(txTimeout);
570
580
  const pubKey = await walletStrategy.getPubKey();
571
581
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
572
582
  /** EIP712 for signing on Ethereum wallets */
@@ -665,7 +675,7 @@ class MsgBroadcaster {
665
675
  }
666
676
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
667
677
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
668
- 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);
669
679
  const pubKey = await walletStrategy.getPubKey();
670
680
  const gas = (tx.gas?.gas || (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs)).toString();
671
681
  /** Prepare the Transaction * */
@@ -770,7 +780,7 @@ class MsgBroadcaster {
770
780
  if (typeof args === 'string') {
771
781
  return (0, utils_1.getStdFee)({
772
782
  ...(baseFee && {
773
- gasPrice: new utils_1.BigNumberInBase(baseFee).toFixed(),
783
+ gasPrice: (0, utils_1.toBigNumber)(baseFee).toFixed(),
774
784
  }),
775
785
  gas: args,
776
786
  });
@@ -778,7 +788,7 @@ class MsgBroadcaster {
778
788
  return (0, utils_1.getStdFee)({
779
789
  ...args,
780
790
  ...(baseFee && {
781
- gasPrice: new utils_1.BigNumberInBase(baseFee).toFixed(),
791
+ gasPrice: (0, utils_1.toBigNumber)(baseFee).toFixed(),
782
792
  }),
783
793
  });
784
794
  }
@@ -808,7 +818,7 @@ class MsgBroadcaster {
808
818
  const stdGasFee = {
809
819
  ...(await this.getStdFeeWithDynamicBaseFee({
810
820
  ...(0, utils_1.getStdFee)(args.fee),
811
- gas: new utils_1.BigNumberInBase(result.gasInfo.gasUsed)
821
+ gas: (0, utils_1.toBigNumber)(result.gasInfo.gasUsed)
812
822
  .times(this.gasBufferCoefficient)
813
823
  .toFixed(),
814
824
  })),
@@ -1,6 +1,6 @@
1
- import { Network } from '@injectivelabs/networks';
2
- import { EvmChainId } from '@injectivelabs/ts-types';
3
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import type { Network } from '@injectivelabs/networks';
2
+ import type { EvmChainId } from '@injectivelabs/ts-types';
3
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
4
  interface SendTransactionOptions {
5
5
  tx: {
6
6
  from: string;
@@ -1,8 +1,8 @@
1
- import { EventEmitter } from 'eventemitter3';
2
- import { Msgs } from '@injectivelabs/sdk-ts';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
- import { Network, NetworkEndpoints } from '@injectivelabs/networks';
5
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import type { EventEmitter } from 'eventemitter3';
2
+ import type { Msgs } from '@injectivelabs/sdk-ts';
3
+ import type { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
5
+ import type { Network, NetworkEndpoints } from '@injectivelabs/networks';
6
6
  export interface MsgBroadcasterTxOptions {
7
7
  memo?: string;
8
8
  ethereumAddress?: string;
@@ -32,16 +32,17 @@ export interface MsgBroadcasterOptions {
32
32
  gasBufferCoefficient?: number;
33
33
  httpHeaders?: Record<string, string>;
34
34
  }
35
- export declare enum WalletStrategyEmitterEventType {
36
- TransactionFail = "transaction-fail",
37
- TransactionSigned = "transaction-signed",
38
- TransactionSignStart = "transaction-sign-start",
39
- TransactionBroadcastEnd = "transaction-broadcast-end",
40
- WalletStrategyDisconnect = "wallet-strategy-disconnect",
41
- TransactionBroadcastStart = "transaction-broadcast-start",
42
- TransactionPreparationEnd = "transaction-preparation-end",
43
- TransactionPreparationStart = "transaction-preparation-start"
44
- }
35
+ export declare const WalletStrategyEmitterEventType: {
36
+ readonly TransactionFail: "transaction-fail";
37
+ readonly TransactionSigned: "transaction-signed";
38
+ readonly TransactionSignStart: "transaction-sign-start";
39
+ readonly TransactionBroadcastEnd: "transaction-broadcast-end";
40
+ readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
41
+ readonly TransactionBroadcastStart: "transaction-broadcast-start";
42
+ readonly TransactionPreparationEnd: "transaction-preparation-end";
43
+ readonly TransactionPreparationStart: "transaction-preparation-start";
44
+ };
45
+ export type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
45
46
  export type WalletStrategyEmitterEvents = {
46
47
  [WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
47
48
  [WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WalletStrategyEmitterEventType = void 0;
4
- var WalletStrategyEmitterEventType;
5
- (function (WalletStrategyEmitterEventType) {
6
- WalletStrategyEmitterEventType["TransactionFail"] = "transaction-fail";
7
- WalletStrategyEmitterEventType["TransactionSigned"] = "transaction-signed";
8
- WalletStrategyEmitterEventType["TransactionSignStart"] = "transaction-sign-start";
9
- WalletStrategyEmitterEventType["TransactionBroadcastEnd"] = "transaction-broadcast-end";
10
- WalletStrategyEmitterEventType["WalletStrategyDisconnect"] = "wallet-strategy-disconnect";
11
- WalletStrategyEmitterEventType["TransactionBroadcastStart"] = "transaction-broadcast-start";
12
- WalletStrategyEmitterEventType["TransactionPreparationEnd"] = "transaction-preparation-end";
13
- WalletStrategyEmitterEventType["TransactionPreparationStart"] = "transaction-preparation-start";
14
- })(WalletStrategyEmitterEventType || (exports.WalletStrategyEmitterEventType = WalletStrategyEmitterEventType = {}));
4
+ exports.WalletStrategyEmitterEventType = {
5
+ TransactionFail: 'transaction-fail',
6
+ TransactionSigned: 'transaction-signed',
7
+ TransactionSignStart: 'transaction-sign-start',
8
+ TransactionBroadcastEnd: 'transaction-broadcast-end',
9
+ WalletStrategyDisconnect: 'wallet-strategy-disconnect',
10
+ TransactionBroadcastStart: 'transaction-broadcast-start',
11
+ TransactionPreparationEnd: 'transaction-preparation-end',
12
+ TransactionPreparationStart: 'transaction-preparation-start',
13
+ };
@@ -1,9 +1,11 @@
1
- import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { Wallet, WalletDeviceType, type WalletMetadata, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface, Eip1193Provider } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
- import { StdSignDoc } from '@keplr-wallet/types';
5
- import { WalletStrategyEmitter } from '../broadcaster/types.js';
6
- import { OfflineSigner } from '@cosmjs/proto-signing';
1
+ import { Wallet, type WalletMetadata } from '@injectivelabs/wallet-base';
2
+ import type { StdSignDoc } from '@keplr-wallet/types';
3
+ import type { OfflineSigner } from '@cosmjs/proto-signing';
4
+ import type { AccountAddress } from '@injectivelabs/ts-types';
5
+ import type { ChainId, EvmChainId } from '@injectivelabs/ts-types';
6
+ import type { WalletStrategyEmitter } from '../broadcaster/types.js';
7
+ import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
8
+ import type { Eip1193Provider, WalletDeviceType, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface } from '@injectivelabs/wallet-base';
7
9
  export default class BaseWalletStrategy implements WalletStrategyInterface {
8
10
  strategies: ConcreteStrategiesArg;
9
11
  wallet: Wallet;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const eventemitter3_1 = require("eventemitter3");
4
- const wallet_base_1 = require("@injectivelabs/wallet-base");
5
4
  const exceptions_1 = require("@injectivelabs/exceptions");
5
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
6
6
  const types_js_1 = require("../broadcaster/types.js");
7
7
  const getInitialWallet = (args) => {
8
8
  if (args.wallet) {
@@ -1,8 +1,9 @@
1
- import { TxResponse } from '@injectivelabs/sdk-ts';
2
- import { NetworkEndpoints } from '@injectivelabs/networks';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
- import { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
5
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import { EvmChainId } from '@injectivelabs/ts-types';
2
+ import type { NetworkEndpoints } from '@injectivelabs/networks';
3
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
+ import type { ChainId as ChainIdType, EvmChainId as EvmChainIdType } from '@injectivelabs/ts-types';
5
+ import type { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
6
+ import type { TxResponse } from '@injectivelabs/sdk-ts';
6
7
  /**
7
8
  * This class is used to broadcast transactions
8
9
  * using the WalletStrategy as a handler
@@ -14,14 +15,14 @@ export declare class MsgBroadcaster {
14
15
  options: MsgBroadcasterOptions;
15
16
  walletStrategy: BaseWalletStrategy;
16
17
  endpoints: NetworkEndpoints;
17
- chainId: ChainId;
18
+ chainId: ChainIdType;
18
19
  txTimeout: number;
19
20
  simulateTx: boolean;
20
21
  txTimeoutOnFeeDelegation: boolean;
21
- evmChainId?: EvmChainId;
22
+ evmChainId?: EvmChainIdType;
22
23
  gasBufferCoefficient: number;
23
24
  retriesOnError: {
24
- "sdk-20": {
25
+ [x: string]: {
25
26
  retries: number;
26
27
  maxRetries: number;
27
28
  timeout: number;
@@ -1,16 +1,19 @@
1
- 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';
2
- import { sleep, getStdFee, BigNumberInBase, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
3
- import { WalletException, GeneralException, isThrownException, UnspecifiedErrorCode, ChainCosmosErrorCode, TransactionException, TransactionChainErrorModule, } from '@injectivelabs/exceptions';
4
- import { isTestnet, isMainnet, getNetworkInfo, getNetworkEndpoints, } from '@injectivelabs/networks';
5
1
  import { EvmChainId } from '@injectivelabs/ts-types';
6
- import { WalletStrategyEmitterEventType, } from './types.js';
7
- import { checkIfTxRunOutOfGas } from '../utils/index.js';
2
+ import { isTestnet, isMainnet, getNetworkInfo, getNetworkEndpoints, } from '@injectivelabs/networks';
3
+ import { sleep, getStdFee, toBigNumber, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
4
+ import { WalletException, GeneralException, isThrownException, UnspecifiedErrorCode, ChainCosmosErrorCode, TransactionException, TransactionChainErrorModule, } from '@injectivelabs/exceptions';
8
5
  import { Wallet, isCosmosWallet, WalletDeviceType, isEvmBrowserWallet, isEip712V2OnlyWallet, createEip712StdSignDoc, isCosmosAminoOnlyWallet, getEthereumSignerAddress, getInjectiveSignerAddress, } from '@injectivelabs/wallet-base';
9
- const getEthereumWalletPubKey = ({ pubKey, eip712TypedData, signature, }) => {
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
+ import { checkIfTxRunOutOfGas } from '../utils/index.js';
8
+ import { WalletStrategyEmitterEventType } from './types.js';
9
+ const getEthereumWalletPubKey = async ({ pubKey, eip712TypedData, signature, }) => {
10
10
  if (pubKey) {
11
11
  return pubKey;
12
12
  }
13
- return hexToBase64(recoverTypedSignaturePubKey(eip712TypedData, signature));
13
+ const recoveredPubKey = await recoverTypedSignaturePubKey(
14
+ // TODO: fix type
15
+ eip712TypedData, signature);
16
+ return hexToBase64(recoveredPubKey);
14
17
  };
15
18
  const defaultRetriesConfig = () => ({
16
19
  [`${TransactionChainErrorModule.CosmosSdk}-${ChainCosmosErrorCode.ErrMempoolIsFull}`]: {
@@ -66,9 +69,18 @@ export class MsgBroadcaster {
66
69
  if (!isEvmBrowserWallet(walletStrategy.wallet)) {
67
70
  return this.evmChainId;
68
71
  }
69
- const mainnetEvmIds = [EvmChainId.Mainnet, EvmChainId.MainnetEvm];
70
- const testnetEvmIds = [EvmChainId.Sepolia, EvmChainId.TestnetEvm];
71
- 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
+ ];
72
84
  try {
73
85
  const chainId = await walletStrategy.getEthereumChainId();
74
86
  if (!chainId) {
@@ -207,7 +219,7 @@ export class MsgBroadcaster {
207
219
  }
208
220
  /** Account Details * */
209
221
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
210
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
222
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
211
223
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
212
224
  let stdFee = getStdFee({ ...tx.gas, gas });
213
225
  /**
@@ -249,7 +261,7 @@ export class MsgBroadcaster {
249
261
  });
250
262
  /** Signing on Ethereum */
251
263
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
252
- const pubKeyOrSignatureDerivedPubKey = getEthereumWalletPubKey({
264
+ const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
253
265
  pubKey: baseAccount.pubKey?.key,
254
266
  eip712TypedData,
255
267
  signature,
@@ -299,7 +311,7 @@ export class MsgBroadcaster {
299
311
  }
300
312
  /** Account Details * */
301
313
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
302
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
314
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
303
315
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
304
316
  let stdFee = getStdFee({ ...tx.gas, gas });
305
317
  /**
@@ -343,7 +355,7 @@ export class MsgBroadcaster {
343
355
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
344
356
  /** Signing on Ethereum */
345
357
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
346
- const pubKeyOrSignatureDerivedPubKey = getEthereumWalletPubKey({
358
+ const pubKeyOrSignatureDerivedPubKey = await getEthereumWalletPubKey({
347
359
  pubKey: baseAccount.pubKey?.key,
348
360
  eip712TypedData,
349
361
  signature,
@@ -398,9 +410,7 @@ export class MsgBroadcaster {
398
410
  if (txTimeoutOnFeeDelegation) {
399
411
  const latestBlock = await new ChainGrpcTendermintApi(endpoints.grpc).fetchLatestBlock();
400
412
  const latestHeight = latestBlock.header.height;
401
- timeoutHeight = new BigNumberInBase(latestHeight)
402
- .plus(txTimeout)
403
- .toNumber();
413
+ timeoutHeight = toBigNumber(latestHeight).plus(txTimeout).toNumber();
404
414
  }
405
415
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationStart);
406
416
  const prepareTxResponse = await transactionApi.prepareTxRequest({
@@ -473,7 +483,7 @@ export class MsgBroadcaster {
473
483
  }
474
484
  }
475
485
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
476
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
486
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
477
487
  const signMode = isCosmosAminoOnlyWallet(walletStrategy.wallet)
478
488
  ? SIGN_EIP712
479
489
  : SIGN_DIRECT;
@@ -563,7 +573,7 @@ export class MsgBroadcaster {
563
573
  }
564
574
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
565
575
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
566
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeout);
576
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeout);
567
577
  const pubKey = await walletStrategy.getPubKey();
568
578
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
569
579
  /** EIP712 for signing on Ethereum wallets */
@@ -662,7 +672,7 @@ export class MsgBroadcaster {
662
672
  }
663
673
  const feePayerAccountDetails = await chainGrpcAuthApi.fetchAccount(feePayer);
664
674
  const { baseAccount: feePayerBaseAccount } = feePayerAccountDetails;
665
- const timeoutHeight = new BigNumberInBase(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
675
+ const timeoutHeight = toBigNumber(latestHeight).plus(txTimeoutOnFeeDelegation ? txTimeout : DEFAULT_BLOCK_TIMEOUT_HEIGHT);
666
676
  const pubKey = await walletStrategy.getPubKey();
667
677
  const gas = (tx.gas?.gas || getGasPriceBasedOnMessage(msgs)).toString();
668
678
  /** Prepare the Transaction * */
@@ -767,7 +777,7 @@ export class MsgBroadcaster {
767
777
  if (typeof args === 'string') {
768
778
  return getStdFee({
769
779
  ...(baseFee && {
770
- gasPrice: new BigNumberInBase(baseFee).toFixed(),
780
+ gasPrice: toBigNumber(baseFee).toFixed(),
771
781
  }),
772
782
  gas: args,
773
783
  });
@@ -775,7 +785,7 @@ export class MsgBroadcaster {
775
785
  return getStdFee({
776
786
  ...args,
777
787
  ...(baseFee && {
778
- gasPrice: new BigNumberInBase(baseFee).toFixed(),
788
+ gasPrice: toBigNumber(baseFee).toFixed(),
779
789
  }),
780
790
  });
781
791
  }
@@ -805,7 +815,7 @@ export class MsgBroadcaster {
805
815
  const stdGasFee = {
806
816
  ...(await this.getStdFeeWithDynamicBaseFee({
807
817
  ...getStdFee(args.fee),
808
- gas: new BigNumberInBase(result.gasInfo.gasUsed)
818
+ gas: toBigNumber(result.gasInfo.gasUsed)
809
819
  .times(this.gasBufferCoefficient)
810
820
  .toFixed(),
811
821
  })),
@@ -1,6 +1,6 @@
1
- import { Network } from '@injectivelabs/networks';
2
- import { EvmChainId } from '@injectivelabs/ts-types';
3
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import type { Network } from '@injectivelabs/networks';
2
+ import type { EvmChainId } from '@injectivelabs/ts-types';
3
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
4
  interface SendTransactionOptions {
5
5
  tx: {
6
6
  from: string;
@@ -1,8 +1,8 @@
1
- import { EventEmitter } from 'eventemitter3';
2
- import { Msgs } from '@injectivelabs/sdk-ts';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
- import { Network, NetworkEndpoints } from '@injectivelabs/networks';
5
- import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
1
+ import type { EventEmitter } from 'eventemitter3';
2
+ import type { Msgs } from '@injectivelabs/sdk-ts';
3
+ import type { ChainId, EvmChainId } from '@injectivelabs/ts-types';
4
+ import type BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
5
+ import type { Network, NetworkEndpoints } from '@injectivelabs/networks';
6
6
  export interface MsgBroadcasterTxOptions {
7
7
  memo?: string;
8
8
  ethereumAddress?: string;
@@ -32,16 +32,17 @@ export interface MsgBroadcasterOptions {
32
32
  gasBufferCoefficient?: number;
33
33
  httpHeaders?: Record<string, string>;
34
34
  }
35
- export declare enum WalletStrategyEmitterEventType {
36
- TransactionFail = "transaction-fail",
37
- TransactionSigned = "transaction-signed",
38
- TransactionSignStart = "transaction-sign-start",
39
- TransactionBroadcastEnd = "transaction-broadcast-end",
40
- WalletStrategyDisconnect = "wallet-strategy-disconnect",
41
- TransactionBroadcastStart = "transaction-broadcast-start",
42
- TransactionPreparationEnd = "transaction-preparation-end",
43
- TransactionPreparationStart = "transaction-preparation-start"
44
- }
35
+ export declare const WalletStrategyEmitterEventType: {
36
+ readonly TransactionFail: "transaction-fail";
37
+ readonly TransactionSigned: "transaction-signed";
38
+ readonly TransactionSignStart: "transaction-sign-start";
39
+ readonly TransactionBroadcastEnd: "transaction-broadcast-end";
40
+ readonly WalletStrategyDisconnect: "wallet-strategy-disconnect";
41
+ readonly TransactionBroadcastStart: "transaction-broadcast-start";
42
+ readonly TransactionPreparationEnd: "transaction-preparation-end";
43
+ readonly TransactionPreparationStart: "transaction-preparation-start";
44
+ };
45
+ export type WalletStrategyEmitterEventType = (typeof WalletStrategyEmitterEventType)[keyof typeof WalletStrategyEmitterEventType];
45
46
  export type WalletStrategyEmitterEvents = {
46
47
  [WalletStrategyEmitterEventType.TransactionFail]: Record<string, any>;
47
48
  [WalletStrategyEmitterEventType.TransactionSigned]: Record<string, any>;
@@ -1,11 +1,10 @@
1
- export var WalletStrategyEmitterEventType;
2
- (function (WalletStrategyEmitterEventType) {
3
- WalletStrategyEmitterEventType["TransactionFail"] = "transaction-fail";
4
- WalletStrategyEmitterEventType["TransactionSigned"] = "transaction-signed";
5
- WalletStrategyEmitterEventType["TransactionSignStart"] = "transaction-sign-start";
6
- WalletStrategyEmitterEventType["TransactionBroadcastEnd"] = "transaction-broadcast-end";
7
- WalletStrategyEmitterEventType["WalletStrategyDisconnect"] = "wallet-strategy-disconnect";
8
- WalletStrategyEmitterEventType["TransactionBroadcastStart"] = "transaction-broadcast-start";
9
- WalletStrategyEmitterEventType["TransactionPreparationEnd"] = "transaction-preparation-end";
10
- WalletStrategyEmitterEventType["TransactionPreparationStart"] = "transaction-preparation-start";
11
- })(WalletStrategyEmitterEventType || (WalletStrategyEmitterEventType = {}));
1
+ export const WalletStrategyEmitterEventType = {
2
+ TransactionFail: 'transaction-fail',
3
+ TransactionSigned: 'transaction-signed',
4
+ TransactionSignStart: 'transaction-sign-start',
5
+ TransactionBroadcastEnd: 'transaction-broadcast-end',
6
+ WalletStrategyDisconnect: 'wallet-strategy-disconnect',
7
+ TransactionBroadcastStart: 'transaction-broadcast-start',
8
+ TransactionPreparationEnd: 'transaction-preparation-end',
9
+ TransactionPreparationStart: 'transaction-preparation-start',
10
+ };
@@ -1,9 +1,11 @@
1
- import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { Wallet, WalletDeviceType, type WalletMetadata, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface, Eip1193Provider } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
- import { StdSignDoc } from '@keplr-wallet/types';
5
- import { WalletStrategyEmitter } from '../broadcaster/types.js';
6
- import { OfflineSigner } from '@cosmjs/proto-signing';
1
+ import { Wallet, type WalletMetadata } from '@injectivelabs/wallet-base';
2
+ import type { StdSignDoc } from '@keplr-wallet/types';
3
+ import type { OfflineSigner } from '@cosmjs/proto-signing';
4
+ import type { AccountAddress } from '@injectivelabs/ts-types';
5
+ import type { ChainId, EvmChainId } from '@injectivelabs/ts-types';
6
+ import type { WalletStrategyEmitter } from '../broadcaster/types.js';
7
+ import type { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
8
+ import type { Eip1193Provider, WalletDeviceType, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface } from '@injectivelabs/wallet-base';
7
9
  export default class BaseWalletStrategy implements WalletStrategyInterface {
8
10
  strategies: ConcreteStrategiesArg;
9
11
  wallet: Wallet;
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { Wallet, isEvmWallet, isCosmosWallet, } from '@injectivelabs/wallet-base';
3
2
  import { GeneralException, WalletException } from '@injectivelabs/exceptions';
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.12",
4
+ "version": "1.16.13-alpha.1",
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.12",
60
- "@injectivelabs/networks": "1.16.12",
61
- "@injectivelabs/sdk-ts": "1.16.12",
62
- "@injectivelabs/ts-types": "1.16.12",
63
- "@injectivelabs/utils": "1.16.12",
64
- "@injectivelabs/wallet-base": "1.16.12",
59
+ "@injectivelabs/exceptions": "1.16.13-alpha.1",
60
+ "@injectivelabs/networks": "1.16.13-alpha.1",
61
+ "@injectivelabs/sdk-ts": "1.16.13-alpha.1",
62
+ "@injectivelabs/ts-types": "1.16.13-alpha.1",
63
+ "@injectivelabs/utils": "1.16.13-alpha.1",
64
+ "@injectivelabs/wallet-base": "1.16.13-alpha.1",
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": "11a4cd78ffb176786df6c4aff98476f90f0b354b"
71
+ "gitHead": "feb3e8f6bd6fa67bb489c94f6373a8d68a9846ae"
72
72
  }