@exodus/hw-ledger 2.9.2 → 2.9.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.9.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.9.2...@exodus/hw-ledger@2.9.3) (2024-08-08)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **ledger:** properly order asset names array ([#7915](https://github.com/ExodusMovement/exodus-hydra/issues/7915)) ([e982d63](https://github.com/ExodusMovement/exodus-hydra/commit/e982d639354234bf93ae27e5f06876895a88aab0))
11
+
6
12
  ## [2.9.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.9.1...@exodus/hw-ledger@2.9.2) (2024-07-25)
7
13
 
8
14
  ### Bug Fixes
@@ -0,0 +1,23 @@
1
+ declare const applications: {
2
+ Bitcoin: {
3
+ applicationName: string;
4
+ supportedVersions: string;
5
+ primaryAssetName: string;
6
+ };
7
+ Solana: {
8
+ applicationName: string;
9
+ supportedVersions: string;
10
+ primaryAssetName: string;
11
+ };
12
+ Ethereum: {
13
+ applicationName: string;
14
+ supportedVersions: string;
15
+ primaryAssetName: string;
16
+ };
17
+ Polygon: {
18
+ applicationName: string;
19
+ supportedVersions: string;
20
+ primaryAssetName: string;
21
+ };
22
+ };
23
+ export default applications;
@@ -0,0 +1,27 @@
1
+ const Bitcoin = {
2
+ applicationName: 'Bitcoin',
3
+ supportedVersions: '^2.1.2',
4
+ primaryAssetName: 'bitcoin',
5
+ };
6
+ const Solana = {
7
+ applicationName: 'Solana',
8
+ supportedVersions: '^1.4.0',
9
+ primaryAssetName: 'solana',
10
+ };
11
+ const Ethereum = {
12
+ applicationName: 'Ethereum',
13
+ supportedVersions: '^1.10.0',
14
+ primaryAssetName: 'ethereum',
15
+ };
16
+ const Polygon = {
17
+ applicationName: 'Polygon',
18
+ supportedVersions: '^1.10.0',
19
+ primaryAssetName: 'matic',
20
+ };
21
+ const applications = {
22
+ Bitcoin,
23
+ Solana,
24
+ Ethereum,
25
+ Polygon,
26
+ };
27
+ export default applications;
@@ -2,6 +2,7 @@ declare const metadata: {
2
2
  applications: {
3
3
  applicationName: string;
4
4
  supportedVersions: string;
5
+ primaryAssetName: string;
5
6
  }[];
6
7
  handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("libraries/hw-common/lib").HardwareWalletAssetHandler>;
7
8
  };
@@ -1,11 +1,7 @@
1
+ import applications from './applications';
1
2
  import ethereum from './ethereum';
2
3
  const metadata = {
3
- applications: [
4
- {
5
- applicationName: 'Ethereum',
6
- supportedVersions: '^1.10.0',
7
- },
8
- ],
4
+ applications: [applications.Ethereum],
9
5
  handler: ethereum.handler,
10
6
  };
11
7
  export default metadata;
@@ -12,6 +12,7 @@ declare const metadata: {
12
12
  applications: {
13
13
  applicationName: string;
14
14
  supportedVersions: string;
15
+ primaryAssetName: string;
15
16
  }[];
16
17
  handler: typeof createHandler;
17
18
  };
@@ -5,6 +5,7 @@ import { splitBip44DerivationPath } from './utils';
5
5
  import assert from 'minimalistic-assert';
6
6
  import { assertPsbtOnlyHasAllowedDerivationPaths, tagPsbtWithDerivationPaths, getWalletPolicy, derivationPathsToWalletPolicy, addDummyInputs, } from './utils/psbt';
7
7
  import { buildBip322PSBT } from './utils/bip322';
8
+ import applications from './applications';
8
9
  async function createHandler(transport) {
9
10
  const app = new AppClient(transport);
10
11
  const getAddress = async (params) => {
@@ -103,12 +104,7 @@ async function createHandler(transport) {
103
104
  };
104
105
  }
105
106
  const metadata = {
106
- applications: [
107
- {
108
- applicationName: 'Bitcoin',
109
- supportedVersions: '^2.1.2',
110
- },
111
- ],
107
+ applications: [applications.Bitcoin],
112
108
  handler: createHandler,
113
109
  };
114
110
  export default metadata;
@@ -5,6 +5,7 @@ declare const metadata: {
5
5
  applications: {
6
6
  applicationName: string;
7
7
  supportedVersions: string;
8
+ primaryAssetName: string;
8
9
  }[];
9
10
  handler: typeof createHandler;
10
11
  };
@@ -5,6 +5,7 @@ import { TypedDataUtils, SignTypedDataVersion, } from '@metamask/eth-sig-util';
5
5
  import assert from 'minimalistic-assert';
6
6
  import { buildFauxXPUB } from './utils';
7
7
  import { RequiresBlindSigningError } from '../errors';
8
+ import applications from './applications';
8
9
  function hashEIP712Message(typedData) {
9
10
  const version = SignTypedDataVersion.V4;
10
11
  const { sanitizeData, hashStruct } = TypedDataUtils;
@@ -137,12 +138,7 @@ async function createHandler(transport) {
137
138
  };
138
139
  }
139
140
  const metadata = {
140
- applications: [
141
- {
142
- applicationName: 'Ethereum',
143
- supportedVersions: '^1.10.0',
144
- },
145
- ],
141
+ applications: [applications.Ethereum],
146
142
  handler: createHandler,
147
143
  };
148
144
  export default metadata;
@@ -4,11 +4,12 @@ type HandlerFactory = (transport: Transport) => Promise<HardwareWalletAssetHandl
4
4
  type AssetMetadata = {
5
5
  applications: {
6
6
  applicationName: string;
7
+ primaryAssetName: string;
7
8
  supportedVersions: string;
8
9
  }[];
9
10
  handler: HandlerFactory;
10
11
  };
11
12
  export declare const assetApplications: Record<string, AssetMetadata>;
12
13
  export declare const supportedBaseAssetNames: string[];
13
- export declare const applicationNameToBaseAssetName: Record<string, string>;
14
+ export declare const applicationNameToBaseAssetNames: Record<string, string[]>;
14
15
  export {};
@@ -3,6 +3,7 @@ import basemainnet from './basemainnet';
3
3
  import ethereum from './ethereum';
4
4
  import matic from './matic';
5
5
  import solana from './solana';
6
+ import applications from './applications';
6
7
  export const assetApplications = {
7
8
  basemainnet,
8
9
  bitcoin,
@@ -11,7 +12,18 @@ export const assetApplications = {
11
12
  ethereum,
12
13
  };
13
14
  export const supportedBaseAssetNames = Object.keys(assetApplications);
14
- export const applicationNameToBaseAssetName = Object.entries(assetApplications).reduce((mapping, [assetName, metadata]) => {
15
- mapping[metadata.applications[0].applicationName] = assetName;
15
+ export const applicationNameToBaseAssetNames = Object.entries(assetApplications).reduce((mapping, [assetName, metadata]) => {
16
+ for (const { applicationName } of metadata.applications) {
17
+ if (!Array.isArray(mapping[applicationName])) {
18
+ mapping[applicationName] = [];
19
+ }
20
+ const isPrimaryAssetForApplication = applications[applicationName]?.primaryAssetName === assetName;
21
+ if (isPrimaryAssetForApplication) {
22
+ mapping[applicationName].unshift(assetName);
23
+ }
24
+ else {
25
+ mapping[applicationName].push(assetName);
26
+ }
27
+ }
16
28
  return mapping;
17
29
  }, Object.create(null));
@@ -2,6 +2,7 @@ declare const metadata: {
2
2
  applications: {
3
3
  applicationName: string;
4
4
  supportedVersions: string;
5
+ primaryAssetName: string;
5
6
  }[];
6
7
  handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("libraries/hw-common/lib").HardwareWalletAssetHandler>;
7
8
  };
@@ -1,12 +1,7 @@
1
+ import applications from './applications';
1
2
  import ethereum from './ethereum';
2
3
  const metadata = {
3
- applications: [
4
- {
5
- applicationName: 'Polygon',
6
- supportedVersions: '^1.10.0',
7
- },
8
- ...ethereum.applications,
9
- ],
4
+ applications: [applications.Polygon, applications.Ethereum],
10
5
  handler: ethereum.handler,
11
6
  };
12
7
  export default metadata;
@@ -5,6 +5,7 @@ declare const metadata: {
5
5
  applications: {
6
6
  applicationName: string;
7
7
  supportedVersions: string;
8
+ primaryAssetName: string;
8
9
  }[];
9
10
  handler: typeof createHandler;
10
11
  };
@@ -3,6 +3,7 @@ import assert from 'minimalistic-assert';
3
3
  import bs58 from 'bs58';
4
4
  import { XPubUnsupportedError } from '@exodus/hw-common';
5
5
  import { RequiresBlindSigningError } from '../errors';
6
+ import applications from './applications';
6
7
  async function createHandler(transport) {
7
8
  const app = new AppSolana(transport);
8
9
  const getAddress = async (params) => {
@@ -63,12 +64,7 @@ async function createHandler(transport) {
63
64
  };
64
65
  }
65
66
  const metadata = {
66
- applications: [
67
- {
68
- applicationName: 'Solana',
69
- supportedVersions: '^1.4.0',
70
- },
71
- ],
67
+ applications: [applications.Solana],
72
68
  handler: createHandler,
73
69
  };
74
70
  export default metadata;
@@ -1,6 +1,6 @@
1
1
  import semver from 'semver';
2
2
  import { AssetUnsupportedError, DeviceLockedError, DeviceConnectionError, UserRefusedError, } from '@exodus/hw-common';
3
- import { applicationNameToBaseAssetName, assetApplications, supportedBaseAssetNames, } from './assets';
3
+ import { applicationNameToBaseAssetNames, assetApplications, supportedBaseAssetNames, } from './assets';
4
4
  import applicationFactory from './management/application';
5
5
  import { UnsupportedVersionError, ApplicationNotFoundError } from './errors';
6
6
  export class LedgerDevice {
@@ -105,16 +105,16 @@ export class LedgerDevice {
105
105
  const installedApplications = await this.#listApplications();
106
106
  const installedAssets = [];
107
107
  installedApplications.forEach(({ name: applicationName }) => {
108
- const assetName = applicationNameToBaseAssetName[applicationName];
109
- if (assetName)
110
- installedAssets.push(assetName);
108
+ const assetNames = applicationNameToBaseAssetNames[applicationName];
109
+ if (assetNames)
110
+ installedAssets.push(...assetNames);
111
111
  });
112
112
  return installedAssets;
113
113
  };
114
114
  listUseableAssetNames = async () => {
115
115
  const { name: applicationName } = await this.#getInformation();
116
- const assetName = applicationNameToBaseAssetName[applicationName];
117
- return assetName ? [assetName] : [];
116
+ const assetNames = applicationNameToBaseAssetNames[applicationName];
117
+ return assetNames || [];
118
118
  };
119
119
  getAddress = async (params) => {
120
120
  await this.ensureApplicationIsOpened(params.assetName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/hw-ledger",
3
- "version": "2.9.2",
3
+ "version": "2.9.3",
4
4
  "description": "The ledger module",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "scripts": {
22
22
  "build": "run -T tsc --build tsconfig.build.json",
23
- "build:watch": "run -T tsc --build tsconfig.build.json && (concurrently 'tsc --build -w tsconfig.build.json')",
23
+ "build:watch": "run -T tsc --build tsconfig.build.json && (concurrently 'run -T tsc --build -w tsconfig.build.json')",
24
24
  "clean": "run -T tsc --build --clean",
25
25
  "test": "run -T jest --testMatch='**/*.unit.test.js' --coverageDirectory coverage/unit",
26
26
  "zemu:install": "docker pull zondax/builder-zemu:speculos-745fe46f81cfc18114b94a37beaefb58a09c0fcd",
@@ -39,7 +39,7 @@
39
39
  "@exodus/ledgerhq-devices": "^8.1.0-exodus.3",
40
40
  "@exodus/ledgerhq-hw-app-eth": "^6.33.7-exodus.8",
41
41
  "@exodus/module": "^1.2.2",
42
- "@exodus/redux-dependency-injection": "^3.0.0",
42
+ "@exodus/redux-dependency-injection": "^4.0.0",
43
43
  "@exodus/secp256k1": "^4.0.2-exodus.0",
44
44
  "@ledgerhq/hw-app-solana": "^7.0.10",
45
45
  "@ledgerhq/hw-transport": "^6.28.5",
@@ -71,5 +71,5 @@
71
71
  "tiny-secp256k1": "^2.2.3",
72
72
  "ts-jest": "^29.0.3"
73
73
  },
74
- "gitHead": "3995391eb48639b2d60ced5224a6a8f4902a2466"
74
+ "gitHead": "221ffd05e9aa1c0ee82f3b8123b91d692066fa88"
75
75
  }