@exodus/hw-ledger 1.2.0 → 1.3.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/CHANGELOG.md +8 -0
- package/lib/module/assets/bitcoin.d.ts +9 -2
- package/lib/module/assets/ethereum.d.ts +2 -2
- package/lib/module/assets/index.d.ts +4 -2
- package/lib/module/assets/index.js +5 -0
- package/lib/module/assets/polygon.d.ts +1 -1
- package/lib/module/assets/solana.d.ts +2 -2
- package/lib/module/device.d.ts +3 -0
- package/lib/module/device.js +22 -1
- package/lib/module/discovery.d.ts +1 -0
- package/lib/module/discovery.js +8 -1
- package/lib/module/errors.d.ts +4 -0
- package/lib/module/errors.js +6 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [1.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@1.2.0...@exodus/hw-ledger@1.3.0) (2023-11-28)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add ability to retrieve supported, installed and useable assets ([#4901](https://github.com/ExodusMovement/exodus-hydra/issues/4901)) ([d821590](https://github.com/ExodusMovement/exodus-hydra/commit/d82159062aa497c1ae5bbe4362cce8a2aff0cc9c))
|
|
11
|
+
- add generic `Message` type in `SignMessageParams` ([#4895](https://github.com/ExodusMovement/exodus-hydra/issues/4895)) ([fb688ea](https://github.com/ExodusMovement/exodus-hydra/commit/fb688ea071c18a1a041bbd53869f7afdce2c0b1d))
|
|
12
|
+
- add ledger `getFirstDevice` helper ([#4897](https://github.com/ExodusMovement/exodus-hydra/issues/4897)) ([6a2b362](https://github.com/ExodusMovement/exodus-hydra/commit/6a2b362e69b46e0d19be80394ff6f5533f6139ba))
|
|
13
|
+
|
|
6
14
|
## [1.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@1.1.0...@exodus/hw-ledger@1.2.0) (2023-11-27)
|
|
7
15
|
|
|
8
16
|
### Features
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Bytes, HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
export interface BitcoinMessage {
|
|
4
|
+
rawMessage?: Bytes;
|
|
5
|
+
bip322Message?: {
|
|
6
|
+
address: string;
|
|
7
|
+
message: Bytes;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler<BitcoinMessage>>;
|
|
4
11
|
declare const metadata: {
|
|
5
12
|
applicationName: string;
|
|
6
13
|
supportedVersions: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
declare function createHandler(transport: Transport): Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
declare const metadata: {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
type HandlerFactory = (transport: Transport) => Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
type HandlerFactory = (transport: Transport) => Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
type AssetMetadata = {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
|
7
7
|
handler: HandlerFactory;
|
|
8
8
|
};
|
|
9
9
|
export declare const assetApplications: Record<string, AssetMetadata>;
|
|
10
|
+
export declare const supportedBaseAssetNames: string[];
|
|
11
|
+
export declare const applicationNameToBaseAssetName: Record<string, string>;
|
|
10
12
|
export {};
|
|
@@ -8,3 +8,8 @@ export const assetApplications = {
|
|
|
8
8
|
polygon,
|
|
9
9
|
solana,
|
|
10
10
|
};
|
|
11
|
+
export const supportedBaseAssetNames = Object.keys(assetApplications);
|
|
12
|
+
export const applicationNameToBaseAssetName = Object.entries(assetApplications).reduce((mapping, [assetName, metadata]) => {
|
|
13
|
+
mapping[metadata.applicationName] = assetName;
|
|
14
|
+
return mapping;
|
|
15
|
+
}, Object.create(null));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const metadata: {
|
|
2
2
|
applicationName: string;
|
|
3
3
|
supportedVersions: string;
|
|
4
|
-
handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("libraries/hw-common/lib").
|
|
4
|
+
handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("libraries/hw-common/lib").HardwareWalletAssetHandler<import("libraries/hw-common/lib").Message>>;
|
|
5
5
|
};
|
|
6
6
|
export default metadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
declare function createHandler(transport: Transport): Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
declare const metadata: {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
package/lib/module/device.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export type Dependencies = {
|
|
|
8
8
|
export declare class LedgerDevice implements HardwareWalletDevice {
|
|
9
9
|
#private;
|
|
10
10
|
constructor({ transportFactory, descriptor }: Dependencies);
|
|
11
|
+
listSupportedAssetNames: () => Promise<string[]>;
|
|
12
|
+
listInstalledAssetNames: () => Promise<string[]>;
|
|
13
|
+
listUseableAssetNames: () => Promise<string[]>;
|
|
11
14
|
getAddress: (params: GetAddressParams) => Promise<string>;
|
|
12
15
|
getXPub: (params: GetXPubParams) => Promise<string>;
|
|
13
16
|
getPublicKey: (params: GetPublicKeyParams) => Promise<Readonly<Uint8Array>>;
|
package/lib/module/device.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { AssetUnsupportedError, DeviceLockedError, DeviceConnectionError, UserRefusedError, } from '@exodus/hw-common';
|
|
3
|
-
import { assetApplications } from './assets';
|
|
3
|
+
import { applicationNameToBaseAssetName, assetApplications, supportedBaseAssetNames, } from './assets';
|
|
4
4
|
import applicationFactory from './management/application';
|
|
5
5
|
import { UnsupportedVersionError } from './errors';
|
|
6
6
|
export class LedgerDevice {
|
|
@@ -69,6 +69,27 @@ export class LedgerDevice {
|
|
|
69
69
|
throw new UnsupportedVersionError(desiredApplicationInfo.version, supportedVersions);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
listSupportedAssetNames = async () => {
|
|
73
|
+
return supportedBaseAssetNames;
|
|
74
|
+
};
|
|
75
|
+
listInstalledAssetNames = async () => {
|
|
76
|
+
const { name: applicationName } = await this.#getInformation();
|
|
77
|
+
if (applicationName !== 'BOLOS')
|
|
78
|
+
await this.#quitApplication();
|
|
79
|
+
const installedApplications = await this.#listApplications();
|
|
80
|
+
const installedAssets = [];
|
|
81
|
+
installedApplications.forEach(({ name: applicationName }) => {
|
|
82
|
+
const assetName = applicationNameToBaseAssetName[applicationName];
|
|
83
|
+
if (assetName)
|
|
84
|
+
installedAssets.push(assetName);
|
|
85
|
+
});
|
|
86
|
+
return installedAssets;
|
|
87
|
+
};
|
|
88
|
+
listUseableAssetNames = async () => {
|
|
89
|
+
const { name: applicationName } = await this.#getInformation();
|
|
90
|
+
const assetName = applicationNameToBaseAssetName[applicationName];
|
|
91
|
+
return assetName ? [assetName] : [];
|
|
92
|
+
};
|
|
72
93
|
getAddress = async (params) => {
|
|
73
94
|
await this.#ensureApplicationIsOpened(params.assetName);
|
|
74
95
|
return this.#runInSession(async (transport) => {
|
|
@@ -14,6 +14,7 @@ export declare class LedgerDiscovery extends ExodusModule implements HardwareWal
|
|
|
14
14
|
#private;
|
|
15
15
|
constructor({ logger, transportsFactories }: Dependencies);
|
|
16
16
|
list: () => Promise<HardwareWalletDescriptor[]>;
|
|
17
|
+
getFirstDevice: () => Promise<import("@exodus/hw-common").HardwareWalletDevice>;
|
|
17
18
|
}
|
|
18
19
|
declare const _default: {
|
|
19
20
|
id: string;
|
package/lib/module/discovery.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ExodusModule from '@exodus/module';
|
|
2
2
|
import { APDU_PORT } from './constants';
|
|
3
3
|
import { LedgerDevice } from './device';
|
|
4
|
-
import { UnknownTransportError } from './errors';
|
|
4
|
+
import { NoDeviceFoundError, UnknownTransportError } from './errors';
|
|
5
5
|
const MODULE_ID = 'ledgerDiscovery';
|
|
6
6
|
export class LedgerDiscovery extends ExodusModule {
|
|
7
7
|
#transportsFactories;
|
|
@@ -48,6 +48,13 @@ export class LedgerDiscovery extends ExodusModule {
|
|
|
48
48
|
}
|
|
49
49
|
return descriptors;
|
|
50
50
|
};
|
|
51
|
+
getFirstDevice = async () => {
|
|
52
|
+
const devices = await this.list();
|
|
53
|
+
if (devices[0]) {
|
|
54
|
+
return devices[0].get();
|
|
55
|
+
}
|
|
56
|
+
throw new NoDeviceFoundError();
|
|
57
|
+
};
|
|
51
58
|
}
|
|
52
59
|
const createLedgerDiscovery = (deps) => new LedgerDiscovery({ ...deps });
|
|
53
60
|
export default {
|
package/lib/module/errors.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ export declare class UnknownTransportError extends HardwareWalletError {
|
|
|
3
3
|
name: string;
|
|
4
4
|
constructor(transportName?: string);
|
|
5
5
|
}
|
|
6
|
+
export declare class NoDeviceFoundError extends HardwareWalletError {
|
|
7
|
+
name: string;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
6
10
|
export declare class UnsupportedVersionError extends HardwareWalletError {
|
|
7
11
|
name: string;
|
|
8
12
|
constructor(actualVersion: string, supportedVersions: string);
|
package/lib/module/errors.js
CHANGED
|
@@ -5,6 +5,12 @@ export class UnknownTransportError extends HardwareWalletError {
|
|
|
5
5
|
super(`unknown transport type ${transportName || ''}`);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
export class NoDeviceFoundError extends HardwareWalletError {
|
|
9
|
+
name = 'NoDeviceFoundError';
|
|
10
|
+
constructor() {
|
|
11
|
+
super(`unable to find a connected device`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
8
14
|
export class UnsupportedVersionError extends HardwareWalletError {
|
|
9
15
|
name = 'UnsupportedVersionError';
|
|
10
16
|
constructor(actualVersion, supportedVersions) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hw-ledger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The ledger module",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"lint:fix": "yarn lint --fix"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@exodus/ethersproject-abi": "^5.4.2-exodus.2",
|
|
32
33
|
"@exodus/ethersproject-transactions": "^5.4.2-exodus.0",
|
|
33
|
-
"@exodus/hw-common": "^1.
|
|
34
|
+
"@exodus/hw-common": "^1.2.0",
|
|
34
35
|
"@exodus/secp256k1": "^4.0.2-exodus.0",
|
|
35
36
|
"@ledgerhq/hw-app-eth": "^6.33.6",
|
|
36
37
|
"@ledgerhq/hw-app-solana": "^7.0.10",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"ts-jest": "^29.0.3",
|
|
62
63
|
"typescript": "^4.7.3"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "7406c4024c15818322f299ff30f2be0686ec3bd8"
|
|
65
66
|
}
|