Skip to content

Commit 443ed9f

Browse files
committed
Update after PR review
1 parent 762b447 commit 443ed9f

File tree

10 files changed

+32
-64
lines changed

10 files changed

+32
-64
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-ledger/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-ledger"
3-
version = "1.7.0"
3+
version = "1.8.0"
44
authors = ["yhql", "agrojean-ledger", "y333"]
55
description = "Build and sideload Ledger devices apps"
66
categories = ["development-tools::cargo-plugins"]

cargo-ledger/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ cargo ledger build flex
5050

5151
Loading on device can optionally be performed by appending `--load` or `-l` to the command.
5252

53-
By default, this program will attempt to build the current program with in `release` mode (full command: `cargo build --release --target=nanos --message-format=json`)
53+
By default, this program will attempt to build the current program with in `release` mode (full command: `cargo build --release --target=nanosplus --message-format=json`)
5454

5555
Arguments can be passed to modify this behaviour after inserting a `--` like so:
5656

5757
```
58-
cargo ledger build nanos --load -- --features one -Z unstable-options --out-dir ./output/
58+
cargo ledger build nanosplus --load -- --features one -Z unstable-options --out-dir ./output/
5959
```

cargo-ledger/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ mod tests {
356356
assert_eq!(metadata_ledger.curve, ["secp256k1"]);
357357
assert_eq!(metadata_ledger.flags, "0x38");
358358
assert_eq!(metadata_ledger.path, ["'44/123"]);
359-
360-
//assert_eq!(metadata_nanos.icon, "./assets/nanos.gif")
361359
}
362360

363361
#[test]
@@ -371,7 +369,6 @@ mod tests {
371369
assert_eq!(metadata_ledger.curve, ["secp256k1"]);
372370
assert_eq!(metadata_ledger.flags, "0x38");
373371
assert_eq!(metadata_ledger.path, ["'44/123"]);
374-
//assert_eq!(metadata_nanos.icon, "./assets/nanos.gif")
375372
}
376373

377374
#[test]
@@ -385,6 +382,5 @@ mod tests {
385382
assert_eq!(metadata_ledger.curve, ["secp256k1"]);
386383
assert_eq!(metadata_ledger.flags, "0");
387384
assert_eq!(metadata_ledger.path, ["'44/123"]);
388-
//assert_eq!(metadata_nanos.icon, "nanos.gif")
389385
}
390386
}

cargo-ledger/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn install_targets() {
3939

4040
// Retrieve each target file independently
4141
// TODO: handle target.json modified upstream
42-
for target in &["nanos", "nanox", "nanosplus", "stax", "flex"] {
42+
for target in &["nanox", "nanosplus", "stax", "flex"] {
4343
let outfilepath = sysroot.join(target).join("target.json");
4444
let targetpath =
4545
outfilepath.clone().into_os_string().into_string().unwrap();

cargo-ledger/tests/valid/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ curve = ["secp256k1"]
1212
flags = "0x38"
1313
path = ["'44/123"]
1414

15-
[package.metadata.ledger.nanos]
16-
icon = "./assets/nanos.gif"
17-
1815
[package.metadata.ledger.nanox]
1916
icon = "./assets/nanox.gif"
2017

cargo-ledger/tests/valid_outdated/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ version = "0.0.0"
66
name = "test"
77
path = ""
88

9-
[package.metadata.nanos]
9+
[package.metadata.ledger]
1010
api_level = "1"
1111
name = "TestApp"
1212
curve = ["secp256k1"]
1313
flags = "0"
14-
icon = "nanos.gif"
15-
icon_small = "nanox.gif"
14+
nanosplus.icon = "nanosplus.gif"
15+
nanox.icon = "nanox.gif"
1616
path = ["'44/123"]

cargo-ledger/tests/valid_variant/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ name = "TestApp"
1111
curve = ["secp256k1"]
1212
flags = "0x38"
1313
path = ["'44/123"]
14-
nanos.icon = "./assets/nanos.gif"
1514
nanox.icon = "./assets/nanox.gif"
1615
nanosplus.icon = "./assets/nanosplus.gif"

ledger_device_sdk/src/ui/gadgets.rs

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -423,44 +423,28 @@ impl<'a> Page<'a> {
423423
self.label.place(Location::Middle, Layout::Centered, true);
424424
}
425425
PageStyle::PictureNormal => {
426-
let mut icon_x = 16;
427-
let mut icon_y = 8;
428-
if cfg!(target_os = "nanos") {
429-
self.label
430-
.place(Location::Middle, Layout::Custom(41), false);
431-
} else {
432-
icon_x = 57;
433-
icon_y = 10;
434-
self.label
435-
.place(Location::Custom(28), Layout::Centered, false);
436-
}
426+
let icon_x = 57;
427+
let icon_y = 10;
428+
self.label
429+
.place(Location::Custom(28), Layout::Centered, false);
437430
if let Some(glyph) = self.glyph {
438431
let icon = Icon::from(glyph);
439432
icon.set_x(icon_x).set_y(icon_y).display();
440433
}
441434
}
442435
PageStyle::PictureBold => {
443-
let mut icon_x = 56;
444-
let mut icon_y = 2;
445-
if cfg!(target_os = "nanos") {
446-
self.label[0].place(Location::Bottom, Layout::Centered, true);
447-
} else {
448-
icon_x = 57;
449-
icon_y = 17;
450-
self.label[0].place(Location::Custom(35), Layout::Centered, true);
451-
self.label[1].place(Location::Custom(49), Layout::Centered, true);
452-
}
436+
let icon_x = 57;
437+
let icon_y = 17;
438+
self.label[0].place(Location::Custom(35), Layout::Centered, true);
439+
self.label[1].place(Location::Custom(49), Layout::Centered, true);
453440
if let Some(glyph) = self.glyph {
454441
let icon = Icon::from(glyph);
455442
icon.set_x(icon_x).set_y(icon_y).display();
456443
}
457444
}
458445
PageStyle::BoldNormal => {
459446
let padding = 1;
460-
let mut max_text_lines = 3;
461-
if cfg!(target_os = "nanos") {
462-
max_text_lines = 1;
463-
}
447+
let max_text_lines = 3;
464448
let total_height = (OPEN_SANS[0].height * max_text_lines) as usize
465449
+ OPEN_SANS[1].height as usize
466450
+ 2 * padding as usize;
@@ -469,29 +453,21 @@ impl<'a> Page<'a> {
469453
self.label[0].place(Location::Custom(cur_y), Layout::Centered, true);
470454
cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize;
471455

472-
// If the device is a Nano S, display the second label as
473-
// a single line of text
474-
if cfg!(target_os = "nanos") {
475-
self.label[1].place(Location::Custom(cur_y), Layout::Centered, false);
476-
}
477-
// Otherwise, display the second label as up to 3 lines of text
478-
else {
479-
let mut indices = [(0, 0); 3];
480-
let len = self.label[1].len();
481-
for (i, indice) in indices.iter_mut().enumerate() {
482-
let start = (i * MAX_CHAR_PER_LINE).min(len);
483-
if start >= len {
484-
break; // Break if we reach the end of the string
485-
}
486-
let end = (start + MAX_CHAR_PER_LINE).min(len);
487-
*indice = (start, end);
488-
(&self.label[1][start..end]).place(
489-
Location::Custom(cur_y),
490-
Layout::Centered,
491-
false,
492-
);
493-
cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize;
456+
let mut indices = [(0, 0); 3];
457+
let len = self.label[1].len();
458+
for (i, indice) in indices.iter_mut().enumerate() {
459+
let start = (i * MAX_CHAR_PER_LINE).min(len);
460+
if start >= len {
461+
break; // Break if we reach the end of the string
494462
}
463+
let end = (start + MAX_CHAR_PER_LINE).min(len);
464+
*indice = (start, end);
465+
(&self.label[1][start..end]).place(
466+
Location::Custom(cur_y),
467+
Layout::Centered,
468+
false,
469+
);
470+
cur_y += OPEN_SANS[0].height as usize + 2 * padding as usize;
495471
}
496472
}
497473
}

ledger_secure_sdk_sys/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Provides access to low-level APIs to the operating system of Ledger devices.
55

66
## Build
77

8-
Depending on the target (`--target nanos`, `--target nanox`, ...), this crate will `git clone` the appropriate branch (`API_LEVEL_x`) of the [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk/) and compile the subset of files necessary for the [Rust SDK](https://github.com/LedgerHQ/ledger-nanos-sdk/) to work.
8+
Depending on the target (`--target nanosplus`, `--target nanox`, ...), this crate will `git clone` the appropriate branch (`API_LEVEL_x`) of the [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk/) and compile the subset of files necessary for the [Rust SDK](https://github.com/LedgerHQ/ledger-device-rust-sdk/) to work.
99

1010
To use an already-cloned C SDK, you can pass its path through the environment variable `LEDGER_SDK_PATH=/path/to/c_sdk` or through `cargo`'s `--config` flag:
1111

0 commit comments

Comments
 (0)