@injectivelabs/wallet-ledger 1.16.2-alpha.0 → 1.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +19 -18
  2. package/dist/cjs/index.d.ts +1 -1
  3. package/dist/cjs/index.js +3 -3
  4. package/dist/cjs/strategy/Ledger/Base.d.ts +5 -5
  5. package/dist/cjs/strategy/Ledger/Base.js +20 -21
  6. package/dist/cjs/strategy/Ledger/LedgerLegacy.d.ts +2 -2
  7. package/dist/cjs/strategy/Ledger/LedgerLegacy.js +1 -1
  8. package/dist/cjs/strategy/Ledger/LedgerLive.d.ts +2 -2
  9. package/dist/cjs/strategy/Ledger/LedgerLive.js +1 -1
  10. package/dist/cjs/strategy/Ledger/hw/AccountManager.d.ts +1 -1
  11. package/dist/cjs/strategy/Ledger/hw/AccountManager.js +2 -2
  12. package/dist/cjs/strategy/Ledger/hw/index.d.ts +2 -2
  13. package/dist/cjs/strategy/Ledger/hw/index.js +13 -14
  14. package/dist/cjs/strategy/LedgerCosmos/hw/AccountManager.d.ts +1 -1
  15. package/dist/cjs/strategy/LedgerCosmos/hw/index.d.ts +2 -2
  16. package/dist/cjs/strategy/LedgerCosmos/hw/index.js +9 -10
  17. package/dist/cjs/strategy/LedgerCosmos/index.d.ts +2 -2
  18. package/dist/cjs/strategy/LedgerCosmos/index.js +2 -3
  19. package/dist/esm/index.d.ts +1 -1
  20. package/dist/esm/index.js +1 -1
  21. package/dist/esm/strategy/Ledger/Base.d.ts +5 -5
  22. package/dist/esm/strategy/Ledger/Base.js +19 -20
  23. package/dist/esm/strategy/Ledger/LedgerLegacy.d.ts +2 -2
  24. package/dist/esm/strategy/Ledger/LedgerLegacy.js +1 -1
  25. package/dist/esm/strategy/Ledger/LedgerLive.d.ts +2 -2
  26. package/dist/esm/strategy/Ledger/LedgerLive.js +1 -1
  27. package/dist/esm/strategy/Ledger/hw/AccountManager.d.ts +1 -1
  28. package/dist/esm/strategy/Ledger/hw/AccountManager.js +2 -2
  29. package/dist/esm/strategy/Ledger/hw/index.d.ts +2 -2
  30. package/dist/esm/strategy/Ledger/hw/index.js +3 -4
  31. package/dist/esm/strategy/LedgerCosmos/hw/AccountManager.d.ts +1 -1
  32. package/dist/esm/strategy/LedgerCosmos/hw/index.d.ts +2 -2
  33. package/dist/esm/strategy/LedgerCosmos/hw/index.js +3 -4
  34. package/dist/esm/strategy/LedgerCosmos/index.d.ts +2 -2
  35. package/dist/esm/strategy/LedgerCosmos/index.js +4 -5
  36. package/package.json +9 -10
  37. package/dist/cjs/strategy/lib.d.ts +0 -14
  38. package/dist/cjs/strategy/lib.js +0 -86
  39. package/dist/esm/strategy/lib.d.ts +0 -14
  40. package/dist/esm/strategy/lib.js +0 -46
package/README.md CHANGED
@@ -13,7 +13,7 @@ _Package to use Ledger Wallets on Injective via the wallet strategy._
13
13
  ## 📚 Installation
14
14
 
15
15
  ```bash
16
- pnpm add @injectivelabs/wallet-ledger
16
+ yarn add @injectivelabs/wallet-ledger
17
17
  ```
18
18
 
19
19
  ---
@@ -30,9 +30,10 @@ dependencies and implementations for their specific wallets.
30
30
  Here's a brief example of how to use this package to send 1 INJ.:
31
31
 
32
32
  ```typescript
33
- import { Wallet } from '@injectivelabs/wallet-base'
34
- import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core'
35
- import { LedgerLive } from '@injectivelabs/wallet-ledger'
33
+ import { Wallet } from '@injectivelabs/wallet-base';
34
+ import { BaseWalletStrategy, MsgBroadcaster } from '@injectivelabs/wallet-core';
35
+ import { LedgerLive } from '@injectivelabs/wallet-ledger';
36
+
36
37
 
37
38
  const strategyArgs: WalletStrategyArguments = {
38
39
  chainId: ChainId.Mainnet,
@@ -55,21 +56,21 @@ const msgBroadcaster = new MsgBroadcaster({
55
56
  })
56
57
 
57
58
  const sendTX = async () => {
58
- const injectiveAddress = 'someInjectiveAddress'
59
-
60
- const message = MsgSend.fromJSON({
61
- srcInjectiveAddress: injectiveAddress,
62
- dstInjectiveAddress: injectiveAddress,
63
- amount: {
64
- amount: '1',
65
- denom: 'inj',
66
- },
67
- })
68
-
69
- return await msgBroadcaster.broadcast({ msgs: message })
70
- }
59
+ const injectiveAddress = 'someInjectiveAddress'
60
+
61
+ const message = MsgSend.fromJSON({
62
+ srcInjectiveAddress: injectiveAddress,
63
+ dstInjectiveAddress: injectiveAddress,
64
+ amount: {
65
+ amount: '1',
66
+ denom: 'inj',
67
+ },
68
+ })
69
+
70
+ return await msgBroadcaster.broadcast({ msgs: message })
71
+ }
71
72
 
72
- const result = await sendTX()
73
+ const result = await sendTX()
73
74
  ```
74
75
 
75
76
  Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)
@@ -1,4 +1,4 @@
1
1
  export { LedgerLive as LedgerLiveStrategy } from './strategy/Ledger/LedgerLive.js';
2
- export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
3
2
  export { LedgerLegacy as LedgerLegacyStrategy } from './strategy/Ledger/LedgerLegacy.js';
3
+ export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
4
4
  export * from './types.js';
package/dist/cjs/index.js CHANGED
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.LedgerLegacyStrategy = exports.LedgerCosmosStrategy = exports.LedgerLiveStrategy = void 0;
17
+ exports.LedgerCosmosStrategy = exports.LedgerLegacyStrategy = exports.LedgerLiveStrategy = void 0;
18
18
  var LedgerLive_js_1 = require("./strategy/Ledger/LedgerLive.js");
19
19
  Object.defineProperty(exports, "LedgerLiveStrategy", { enumerable: true, get: function () { return LedgerLive_js_1.LedgerLive; } });
20
- var index_js_1 = require("./strategy/LedgerCosmos/index.js");
21
- Object.defineProperty(exports, "LedgerCosmosStrategy", { enumerable: true, get: function () { return index_js_1.LedgerCosmos; } });
22
20
  var LedgerLegacy_js_1 = require("./strategy/Ledger/LedgerLegacy.js");
23
21
  Object.defineProperty(exports, "LedgerLegacyStrategy", { enumerable: true, get: function () { return LedgerLegacy_js_1.LedgerLegacy; } });
22
+ var index_js_1 = require("./strategy/LedgerCosmos/index.js");
23
+ Object.defineProperty(exports, "LedgerCosmosStrategy", { enumerable: true, get: function () { return index_js_1.LedgerCosmos; } });
24
24
  __exportStar(require("./types.js"), exports);
@@ -1,14 +1,14 @@
1
+ import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { TxRaw, TxResponse, DirectSignResponse, AminoSignResponse } from '@injectivelabs/sdk-ts';
2
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, SendTransactionOptions, ConcreteWalletStrategy, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
3
- import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, SendTransactionOptions, ConcreteWalletStrategy, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
4
  import { LedgerDerivationPathType } from '../../types.js';
5
5
  export default class LedgerBase extends BaseConcreteStrategy implements ConcreteWalletStrategy {
6
6
  private baseDerivationPath;
7
7
  private derivationPathType;
8
8
  private ledger;
9
- private evmOptions;
9
+ private ethereumOptions;
10
10
  private alchemy;
11
- constructor(args: ConcreteEvmWalletStrategyArgs & {
11
+ constructor(args: ConcreteEthereumWalletStrategyArgs & {
12
12
  derivationPathType: LedgerDerivationPathType;
13
13
  });
14
14
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -18,7 +18,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
18
18
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
19
19
  sendEvmTransaction(txData: any, args: {
20
20
  address: string;
21
- evmChainId: EvmChainId;
21
+ ethereumChainId: EthereumChainId;
22
22
  }): Promise<string>;
23
23
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
24
24
  signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
@@ -4,25 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable class-methods-use-this */
7
- const sdk_ts_1 = require("@injectivelabs/sdk-ts");
8
- const exceptions_1 = require("@injectivelabs/exceptions");
9
- const wallet_base_1 = require("@injectivelabs/wallet-base");
7
+ const ts_types_1 = require("@injectivelabs/ts-types");
10
8
  const ethereumjs_util_1 = require("ethereumjs-util");
11
9
  const common_1 = require("@ethereumjs/common");
12
10
  const tx_1 = require("@ethereumjs/tx");
13
- const alchemy_sdk_1 = require("alchemy-sdk");
14
- const ts_types_1 = require("@injectivelabs/ts-types");
11
+ const ledgerhq_hw_app_eth_1 = require("@bangjelkoski/ledgerhq-hw-app-eth");
12
+ const exceptions_1 = require("@injectivelabs/exceptions");
13
+ const sdk_ts_1 = require("@injectivelabs/sdk-ts");
14
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
15
15
  const index_js_1 = __importDefault(require("./hw/index.js"));
16
- const lib_js_1 = require("./../lib.js");
17
16
  const utils_js_1 = require("./utils.js");
17
+ const alchemy_sdk_1 = require("alchemy-sdk");
18
18
  const getNetworkFromChainId = (chainId) => {
19
- if (chainId === ts_types_1.EvmChainId.Goerli) {
19
+ if (chainId === ts_types_1.EthereumChainId.Goerli) {
20
20
  return common_1.Chain.Goerli;
21
21
  }
22
- if (chainId === ts_types_1.EvmChainId.Sepolia) {
22
+ if (chainId === ts_types_1.EthereumChainId.Sepolia) {
23
23
  return common_1.Chain.Sepolia;
24
24
  }
25
- if (chainId === ts_types_1.EvmChainId.Kovan) {
25
+ if (chainId === ts_types_1.EthereumChainId.Kovan) {
26
26
  return common_1.Chain.Goerli;
27
27
  }
28
28
  return common_1.Chain.Mainnet;
@@ -31,14 +31,14 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
31
31
  baseDerivationPath;
32
32
  derivationPathType;
33
33
  ledger;
34
- evmOptions;
34
+ ethereumOptions;
35
35
  alchemy;
36
36
  constructor(args) {
37
37
  super(args);
38
38
  this.baseDerivationPath = wallet_base_1.DEFAULT_BASE_DERIVATION_PATH;
39
39
  this.derivationPathType = args.derivationPathType;
40
40
  this.ledger = new index_js_1.default();
41
- this.evmOptions = args.evmOptions;
41
+ this.ethereumOptions = args.ethereumOptions;
42
42
  }
43
43
  async getWalletDeviceType() {
44
44
  return Promise.resolve(wallet_base_1.WalletDeviceType.Hardware);
@@ -70,7 +70,7 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
70
70
  async sendEvmTransaction(txData, args) {
71
71
  const signedTransaction = await this.signEvmTransaction(txData, args);
72
72
  try {
73
- const alchemy = await this.getAlchemy(args.evmChainId);
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
  }
@@ -179,9 +179,8 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
179
179
  throw new exceptions_1.WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
180
180
  }
181
181
  async signEvmTransaction(txData, args) {
182
- const ledgerService = await (0, lib_js_1.loadLedgerServiceType)();
183
- const alchemy = await this.getAlchemy(args.evmChainId);
184
- const chainId = parseInt(args.evmChainId.toString(), 10);
182
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
183
+ const chainId = parseInt(args.ethereumChainId.toString(), 10);
185
184
  const nonce = await alchemy.core.getTransactionCount(args.address);
186
185
  const common = new common_1.Common({
187
186
  chain: getNetworkFromChainId(chainId),
@@ -204,7 +203,7 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
204
203
  try {
205
204
  const ledger = await this.ledger.getInstance();
206
205
  const { derivationPath } = await this.getWalletForAddress(args.address);
207
- const resolution = await ledgerService.resolveTransaction(encodedMessageHex, {}, {});
206
+ const resolution = await ledgerhq_hw_app_eth_1.ledgerService.resolveTransaction(encodedMessageHex, {}, {});
208
207
  const txSig = await ledger.signTransaction(derivationPath, encodedMessageHex, resolution);
209
208
  const signedTxData = {
210
209
  ...eip1559TxData,
@@ -246,19 +245,19 @@ class LedgerBase extends wallet_base_1.BaseConcreteStrategy {
246
245
  });
247
246
  }
248
247
  }
249
- async getAlchemy(evmChainId) {
248
+ async getAlchemy(ethereumChainId) {
250
249
  if (this.alchemy) {
251
250
  return this.alchemy;
252
251
  }
253
- const options = this.evmOptions;
254
- const chainId = evmChainId || options.evmChainId;
252
+ const options = this.ethereumOptions;
253
+ const chainId = ethereumChainId || options.ethereumChainId;
255
254
  const url = options.rpcUrl || options.rpcUrls?.[chainId];
256
255
  if (!url) {
257
- throw new exceptions_1.GeneralException(new Error('Please pass rpcUrl within the evmOptions'));
256
+ throw new exceptions_1.GeneralException(new Error('Please pass rpcUrl within the ethereumOptions'));
258
257
  }
259
258
  this.alchemy = new alchemy_sdk_1.Alchemy({
260
259
  apiKey: (0, wallet_base_1.getKeyFromRpcUrl)(url),
261
- network: chainId === ts_types_1.EvmChainId.Mainnet
260
+ network: chainId === ts_types_1.EthereumChainId.Mainnet
262
261
  ? alchemy_sdk_1.Network.ETH_MAINNET
263
262
  : alchemy_sdk_1.Network.ETH_SEPOLIA,
264
263
  });
@@ -1,5 +1,5 @@
1
- import { ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
1
+ import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
2
2
  import LedgerBase from './Base.js';
3
3
  export declare class LedgerLegacy extends LedgerBase {
4
- constructor(args: ConcreteEvmWalletStrategyArgs);
4
+ constructor(args: ConcreteEthereumWalletStrategyArgs);
5
5
  }
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LedgerLegacy = void 0;
7
- const Base_js_1 = __importDefault(require("./Base.js"));
8
7
  const types_js_1 = require("../../types.js");
8
+ const Base_js_1 = __importDefault(require("./Base.js"));
9
9
  class LedgerLegacy extends Base_js_1.default {
10
10
  constructor(args) {
11
11
  super({
@@ -1,5 +1,5 @@
1
- import { ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
1
+ import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
2
2
  import LedgerBase from './Base.js';
3
3
  export declare class LedgerLive extends LedgerBase {
4
- constructor(args: ConcreteEvmWalletStrategyArgs);
4
+ constructor(args: ConcreteEthereumWalletStrategyArgs);
5
5
  }
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LedgerLive = void 0;
7
- const Base_js_1 = __importDefault(require("./Base.js"));
8
7
  const types_js_1 = require("../../types.js");
8
+ const Base_js_1 = __importDefault(require("./Base.js"));
9
9
  class LedgerLive extends Base_js_1.default {
10
10
  constructor(args) {
11
11
  super({
@@ -1,6 +1,6 @@
1
1
  import { AccountAddress } from '@injectivelabs/ts-types';
2
+ import { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
2
3
  import { LedgerDerivationPathType, LedgerWalletInfo } from '../../../types.js';
3
- import type { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
4
4
  export default class AccountManager {
5
5
  private wallets;
6
6
  private ledger;
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const hdkey_1 = __importDefault(require("hdkey"));
7
6
  const ethereumjs_util_1 = require("ethereumjs-util");
8
- const wallet_base_1 = require("@injectivelabs/wallet-base");
7
+ const hdkey_1 = __importDefault(require("hdkey"));
9
8
  const types_js_1 = require("../../../types.js");
9
+ const wallet_base_1 = require("@injectivelabs/wallet-base");
10
10
  const addressOfHDKey = (hdKey) => {
11
11
  const shouldSanitizePublicKey = true;
12
12
  const derivedPublicKey = hdKey.publicKey;
@@ -1,6 +1,6 @@
1
+ import { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
2
+ import { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
1
3
  import AccountManager from './AccountManager.js';
2
- import type { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
3
- import type { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
4
4
  export default class LedgerTransport {
5
5
  private ledger;
6
6
  private accountManager;
@@ -3,45 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ledgerhq_hw_transport_webhid_1 = require("@bangjelkoski/ledgerhq-hw-transport-webhid");
7
+ const ledgerhq_hw_transport_webusb_1 = require("@bangjelkoski/ledgerhq-hw-transport-webusb");
8
+ const ledgerhq_hw_app_eth_1 = require("@bangjelkoski/ledgerhq-hw-app-eth");
6
9
  const exceptions_1 = require("@injectivelabs/exceptions");
7
- const lib_js_1 = require("../../lib.js");
8
10
  const AccountManager_js_1 = __importDefault(require("./AccountManager.js"));
9
11
  class LedgerTransport {
10
12
  ledger = null;
11
13
  accountManager = null;
12
14
  static async getTransport() {
13
- const TransportWebUSB = await (0, lib_js_1.loadTransportWebUSB)();
14
- const TransportWebHID = await (0, lib_js_1.loadTransportWebHIDType)();
15
15
  try {
16
- if (await TransportWebHID.isSupported()) {
17
- const list = await TransportWebHID.list();
16
+ if (await ledgerhq_hw_transport_webhid_1.TransportWebHID.isSupported()) {
17
+ const list = await ledgerhq_hw_transport_webhid_1.TransportWebHID.list();
18
18
  if (list.length > 0 && list[0].opened) {
19
- return new TransportWebHID(list[0]);
19
+ return new ledgerhq_hw_transport_webhid_1.TransportWebHID(list[0]);
20
20
  }
21
- const existing = await TransportWebHID.openConnected().catch(() => null);
21
+ const existing = await ledgerhq_hw_transport_webhid_1.TransportWebHID.openConnected().catch(() => null);
22
22
  if (existing) {
23
23
  return existing;
24
24
  }
25
- return await TransportWebHID.request();
25
+ return await ledgerhq_hw_transport_webhid_1.TransportWebHID.request();
26
26
  }
27
- if (await TransportWebUSB.isSupported()) {
28
- const existing = await TransportWebUSB.openConnected().catch(() => null);
27
+ if (await ledgerhq_hw_transport_webusb_1.TransportWebUSB.isSupported()) {
28
+ const existing = await ledgerhq_hw_transport_webusb_1.TransportWebUSB.openConnected().catch(() => null);
29
29
  if (existing) {
30
30
  return existing;
31
31
  }
32
- return await TransportWebUSB.request();
32
+ return await ledgerhq_hw_transport_webusb_1.TransportWebUSB.request();
33
33
  }
34
34
  }
35
35
  catch (e) {
36
36
  throw new exceptions_1.LedgerException(new Error(e.message));
37
37
  }
38
- return TransportWebUSB.request();
38
+ return ledgerhq_hw_transport_webusb_1.TransportWebUSB.request();
39
39
  }
40
40
  async getInstance() {
41
- const EthereumApp = await (0, lib_js_1.loadEthType)();
42
41
  if (!this.ledger) {
43
42
  const transport = await LedgerTransport.getTransport();
44
- this.ledger = new EthereumApp(transport);
43
+ this.ledger = new ledgerhq_hw_app_eth_1.Eth(transport);
45
44
  transport.on('disconnect', () => {
46
45
  this.ledger = null;
47
46
  this.accountManager = null;
@@ -1,6 +1,6 @@
1
1
  import { AccountAddress } from '@injectivelabs/ts-types';
2
+ import { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
2
3
  import { LedgerWalletInfo } from '../../../types.js';
3
- import type { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
4
4
  export default class AccountManager {
5
5
  private wallets;
6
6
  private ledger;
@@ -1,6 +1,6 @@
1
+ import { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
2
+ import { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
1
3
  import AccountManager from './AccountManager.js';
2
- import type { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
3
- import type { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
4
4
  export default class LedgerTransport {
5
5
  private ledger;
6
6
  private accountManager;
@@ -3,32 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ledgerhq_hw_transport_webusb_1 = require("@bangjelkoski/ledgerhq-hw-transport-webusb");
7
+ const ledgerhq_hw_transport_webhid_1 = require("@bangjelkoski/ledgerhq-hw-transport-webhid");
8
+ const ledgerhq_hw_app_cosmos_1 = require("@bangjelkoski/ledgerhq-hw-app-cosmos");
6
9
  const exceptions_1 = require("@injectivelabs/exceptions");
7
- const lib_js_1 = require("./../../lib.js");
8
10
  const AccountManager_js_1 = __importDefault(require("./AccountManager.js"));
9
11
  class LedgerTransport {
10
12
  ledger = null;
11
13
  accountManager = null;
12
14
  static async getTransport() {
13
- const TransportWebUSB = await (0, lib_js_1.loadTransportWebUSB)();
14
- const TransportWebHID = await (0, lib_js_1.loadTransportWebHIDType)();
15
15
  try {
16
- if (await TransportWebHID.isSupported()) {
17
- return await TransportWebHID.create();
16
+ if (await ledgerhq_hw_transport_webhid_1.TransportWebHID.isSupported()) {
17
+ return await ledgerhq_hw_transport_webhid_1.TransportWebHID.create();
18
18
  }
19
- if (await TransportWebUSB.isSupported()) {
20
- return await TransportWebHID.create();
19
+ if (await ledgerhq_hw_transport_webusb_1.TransportWebUSB.isSupported()) {
20
+ return await ledgerhq_hw_transport_webhid_1.TransportWebHID.create();
21
21
  }
22
22
  }
23
23
  catch (e) {
24
24
  throw new exceptions_1.LedgerCosmosException(new Error(e.message));
25
25
  }
26
- return await TransportWebHID.create();
26
+ return await ledgerhq_hw_transport_webhid_1.TransportWebHID.create();
27
27
  }
28
28
  async getInstance() {
29
- const CosmosApp = await (0, lib_js_1.loadCosmosType)();
30
29
  if (!this.ledger) {
31
- this.ledger = new CosmosApp((await LedgerTransport.getTransport()));
30
+ this.ledger = new ledgerhq_hw_app_cosmos_1.Cosmos((await LedgerTransport.getTransport()));
32
31
  }
33
32
  return this.ledger;
34
33
  }
@@ -1,6 +1,6 @@
1
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
3
  import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
4
  export declare class LedgerCosmos extends BaseConcreteStrategy implements ConcreteWalletStrategy {
5
5
  private baseDerivationPath;
6
6
  private ledger;
@@ -14,7 +14,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
14
14
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
15
15
  sendEvmTransaction(_txData: any, _options: {
16
16
  address: string;
17
- evmChainId: EvmChainId;
17
+ ethereumChainId: EthereumChainId;
18
18
  }): Promise<string>;
19
19
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
20
20
  signAminoCosmosTransaction(transaction: {
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LedgerCosmos = void 0;
7
- /* eslint-disable class-methods-use-this */
8
7
  const exceptions_1 = require("@injectivelabs/exceptions");
9
8
  const sdk_ts_1 = require("@injectivelabs/sdk-ts");
10
9
  const wallet_base_1 = require("@injectivelabs/wallet-base");
11
- const exceptions_2 = require("@injectivelabs/exceptions");
12
10
  const index_js_1 = __importDefault(require("./hw/index.js"));
11
+ const exceptions_2 = require("@injectivelabs/exceptions");
13
12
  class LedgerCosmos extends wallet_base_1.BaseConcreteStrategy {
14
13
  baseDerivationPath;
15
14
  ledger;
@@ -95,7 +94,7 @@ class LedgerCosmos extends wallet_base_1.BaseConcreteStrategy {
95
94
  });
96
95
  }
97
96
  async signEip712TypedData(_eip712Json, _address) {
98
- throw new exceptions_2.CosmosWalletException(new Error('This wallet does not support signing Evm transactions'), {
97
+ throw new exceptions_2.CosmosWalletException(new Error('This wallet does not support signing Ethereum transactions'), {
99
98
  code: exceptions_1.UnspecifiedErrorCode,
100
99
  context: wallet_base_1.WalletAction.SendTransaction,
101
100
  });
@@ -1,4 +1,4 @@
1
1
  export { LedgerLive as LedgerLiveStrategy } from './strategy/Ledger/LedgerLive.js';
2
- export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
3
2
  export { LedgerLegacy as LedgerLegacyStrategy } from './strategy/Ledger/LedgerLegacy.js';
3
+ export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
4
4
  export * from './types.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { LedgerLive as LedgerLiveStrategy } from './strategy/Ledger/LedgerLive.js';
2
- export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
3
2
  export { LedgerLegacy as LedgerLegacyStrategy } from './strategy/Ledger/LedgerLegacy.js';
3
+ export { LedgerCosmos as LedgerCosmosStrategy } from './strategy/LedgerCosmos/index.js';
4
4
  export * from './types.js';
@@ -1,14 +1,14 @@
1
+ import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { TxRaw, TxResponse, DirectSignResponse, AminoSignResponse } from '@injectivelabs/sdk-ts';
2
- import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, SendTransactionOptions, ConcreteWalletStrategy, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
3
- import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
3
+ import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, SendTransactionOptions, ConcreteWalletStrategy, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
4
  import { LedgerDerivationPathType } from '../../types.js';
5
5
  export default class LedgerBase extends BaseConcreteStrategy implements ConcreteWalletStrategy {
6
6
  private baseDerivationPath;
7
7
  private derivationPathType;
8
8
  private ledger;
9
- private evmOptions;
9
+ private ethereumOptions;
10
10
  private alchemy;
11
- constructor(args: ConcreteEvmWalletStrategyArgs & {
11
+ constructor(args: ConcreteEthereumWalletStrategyArgs & {
12
12
  derivationPathType: LedgerDerivationPathType;
13
13
  });
14
14
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -18,7 +18,7 @@ export default class LedgerBase extends BaseConcreteStrategy implements Concrete
18
18
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
19
19
  sendEvmTransaction(txData: any, args: {
20
20
  address: string;
21
- evmChainId: EvmChainId;
21
+ ethereumChainId: EthereumChainId;
22
22
  }): Promise<string>;
23
23
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
24
24
  signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
@@ -1,23 +1,23 @@
1
1
  /* eslint-disable class-methods-use-this */
2
- import { toUtf8, TxGrpcApi, } from '@injectivelabs/sdk-ts';
3
- import { ErrorType, LedgerException, WalletException, GeneralException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
4
- 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';
2
+ import { EthereumChainId } from '@injectivelabs/ts-types';
5
3
  import { bufferToHex, addHexPrefix } from 'ethereumjs-util';
6
4
  import { Common, Chain, Hardfork } from '@ethereumjs/common';
7
5
  import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx';
8
- import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
9
- import { EvmChainId } from '@injectivelabs/ts-types';
6
+ import { ledgerService } from '@bangjelkoski/ledgerhq-hw-app-eth';
7
+ import { ErrorType, LedgerException, WalletException, GeneralException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions';
8
+ import { toUtf8, TxGrpcApi, } from '@injectivelabs/sdk-ts';
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
- import { loadLedgerServiceType } from './../lib.js';
12
11
  import { domainHash, messageHash } from './utils.js';
12
+ import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk';
13
13
  const getNetworkFromChainId = (chainId) => {
14
- if (chainId === EvmChainId.Goerli) {
14
+ if (chainId === EthereumChainId.Goerli) {
15
15
  return Chain.Goerli;
16
16
  }
17
- if (chainId === EvmChainId.Sepolia) {
17
+ if (chainId === EthereumChainId.Sepolia) {
18
18
  return Chain.Sepolia;
19
19
  }
20
- if (chainId === EvmChainId.Kovan) {
20
+ if (chainId === EthereumChainId.Kovan) {
21
21
  return Chain.Goerli;
22
22
  }
23
23
  return Chain.Mainnet;
@@ -26,14 +26,14 @@ export default class LedgerBase extends BaseConcreteStrategy {
26
26
  baseDerivationPath;
27
27
  derivationPathType;
28
28
  ledger;
29
- evmOptions;
29
+ ethereumOptions;
30
30
  alchemy;
31
31
  constructor(args) {
32
32
  super(args);
33
33
  this.baseDerivationPath = DEFAULT_BASE_DERIVATION_PATH;
34
34
  this.derivationPathType = args.derivationPathType;
35
35
  this.ledger = new LedgerHW();
36
- this.evmOptions = args.evmOptions;
36
+ this.ethereumOptions = args.ethereumOptions;
37
37
  }
38
38
  async getWalletDeviceType() {
39
39
  return Promise.resolve(WalletDeviceType.Hardware);
@@ -65,7 +65,7 @@ export default class LedgerBase extends BaseConcreteStrategy {
65
65
  async sendEvmTransaction(txData, args) {
66
66
  const signedTransaction = await this.signEvmTransaction(txData, args);
67
67
  try {
68
- const alchemy = await this.getAlchemy(args.evmChainId);
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
  }
@@ -174,9 +174,8 @@ export default class LedgerBase extends BaseConcreteStrategy {
174
174
  throw new WalletException(new Error('You can only fetch PubKey from Cosmos native wallets'));
175
175
  }
176
176
  async signEvmTransaction(txData, args) {
177
- const ledgerService = await loadLedgerServiceType();
178
- const alchemy = await this.getAlchemy(args.evmChainId);
179
- const chainId = parseInt(args.evmChainId.toString(), 10);
177
+ const alchemy = await this.getAlchemy(args.ethereumChainId);
178
+ const chainId = parseInt(args.ethereumChainId.toString(), 10);
180
179
  const nonce = await alchemy.core.getTransactionCount(args.address);
181
180
  const common = new Common({
182
181
  chain: getNetworkFromChainId(chainId),
@@ -241,19 +240,19 @@ export default class LedgerBase extends BaseConcreteStrategy {
241
240
  });
242
241
  }
243
242
  }
244
- async getAlchemy(evmChainId) {
243
+ async getAlchemy(ethereumChainId) {
245
244
  if (this.alchemy) {
246
245
  return this.alchemy;
247
246
  }
248
- const options = this.evmOptions;
249
- const chainId = evmChainId || options.evmChainId;
247
+ const options = this.ethereumOptions;
248
+ const chainId = ethereumChainId || options.ethereumChainId;
250
249
  const url = options.rpcUrl || options.rpcUrls?.[chainId];
251
250
  if (!url) {
252
- throw new GeneralException(new Error('Please pass rpcUrl within the evmOptions'));
251
+ throw new GeneralException(new Error('Please pass rpcUrl within the ethereumOptions'));
253
252
  }
254
253
  this.alchemy = new Alchemy({
255
254
  apiKey: getKeyFromRpcUrl(url),
256
- network: chainId === EvmChainId.Mainnet
255
+ network: chainId === EthereumChainId.Mainnet
257
256
  ? AlchemyNetwork.ETH_MAINNET
258
257
  : AlchemyNetwork.ETH_SEPOLIA,
259
258
  });
@@ -1,5 +1,5 @@
1
- import { ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
1
+ import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
2
2
  import LedgerBase from './Base.js';
3
3
  export declare class LedgerLegacy extends LedgerBase {
4
- constructor(args: ConcreteEvmWalletStrategyArgs);
4
+ constructor(args: ConcreteEthereumWalletStrategyArgs);
5
5
  }
@@ -1,5 +1,5 @@
1
- import LedgerBase from './Base.js';
2
1
  import { LedgerDerivationPathType } from '../../types.js';
2
+ import LedgerBase from './Base.js';
3
3
  export class LedgerLegacy extends LedgerBase {
4
4
  constructor(args) {
5
5
  super({
@@ -1,5 +1,5 @@
1
- import { ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
1
+ import { ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
2
2
  import LedgerBase from './Base.js';
3
3
  export declare class LedgerLive extends LedgerBase {
4
- constructor(args: ConcreteEvmWalletStrategyArgs);
4
+ constructor(args: ConcreteEthereumWalletStrategyArgs);
5
5
  }
@@ -1,5 +1,5 @@
1
- import LedgerBase from './Base.js';
2
1
  import { LedgerDerivationPathType } from '../../types.js';
2
+ import LedgerBase from './Base.js';
3
3
  export class LedgerLive extends LedgerBase {
4
4
  constructor(args) {
5
5
  super({
@@ -1,6 +1,6 @@
1
1
  import { AccountAddress } from '@injectivelabs/ts-types';
2
+ import { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
2
3
  import { LedgerDerivationPathType, LedgerWalletInfo } from '../../../types.js';
3
- import type { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
4
4
  export default class AccountManager {
5
5
  private wallets;
6
6
  private ledger;
@@ -1,7 +1,7 @@
1
- import HDNode from 'hdkey';
2
1
  import { publicToAddress, addHexPrefix } from 'ethereumjs-util';
3
- import { DEFAULT_NUM_ADDRESSES_TO_FETCH } from '@injectivelabs/wallet-base';
2
+ import HDNode from 'hdkey';
4
3
  import { LedgerDerivationPathType } from '../../../types.js';
4
+ import { DEFAULT_NUM_ADDRESSES_TO_FETCH } from '@injectivelabs/wallet-base';
5
5
  const addressOfHDKey = (hdKey) => {
6
6
  const shouldSanitizePublicKey = true;
7
7
  const derivedPublicKey = hdKey.publicKey;
@@ -1,6 +1,6 @@
1
+ import { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
2
+ import { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
1
3
  import AccountManager from './AccountManager.js';
2
- import type { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
3
- import type { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
4
4
  export default class LedgerTransport {
5
5
  private ledger;
6
6
  private accountManager;
@@ -1,12 +1,12 @@
1
+ import { TransportWebHID } from '@bangjelkoski/ledgerhq-hw-transport-webhid';
2
+ import { TransportWebUSB } from '@bangjelkoski/ledgerhq-hw-transport-webusb';
3
+ import { Eth as EthereumApp } from '@bangjelkoski/ledgerhq-hw-app-eth';
1
4
  import { LedgerException } from '@injectivelabs/exceptions';
2
- import { loadEthType, loadTransportWebUSB, loadTransportWebHIDType, } from '../../lib.js';
3
5
  import AccountManager from './AccountManager.js';
4
6
  export default class LedgerTransport {
5
7
  ledger = null;
6
8
  accountManager = null;
7
9
  static async getTransport() {
8
- const TransportWebUSB = await loadTransportWebUSB();
9
- const TransportWebHID = await loadTransportWebHIDType();
10
10
  try {
11
11
  if (await TransportWebHID.isSupported()) {
12
12
  const list = await TransportWebHID.list();
@@ -33,7 +33,6 @@ export default class LedgerTransport {
33
33
  return TransportWebUSB.request();
34
34
  }
35
35
  async getInstance() {
36
- const EthereumApp = await loadEthType();
37
36
  if (!this.ledger) {
38
37
  const transport = await LedgerTransport.getTransport();
39
38
  this.ledger = new EthereumApp(transport);
@@ -1,6 +1,6 @@
1
1
  import { AccountAddress } from '@injectivelabs/ts-types';
2
+ import { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
2
3
  import { LedgerWalletInfo } from '../../../types.js';
3
- import type { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
4
4
  export default class AccountManager {
5
5
  private wallets;
6
6
  private ledger;
@@ -1,6 +1,6 @@
1
+ import { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
2
+ import { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
1
3
  import AccountManager from './AccountManager.js';
2
- import type { Transport } from '@bangjelkoski/ledgerhq-hw-transport';
3
- import type { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
4
4
  export default class LedgerTransport {
5
5
  private ledger;
6
6
  private accountManager;
@@ -1,12 +1,12 @@
1
+ import { TransportWebUSB } from '@bangjelkoski/ledgerhq-hw-transport-webusb';
2
+ import { TransportWebHID } from '@bangjelkoski/ledgerhq-hw-transport-webhid';
3
+ import { Cosmos as CosmosApp } from '@bangjelkoski/ledgerhq-hw-app-cosmos';
1
4
  import { LedgerCosmosException } from '@injectivelabs/exceptions';
2
- import { loadCosmosType, loadTransportWebUSB, loadTransportWebHIDType, } from './../../lib.js';
3
5
  import AccountManager from './AccountManager.js';
4
6
  export default class LedgerTransport {
5
7
  ledger = null;
6
8
  accountManager = null;
7
9
  static async getTransport() {
8
- const TransportWebUSB = await loadTransportWebUSB();
9
- const TransportWebHID = await loadTransportWebHIDType();
10
10
  try {
11
11
  if (await TransportWebHID.isSupported()) {
12
12
  return await TransportWebHID.create();
@@ -21,7 +21,6 @@ export default class LedgerTransport {
21
21
  return await TransportWebHID.create();
22
22
  }
23
23
  async getInstance() {
24
- const CosmosApp = await loadCosmosType();
25
24
  if (!this.ledger) {
26
25
  this.ledger = new CosmosApp((await LedgerTransport.getTransport()));
27
26
  }
@@ -1,6 +1,6 @@
1
+ import { ChainId, AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
1
2
  import { TxRaw, TxResponse, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
3
  import { StdSignDoc, WalletDeviceType, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions } from '@injectivelabs/wallet-base';
3
- import { ChainId, EvmChainId, AccountAddress } from '@injectivelabs/ts-types';
4
4
  export declare class LedgerCosmos extends BaseConcreteStrategy implements ConcreteWalletStrategy {
5
5
  private baseDerivationPath;
6
6
  private ledger;
@@ -14,7 +14,7 @@ export declare class LedgerCosmos extends BaseConcreteStrategy implements Concre
14
14
  getSessionOrConfirm(address: AccountAddress): Promise<string>;
15
15
  sendEvmTransaction(_txData: any, _options: {
16
16
  address: string;
17
- evmChainId: EvmChainId;
17
+ ethereumChainId: EthereumChainId;
18
18
  }): Promise<string>;
19
19
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<TxResponse>;
20
20
  signAminoCosmosTransaction(transaction: {
@@ -1,9 +1,8 @@
1
- /* eslint-disable class-methods-use-this */
2
- import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, LedgerCosmosException, } from '@injectivelabs/exceptions';
1
+ import { ErrorType, LedgerCosmosException, TransactionException, UnspecifiedErrorCode, WalletException, } from '@injectivelabs/exceptions';
3
2
  import { toUtf8, TxGrpcApi, sortObjectByKeys, } from '@injectivelabs/sdk-ts';
4
- import { WalletAction, WalletDeviceType, BaseConcreteStrategy, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
5
- import { CosmosWalletException } from '@injectivelabs/exceptions';
3
+ import { WalletAction, WalletDeviceType, BaseConcreteStrategy, DEFAULT_BASE_DERIVATION_PATH, DEFAULT_ADDRESS_SEARCH_LIMIT, DEFAULT_NUM_ADDRESSES_TO_FETCH, } from '@injectivelabs/wallet-base';
6
4
  import LedgerHW from './hw/index.js';
5
+ import { CosmosWalletException } from '@injectivelabs/exceptions';
7
6
  export class LedgerCosmos extends BaseConcreteStrategy {
8
7
  baseDerivationPath;
9
8
  ledger;
@@ -89,7 +88,7 @@ export class LedgerCosmos extends BaseConcreteStrategy {
89
88
  });
90
89
  }
91
90
  async signEip712TypedData(_eip712Json, _address) {
92
- throw new CosmosWalletException(new Error('This wallet does not support signing Evm transactions'), {
91
+ throw new CosmosWalletException(new Error('This wallet does not support signing Ethereum transactions'), {
93
92
  code: UnspecifiedErrorCode,
94
93
  context: WalletAction.SendTransaction,
95
94
  });
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.16.2-alpha.0",
4
+ "version": "1.16.2",
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:esm && pnpm build:cjs && pnpm build:post",
44
+ "build": "yarn build:esm && yarn build:cjs && 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",
@@ -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.16.2-alpha.0",
67
- "@injectivelabs/sdk-ts": "1.16.2-alpha.0",
68
- "@injectivelabs/ts-types": "1.16.2-alpha.0",
69
- "@injectivelabs/wallet-base": "1.16.2-alpha.0",
66
+ "@injectivelabs/exceptions": "^1.16.2",
67
+ "@injectivelabs/sdk-ts": "^1.16.2",
68
+ "@injectivelabs/ts-types": "^1.16.2",
69
+ "@injectivelabs/wallet-base": "^1.16.2",
70
70
  "alchemy-sdk": "^3.4.7",
71
71
  "eth-sig-util": "^3.0.1",
72
72
  "ethereumjs-util": "^7.1.0",
@@ -76,8 +76,7 @@
76
76
  "@types/eth-sig-util": "^2.1.1",
77
77
  "@types/ethereumjs-util": "^6.1.0",
78
78
  "@types/hdkey": "^2.0.1",
79
- "@types/ledgerhq__hw-transport-webusb": "^4.70.1",
80
- "shx": "^0.3.4"
79
+ "@types/ledgerhq__hw-transport-webusb": "^4.70.1"
81
80
  },
82
- "gitHead": "0377b0c3b44d79b598d08ca01930057dc05d9c7a"
81
+ "gitHead": "56e3f6c8f399c2d881a65858e8e0b1b39828a917"
83
82
  }
@@ -1,14 +0,0 @@
1
- export type EthType = typeof import('@bangjelkoski/ledgerhq-hw-app-eth').Eth;
2
- export type CosmosType = typeof import('@bangjelkoski/ledgerhq-hw-app-cosmos').Cosmos;
3
- export type ledgerServiceType = typeof import('@bangjelkoski/ledgerhq-hw-app-eth').ledgerService;
4
- export type TransportWebHIDType = typeof import('@bangjelkoski/ledgerhq-hw-transport-webhid').TransportWebHID;
5
- export type TransportWebUSBType = typeof import('@bangjelkoski/ledgerhq-hw-transport-webusb').TransportWebUSB;
6
- declare let EthType: EthType;
7
- declare let CosmosType: CosmosType;
8
- declare let ledgerServiceType: ledgerServiceType;
9
- export declare function loadEthType(): Promise<typeof EthType>;
10
- export declare function loadCosmosType(): Promise<typeof CosmosType>;
11
- export declare function loadLedgerServiceType(): Promise<typeof ledgerServiceType>;
12
- export declare function loadTransportWebUSB(): Promise<TransportWebUSBType>;
13
- export declare function loadTransportWebHIDType(): Promise<TransportWebHIDType>;
14
- export {};
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.loadEthType = loadEthType;
37
- exports.loadCosmosType = loadCosmosType;
38
- exports.loadLedgerServiceType = loadLedgerServiceType;
39
- exports.loadTransportWebUSB = loadTransportWebUSB;
40
- exports.loadTransportWebHIDType = loadTransportWebHIDType;
41
- let EthType;
42
- let CosmosType;
43
- let ledgerServiceType;
44
- let TransportWebUSB;
45
- let TransportWebHID;
46
- async function loadEthType() {
47
- if (!EthType) {
48
- const module = await Promise.resolve().then(() => __importStar(require('@bangjelkoski/ledgerhq-hw-app-eth')));
49
- EthType = module.Eth ? module.Eth : module.default.Eth;
50
- }
51
- return EthType;
52
- }
53
- async function loadCosmosType() {
54
- if (!CosmosType) {
55
- const module = await Promise.resolve().then(() => __importStar(require('@bangjelkoski/ledgerhq-hw-app-cosmos')));
56
- CosmosType = module.Cosmos ? module.Cosmos : module.default.Cosmos;
57
- }
58
- return CosmosType;
59
- }
60
- async function loadLedgerServiceType() {
61
- if (!ledgerServiceType) {
62
- const module = await Promise.resolve().then(() => __importStar(require('@bangjelkoski/ledgerhq-hw-app-eth')));
63
- ledgerServiceType =
64
- module.ledgerService ||
65
- module.default.ledgerService;
66
- }
67
- return ledgerServiceType;
68
- }
69
- async function loadTransportWebUSB() {
70
- if (!TransportWebUSB) {
71
- const module = await Promise.resolve().then(() => __importStar(require('@bangjelkoski/ledgerhq-hw-transport-webusb')));
72
- TransportWebUSB =
73
- module.TransportWebUSB ||
74
- module.default.TransportWebUSB;
75
- }
76
- return TransportWebUSB;
77
- }
78
- async function loadTransportWebHIDType() {
79
- if (!TransportWebHID) {
80
- const module = await Promise.resolve().then(() => __importStar(require('@bangjelkoski/ledgerhq-hw-transport-webhid')));
81
- TransportWebHID =
82
- module.TransportWebHID ||
83
- module.default.TransportWebHID;
84
- }
85
- return TransportWebHID;
86
- }
@@ -1,14 +0,0 @@
1
- export type EthType = typeof import('@bangjelkoski/ledgerhq-hw-app-eth').Eth;
2
- export type CosmosType = typeof import('@bangjelkoski/ledgerhq-hw-app-cosmos').Cosmos;
3
- export type ledgerServiceType = typeof import('@bangjelkoski/ledgerhq-hw-app-eth').ledgerService;
4
- export type TransportWebHIDType = typeof import('@bangjelkoski/ledgerhq-hw-transport-webhid').TransportWebHID;
5
- export type TransportWebUSBType = typeof import('@bangjelkoski/ledgerhq-hw-transport-webusb').TransportWebUSB;
6
- declare let EthType: EthType;
7
- declare let CosmosType: CosmosType;
8
- declare let ledgerServiceType: ledgerServiceType;
9
- export declare function loadEthType(): Promise<typeof EthType>;
10
- export declare function loadCosmosType(): Promise<typeof CosmosType>;
11
- export declare function loadLedgerServiceType(): Promise<typeof ledgerServiceType>;
12
- export declare function loadTransportWebUSB(): Promise<TransportWebUSBType>;
13
- export declare function loadTransportWebHIDType(): Promise<TransportWebHIDType>;
14
- export {};
@@ -1,46 +0,0 @@
1
- let EthType;
2
- let CosmosType;
3
- let ledgerServiceType;
4
- let TransportWebUSB;
5
- let TransportWebHID;
6
- export async function loadEthType() {
7
- if (!EthType) {
8
- const module = await import('@bangjelkoski/ledgerhq-hw-app-eth');
9
- EthType = module.Eth ? module.Eth : module.default.Eth;
10
- }
11
- return EthType;
12
- }
13
- export async function loadCosmosType() {
14
- if (!CosmosType) {
15
- const module = await import('@bangjelkoski/ledgerhq-hw-app-cosmos');
16
- CosmosType = module.Cosmos ? module.Cosmos : module.default.Cosmos;
17
- }
18
- return CosmosType;
19
- }
20
- export async function loadLedgerServiceType() {
21
- if (!ledgerServiceType) {
22
- const module = await import('@bangjelkoski/ledgerhq-hw-app-eth');
23
- ledgerServiceType =
24
- module.ledgerService ||
25
- module.default.ledgerService;
26
- }
27
- return ledgerServiceType;
28
- }
29
- export async function loadTransportWebUSB() {
30
- if (!TransportWebUSB) {
31
- const module = await import('@bangjelkoski/ledgerhq-hw-transport-webusb');
32
- TransportWebUSB =
33
- module.TransportWebUSB ||
34
- module.default.TransportWebUSB;
35
- }
36
- return TransportWebUSB;
37
- }
38
- export async function loadTransportWebHIDType() {
39
- if (!TransportWebHID) {
40
- const module = await import('@bangjelkoski/ledgerhq-hw-transport-webhid');
41
- TransportWebHID =
42
- module.TransportWebHID ||
43
- module.default.TransportWebHID;
44
- }
45
- return TransportWebHID;
46
- }