Skip to content

Commit 2dac01d

Browse files
Merge pull request #50 from LedgerHQ/fix
[fix] When parsing a manifest, 'nanos+' was converted into 'nanosp'
2 parents 8ff4a1c + 780f755 commit 2dac01d

8 files changed

Lines changed: 27 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.10.1] - 2025-05-14
9+
10+
### Fix
11+
12+
- Parsing 'nanos+' in manifests now returns 'nanosp', which is breaking when this name is used to
13+
gather a SDK tag.
14+
Added a specific "sdk_name" field in the JSON / `Device` to be returned when parsing the manifest,
15+
to get back the previous, 0.9.1- behavior.
16+
817
## [0.10.0] - 2025-05-09
918

1019
### Added

src/ledgered/devices/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from enum import IntEnum, auto
44
from pathlib import Path
55
from pydantic.dataclasses import dataclass
6+
from typing import Optional
67

78

89
class DeviceType(IntEnum):
@@ -26,6 +27,7 @@ class Device:
2627
touchable: bool = True
2728
deprecated: bool = False
2829
names: list[str] = dataclasses.field(default_factory=lambda: [])
30+
_sdk_name: Optional[str] = None
2931

3032
@property
3133
def name(self) -> str:
@@ -34,6 +36,14 @@ def name(self) -> str:
3436
"""
3537
return self.type.name.lower()
3638

39+
@property
40+
def sdk_name(self) -> str:
41+
"""
42+
Returns the SDK name, meaning the device name used to tag the SDK.
43+
If the device does not have a SDK name, returns the default name
44+
"""
45+
return self._sdk_name or self.name
46+
3747
@property
3848
def is_nano(self):
3949
"""

src/ledgered/devices/devices.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{"type": "nanos", "resolution": {"x": 128, "y": 32}, "touchable": false, "deprecated": true},
3-
{"type": "nanosp", "resolution": {"x": 128, "y": 64}, "touchable": false, "names": ["nanos+", "nanos2", "nanosplus"]},
3+
{"type": "nanosp", "resolution": {"x": 128, "y": 64}, "touchable": false, "names": ["nanos+", "nanos2", "nanosplus"], "_sdk_name": "nanos+"},
44
{"type": "nanox", "resolution": {"x": 128, "y": 64}, "touchable": false},
55
{"type": "flex", "resolution": {"x": 480, "y": 600}},
66
{"type": "stax", "resolution": {"x": 400, "y": 670}}

src/ledgered/manifest/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, sdk: str, build_directory: Union[str, Path], devices: Iterabl
1818
raise ValueError(f"'{sdk}' unknown. Must be either 'C' or 'Rust'")
1919
self.sdk = sdk
2020
self.build_directory = Path(build_directory)
21-
self.devices = JsonSet(Devices.get_by_name(device).name for device in devices)
21+
self.devices = JsonSet(Devices.get_by_name(device).sdk_name for device in devices)
2222

2323
@property
2424
def is_rust(self) -> bool:

tests/_data/full_correct.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[app]
22
build_directory = "./"
33
sdk = "C"
4-
devices = ["nanox"]
4+
devices = ["nanos+"]
55

66
[use_cases]
77
debug = "DEBUG=1"

tests/functional/manifest/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get(self):
2020
FULL_EXPECTED_TEXT = """build_directory: .
2121
sdk: c
2222
devices:
23-
0. nanox
23+
0. nanos+
2424
use_cases:
2525
debug: DEBUG=1
2626
test: DEBUG=1
@@ -31,7 +31,7 @@ def get(self):
3131
FULL_EXPECTED_JSON = {
3232
"build_directory": ".",
3333
"sdk": "c",
34-
"devices": ["nanox"],
34+
"devices": ["nanos+"],
3535
"use_cases": {"debug": "DEBUG=1", "test": "DEBUG=1"},
3636
"tests": {"unit_directory": "tests/unit", "pytest_directory": "tests/functional"},
3737
}

tests/unit/devices/test___init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def test_get_by_name_ok(self):
5353
device = Devices.get_by_name("nanos+")
5454
self.assertIsInstance(device, Device)
5555
self.assertEqual(device.type, DeviceType.NANOSP)
56+
self.assertEqual(device.name, "nanosp")
57+
self.assertEqual(device.sdk_name, "nanos+")
5658

5759
def test_get_by_name_nok(self):
5860
with self.assertRaises(KeyError):

tests/unit/manifest/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test___init___ok_complete(self):
1212
config = AppConfig(sdk=sdk, build_directory=str(bd), devices=devices)
1313
self.assertEqual(config.sdk, sdk.lower())
1414
self.assertEqual(config.build_directory, bd)
15-
self.assertEqual(config.devices, {"nanos", "nanosp"})
15+
self.assertEqual(config.devices, {"nanos", "nanos+"})
1616
self.assertTrue(config.is_rust)
1717
self.assertFalse(config.is_c)
1818

0 commit comments

Comments
 (0)