Skip to content

Commit

Permalink
Use dependencies from the new SDK workspace.
Browse files Browse the repository at this point in the history
Code cleanup.
  • Loading branch information
agrojean-ledger committed Nov 16, 2023
1 parent b57d5bd commit 97e3e2e
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 107 deletions.
123 changes: 73 additions & 50 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ authors = ["yhql", "agrojean-ledger"]
edition = "2021"

[dependencies]
nanos_sdk = { git = "https://github.com/LedgerHQ/ledger-nanos-sdk.git" }
nanos_ui = { git = "https://github.com/LedgerHQ/ledger-nanos-ui.git" }
include_gif = { git = "https://github.com/LedgerHQ/sdk_include_gif" }
ledger_device_sdk = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "add-ui-gadgets" }
ledger_device_ui_sdk = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "add-ui-gadgets" }
ledger_secure_sdk_sys = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "add-ui-gadgets" }
include_gif = { git = "https://github.com/LedgerHQ/ledger-device-rust-sdk.git", branch = "add-ui-gadgets" }
numtoa = "0.2.4"

[profile.release]
opt-level = 'z'
lto = true

[features]
pending_review_screen = ["nanos_sdk/pending_review_screen"]
pending_review_screen = ["ledger_device_sdk/pending_review_screen"]

[package.metadata.ledger]
curve = ["secp256k1"]
Expand All @@ -29,4 +30,4 @@ icon = "crab.gif"
icon = "crab_14x14.gif"

[package.metadata.ledger.nanosplus]
icon = "crab_14x14.gif"
icon = "crab_14x14.gif"
6 changes: 3 additions & 3 deletions src/app_ui/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
use crate::utils::{concatenate, to_hex_all_caps};
use crate::SW_DISPLAY_ADDRESS_FAIL;
use core::str::from_utf8;
use nanos_sdk::io::Reply;
use nanos_ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
use nanos_ui::ui::{Field, MultiFieldReview};
use ledger_device_sdk::io::Reply;
use ledger_device_ui_sdk::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
use ledger_device_ui_sdk::ui::{Field, MultiFieldReview};

// Display only the last 20 bytes of the address
const DISPLAY_ADDR_BYTES_LEN: usize = 20;
Expand Down
12 changes: 6 additions & 6 deletions src/app_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*****************************************************************************/

use include_gif::include_gif;
use nanos_sdk::io;
use nanos_ui::bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X};
use nanos_ui::ui::{EventOrPageIndex, MultiPageMenu, Page};
use ledger_device_sdk::io::{ApduHeader, Comm, Event};
use ledger_device_ui_sdk::bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X};
use ledger_device_ui_sdk::ui::{EventOrPageIndex, MultiPageMenu, Page};

fn ui_about_menu(comm: &mut io::Comm) -> io::Event<io::ApduHeader> {
fn ui_about_menu(comm: &mut Comm) -> Event<ApduHeader> {
let pages = [
&Page::from((["Rust Boilerplate", "(c) 2023 Ledger"], true)),
&Page::from(("Back", &BACK)),
Expand All @@ -36,7 +36,7 @@ fn ui_about_menu(comm: &mut io::Comm) -> io::Event<io::ApduHeader> {
}
}

pub fn ui_menu_main(comm: &mut io::Comm) -> io::Event<io::ApduHeader> {
pub fn ui_menu_main(comm: &mut Comm) -> Event<ApduHeader> {
const APP_ICON: Glyph = Glyph::from_include(include_gif!("crab.gif"));
let pages = [
// The from trait allows to create different styles of pages
Expand All @@ -51,7 +51,7 @@ pub fn ui_menu_main(comm: &mut io::Comm) -> io::Event<io::ApduHeader> {
EventOrPageIndex::Event(e) => return e,
i => match i {
EventOrPageIndex::Index(2) => return ui_about_menu(comm),
EventOrPageIndex::Index(3) => nanos_sdk::exit_app(0),
EventOrPageIndex::Index(3) => ledger_device_sdk::exit_app(0),
_ => (),
},
}
Expand Down
7 changes: 3 additions & 4 deletions src/app_ui/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ use crate::handlers::sign_tx::Tx;
use crate::utils::{concatenate, to_hex_all_caps};
use crate::SW_TX_DISPLAY_FAIL;
use core::str::from_utf8;
use nanos_sdk::io::Reply;
use nanos_ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
use nanos_ui::ui::{Field, MultiFieldReview};
use ledger_device_sdk::io::Reply;
use ledger_device_ui_sdk::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
use ledger_device_ui_sdk::ui::{Field, MultiFieldReview};
use numtoa::NumToA;
// use nanos_sdk::testing;

pub fn ui_display_tx(tx: &Tx) -> Result<bool, Reply> {
// Format amount value
Expand Down
12 changes: 6 additions & 6 deletions src/handlers/get_public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
use crate::app_ui::address::ui_display_pk;
use crate::utils::{read_bip32_path, MAX_ALLOWED_PATH_LEN};
use crate::{SW_DENY, SW_DISPLAY_ADDRESS_FAIL};
use nanos_sdk::bindings::{
use ledger_device_sdk::ecc::{Secp256k1, SeedDerive};
use ledger_device_sdk::io::{Comm, Reply};
use ledger_device_sdk::testing;
use ledger_secure_sdk_sys::{
cx_hash_no_throw, cx_hash_t, cx_keccak_init_no_throw, cx_sha3_t, CX_LAST, CX_OK,
};
use nanos_sdk::ecc::{Secp256k1, SeedDerive};
use nanos_sdk::io::{Comm, Reply};
use nanos_sdk::testing;

pub fn handler_get_public_key(comm: &mut Comm, display: bool) -> Result<(), Reply> {
let mut path = [0u32; MAX_ALLOWED_PATH_LEN];
Expand Down Expand Up @@ -51,9 +51,9 @@ pub fn handler_get_public_key(comm: &mut Comm, display: bool) -> Result<(), Repl
&mut keccak256.header as *mut cx_hash_t,
CX_LAST,
pk_ptr,
64 as u32,
64 as usize,
address.as_mut_ptr(),
address.len() as u32,
address.len(),
) != CX_OK
{
return Err(Reply(SW_DISPLAY_ADDRESS_FAIL));
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/get_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*****************************************************************************/

use core::str::FromStr;
use nanos_sdk::io;
use ledger_device_sdk::io;

pub fn handler_get_version(comm: &mut io::Comm) -> Result<(), io::Reply> {
if let Some((major, minor, patch)) = parse_version_string(env!("CARGO_PKG_VERSION")) {
Expand Down
Loading

0 comments on commit 97e3e2e

Please sign in to comment.