@injectivelabs/wallet-core 1.16.1-alpha.6 → 1.16.2-alpha.0

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
- yarn add @injectivelabs/wallet-core
16
+ pnpm 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, EthereumChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EvmChainId } 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
- ethereumChainId?: EthereumChainId;
21
+ evmChainId?: EvmChainId;
22
22
  gasBufferCoefficient: number;
23
23
  retriesOnError: {
24
24
  "sdk-20": {
@@ -36,7 +36,7 @@ class MsgBroadcaster {
36
36
  txTimeout = utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT;
37
37
  simulateTx = true;
38
38
  txTimeoutOnFeeDelegation = false;
39
- ethereumChainId;
39
+ evmChainId;
40
40
  gasBufferCoefficient = 1.2;
41
41
  retriesOnError = defaultRetriesConfig();
42
42
  httpHeaders;
@@ -52,8 +52,7 @@ class MsgBroadcaster {
52
52
  : true;
53
53
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
54
54
  this.chainId = options.chainId || networkInfo.chainId;
55
- this.ethereumChainId =
56
- options.ethereumChainId || networkInfo.ethereumChainId;
55
+ this.evmChainId = options.evmChainId || networkInfo.evmChainId;
57
56
  this.endpoints = options.endpoints || (0, networks_1.getNetworkEndpoints)(options.network);
58
57
  this.walletStrategy = options.walletStrategy;
59
58
  this.httpHeaders = options.httpHeaders;
@@ -170,10 +169,10 @@ class MsgBroadcaster {
170
169
  * @returns transaction hash
171
170
  */
172
171
  async broadcastEip712(tx) {
173
- const { chainId, txTimeout, endpoints, ethereumChainId, walletStrategy } = this;
172
+ const { chainId, txTimeout, endpoints, evmChainId, walletStrategy } = this;
174
173
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
175
- if (!ethereumChainId) {
176
- throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
174
+ if (!evmChainId) {
175
+ throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
177
176
  }
178
177
  /** Account Details * */
179
178
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -215,7 +214,7 @@ class MsgBroadcaster {
215
214
  timeoutHeight: timeoutHeight.toFixed(),
216
215
  chainId,
217
216
  },
218
- ethereumChainId,
217
+ evmChainId,
219
218
  });
220
219
  /** Signing on Ethereum */
221
220
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
@@ -237,7 +236,7 @@ class MsgBroadcaster {
237
236
  chainId,
238
237
  });
239
238
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
240
- ethereumChainId,
239
+ evmChainId,
241
240
  });
242
241
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
243
242
  /** Append Signatures */
@@ -261,10 +260,10 @@ class MsgBroadcaster {
261
260
  * @returns transaction hash
262
261
  */
263
262
  async broadcastEip712V2(tx) {
264
- const { chainId, endpoints, txTimeout, walletStrategy, ethereumChainId } = this;
263
+ const { chainId, endpoints, txTimeout, walletStrategy, evmChainId } = this;
265
264
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
266
- if (!ethereumChainId) {
267
- throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
265
+ if (!evmChainId) {
266
+ throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
268
267
  }
269
268
  /** Account Details * */
270
269
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -307,7 +306,7 @@ class MsgBroadcaster {
307
306
  timeoutHeight: timeoutHeight.toFixed(),
308
307
  chainId,
309
308
  },
310
- ethereumChainId,
309
+ evmChainId,
311
310
  });
312
311
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionPreparationEnd);
313
312
  /** Signing on Ethereum */
@@ -330,7 +329,7 @@ class MsgBroadcaster {
330
329
  chainId,
331
330
  });
332
331
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
333
- ethereumChainId,
332
+ evmChainId,
334
333
  });
335
334
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
336
335
  /** Append Signatures */
@@ -352,11 +351,11 @@ class MsgBroadcaster {
352
351
  * @returns transaction hash
353
352
  */
354
353
  async broadcastEip712WithFeeDelegation(tx) {
355
- const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
354
+ const { txTimeout, endpoints, evmChainId, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
356
355
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
357
356
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
358
- if (!ethereumChainId) {
359
- throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
357
+ if (!evmChainId) {
358
+ throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
360
359
  }
361
360
  const transactionApi = new sdk_ts_1.IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
362
361
  if (httpHeaders) {
@@ -376,7 +375,7 @@ class MsgBroadcaster {
376
375
  memo: tx.memo,
377
376
  message: web3Msgs,
378
377
  address: tx.ethereumAddress,
379
- chainId: ethereumChainId,
378
+ chainId: evmChainId,
380
379
  gasLimit: (0, sdk_ts_1.getGasPriceBasedOnMessage)(msgs),
381
380
  estimateGas: simulateTx,
382
381
  });
@@ -386,7 +385,7 @@ class MsgBroadcaster {
386
385
  signature,
387
386
  message: web3Msgs,
388
387
  txResponse: prepareTxResponse,
389
- chainId: ethereumChainId,
388
+ chainId: evmChainId,
390
389
  });
391
390
  try {
392
391
  walletStrategy.emit(types_js_1.WalletStrategyEmitterEventType.TransactionBroadcastStart);
@@ -513,7 +512,7 @@ class MsgBroadcaster {
513
512
  * @param tx the transaction that needs to be broadcasted
514
513
  */
515
514
  async experimentalBroadcastWalletThroughLedger(tx) {
516
- const { chainId, txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, } = this;
515
+ const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
517
516
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
518
517
  /**
519
518
  * We can only use this method
@@ -526,8 +525,8 @@ class MsgBroadcaster {
526
525
  throw new exceptions_1.GeneralException(new Error(`This method can only be used when Ledger is connected through ${walletStrategy.getWallet()}`));
527
526
  }
528
527
  }
529
- if (!ethereumChainId) {
530
- throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
528
+ if (!evmChainId) {
529
+ throw new exceptions_1.GeneralException(new Error('Please provide evmChainId'));
531
530
  }
532
531
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
533
532
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -545,7 +544,7 @@ class MsgBroadcaster {
545
544
  sequence: baseAccount.sequence.toString(),
546
545
  accountNumber: baseAccount.accountNumber.toString(),
547
546
  },
548
- ethereumChainId,
547
+ evmChainId,
549
548
  });
550
549
  const aminoSignResponse = await cosmosWallet.signEIP712CosmosTx({
551
550
  eip712: eip712TypedData,
@@ -576,7 +575,7 @@ class MsgBroadcaster {
576
575
  });
577
576
  /** Preparing the transaction for client broadcasting */
578
577
  const web3Extension = (0, sdk_ts_1.createWeb3Extension)({
579
- ethereumChainId,
578
+ evmChainId,
580
579
  });
581
580
  const txRawEip712 = (0, sdk_ts_1.createTxRawEIP712)(txRaw, web3Extension);
582
581
  if (simulateTx) {
@@ -1,5 +1,5 @@
1
- import { EthereumChainId } from '@injectivelabs/ts-types';
2
1
  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
- ethereumChainId?: EthereumChainId;
14
+ evmChainId?: EvmChainId;
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 ethereumChainId;
23
- constructor({ walletStrategy, ethereumChainId, }: {
22
+ private evmChainId;
23
+ constructor({ walletStrategy, evmChainId, }: {
24
24
  walletStrategy: BaseWalletStrategy;
25
- ethereumChainId: EthereumChainId;
25
+ evmChainId: EvmChainId;
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
- ethereumChainId;
12
- constructor({ walletStrategy, ethereumChainId, }) {
11
+ evmChainId;
12
+ constructor({ walletStrategy, evmChainId, }) {
13
+ this.evmChainId = evmChainId;
13
14
  this.walletStrategy = walletStrategy;
14
- this.ethereumChainId = ethereumChainId;
15
15
  }
16
16
  async sendTransaction(args) {
17
- const { walletStrategy, ethereumChainId } = this;
17
+ const { evmChainId, walletStrategy } = this;
18
18
  try {
19
- const chainId = args.ethereumChainId || ethereumChainId;
19
+ const chainId = args.evmChainId || evmChainId;
20
20
  const txHash = await walletStrategy.sendEvmTransaction(args.tx, {
21
+ evmChainId: chainId,
21
22
  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, EthereumChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EvmChainId } 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
- ethereumChainId?: EthereumChainId;
26
+ evmChainId?: EvmChainId;
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';
3
2
  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, ethereumChainId?: EthereumChainId): Promise<void>;
27
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): 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;
32
33
  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 exceptions_1 = require("@injectivelabs/exceptions");
5
4
  const wallet_base_1 = require("@injectivelabs/wallet-base");
5
+ const exceptions_1 = require("@injectivelabs/exceptions");
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
- throw new exceptions_1.GeneralException(new Error('No strategies provided to BaseWalletStrategy'));
13
+ return wallet_base_1.Wallet.Metamask;
14
14
  }
15
- if (keys.includes(wallet_base_1.Wallet.Metamask) && args.ethereumOptions) {
15
+ if (keys.includes(wallet_base_1.Wallet.Metamask) && args.evmOptions) {
16
16
  return wallet_base_1.Wallet.Metamask;
17
17
  }
18
- if (keys.includes(wallet_base_1.Wallet.Keplr) && !args.ethereumOptions) {
18
+ if (keys.includes(wallet_base_1.Wallet.Keplr) && !args.evmOptions) {
19
19
  return wallet_base_1.Wallet.Keplr;
20
20
  }
21
21
  return keys[0];
@@ -45,8 +45,10 @@ class BaseWalletStrategy {
45
45
  }
46
46
  setWallet(wallet) {
47
47
  this.wallet = wallet;
48
+ this.getStrategy();
48
49
  }
49
50
  setMetadata(metadata) {
51
+ console.log('Setting metadata', metadata);
50
52
  this.metadata = metadata;
51
53
  this.getStrategy().setMetadata?.(metadata);
52
54
  }
@@ -75,8 +77,8 @@ class BaseWalletStrategy {
75
77
  getEthereumChainId() {
76
78
  return this.getStrategy().getEthereumChainId();
77
79
  }
78
- async getEvmTransactionReceipt(txHash, ethereumChainId) {
79
- return this.getStrategy().getEvmTransactionReceipt(txHash, ethereumChainId);
80
+ async getEvmTransactionReceipt(txHash, evmChainId) {
81
+ return this.getStrategy().getEvmTransactionReceipt(txHash, evmChainId);
80
82
  }
81
83
  async getSessionOrConfirm(address) {
82
84
  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, EthereumChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EvmChainId } 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
- ethereumChainId?: EthereumChainId;
21
+ evmChainId?: EvmChainId;
22
22
  gasBufferCoefficient: number;
23
23
  retriesOnError: {
24
24
  "sdk-20": {
@@ -33,7 +33,7 @@ export class MsgBroadcaster {
33
33
  txTimeout = DEFAULT_BLOCK_TIMEOUT_HEIGHT;
34
34
  simulateTx = true;
35
35
  txTimeoutOnFeeDelegation = false;
36
- ethereumChainId;
36
+ evmChainId;
37
37
  gasBufferCoefficient = 1.2;
38
38
  retriesOnError = defaultRetriesConfig();
39
39
  httpHeaders;
@@ -49,8 +49,7 @@ export class MsgBroadcaster {
49
49
  : true;
50
50
  this.gasBufferCoefficient = options.gasBufferCoefficient || 1.2;
51
51
  this.chainId = options.chainId || networkInfo.chainId;
52
- this.ethereumChainId =
53
- options.ethereumChainId || networkInfo.ethereumChainId;
52
+ this.evmChainId = options.evmChainId || networkInfo.evmChainId;
54
53
  this.endpoints = options.endpoints || getNetworkEndpoints(options.network);
55
54
  this.walletStrategy = options.walletStrategy;
56
55
  this.httpHeaders = options.httpHeaders;
@@ -167,10 +166,10 @@ export class MsgBroadcaster {
167
166
  * @returns transaction hash
168
167
  */
169
168
  async broadcastEip712(tx) {
170
- const { chainId, txTimeout, endpoints, ethereumChainId, walletStrategy } = this;
169
+ const { chainId, txTimeout, endpoints, evmChainId, walletStrategy } = this;
171
170
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
172
- if (!ethereumChainId) {
173
- throw new GeneralException(new Error('Please provide ethereumChainId'));
171
+ if (!evmChainId) {
172
+ throw new GeneralException(new Error('Please provide evmChainId'));
174
173
  }
175
174
  /** Account Details * */
176
175
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -212,7 +211,7 @@ export class MsgBroadcaster {
212
211
  timeoutHeight: timeoutHeight.toFixed(),
213
212
  chainId,
214
213
  },
215
- ethereumChainId,
214
+ evmChainId,
216
215
  });
217
216
  /** Signing on Ethereum */
218
217
  const signature = await walletStrategy.signEip712TypedData(JSON.stringify(eip712TypedData), tx.ethereumAddress);
@@ -234,7 +233,7 @@ export class MsgBroadcaster {
234
233
  chainId,
235
234
  });
236
235
  const web3Extension = createWeb3Extension({
237
- ethereumChainId,
236
+ evmChainId,
238
237
  });
239
238
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
240
239
  /** Append Signatures */
@@ -258,10 +257,10 @@ export class MsgBroadcaster {
258
257
  * @returns transaction hash
259
258
  */
260
259
  async broadcastEip712V2(tx) {
261
- const { chainId, endpoints, txTimeout, walletStrategy, ethereumChainId } = this;
260
+ const { chainId, endpoints, txTimeout, walletStrategy, evmChainId } = this;
262
261
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
263
- if (!ethereumChainId) {
264
- throw new GeneralException(new Error('Please provide ethereumChainId'));
262
+ if (!evmChainId) {
263
+ throw new GeneralException(new Error('Please provide evmChainId'));
265
264
  }
266
265
  /** Account Details * */
267
266
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -304,7 +303,7 @@ export class MsgBroadcaster {
304
303
  timeoutHeight: timeoutHeight.toFixed(),
305
304
  chainId,
306
305
  },
307
- ethereumChainId,
306
+ evmChainId,
308
307
  });
309
308
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionPreparationEnd);
310
309
  /** Signing on Ethereum */
@@ -327,7 +326,7 @@ export class MsgBroadcaster {
327
326
  chainId,
328
327
  });
329
328
  const web3Extension = createWeb3Extension({
330
- ethereumChainId,
329
+ evmChainId,
331
330
  });
332
331
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
333
332
  /** Append Signatures */
@@ -349,11 +348,11 @@ export class MsgBroadcaster {
349
348
  * @returns transaction hash
350
349
  */
351
350
  async broadcastEip712WithFeeDelegation(tx) {
352
- const { txTimeout, endpoints, simulateTx, httpHeaders, walletStrategy, ethereumChainId, txTimeoutOnFeeDelegation, } = this;
351
+ const { txTimeout, endpoints, evmChainId, simulateTx, httpHeaders, walletStrategy, txTimeoutOnFeeDelegation, } = this;
353
352
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
354
353
  const web3Msgs = msgs.map((msg) => msg.toWeb3());
355
- if (!ethereumChainId) {
356
- throw new GeneralException(new Error('Please provide ethereumChainId'));
354
+ if (!evmChainId) {
355
+ throw new GeneralException(new Error('Please provide evmChainId'));
357
356
  }
358
357
  const transactionApi = new IndexerGrpcWeb3GwApi(endpoints.web3gw || endpoints.indexer);
359
358
  if (httpHeaders) {
@@ -373,7 +372,7 @@ export class MsgBroadcaster {
373
372
  memo: tx.memo,
374
373
  message: web3Msgs,
375
374
  address: tx.ethereumAddress,
376
- chainId: ethereumChainId,
375
+ chainId: evmChainId,
377
376
  gasLimit: getGasPriceBasedOnMessage(msgs),
378
377
  estimateGas: simulateTx,
379
378
  });
@@ -383,7 +382,7 @@ export class MsgBroadcaster {
383
382
  signature,
384
383
  message: web3Msgs,
385
384
  txResponse: prepareTxResponse,
386
- chainId: ethereumChainId,
385
+ chainId: evmChainId,
387
386
  });
388
387
  try {
389
388
  walletStrategy.emit(WalletStrategyEmitterEventType.TransactionBroadcastStart);
@@ -510,7 +509,7 @@ export class MsgBroadcaster {
510
509
  * @param tx the transaction that needs to be broadcasted
511
510
  */
512
511
  async experimentalBroadcastWalletThroughLedger(tx) {
513
- const { chainId, txTimeout, endpoints, simulateTx, walletStrategy, ethereumChainId, } = this;
512
+ const { chainId, txTimeout, endpoints, evmChainId, simulateTx, walletStrategy, } = this;
514
513
  const msgs = Array.isArray(tx.msgs) ? tx.msgs : [tx.msgs];
515
514
  /**
516
515
  * We can only use this method
@@ -523,8 +522,8 @@ export class MsgBroadcaster {
523
522
  throw new GeneralException(new Error(`This method can only be used when Ledger is connected through ${walletStrategy.getWallet()}`));
524
523
  }
525
524
  }
526
- if (!ethereumChainId) {
527
- throw new GeneralException(new Error('Please provide ethereumChainId'));
525
+ if (!evmChainId) {
526
+ throw new GeneralException(new Error('Please provide evmChainId'));
528
527
  }
529
528
  const cosmosWallet = walletStrategy.getCosmosWallet(chainId);
530
529
  const { baseAccount, latestHeight } = await this.fetchAccountAndBlockDetails(tx.injectiveAddress);
@@ -542,7 +541,7 @@ export class MsgBroadcaster {
542
541
  sequence: baseAccount.sequence.toString(),
543
542
  accountNumber: baseAccount.accountNumber.toString(),
544
543
  },
545
- ethereumChainId,
544
+ evmChainId,
546
545
  });
547
546
  const aminoSignResponse = await cosmosWallet.signEIP712CosmosTx({
548
547
  eip712: eip712TypedData,
@@ -573,7 +572,7 @@ export class MsgBroadcaster {
573
572
  });
574
573
  /** Preparing the transaction for client broadcasting */
575
574
  const web3Extension = createWeb3Extension({
576
- ethereumChainId,
575
+ evmChainId,
577
576
  });
578
577
  const txRawEip712 = createTxRawEIP712(txRaw, web3Extension);
579
578
  if (simulateTx) {
@@ -1,5 +1,5 @@
1
- import { EthereumChainId } from '@injectivelabs/ts-types';
2
1
  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
- ethereumChainId?: EthereumChainId;
14
+ evmChainId?: EvmChainId;
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 ethereumChainId;
23
- constructor({ walletStrategy, ethereumChainId, }: {
22
+ private evmChainId;
23
+ constructor({ walletStrategy, evmChainId, }: {
24
24
  walletStrategy: BaseWalletStrategy;
25
- ethereumChainId: EthereumChainId;
25
+ evmChainId: EvmChainId;
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
- ethereumChainId;
9
- constructor({ walletStrategy, ethereumChainId, }) {
8
+ evmChainId;
9
+ constructor({ walletStrategy, evmChainId, }) {
10
+ this.evmChainId = evmChainId;
10
11
  this.walletStrategy = walletStrategy;
11
- this.ethereumChainId = ethereumChainId;
12
12
  }
13
13
  async sendTransaction(args) {
14
- const { walletStrategy, ethereumChainId } = this;
14
+ const { evmChainId, walletStrategy } = this;
15
15
  try {
16
- const chainId = args.ethereumChainId || ethereumChainId;
16
+ const chainId = args.evmChainId || evmChainId;
17
17
  const txHash = await walletStrategy.sendEvmTransaction(args.tx, {
18
+ evmChainId: chainId,
18
19
  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, EthereumChainId } from '@injectivelabs/ts-types';
3
+ import { ChainId, EvmChainId } 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
- ethereumChainId?: EthereumChainId;
26
+ evmChainId?: EvmChainId;
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';
3
2
  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, ethereumChainId?: EthereumChainId): Promise<void>;
27
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): 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;
32
33
  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 { GeneralException, WalletException } from '@injectivelabs/exceptions';
3
2
  import { Wallet, isEvmWallet, isCosmosWallet, } from '@injectivelabs/wallet-base';
3
+ import { GeneralException, WalletException } from '@injectivelabs/exceptions';
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
- throw new GeneralException(new Error('No strategies provided to BaseWalletStrategy'));
11
+ return Wallet.Metamask;
12
12
  }
13
- if (keys.includes(Wallet.Metamask) && args.ethereumOptions) {
13
+ if (keys.includes(Wallet.Metamask) && args.evmOptions) {
14
14
  return Wallet.Metamask;
15
15
  }
16
- if (keys.includes(Wallet.Keplr) && !args.ethereumOptions) {
16
+ if (keys.includes(Wallet.Keplr) && !args.evmOptions) {
17
17
  return Wallet.Keplr;
18
18
  }
19
19
  return keys[0];
@@ -43,8 +43,10 @@ export default class BaseWalletStrategy {
43
43
  }
44
44
  setWallet(wallet) {
45
45
  this.wallet = wallet;
46
+ this.getStrategy();
46
47
  }
47
48
  setMetadata(metadata) {
49
+ console.log('Setting metadata', metadata);
48
50
  this.metadata = metadata;
49
51
  this.getStrategy().setMetadata?.(metadata);
50
52
  }
@@ -73,8 +75,8 @@ export default class BaseWalletStrategy {
73
75
  getEthereumChainId() {
74
76
  return this.getStrategy().getEthereumChainId();
75
77
  }
76
- async getEvmTransactionReceipt(txHash, ethereumChainId) {
77
- return this.getStrategy().getEvmTransactionReceipt(txHash, ethereumChainId);
78
+ async getEvmTransactionReceipt(txHash, evmChainId) {
79
+ return this.getStrategy().getEvmTransactionReceipt(txHash, evmChainId);
78
80
  }
79
81
  async getSessionOrConfirm(address) {
80
82
  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.1-alpha.6",
4
+ "version": "1.16.2-alpha.0",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -41,10 +41,10 @@
41
41
  }
42
42
  },
43
43
  "scripts": {
44
- "build": "yarn build:cjs && yarn build:esm && yarn build:post",
44
+ "build": "pnpm build:cjs && pnpm build:esm && pnpm 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 && yarn build:post",
47
+ "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && pnpm 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.1-alpha.6",
60
- "@injectivelabs/networks": "^1.16.1-alpha.6",
61
- "@injectivelabs/sdk-ts": "^1.16.1-alpha.6",
62
- "@injectivelabs/ts-types": "^1.16.1-alpha.6",
63
- "@injectivelabs/utils": "^1.16.1-alpha.6",
64
- "@injectivelabs/wallet-base": "^1.16.1-alpha.6",
59
+ "@injectivelabs/exceptions": "1.16.2-alpha.0",
60
+ "@injectivelabs/networks": "1.16.2-alpha.0",
61
+ "@injectivelabs/sdk-ts": "1.16.2-alpha.0",
62
+ "@injectivelabs/ts-types": "1.16.2-alpha.0",
63
+ "@injectivelabs/utils": "1.16.2-alpha.0",
64
+ "@injectivelabs/wallet-base": "1.16.2-alpha.0",
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": "2e0a988a094d8284191b29502dde14f9696e7932"
71
+ "gitHead": "0377b0c3b44d79b598d08ca01930057dc05d9c7a"
72
72
  }