@injectivelabs/wallet-ledger 1.15.30 → 1.15.32

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.
@@ -16,7 +16,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
16
16
  disconnect(): Promise<void>;
17
17
  getAddresses(): Promise<string[]>;
18
18
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
19
- sendEthereumTransaction(txData: any, options: {
19
+ sendEvmTransaction(txData: any, args: {
20
20
  address: string;
21
21
  ethereumChainId: EthereumChainId;
22
22
  }): Promise<string>;
@@ -34,9 +34,9 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
34
34
  }): Promise<DirectSignResponse>;
35
35
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
36
36
  getEthereumChainId(): Promise<string>;
37
- getEthereumTransactionReceipt(txHash: string): Promise<string>;
37
+ getEvmTransactionReceipt(txHash: string): Promise<string>;
38
38
  getPubKey(): Promise<string>;
39
- private signEthereumTransaction;
39
+ private signEvmTransaction;
40
40
  private getWalletForAddress;
41
41
  private getAlchemy;
42
42
  }
@@ -67,10 +67,10 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
67
67
  async getSessionOrConfirm(address) {
68
68
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
69
69
  }
70
- async sendEthereumTransaction(txData, options) {
71
- const signedTransaction = await this.signEthereumTransaction(txData, options);
70
+ async sendEvmTransaction(txData, args) {
71
+ const signedTransaction = await this.signEvmTransaction(txData, args);
72
72
  try {
73
- const alchemy = await this.getAlchemy();
73
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
74
74
  const txReceipt = await alchemy.core.sendTransaction((0, ethereumjs_util_1.addHexPrefix)(signedTransaction.serialize().toString('hex')));
75
75
  return txReceipt.hash;
76
76
  }
@@ -78,7 +78,7 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
78
78
  throw new exceptions_1.LedgerException(new Error(e.message), {
79
79
  code: exceptions_1.UnspecifiedErrorCode,
80
80
  type: exceptions_1.ErrorType.WalletError,
81
- contextModule: wallet_base_1.WalletAction.SendEthereumTransaction,
81
+ contextModule: wallet_base_1.WalletAction.SendEvmTransaction,
82
82
  });
83
83
  }
84
84
  }
@@ -171,17 +171,17 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
171
171
  const alchemyProvider = await alchemy.config.getProvider();
172
172
  return alchemyProvider.network.chainId.toString();
173
173
  }
174
- async getEthereumTransactionReceipt(txHash) {
174
+ async getEvmTransactionReceipt(txHash) {
175
175
  return Promise.resolve(txHash);
176
176
  }
177
177
  // eslint-disable-next-line class-methods-use-this
178
178
  async getPubKey() {
179
179
  throw new exceptions_1.WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
180
180
  }
181
- async signEthereumTransaction(txData, options) {
182
- const alchemy = await this.getAlchemy();
183
- const chainId = parseInt(options.ethereumChainId.toString(), 10);
184
- const nonce = await alchemy.core.getTransactionCount(options.address);
181
+ async signEvmTransaction(txData, args) {
182
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
183
+ const chainId = parseInt(args.ethereumChainId.toString(), 10);
184
+ const nonce = await alchemy.core.getTransactionCount(args.address);
185
185
  const common = new common_1.Common({
186
186
  chain: getNetworkFromChainId(chainId),
187
187
  hardfork: common_1.Hardfork.London,
@@ -202,7 +202,7 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
202
202
  const encodedMessageHex = msg.toString('hex');
203
203
  try {
204
204
  const ledger = await this.ledger.getInstance();
205
- const { derivationPath } = await this.getWalletForAddress(options.address);
205
+ const { derivationPath } = await this.getWalletForAddress(args.address);
206
206
  const resolution = await ledgerhq_hw_app_eth_1.ledgerService.resolveTransaction(encodedMessageHex, {}, {});
207
207
  const txSig = await ledger.signTransaction(derivationPath, encodedMessageHex, resolution);
208
208
  const signedTxData = {
@@ -219,7 +219,7 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
219
219
  throw new exceptions_1.LedgerException(new Error(e.message), {
220
220
  code: exceptions_1.UnspecifiedErrorCode,
221
221
  type: exceptions_1.ErrorType.WalletError,
222
- contextModule: wallet_base_1.WalletAction.SignEthereumTransaction,
222
+ contextModule: wallet_base_1.WalletAction.SignEvmTransaction,
223
223
  });
224
224
  }
225
225
  }
@@ -245,17 +245,19 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
245
245
  });
246
246
  }
247
247
  }
248
- async getAlchemy() {
248
+ async getAlchemy(ethereumChainId) {
249
249
  if (this.alchemy) {
250
250
  return this.alchemy;
251
251
  }
252
- const { rpcUrl, ethereumChainId } = this.ethereumOptions;
253
- if (!rpcUrl) {
252
+ const options = this.ethereumOptions;
253
+ const chainId = ethereumChainId || options.ethereumChainId;
254
+ const url = options.rpcUrl || options.rpcUrls?.[chainId];
255
+ if (!url) {
254
256
  throw new exceptions_1.GeneralException(new Error('Please pass rpcUrl within the ethereumOptions'));
255
257
  }
256
258
  this.alchemy = new alchemy_sdk_1.Alchemy({
257
- apiKey: (0, wallet_base_1.getKeyFromRpcUrl)(rpcUrl),
258
- network: ethereumChainId === ts_types_1.EthereumChainId.Mainnet
259
+ apiKey: (0, wallet_base_1.getKeyFromRpcUrl)(url),
260
+ network: chainId === ts_types_1.EthereumChainId.Mainnet
259
261
  ? alchemy_sdk_1.Network.ETH_MAINNET
260
262
  : alchemy_sdk_1.Network.ETH_SEPOLIA,
261
263
  });
@@ -12,7 +12,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
12
12
  disconnect(): Promise<void>;
13
13
  getAddresses(): Promise<string[]>;
14
14
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
15
- sendEthereumTransaction(_txData: any, _options: {
15
+ sendEvmTransaction(_txData: any, _options: {
16
16
  address: string;
17
17
  ethereumChainId: EthereumChainId;
18
18
  }): Promise<string>;
@@ -30,7 +30,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
30
30
  signEip712TypedData(_eip712Json: string, _address: AccountAddress): Promise<string>;
31
31
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
32
32
  getEthereumChainId(): Promise<string>;
33
- getEthereumTransactionReceipt(_txHash: string): Promise<string>;
33
+ getEvmTransactionReceipt(_txHash: string): Promise<string>;
34
34
  getPubKey(address?: string): Promise<string>;
35
35
  private getWalletForAddress;
36
36
  }
@@ -44,10 +44,10 @@ class LedgerCosmos extends wallet_base_1.BaseConcreteStrategy {
44
44
  async getSessionOrConfirm(address) {
45
45
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
46
46
  }
47
- async sendEthereumTransaction(_txData, _options) {
48
- throw new exceptions_2.CosmosWalletException(new Error('sendEthereumTransaction is not supported. LedgerCosmos only supports sending cosmos transactions'), {
47
+ async sendEvmTransaction(_txData, _options) {
48
+ throw new exceptions_2.CosmosWalletException(new Error('sendEvmTransaction is not supported. LedgerCosmos only supports sending cosmos transactions'), {
49
49
  code: exceptions_1.UnspecifiedErrorCode,
50
- context: wallet_base_1.WalletAction.SendEthereumTransaction,
50
+ context: wallet_base_1.WalletAction.SendEvmTransaction,
51
51
  });
52
52
  }
53
53
  async sendTransaction(transaction, options) {
@@ -120,10 +120,10 @@ class LedgerCosmos extends wallet_base_1.BaseConcreteStrategy {
120
120
  context: wallet_base_1.WalletAction.GetChainId,
121
121
  });
122
122
  }
123
- async getEthereumTransactionReceipt(_txHash) {
124
- throw new exceptions_2.CosmosWalletException(new Error('getEthereumTransactionReceipt is not supported on Keplr'), {
123
+ async getEvmTransactionReceipt(_txHash) {
124
+ throw new exceptions_2.CosmosWalletException(new Error('getEvmTransactionReceipt is not supported on Keplr'), {
125
125
  code: exceptions_1.UnspecifiedErrorCode,
126
- context: wallet_base_1.WalletAction.GetEthereumTransactionReceipt,
126
+ context: wallet_base_1.WalletAction.GetEvmTransactionReceipt,
127
127
  });
128
128
  }
129
129
  async getPubKey(address) {
@@ -16,7 +16,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
16
16
  disconnect(): Promise<void>;
17
17
  getAddresses(): Promise<string[]>;
18
18
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
19
- sendEthereumTransaction(txData: any, options: {
19
+ sendEvmTransaction(txData: any, args: {
20
20
  address: string;
21
21
  ethereumChainId: EthereumChainId;
22
22
  }): Promise<string>;
@@ -34,9 +34,9 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
34
34
  }): Promise<DirectSignResponse>;
35
35
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
36
36
  getEthereumChainId(): Promise<string>;
37
- getEthereumTransactionReceipt(txHash: string): Promise<string>;
37
+ getEvmTransactionReceipt(txHash: string): Promise<string>;
38
38
  getPubKey(): Promise<string>;
39
- private signEthereumTransaction;
39
+ private signEvmTransaction;
40
40
  private getWalletForAddress;
41
41
  private getAlchemy;
42
42
  }
@@ -4,9 +4,9 @@ import { bufferToHex, addHexPrefix } from 'ethereumjs-util';
4
4
  import { Common, Chain, Hardfork } from '@ethereumjs/common';
5
5
  import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx';
6
6
  import { ledgerService } from '@bangjelkoski/ledgerhq-hw-app-eth';
7
- import { ErrorType, GeneralException, LedgerException, TransactionException, UnspecifiedErrorCode, WalletException, } from '@injectivelabs/exceptions';
7
+ import { ErrorType, LedgerException, WalletException, GeneralException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
8
8
  import { toUtf8, TxGrpcApi, } from '@injectivelabs/sdk-ts';
9
- import { TIP_IN_GWEI, WalletAction, WalletDeviceType, getKeyFromRpcUrl, BaseConcreteStrategy, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
9
+ import { TIP_IN_GWEI, WalletAction, getKeyFromRpcUrl, WalletDeviceType, BaseConcreteStrategy, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
10
10
  import LedgerHW from './hw/index.js';
11
11
  import { domainHash, messageHash } from './utils.js';
12
12
  import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
@@ -62,10 +62,10 @@ export default class LedgerBase extends BaseConcreteStrategy {
62
62
  async getSessionOrConfirm(address) {
63
63
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
64
64
  }
65
- async sendEthereumTransaction(txData, options) {
66
- const signedTransaction = await this.signEthereumTransaction(txData, options);
65
+ async sendEvmTransaction(txData, args) {
66
+ const signedTransaction = await this.signEvmTransaction(txData, args);
67
67
  try {
68
- const alchemy = await this.getAlchemy();
68
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
69
69
  const txReceipt = await alchemy.core.sendTransaction(addHexPrefix(signedTransaction.serialize().toString('hex')));
70
70
  return txReceipt.hash;
71
71
  }
@@ -73,7 +73,7 @@ export default class LedgerBase extends BaseConcreteStrategy {
73
73
  throw new LedgerException(new Error(e.message), {
74
74
  code: UnspecifiedErrorCode,
75
75
  type: ErrorType.WalletError,
76
- contextModule: WalletAction.SendEthereumTransaction,
76
+ contextModule: WalletAction.SendEvmTransaction,
77
77
  });
78
78
  }
79
79
  }
@@ -166,17 +166,17 @@ export default class LedgerBase extends BaseConcreteStrategy {
166
166
  const alchemyProvider = await alchemy.config.getProvider();
167
167
  return alchemyProvider.network.chainId.toString();
168
168
  }
169
- async getEthereumTransactionReceipt(txHash) {
169
+ async getEvmTransactionReceipt(txHash) {
170
170
  return Promise.resolve(txHash);
171
171
  }
172
172
  // eslint-disable-next-line class-methods-use-this
173
173
  async getPubKey() {
174
174
  throw new WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
175
175
  }
176
- async signEthereumTransaction(txData, options) {
177
- const alchemy = await this.getAlchemy();
178
- const chainId = parseInt(options.ethereumChainId.toString(), 10);
179
- const nonce = await alchemy.core.getTransactionCount(options.address);
176
+ async signEvmTransaction(txData, args) {
177
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
178
+ const chainId = parseInt(args.ethereumChainId.toString(), 10);
179
+ const nonce = await alchemy.core.getTransactionCount(args.address);
180
180
  const common = new Common({
181
181
  chain: getNetworkFromChainId(chainId),
182
182
  hardfork: Hardfork.London,
@@ -197,7 +197,7 @@ export default class LedgerBase extends BaseConcreteStrategy {
197
197
  const encodedMessageHex = msg.toString('hex');
198
198
  try {
199
199
  const ledger = await this.ledger.getInstance();
200
- const { derivationPath } = await this.getWalletForAddress(options.address);
200
+ const { derivationPath } = await this.getWalletForAddress(args.address);
201
201
  const resolution = await ledgerService.resolveTransaction(encodedMessageHex, {}, {});
202
202
  const txSig = await ledger.signTransaction(derivationPath, encodedMessageHex, resolution);
203
203
  const signedTxData = {
@@ -214,7 +214,7 @@ export default class LedgerBase extends BaseConcreteStrategy {
214
214
  throw new LedgerException(new Error(e.message), {
215
215
  code: UnspecifiedErrorCode,
216
216
  type: ErrorType.WalletError,
217
- contextModule: WalletAction.SignEthereumTransaction,
217
+ contextModule: WalletAction.SignEvmTransaction,
218
218
  });
219
219
  }
220
220
  }
@@ -240,17 +240,19 @@ export default class LedgerBase extends BaseConcreteStrategy {
240
240
  });
241
241
  }
242
242
  }
243
- async getAlchemy() {
243
+ async getAlchemy(ethereumChainId) {
244
244
  if (this.alchemy) {
245
245
  return this.alchemy;
246
246
  }
247
- const { rpcUrl, ethereumChainId } = this.ethereumOptions;
248
- if (!rpcUrl) {
247
+ const options = this.ethereumOptions;
248
+ const chainId = ethereumChainId || options.ethereumChainId;
249
+ const url = options.rpcUrl || options.rpcUrls?.[chainId];
250
+ if (!url) {
249
251
  throw new GeneralException(new Error('Please pass rpcUrl within the ethereumOptions'));
250
252
  }
251
253
  this.alchemy = new Alchemy({
252
- apiKey: getKeyFromRpcUrl(rpcUrl),
253
- network: ethereumChainId === EthereumChainId.Mainnet
254
+ apiKey: getKeyFromRpcUrl(url),
255
+ network: chainId === EthereumChainId.Mainnet
254
256
  ? AlchemyNetwork.ETH_MAINNET
255
257
  : AlchemyNetwork.ETH_SEPOLIA,
256
258
  });
@@ -12,7 +12,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
12
12
  disconnect(): Promise<void>;
13
13
  getAddresses(): Promise<string[]>;
14
14
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
15
- sendEthereumTransaction(_txData: any, _options: {
15
+ sendEvmTransaction(_txData: any, _options: {
16
16
  address: string;
17
17
  ethereumChainId: EthereumChainId;
18
18
  }): Promise<string>;
@@ -30,7 +30,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
30
30
  signEip712TypedData(_eip712Json: string, _address: AccountAddress): Promise<string>;
31
31
  signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
32
32
  getEthereumChainId(): Promise<string>;
33
- getEthereumTransactionReceipt(_txHash: string): Promise<string>;
33
+ getEvmTransactionReceipt(_txHash: string): Promise<string>;
34
34
  getPubKey(address?: string): Promise<string>;
35
35
  private getWalletForAddress;
36
36
  }
@@ -38,10 +38,10 @@ export class LedgerCosmos extends BaseConcreteStrategy {
38
38
  async getSessionOrConfirm(address) {
39
39
  return Promise.resolve(`0x${Buffer.from(`Confirmation for ${address} at time: ${Date.now()}`).toString('hex')}`);
40
40
  }
41
- async sendEthereumTransaction(_txData, _options) {
42
- throw new CosmosWalletException(new Error('sendEthereumTransaction is not supported. LedgerCosmos only supports sending cosmos transactions'), {
41
+ async sendEvmTransaction(_txData, _options) {
42
+ throw new CosmosWalletException(new Error('sendEvmTransaction is not supported. LedgerCosmos only supports sending cosmos transactions'), {
43
43
  code: UnspecifiedErrorCode,
44
- context: WalletAction.SendEthereumTransaction,
44
+ context: WalletAction.SendEvmTransaction,
45
45
  });
46
46
  }
47
47
  async sendTransaction(transaction, options) {
@@ -114,10 +114,10 @@ export class LedgerCosmos extends BaseConcreteStrategy {
114
114
  context: WalletAction.GetChainId,
115
115
  });
116
116
  }
117
- async getEthereumTransactionReceipt(_txHash) {
118
- throw new CosmosWalletException(new Error('getEthereumTransactionReceipt is not supported on Keplr'), {
117
+ async getEvmTransactionReceipt(_txHash) {
118
+ throw new CosmosWalletException(new Error('getEvmTransactionReceipt is not supported on Keplr'), {
119
119
  code: UnspecifiedErrorCode,
120
- context: WalletAction.GetEthereumTransactionReceipt,
120
+ context: WalletAction.GetEvmTransactionReceipt,
121
121
  });
122
122
  }
123
123
  async getPubKey(address) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-ledger",
3
3
  "description": "Ledger wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.15.30",
4
+ "version": "1.15.32",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "author": {
@@ -63,10 +63,10 @@
63
63
  "@bangjelkoski/ledgerhq-hw-transport-webusb": "6.29.4-beta.0",
64
64
  "@ethereumjs/common": "^3.1.1",
65
65
  "@ethereumjs/tx": "^4.1.1",
66
- "@injectivelabs/exceptions": "^1.15.27",
67
- "@injectivelabs/sdk-ts": "^1.15.30",
68
- "@injectivelabs/ts-types": "^1.15.28",
69
- "@injectivelabs/wallet-base": "^1.15.30",
66
+ "@injectivelabs/exceptions": "^1.15.29",
67
+ "@injectivelabs/sdk-ts": "^1.15.32",
68
+ "@injectivelabs/ts-types": "^1.15.30",
69
+ "@injectivelabs/wallet-base": "^1.15.32",
70
70
  "alchemy-sdk": "^3.4.7",
71
71
  "eth-sig-util": "^3.0.1",
72
72
  "ethereumjs-util": "^7.1.0",
@@ -78,5 +78,5 @@
78
78
  "@types/hdkey": "^2.0.1",
79
79
  "@types/ledgerhq__hw-transport-webusb": "^4.70.1"
80
80
  },
81
- "gitHead": "2c2a365b27e08ad2e0eb06efe3c490c88888fee4"
81
+ "gitHead": "e8fa12c489c4b3432579c5df30fd6f939d57b442"
82
82
  }