@injectivelabs/wallet-core 1.16.6-alpha.0 → 1.16.6

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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ _Package to use Wallets on Injective via the wallet strategy._
13
13
  ## 📚 Installation
14
14
 
15
15
  ```bash
16
- pnpm add @injectivelabs/wallet-core
16
+ yarn add @injectivelabs/wallet-core
17
17
  ```
18
18
 
19
19
  ---
@@ -30,13 +30,13 @@ import { PrivateKeyWalletStrategy } from '@injectivelabs/wallet-private-key'
30
30
  const strategyArgs: WalletStrategyArguments = {} /** define the args */
31
31
  const strategyEthArgs: ConcreteEthereumWalletStrategyArgs = {} /** if the wallet is an Ethereum wallet */
32
32
  const strategies = {
33
- [Wallet.PrivateKey]: new PrivateKeyWalletStrategy(strategyEthArgs),
33
+ [Wallet.PrivateKey]: new PrivateKeyWalletStrategy(strategyEthArgs)
34
34
  }
35
35
 
36
- export const walletStrategy = new BaseWalletStrategy({ ...strategyArgs, strategies })
36
+ export const walletStrategy = new BaseWalletStrategy({...strategyArgs, strategies})
37
37
 
38
38
  const broadcasterArgs: MsgBroadcasterOptions = {} /** define the broadcaster args */
39
- export const msgBroadcaster = new MsgBroadcaster({ ...broadcasterArgs, walletStrategy })
39
+ export const msgBroadcaster = new MsgBroadcaster({...broadcasterArgs, walletStrategy})
40
40
  ```
41
41
 
42
42
  Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
@@ -1,6 +1,6 @@
1
1
  import { TxResponse } from '@injectivelabs/sdk-ts';
2
2
  import { NetworkEndpoints } from '@injectivelabs/networks';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
4
4
  import { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
5
5
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
6
6
  /**
@@ -18,7 +18,7 @@ export declare class MsgBroadcaster {
18
18
  txTimeout: number;
19
19
  simulateTx: boolean;
20
20
  txTimeoutOnFeeDelegation: boolean;
21
- evmChainId?: EvmChainId;
21
+ ethereumChainId?: EthereumChainId;
22
22
  gasBufferCoefficient: number;
23
23
  retriesOnError: {
24
24
  "sdk-20": {
@@ -30,7 +30,7 @@ export declare class MsgBroadcaster {
30
30
  httpHeaders?: Record<string, string>;
31
31
  constructor(options: MsgBroadcasterOptions);
32
32
  setOptions(options: Partial<MsgBroadcasterOptions>): void;
33
- getEvmChainId(): Promise<EvmChainId | undefined>;
33
+ getEvmChainId(): Promise<EthereumChainId | undefined>;
34
34
  /**
35
35
  * Broadcasting the transaction using the client
36
36
  * side approach for both cosmos and ethereum native wallets
@@ -37,7 +37,7 @@ class MsgBroadcaster {
37
37
  txTimeout = utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT;
38
38
  simulateTx = true;
39
39
  txTimeoutOnFeeDelegation = false;
40
- evmChainId;
40
+ ethereumChainId;
41
41
  gasBufferCoefficient = 1.2;
42
42
  retriesOnError = defaultRetriesConfig();
43
43
  httpHeaders;
@@ -53,7 +53,8 @@ class MsgBroadcaster {
53
53
  : true;
54
54
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
55
55
  this.chainId = options.chainId || networkInfo.chainId;
56
- this.evmChainId = options.evmChainId || networkInfo.evmChainId;
56
+ this.ethereumChainId =
57
+ options.ethereumChainId || networkInfo.ethereumChainId;
57
58
  this.endpoints = options.endpoints || (0, networks_1.getNetworkEndpoints)(options.network);
58
59
  this.walletStrategy = options.walletStrategy;
59
60
  this.httpHeaders = options.httpHeaders;
@@ -67,19 +68,19 @@ class MsgBroadcaster {
67
68
  async getEvmChainId() {
68
69
  const { walletStrategy } = this;
69
70
  if (!(0, wallet_base_1.isEvmBrowserWallet)(walletStrategy.wallet)) {
70
- return this.evmChainId;
71
+ return this.ethereumChainId;
71
72
  }
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];
73
+ const mainnetEvmIds = [ts_types_1.EthereumChainId.Mainnet, ts_types_1.EthereumChainId.MainnetEvm];
74
+ const testnetEvmIds = [ts_types_1.EthereumChainId.Sepolia, ts_types_1.EthereumChainId.TestnetEvm];
75
+ const devnetEvmIds = [ts_types_1.EthereumChainId.Sepolia, ts_types_1.EthereumChainId.DevnetEvm];
75
76
  try {
76
77
  const chainId = await walletStrategy.getEthereumChainId();
77
78
  if (!chainId) {
78
- return this.evmChainId;
79
+ return this.ethereumChainId;
79
80
  }
80
81
  const evmChainId = parseInt(chainId, 16);
81
82
  if (isNaN(evmChainId)) {
82
- return this.evmChainId;
83
+ return this.ethereumChainId;
83
84
  }
84
85
  if (((0, networks_1.isMainnet)(this.options.network) &&
85
86
  !mainnetEvmIds.includes(evmChainId)) ||
@@ -204,9 +205,9 @@ class MsgBroadcaster {
204
205
  async broadcastEip712(tx) {
205
206
  const { chainId, txTimeout, endpoints, walletStrategy } = this;
206
207
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
207
- const evmChainId = await this.getEvmChainId();
208
- if (!evmChainId) {
209
- throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
208
+ const ethereumChainId = await this.getEvmChainId();
209
+ if (!ethereumChainId) {
210
+ throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
210
211
  }
211
212
  /** Account Details * */
212
213
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -248,7 +249,7 @@ class MsgBroadcaster {
248
249
  timeoutHeight: timeoutHeight.toFixed(),
249
250
  chainId,
250
251
  },
251
- evmChainId,
252
+ ethereumChainId,
252
253
  });
253
254
  /** Signing on Ethereum */
254
255
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
@@ -270,7 +271,7 @@ class MsgBroadcaster {
270
271
  chainId,
271
272
  });
272
273
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
273
- evmChainId,
274
+ ethereumChainId,
274
275
  });
275
276
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
276
277
  /** Append Signatures */
@@ -296,9 +297,9 @@ class MsgBroadcaster {
296
297
  async broadcastEip712V2(tx) {
297
298
  const { chainId, endpoints, txTimeout, walletStrategy } = this;
298
299
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
299
- const evmChainId = await this.getEvmChainId();
300
- if (!evmChainId) {
301
- throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
300
+ const ethereumChainId = await this.getEvmChainId();
301
+ if (!ethereumChainId) {
302
+ throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
302
303
  }
303
304
  /** Account Details * */
304
305
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -341,7 +342,7 @@ class MsgBroadcaster {
341
342
  timeoutHeight: timeoutHeight.toFixed(),
342
343
  chainId,
343
344
  },
344
- evmChainId,
345
+ ethereumChainId,
345
346
  });
346
347
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationEnd);
347
348
  /** Signing on Ethereum */
@@ -364,7 +365,7 @@ class MsgBroadcaster {
364
365
  chainId,
365
366
  });
366
367
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
367
- evmChainId,
368
+ ethereumChainId,
368
369
  });
369
370
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
370
371
  /** Append Signatures */
@@ -389,9 +390,9 @@ class MsgBroadcaster {
389
390
  const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
390
391
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
391
392
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
392
- const evmChainId = await this.getEvmChainId();
393
- if (!evmChainId) {
394
- throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
393
+ const ethereumChainId = await this.getEvmChainId();
394
+ if (!ethereumChainId) {
395
+ throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
395
396
  }
396
397
  const transactionApi = new sdk_ts_1.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
397
398
  if (httpHeaders) {
@@ -411,7 +412,7 @@ class MsgBroadcaster {
411
412
  memo: tx.memo,
412
413
  message: web3Msgs,
413
414
  address: tx.ethereumAddress,
414
- chainId: evmChainId,
415
+ chainId: ethereumChainId,
415
416
  gasLimit: (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs),
416
417
  estimateGas: simulateTx,
417
418
  });
@@ -421,7 +422,7 @@ class MsgBroadcaster {
421
422
  signature,
422
423
  message: web3Msgs,
423
424
  txResponse: prepareTxResponse,
424
- chainId: evmChainId,
425
+ chainId: ethereumChainId,
425
426
  });
426
427
  try {
427
428
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastStart);
@@ -548,7 +549,7 @@ class MsgBroadcaster {
548
549
  * @param tx the transaction that needs to be broadcasted
549
550
  */
550
551
  async experimentalBroadcastWalletThroughLedger(tx) {
551
- const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
552
+ const { chainId, txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, } = this;
552
553
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
553
554
  /**
554
555
  * We can only use this method
@@ -561,8 +562,8 @@ class MsgBroadcaster {
561
562
  throw new exceptions_1.GeneralException(new Error(`This method can only be used when Ledger is connected through ${walletStrategy.getWallet()}`));
562
563
  }
563
564
  }
564
- if (!evmChainId) {
565
- throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
565
+ if (!ethereumChainId) {
566
+ throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
566
567
  }
567
568
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
568
569
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -580,7 +581,7 @@ class MsgBroadcaster {
580
581
  sequence: baseAccount.sequence.toString(),
581
582
  accountNumber: baseAccount.accountNumber.toString(),
582
583
  },
583
- evmChainId,
584
+ ethereumChainId,
584
585
  });
585
586
  const aminoSignResponse = await cosmosWallet.signEIP712CosmosTx({
586
587
  eip712: eip712TypedData,
@@ -611,7 +612,7 @@ class MsgBroadcaster {
611
612
  });
612
613
  /** Preparing the transaction for client broadcasting */
613
614
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
614
- evmChainId,
615
+ ethereumChainId,
615
616
  });
616
617
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
617
618
  if (simulateTx) {
@@ -1,5 +1,5 @@
1
+ import { EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { Network } from '@injectivelabs/networks';
2
- import { EvmChainId } from '@injectivelabs/ts-types';
3
3
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
4
  interface SendTransactionOptions {
5
5
  tx: {
@@ -11,7 +11,7 @@ interface SendTransactionOptions {
11
11
  data: any;
12
12
  };
13
13
  address: string;
14
- evmChainId?: EvmChainId;
14
+ ethereumChainId?: EthereumChainId;
15
15
  }
16
16
  /**
17
17
  * Preparing and broadcasting
@@ -19,10 +19,10 @@ interface SendTransactionOptions {
19
19
  */
20
20
  export declare class Web3Broadcaster {
21
21
  private walletStrategy;
22
- private evmChainId;
23
- constructor({ walletStrategy, evmChainId, }: {
22
+ private ethereumChainId;
23
+ constructor({ walletStrategy, ethereumChainId, }: {
24
24
  walletStrategy: BaseWalletStrategy;
25
- evmChainId: EvmChainId;
25
+ ethereumChainId: EthereumChainId;
26
26
  network: Network;
27
27
  });
28
28
  sendTransaction(args: SendTransactionOptions): Promise<string>;
@@ -8,18 +8,18 @@ const exceptions_1 = require("@injectivelabs/exceptions");
8
8
  */
9
9
  class Web3Broadcaster {
10
10
  walletStrategy;
11
- evmChainId;
12
- constructor({ walletStrategy, evmChainId, }) {
13
- this.evmChainId = evmChainId;
11
+ ethereumChainId;
12
+ constructor({ walletStrategy, ethereumChainId, }) {
14
13
  this.walletStrategy = walletStrategy;
14
+ this.ethereumChainId = ethereumChainId;
15
15
  }
16
16
  async sendTransaction(args) {
17
- const { evmChainId, walletStrategy } = this;
17
+ const { walletStrategy, ethereumChainId } = this;
18
18
  try {
19
- const chainId = args.evmChainId || evmChainId;
19
+ const chainId = args.ethereumChainId || ethereumChainId;
20
20
  const txHash = await walletStrategy.sendEvmTransaction(args.tx, {
21
- evmChainId: chainId,
22
21
  address: args.address,
22
+ ethereumChainId: chainId,
23
23
  });
24
24
  await walletStrategy.getEvmTransactionReceipt(txHash, chainId);
25
25
  return txHash;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { Msgs } from '@injectivelabs/sdk-ts';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
4
4
  import { Network, NetworkEndpoints } from '@injectivelabs/networks';
5
5
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
6
6
  export interface MsgBroadcasterTxOptions {
@@ -23,7 +23,7 @@ export interface MsgBroadcasterOptions {
23
23
  network: Network;
24
24
  endpoints?: NetworkEndpoints;
25
25
  chainId?: ChainId;
26
- evmChainId?: EvmChainId;
26
+ ethereumChainId?: EthereumChainId;
27
27
  feePayerPubKey?: string;
28
28
  simulateTx?: boolean;
29
29
  txTimeoutOnFeeDelegation?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
3
  import { Wallet, WalletDeviceType, type WalletMetadata, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
4
  import { StdSignDoc } from '@keplr-wallet/types';
5
5
  import { WalletStrategyEmitter } from '../broadcaster/types.js';
6
6
  export default class BaseWalletStrategy implements WalletStrategyInterface {
@@ -24,13 +24,13 @@ export default class BaseWalletStrategy implements WalletStrategyInterface {
24
24
  enable(args?: unknown): Promise<boolean>;
25
25
  enableAndGetAddresses(args?: unknown): Promise<AccountAddress[]>;
26
26
  getEthereumChainId(): Promise<string>;
27
- getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<void>;
27
+ getEvmTransactionReceipt(txHash: string, ethereumChainId?: EthereumChainId): Promise<void>;
28
28
  getSessionOrConfirm(address?: AccountAddress): Promise<string>;
29
29
  getWalletClient<T>(): Promise<T>;
30
30
  sendTransaction(tx: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
31
31
  sendEvmTransaction(tx: any, options: {
32
- evmChainId: EvmChainId;
33
32
  address: AccountAddress;
33
+ ethereumChainId: EthereumChainId;
34
34
  }): Promise<string>;
35
35
  signEip712TypedData(eip712TypedData: string, address: AccountAddress): Promise<string>;
36
36
  signAminoCosmosTransaction(transaction: {
@@ -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) {
@@ -10,12 +10,12 @@ const getInitialWallet = (args) => {
10
10
  }
11
11
  const keys = Object.keys(args.strategies || {});
12
12
  if (keys.length === 0) {
13
- return wallet_base_1.Wallet.Metamask;
13
+ throw new exceptions_1.GeneralException(new Error('No strategies provided to BaseWalletStrategy'));
14
14
  }
15
- if (keys.includes(wallet_base_1.Wallet.Metamask) && args.evmOptions) {
15
+ if (keys.includes(wallet_base_1.Wallet.Metamask) && args.ethereumOptions) {
16
16
  return wallet_base_1.Wallet.Metamask;
17
17
  }
18
- if (keys.includes(wallet_base_1.Wallet.Keplr) && !args.evmOptions) {
18
+ if (keys.includes(wallet_base_1.Wallet.Keplr) && !args.ethereumOptions) {
19
19
  return wallet_base_1.Wallet.Keplr;
20
20
  }
21
21
  return keys[0];
@@ -45,10 +45,8 @@ class BaseWalletStrategy {
45
45
  }
46
46
  setWallet(wallet) {
47
47
  this.wallet = wallet;
48
- this.getStrategy();
49
48
  }
50
49
  setMetadata(metadata) {
51
- console.log('Setting metadata', metadata);
52
50
  this.metadata = metadata;
53
51
  this.getStrategy().setMetadata?.(metadata);
54
52
  }
@@ -77,8 +75,8 @@ class BaseWalletStrategy {
77
75
  getEthereumChainId() {
78
76
  return this.getStrategy().getEthereumChainId();
79
77
  }
80
- async getEvmTransactionReceipt(txHash, evmChainId) {
81
- return this.getStrategy().getEvmTransactionReceipt(txHash, evmChainId);
78
+ async getEvmTransactionReceipt(txHash, ethereumChainId) {
79
+ return this.getStrategy().getEvmTransactionReceipt(txHash, ethereumChainId);
82
80
  }
83
81
  async getSessionOrConfirm(address) {
84
82
  return this.getStrategy().getSessionOrConfirm(address);
@@ -1,6 +1,6 @@
1
1
  import { TxResponse } from '@injectivelabs/sdk-ts';
2
2
  import { NetworkEndpoints } from '@injectivelabs/networks';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
4
4
  import { MsgBroadcasterOptions, MsgBroadcasterTxOptions } from './types.js';
5
5
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
6
6
  /**
@@ -18,7 +18,7 @@ export declare class MsgBroadcaster {
18
18
  txTimeout: number;
19
19
  simulateTx: boolean;
20
20
  txTimeoutOnFeeDelegation: boolean;
21
- evmChainId?: EvmChainId;
21
+ ethereumChainId?: EthereumChainId;
22
22
  gasBufferCoefficient: number;
23
23
  retriesOnError: {
24
24
  "sdk-20": {
@@ -30,7 +30,7 @@ export declare class MsgBroadcaster {
30
30
  httpHeaders?: Record<string, string>;
31
31
  constructor(options: MsgBroadcasterOptions);
32
32
  setOptions(options: Partial<MsgBroadcasterOptions>): void;
33
- getEvmChainId(): Promise<EvmChainId | undefined>;
33
+ getEvmChainId(): Promise<EthereumChainId | undefined>;
34
34
  /**
35
35
  * Broadcasting the transaction using the client
36
36
  * side approach for both cosmos and ethereum native wallets
@@ -2,7 +2,7 @@ import { TxGrpcApi, hexToBuff, PublicKey, SIGN_DIRECT, hexToBase64, ofacWallets,
2
2
  import { sleep, getStdFee, BigNumberInBase, DEFAULT_GAS_PRICE, DEFAULT_BLOCK_TIMEOUT_HEIGHT, } from '@injectivelabs/utils';
3
3
  import { WalletException, GeneralException, isThrownException, UnspecifiedErrorCode, ChainCosmosErrorCode, TransactionException, TransactionChainErrorModule, } from '@injectivelabs/exceptions';
4
4
  import { isTestnet, isMainnet, getNetworkInfo, getNetworkEndpoints, } from '@injectivelabs/networks';
5
- import { EvmChainId } from '@injectivelabs/ts-types';
5
+ import { EthereumChainId } from '@injectivelabs/ts-types';
6
6
  import { WalletStrategyEmitterEventType, } from './types.js';
7
7
  import { checkIfTxRunOutOfGas } from '../utils/index.js';
8
8
  import { Wallet, isCosmosWallet, WalletDeviceType, isEvmBrowserWallet, isEip712V2OnlyWallet, createEip712StdSignDoc, isCosmosAminoOnlyWallet, getEthereumSignerAddress, getInjectiveSignerAddress, } from '@injectivelabs/wallet-base';
@@ -34,7 +34,7 @@ export class MsgBroadcaster {
34
34
  txTimeout = DEFAULT_BLOCK_TIMEOUT_HEIGHT;
35
35
  simulateTx = true;
36
36
  txTimeoutOnFeeDelegation = false;
37
- evmChainId;
37
+ ethereumChainId;
38
38
  gasBufferCoefficient = 1.2;
39
39
  retriesOnError = defaultRetriesConfig();
40
40
  httpHeaders;
@@ -50,7 +50,8 @@ export class MsgBroadcaster {
50
50
  : true;
51
51
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
52
52
  this.chainId = options.chainId || networkInfo.chainId;
53
- this.evmChainId = options.evmChainId || networkInfo.evmChainId;
53
+ this.ethereumChainId =
54
+ options.ethereumChainId || networkInfo.ethereumChainId;
54
55
  this.endpoints = options.endpoints || getNetworkEndpoints(options.network);
55
56
  this.walletStrategy = options.walletStrategy;
56
57
  this.httpHeaders = options.httpHeaders;
@@ -64,19 +65,19 @@ export class MsgBroadcaster {
64
65
  async getEvmChainId() {
65
66
  const { walletStrategy } = this;
66
67
  if (!isEvmBrowserWallet(walletStrategy.wallet)) {
67
- return this.evmChainId;
68
+ return this.ethereumChainId;
68
69
  }
69
- const mainnetEvmIds = [EvmChainId.Mainnet, EvmChainId.MainnetEvm];
70
- const testnetEvmIds = [EvmChainId.Sepolia, EvmChainId.TestnetEvm];
71
- const devnetEvmIds = [EvmChainId.Sepolia, EvmChainId.DevnetEvm];
70
+ const mainnetEvmIds = [EthereumChainId.Mainnet, EthereumChainId.MainnetEvm];
71
+ const testnetEvmIds = [EthereumChainId.Sepolia, EthereumChainId.TestnetEvm];
72
+ const devnetEvmIds = [EthereumChainId.Sepolia, EthereumChainId.DevnetEvm];
72
73
  try {
73
74
  const chainId = await walletStrategy.getEthereumChainId();
74
75
  if (!chainId) {
75
- return this.evmChainId;
76
+ return this.ethereumChainId;
76
77
  }
77
78
  const evmChainId = parseInt(chainId, 16);
78
79
  if (isNaN(evmChainId)) {
79
- return this.evmChainId;
80
+ return this.ethereumChainId;
80
81
  }
81
82
  if ((isMainnet(this.options.network) &&
82
83
  !mainnetEvmIds.includes(evmChainId)) ||
@@ -201,9 +202,9 @@ export class MsgBroadcaster {
201
202
  async broadcastEip712(tx) {
202
203
  const { chainId, txTimeout, endpoints, walletStrategy } = this;
203
204
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
204
- const evmChainId = await this.getEvmChainId();
205
- if (!evmChainId) {
206
- throw new GeneralException(new Error('Please provide evmChainId'));
205
+ const ethereumChainId = await this.getEvmChainId();
206
+ if (!ethereumChainId) {
207
+ throw new GeneralException(new Error('Please provide ethereumChainId'));
207
208
  }
208
209
  /** Account Details * */
209
210
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -245,7 +246,7 @@ export class MsgBroadcaster {
245
246
  timeoutHeight: timeoutHeight.toFixed(),
246
247
  chainId,
247
248
  },
248
- evmChainId,
249
+ ethereumChainId,
249
250
  });
250
251
  /** Signing on Ethereum */
251
252
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
@@ -267,7 +268,7 @@ export class MsgBroadcaster {
267
268
  chainId,
268
269
  });
269
270
  const web3Extension = createWeb3Extension({
270
- evmChainId,
271
+ ethereumChainId,
271
272
  });
272
273
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
273
274
  /** Append Signatures */
@@ -293,9 +294,9 @@ export class MsgBroadcaster {
293
294
  async broadcastEip712V2(tx) {
294
295
  const { chainId, endpoints, txTimeout, walletStrategy } = this;
295
296
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
296
- const evmChainId = await this.getEvmChainId();
297
- if (!evmChainId) {
298
- throw new GeneralException(new Error('Please provide evmChainId'));
297
+ const ethereumChainId = await this.getEvmChainId();
298
+ if (!ethereumChainId) {
299
+ throw new GeneralException(new Error('Please provide ethereumChainId'));
299
300
  }
300
301
  /** Account Details * */
301
302
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -338,7 +339,7 @@ export class MsgBroadcaster {
338
339
  timeoutHeight: timeoutHeight.toFixed(),
339
340
  chainId,
340
341
  },
341
- evmChainId,
342
+ ethereumChainId,
342
343
  });
343
344
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
344
345
  /** Signing on Ethereum */
@@ -361,7 +362,7 @@ export class MsgBroadcaster {
361
362
  chainId,
362
363
  });
363
364
  const web3Extension = createWeb3Extension({
364
- evmChainId,
365
+ ethereumChainId,
365
366
  });
366
367
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
367
368
  /** Append Signatures */
@@ -386,9 +387,9 @@ export class MsgBroadcaster {
386
387
  const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
387
388
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
388
389
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
389
- const evmChainId = await this.getEvmChainId();
390
- if (!evmChainId) {
391
- throw new GeneralException(new Error('Please provide evmChainId'));
390
+ const ethereumChainId = await this.getEvmChainId();
391
+ if (!ethereumChainId) {
392
+ throw new GeneralException(new Error('Please provide ethereumChainId'));
392
393
  }
393
394
  const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
394
395
  if (httpHeaders) {
@@ -408,7 +409,7 @@ export class MsgBroadcaster {
408
409
  memo: tx.memo,
409
410
  message: web3Msgs,
410
411
  address: tx.ethereumAddress,
411
- chainId: evmChainId,
412
+ chainId: ethereumChainId,
412
413
  gasLimit: getGasPriceBasedOnMessage(msgs),
413
414
  estimateGas: simulateTx,
414
415
  });
@@ -418,7 +419,7 @@ export class MsgBroadcaster {
418
419
  signature,
419
420
  message: web3Msgs,
420
421
  txResponse: prepareTxResponse,
421
- chainId: evmChainId,
422
+ chainId: ethereumChainId,
422
423
  });
423
424
  try {
424
425
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
@@ -545,7 +546,7 @@ export class MsgBroadcaster {
545
546
  * @param tx the transaction that needs to be broadcasted
546
547
  */
547
548
  async experimentalBroadcastWalletThroughLedger(tx) {
548
- const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
549
+ const { chainId, txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, } = this;
549
550
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
550
551
  /**
551
552
  * We can only use this method
@@ -558,8 +559,8 @@ export class MsgBroadcaster {
558
559
  throw new GeneralException(new Error(`This method can only be used when Ledger is connected through ${walletStrategy.getWallet()}`));
559
560
  }
560
561
  }
561
- if (!evmChainId) {
562
- throw new GeneralException(new Error('Please provide evmChainId'));
562
+ if (!ethereumChainId) {
563
+ throw new GeneralException(new Error('Please provide ethereumChainId'));
563
564
  }
564
565
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
565
566
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -577,7 +578,7 @@ export class MsgBroadcaster {
577
578
  sequence: baseAccount.sequence.toString(),
578
579
  accountNumber: baseAccount.accountNumber.toString(),
579
580
  },
580
- evmChainId,
581
+ ethereumChainId,
581
582
  });
582
583
  const aminoSignResponse = await cosmosWallet.signEIP712CosmosTx({
583
584
  eip712: eip712TypedData,
@@ -608,7 +609,7 @@ export class MsgBroadcaster {
608
609
  });
609
610
  /** Preparing the transaction for client broadcasting */
610
611
  const web3Extension = createWeb3Extension({
611
- evmChainId,
612
+ ethereumChainId,
612
613
  });
613
614
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
614
615
  if (simulateTx) {
@@ -1,5 +1,5 @@
1
+ import { EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { Network } from '@injectivelabs/networks';
2
- import { EvmChainId } from '@injectivelabs/ts-types';
3
3
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
4
4
  interface SendTransactionOptions {
5
5
  tx: {
@@ -11,7 +11,7 @@ interface SendTransactionOptions {
11
11
  data: any;
12
12
  };
13
13
  address: string;
14
- evmChainId?: EvmChainId;
14
+ ethereumChainId?: EthereumChainId;
15
15
  }
16
16
  /**
17
17
  * Preparing and broadcasting
@@ -19,10 +19,10 @@ interface SendTransactionOptions {
19
19
  */
20
20
  export declare class Web3Broadcaster {
21
21
  private walletStrategy;
22
- private evmChainId;
23
- constructor({ walletStrategy, evmChainId, }: {
22
+ private ethereumChainId;
23
+ constructor({ walletStrategy, ethereumChainId, }: {
24
24
  walletStrategy: BaseWalletStrategy;
25
- evmChainId: EvmChainId;
25
+ ethereumChainId: EthereumChainId;
26
26
  network: Network;
27
27
  });
28
28
  sendTransaction(args: SendTransactionOptions): Promise<string>;
@@ -5,18 +5,18 @@ import { Web3Exception } from '@injectivelabs/exceptions';
5
5
  */
6
6
  export class Web3Broadcaster {
7
7
  walletStrategy;
8
- evmChainId;
9
- constructor({ walletStrategy, evmChainId, }) {
10
- this.evmChainId = evmChainId;
8
+ ethereumChainId;
9
+ constructor({ walletStrategy, ethereumChainId, }) {
11
10
  this.walletStrategy = walletStrategy;
11
+ this.ethereumChainId = ethereumChainId;
12
12
  }
13
13
  async sendTransaction(args) {
14
- const { evmChainId, walletStrategy } = this;
14
+ const { walletStrategy, ethereumChainId } = this;
15
15
  try {
16
- const chainId = args.evmChainId || evmChainId;
16
+ const chainId = args.ethereumChainId || ethereumChainId;
17
17
  const txHash = await walletStrategy.sendEvmTransaction(args.tx, {
18
- evmChainId: chainId,
19
18
  address: args.address,
19
+ ethereumChainId: chainId,
20
20
  });
21
21
  await walletStrategy.getEvmTransactionReceipt(txHash, chainId);
22
22
  return txHash;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { Msgs } from '@injectivelabs/sdk-ts';
3
- import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EthereumChainId } from '@injectivelabs/ts-types';
4
4
  import { Network, NetworkEndpoints } from '@injectivelabs/networks';
5
5
  import BaseWalletStrategy from '../strategy/BaseWalletStrategy.js';
6
6
  export interface MsgBroadcasterTxOptions {
@@ -23,7 +23,7 @@ export interface MsgBroadcasterOptions {
23
23
  network: Network;
24
24
  endpoints?: NetworkEndpoints;
25
25
  chainId?: ChainId;
26
- evmChainId?: EvmChainId;
26
+ ethereumChainId?: EthereumChainId;
27
27
  feePayerPubKey?: string;
28
28
  simulateTx?: boolean;
29
29
  txTimeoutOnFeeDelegation?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
3
  import { Wallet, WalletDeviceType, type WalletMetadata, ConcreteStrategiesArg, SendTransactionOptions, ConcreteWalletStrategy, onAccountChangeCallback, onChainIdChangeCallback, WalletStrategyArguments, CosmosWalletAbstraction, WalletStrategy as WalletStrategyInterface } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
4
  import { StdSignDoc } from '@keplr-wallet/types';
5
5
  import { WalletStrategyEmitter } from '../broadcaster/types.js';
6
6
  export default class BaseWalletStrategy implements WalletStrategyInterface {
@@ -24,13 +24,13 @@ export default class BaseWalletStrategy implements WalletStrategyInterface {
24
24
  enable(args?: unknown): Promise<boolean>;
25
25
  enableAndGetAddresses(args?: unknown): Promise<AccountAddress[]>;
26
26
  getEthereumChainId(): Promise<string>;
27
- getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<void>;
27
+ getEvmTransactionReceipt(txHash: string, ethereumChainId?: EthereumChainId): Promise<void>;
28
28
  getSessionOrConfirm(address?: AccountAddress): Promise<string>;
29
29
  getWalletClient<T>(): Promise<T>;
30
30
  sendTransaction(tx: DirectSignResponse | TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
31
31
  sendEvmTransaction(tx: any, options: {
32
- evmChainId: EvmChainId;
33
32
  address: AccountAddress;
33
+ ethereumChainId: EthereumChainId;
34
34
  }): Promise<string>;
35
35
  signEip712TypedData(eip712TypedData: string, address: AccountAddress): Promise<string>;
36
36
  signAminoCosmosTransaction(transaction: {
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { Wallet, isEvmWallet, isCosmosWallet, } from '@injectivelabs/wallet-base';
3
2
  import { GeneralException, WalletException } from '@injectivelabs/exceptions';
3
+ import { Wallet, isEvmWallet, isCosmosWallet, } from '@injectivelabs/wallet-base';
4
4
  import { WalletStrategyEmitterEventType, } from '../broadcaster/types.js';
5
5
  const getInitialWallet = (args) => {
6
6
  if (args.wallet) {
@@ -8,12 +8,12 @@ const getInitialWallet = (args) => {
8
8
  }
9
9
  const keys = Object.keys(args.strategies || {});
10
10
  if (keys.length === 0) {
11
- return Wallet.Metamask;
11
+ throw new GeneralException(new Error('No strategies provided to BaseWalletStrategy'));
12
12
  }
13
- if (keys.includes(Wallet.Metamask) && args.evmOptions) {
13
+ if (keys.includes(Wallet.Metamask) && args.ethereumOptions) {
14
14
  return Wallet.Metamask;
15
15
  }
16
- if (keys.includes(Wallet.Keplr) && !args.evmOptions) {
16
+ if (keys.includes(Wallet.Keplr) && !args.ethereumOptions) {
17
17
  return Wallet.Keplr;
18
18
  }
19
19
  return keys[0];
@@ -43,10 +43,8 @@ export default class BaseWalletStrategy {
43
43
  }
44
44
  setWallet(wallet) {
45
45
  this.wallet = wallet;
46
- this.getStrategy();
47
46
  }
48
47
  setMetadata(metadata) {
49
- console.log('Setting metadata', metadata);
50
48
  this.metadata = metadata;
51
49
  this.getStrategy().setMetadata?.(metadata);
52
50
  }
@@ -75,8 +73,8 @@ export default class BaseWalletStrategy {
75
73
  getEthereumChainId() {
76
74
  return this.getStrategy().getEthereumChainId();
77
75
  }
78
- async getEvmTransactionReceipt(txHash, evmChainId) {
79
- return this.getStrategy().getEvmTransactionReceipt(txHash, evmChainId);
76
+ async getEvmTransactionReceipt(txHash, ethereumChainId) {
77
+ return this.getStrategy().getEvmTransactionReceipt(txHash, ethereumChainId);
80
78
  }
81
79
  async getSessionOrConfirm(address) {
82
80
  return this.getStrategy().getSessionOrConfirm(address);
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.6-alpha.0",
4
+ "version": "1.16.6",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -41,10 +41,10 @@
41
41
  }
42
42
  },
43
43
  "scripts": {
44
- "build": "pnpm build:cjs && pnpm build:esm && pnpm build:post",
44
+ "build": "yarn build:cjs && yarn build:esm && yarn build:post",
45
45
  "build:cjs": "tsc --build --force tsconfig.build.json",
46
46
  "build:esm": "tsc --build --force tsconfig.build.esm.json",
47
- "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && pnpm build:post",
47
+ "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post",
48
48
  "build:post": "shx cp ../../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../../etc/stub/package.esm.json.stub dist/esm/package.json",
49
49
  "clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
50
50
  "test": "jest",
@@ -56,17 +56,17 @@
56
56
  "start": "node dist/index.js"
57
57
  },
58
58
  "dependencies": {
59
- "@injectivelabs/exceptions": "1.16.6-alpha.0",
60
- "@injectivelabs/networks": "1.16.6-alpha.0",
61
- "@injectivelabs/sdk-ts": "1.16.6-alpha.0",
62
- "@injectivelabs/ts-types": "1.16.6-alpha.0",
63
- "@injectivelabs/utils": "1.16.6-alpha.0",
64
- "@injectivelabs/wallet-base": "1.16.6-alpha.0",
59
+ "@injectivelabs/exceptions": "^1.16.6",
60
+ "@injectivelabs/networks": "^1.16.6",
61
+ "@injectivelabs/sdk-ts": "^1.16.6",
62
+ "@injectivelabs/ts-types": "^1.16.6",
63
+ "@injectivelabs/utils": "^1.16.6",
64
+ "@injectivelabs/wallet-base": "^1.16.6",
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": "b2bd329705e0848283332658754771d45c09d4f7"
71
+ "gitHead": "41794b09a1047a01dbb1d0e0a473a2f26305752d"
72
72
  }