Skip to content

Commit 64edaae

Browse files
authored
Merge pull request #2975 from input-output-hk/feature/ddw-1092-support-for-ledger-nano-s-plus
2 parents 8c81e9d + 930d833 commit 64edaae

File tree

17 files changed

+133
-73
lines changed

17 files changed

+133
-73
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
### Features
66

7+
- Added support for Ledger Nano S Plus ([PR 2975](https://github.com/input-output-hk/daedalus/pull/2975))
8+
9+
## 4.10.0
10+
11+
### Features
12+
713
- Implemented hover tooltips for menu ([PR 2938](https://github.com/input-output-hk/daedalus/pull/2938))
814
- Improved UI regarding the Hardware Wallet public key export error ([PR 2922](https://github.com/input-output-hk/daedalus/pull/2922))
915
- Added ASCII name to token header when metadata name is missing ([PR 2904](https://github.com/input-output-hk/daedalus/pull/2904))

hardware-wallet-tests/connect-multiple-hardware-wallets.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const run = () => {
1919
createTestInstructions([
2020
'Start test runner',
2121
'Plug Ledger Nano S to your computer',
22+
'Plug Ledger Nano S Plus to your computer',
2223
'Plug Ledger Nano X to your computer',
2324
]);
2425

@@ -27,6 +28,10 @@ export const run = () => {
2728
disconnected: false,
2829
deviceModel: 'nanoS',
2930
},
31+
{
32+
disconnected: false,
33+
deviceModel: 'nanoSP',
34+
},
3035
{
3136
disconnected: false,
3237
deviceModel: 'nanoX',

hardware-wallet-tests/disconnect-multiple-hardware-wallets.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const getNextExpectedSequence = createSequentialResult([
1414
disconnected: false,
1515
deviceModel: 'nanoS',
1616
},
17+
{
18+
disconnected: false,
19+
deviceModel: 'nanoSP',
20+
},
1721
{
1822
disconnected: false,
1923
deviceModel: 'nanoX',
@@ -22,6 +26,10 @@ const getNextExpectedSequence = createSequentialResult([
2226
disconnected: true,
2327
deviceModel: 'nanoS',
2428
},
29+
{
30+
disconnected: true,
31+
deviceModel: 'nanoSP',
32+
},
2533
{
2634
disconnected: true,
2735
deviceModel: 'nanoX',
@@ -37,8 +45,10 @@ export const run = () => {
3745

3846
createTestInstructions([
3947
'Connect Nano S',
48+
'Connect Nano S Plus',
4049
'Connect Nano X',
4150
'Disconnect Nano S',
51+
'Disconnect Nano S Plus',
4252
'Disconnect Nano X',
4353
]);
4454

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"dependencies": {
199199
"@cardano-foundation/ledgerjs-hw-app-cardano": "5.0.0",
200200
"@iohk-jormungandr/wallet-js": "0.5.0-pre7",
201-
"@ledgerhq/hw-transport-node-hid": "5.51.1",
201+
"@ledgerhq/hw-transport-node-hid": "6.27.1",
202202
"aes-js": "3.1.2",
203203
"bech32": "2.0.0",
204204
"bignumber.js": "9.0.1",

source/common/types/hardware-wallets.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BridgeInfo, Device as TrezorDevice, UdevInfo } from 'trezor-connect';
22

33
export type BIP32Path = Array<number>;
4-
export type LedgerModel = 'nanoS' | 'nanoX';
4+
export type LedgerModel = 'nanoS' | 'nanoSP' | 'nanoX';
55
export type TrezorModel = '1' | 'T';
66
export type DeviceType = 'ledger' | 'trezor';
77
export type DeviceEvent =
@@ -24,11 +24,13 @@ export type DeviceEvent =
2424
| 'unreadable-device';
2525
export const DeviceModels: {
2626
LEDGER_NANO_S: LedgerModel;
27+
LEDGER_NANO_S_PLUS: LedgerModel;
2728
LEDGER_NANO_X: LedgerModel;
2829
TREZOR_ONE: TrezorModel;
2930
TREZOR_T: TrezorModel;
3031
} = {
3132
LEDGER_NANO_S: 'nanoS',
33+
LEDGER_NANO_S_PLUS: 'nanoSP',
3234
LEDGER_NANO_X: 'nanoX',
3335
TREZOR_ONE: '1',
3436
TREZOR_T: 'T',

source/main/ipc/getHardwareWalletChannel.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { IpcSender } from '../../common/ipc/lib/IpcChannel';
2121
import { logger } from '../utils/logging';
2222
import {
2323
HardwareWalletTransportDeviceRequest,
24+
LedgerDevicePayload,
2425
TransportDevice,
2526
} from '../../common/types/hardware-wallets.types';
2627

@@ -79,6 +80,19 @@ class EventObserver {
7980
if (!devicesMemo[device.path]) {
8081
logger.info('[HW-DEBUG] CONSTRUCTOR ADD');
8182

83+
const walletData: LedgerDevicePayload = {
84+
disconnected: false,
85+
deviceType: 'ledger',
86+
deviceId: null,
87+
// Available only when Cardano APP opened
88+
deviceModel: deviceModel.id,
89+
// e.g. nanoS
90+
deviceName: deviceModel.productName,
91+
// e.g. Test Name
92+
path: device.path,
93+
product: device.product,
94+
};
95+
8296
try {
8397
const transport = await TransportNodeHid.open(device.path);
8498
const AdaConnection = new AppAda(transport);
@@ -88,22 +102,14 @@ class EventObserver {
88102
AdaConnection,
89103
};
90104
this.getHardwareWalletConnectionChannel.send(
91-
{
92-
disconnected: false,
93-
deviceType: 'ledger',
94-
deviceId: null,
95-
// Available only when Cardano APP opened
96-
deviceModel: deviceModel.id,
97-
// e.g. nanoS
98-
deviceName: deviceModel.productName,
99-
// e.g. Test Name
100-
path: device.path,
101-
product: device.product,
102-
},
105+
walletData,
103106
this.mainWindow
104107
);
105-
} catch (e) {
106-
logger.info('[HW-DEBUG] CONSTRUCTOR error');
108+
} catch (error) {
109+
logger.error('[HW-DEBUG] CONSTRUCTOR error', {
110+
walletData,
111+
error,
112+
});
107113
}
108114
}
109115
} else {

source/main/ipc/hardwareWallets/ledger/deviceDetection/deviceDetection.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ export const deviceDetection = (
2727
) => {
2828
// detect existing connected devices without blocking the subscription registration
2929
// https://github.com/LedgerHQ/ledgerjs/blob/master/packages/hw-transport-node-hid-singleton/src/TransportNodeHid.ts#L56
30-
Promise.resolve(DeviceTracker.getDevices()).then((devices) => {
31-
// this needs to run asynchronously so the subscription is defined during this phase
32-
for (const device of devices) {
33-
onAdd({
34-
type: 'add',
35-
...DeviceTracker.getTrackedDeviceByPath(device.path),
36-
});
37-
}
38-
});
30+
Promise.resolve(DeviceTracker.getDevices())
31+
.then((devices) => {
32+
// this needs to run asynchronously so the subscription is defined during this phase
33+
for (const device of devices) {
34+
onAdd({
35+
type: 'add',
36+
...DeviceTracker.getTrackedDeviceByPath(device.path),
37+
});
38+
}
39+
})
40+
.catch((e) => {
41+
logger.error(`[HW-DEBUG] ERROR getting devices ${JSON.stringify(e)}`);
42+
});
3943

4044
const handleOnAdd = (trackedDevice: TrackedDevice) =>
4145
onAdd({ type: 'add', ...trackedDevice });
@@ -48,6 +52,7 @@ export const deviceDetection = (
4852
};
4953

5054
export const waitForDevice = () => {
55+
logger.debug('[HW-DEBUG] Wait for device ...');
5156
return new Promise<TrackedDevice>((resolve) => {
5257
const currentDevices = DeviceTracker.getDevices();
5358

source/main/ipc/hardwareWallets/ledger/deviceDetection/deviceTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class DeviceTracker {
3333
constructor() {
3434
this.knownDevices = new Map();
3535

36-
getDevices().forEach((d) => this.knownDevices.set(d.path, d));
36+
getDevices()?.forEach((d) => this.knownDevices.set(d.path, d));
3737
}
3838

3939
findNewDevice() {

source/main/ipc/hardwareWallets/ledger/deviceDetection/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type Device = {
1313
usage: number;
1414
};
1515

16+
// TODO: Use native types instead of creating new ones https://github.com/LedgerHQ/ledgerjs/blob/23ba9fa883db9f49f81de236c9232df2c5ca1020/packages/devices/src/index.ts#L197
1617
export type DeviceModel = {
1718
id: string;
1819
productName: string;
Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)