@exodus/hw-ledger 3.0.0 → 3.1.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 +10 -0
- package/lib/module/device.d.ts +3 -3
- package/lib/module/device.js +6 -3
- package/lib/module/discovery.js +14 -8
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@3.0.0...@exodus/hw-ledger@3.1.0) (2024-10-17)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- support adding model to wallet account ([#9936](https://github.com/ExodusMovement/exodus-hydra/issues/9936)) ([8c858f6](https://github.com/ExodusMovement/exodus-hydra/commit/8c858f6e08e41bee3261f444c3d25e8bdd385014))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- unify user refused error handling ([#10052](https://github.com/ExodusMovement/exodus-hydra/issues/10052)) ([db85d10](https://github.com/ExodusMovement/exodus-hydra/commit/db85d108333630d09bad545c5ec1169b937e08fe))
|
|
15
|
+
|
|
6
16
|
## [3.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.13.1...@exodus/hw-ledger@3.0.0) (2024-10-15)
|
|
7
17
|
|
|
8
18
|
### ⚠ BREAKING CHANGES
|
package/lib/module/device.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { GetAddressParams, GetPublicKeyParams, GetXPubParams, HardwareWalletDevice, SignMessageParams, SignTransactionParams } from '@exodus/hw-common';
|
|
1
|
+
import type { GetAddressParams, GetPublicKeyParams, GetXPubParams, HardwareWalletDescriptor, HardwareWalletDevice, SignMessageParams, SignTransactionParams } from '@exodus/hw-common';
|
|
2
2
|
import type { TransportFactory } from './types';
|
|
3
3
|
import type { Atom } from '@exodus/atoms';
|
|
4
|
-
export type Descriptor = unknown;
|
|
5
4
|
export type Dependencies = {
|
|
6
5
|
transportFactory: TransportFactory;
|
|
7
|
-
descriptor:
|
|
6
|
+
descriptor: HardwareWalletDescriptor;
|
|
8
7
|
walletPolicyAtom: Atom<Record<string, Buffer>>;
|
|
9
8
|
};
|
|
10
9
|
export declare class LedgerDevice implements HardwareWalletDevice {
|
|
11
10
|
#private;
|
|
12
11
|
constructor({ transportFactory, descriptor, walletPolicyAtom }: Dependencies);
|
|
12
|
+
get descriptor(): HardwareWalletDescriptor;
|
|
13
13
|
ensureApplicationIsOpened: (baseAssetName: string) => Promise<void>;
|
|
14
14
|
listSupportedAssetNames: () => Promise<string[]>;
|
|
15
15
|
listInstalledAssetNames: () => Promise<string[]>;
|
package/lib/module/device.js
CHANGED
|
@@ -12,8 +12,11 @@ export class LedgerDevice {
|
|
|
12
12
|
this.#descriptor = descriptor;
|
|
13
13
|
this.#walletPolicyAtom = walletPolicyAtom;
|
|
14
14
|
}
|
|
15
|
+
get descriptor() {
|
|
16
|
+
return this.#descriptor;
|
|
17
|
+
}
|
|
15
18
|
#runInSession = async (operation, expectErrorWhenClosing = false) => {
|
|
16
|
-
const transport = await this.#transportFactory.open(this.#descriptor);
|
|
19
|
+
const transport = await this.#transportFactory.open(this.#descriptor.internalDescriptor);
|
|
17
20
|
try {
|
|
18
21
|
return await operation(transport);
|
|
19
22
|
}
|
|
@@ -158,8 +161,8 @@ function transformToCommonError(_err) {
|
|
|
158
161
|
if (err.name === 'LockedDeviceError') {
|
|
159
162
|
return new DeviceLockedError();
|
|
160
163
|
}
|
|
161
|
-
if (err.name === 'UserRefusedOnDevice') {
|
|
162
|
-
return new UserRefusedError();
|
|
164
|
+
if (err.name === 'UserRefusedOnDevice' || err.statusCode === 0x69_85) {
|
|
165
|
+
return new UserRefusedError(true);
|
|
163
166
|
}
|
|
164
167
|
if ([
|
|
165
168
|
'HwTransportError',
|
package/lib/module/discovery.js
CHANGED
|
@@ -95,52 +95,58 @@ export class LedgerDiscovery {
|
|
|
95
95
|
for (const [transportName, transportFactory] of Object.entries(this.#transportsFactories)) {
|
|
96
96
|
switch (transportName) {
|
|
97
97
|
case 'usb':
|
|
98
|
-
const deviceList = await transportFactory.list();
|
|
98
|
+
const deviceList = (await transportFactory.list());
|
|
99
99
|
const usbDeviceList = deviceList.map((hidDevice) => {
|
|
100
100
|
const deviceModel = identifyUSBProductId(hidDevice.productId);
|
|
101
|
-
|
|
101
|
+
const descriptor = {
|
|
102
102
|
name: deviceModel?.productName ?? 'Ledger USB',
|
|
103
103
|
manufacturer: 'ledger',
|
|
104
104
|
transport: 'usb',
|
|
105
105
|
model: deviceModel?.id ?? 'unknown',
|
|
106
|
+
internalDescriptor: hidDevice,
|
|
106
107
|
get: async () => new LedgerDevice({
|
|
107
108
|
transportFactory,
|
|
108
|
-
descriptor
|
|
109
|
+
descriptor,
|
|
109
110
|
walletPolicyAtom: this.#walletPolicyAtom,
|
|
110
111
|
}),
|
|
111
112
|
};
|
|
113
|
+
return descriptor;
|
|
112
114
|
});
|
|
113
115
|
descriptors.push(...usbDeviceList);
|
|
114
116
|
break;
|
|
115
117
|
case 'bluetooth':
|
|
116
118
|
const bluetoothDeviceList = Object.values(this.#discoveredBluetoothDevices).map((bluetoothDevice) => {
|
|
117
119
|
const deviceModel = getInfosForServiceUuid(bluetoothDevice.serviceUUIDs?.[0] ?? '')?.deviceModel;
|
|
118
|
-
|
|
120
|
+
const descriptor = {
|
|
119
121
|
name: bluetoothDevice.localName ?? deviceModel?.productName,
|
|
120
122
|
manufacturer: 'ledger',
|
|
121
123
|
transport: 'bluetooth',
|
|
122
124
|
model: deviceModel?.id ?? 'unknown',
|
|
125
|
+
internalDescriptor: bluetoothDevice,
|
|
123
126
|
get: async () => new LedgerDevice({
|
|
124
127
|
transportFactory,
|
|
125
|
-
descriptor
|
|
128
|
+
descriptor,
|
|
126
129
|
walletPolicyAtom: this.#walletPolicyAtom,
|
|
127
130
|
}),
|
|
128
131
|
};
|
|
132
|
+
return descriptor;
|
|
129
133
|
});
|
|
130
134
|
descriptors.push(...bluetoothDeviceList);
|
|
131
135
|
break;
|
|
132
136
|
case 'tcp':
|
|
133
|
-
|
|
137
|
+
const descriptor = {
|
|
134
138
|
name: 'TCP Emulator',
|
|
135
139
|
manufacturer: 'ledger',
|
|
136
140
|
transport: 'tcp',
|
|
137
141
|
model: 'unknown',
|
|
142
|
+
internalDescriptor: { apduPort: APDU_PORT },
|
|
138
143
|
get: async () => new LedgerDevice({
|
|
139
144
|
transportFactory,
|
|
140
|
-
descriptor
|
|
145
|
+
descriptor,
|
|
141
146
|
walletPolicyAtom: this.#walletPolicyAtom,
|
|
142
147
|
}),
|
|
143
|
-
}
|
|
148
|
+
};
|
|
149
|
+
descriptors.push(descriptor);
|
|
144
150
|
break;
|
|
145
151
|
default:
|
|
146
152
|
throw new UnknownTransportError(transportName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hw-ledger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "The ledger module",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@exodus/bip322-js": "^1.1.0-exodus.4",
|
|
35
35
|
"@exodus/bitcoinjs-lib": "^6.1.5-exodus.0",
|
|
36
36
|
"@exodus/ethersproject-transactions": "^5.4.2-exodus.0",
|
|
37
|
-
"@exodus/hw-common": "^
|
|
37
|
+
"@exodus/hw-common": "^3.0.0",
|
|
38
38
|
"@exodus/ledger-bitcoin": "^0.2.3-exodus.3",
|
|
39
39
|
"@exodus/ledgerhq-devices": "^8.1.0-exodus.3",
|
|
40
40
|
"@exodus/ledgerhq-hw-app-eth": "^6.33.7-exodus.8",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"tiny-secp256k1": "^2.2.3",
|
|
66
66
|
"ts-jest": "^29.0.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "a4f949331317cbeb49ea2392703722914a67fcac"
|
|
69
69
|
}
|