Skip to content

Commit

Permalink
Add Flex support.
Browse files Browse the repository at this point in the history
  • Loading branch information
agrojean-ledger committed Apr 30, 2024
1 parent 7ac5f79 commit 7f82152
Show file tree
Hide file tree
Showing 37 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/app_ui/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
use crate::AppSW;
use core::str::from_utf8_mut;

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview};

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
use ledger_device_sdk::nbgl::{NbglAddressConfirm, NbglGlyph};

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
use include_gif::include_gif;

// Display only the last 20 bytes of the address
Expand All @@ -43,7 +43,7 @@ pub fn ui_display_pk(addr: &[u8]) -> Result<bool, AppSW> {
let addr_hex = from_utf8_mut(&mut addr_hex).unwrap();
addr_hex[2..].make_ascii_uppercase();

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
{
let my_field = [Field {
name: "Address",
Expand All @@ -63,7 +63,7 @@ pub fn ui_display_pk(addr: &[u8]) -> Result<bool, AppSW> {
Ok(my_review.show())
}

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
{
// Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph.
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL));
Expand Down
16 changes: 8 additions & 8 deletions src/app_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
use include_gif::include_gif;
use ledger_device_sdk::io::{Comm, Event};

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::bitmaps::{Glyph, BACK, CERTIFICATE, DASHBOARD_X};
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::gadgets::{EventOrPageIndex, MultiPageMenu, Page};

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
use ledger_device_sdk::nbgl::{NbglGlyph, NbglHome};

use crate::Instruction;

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
fn ui_about_menu(comm: &mut Comm) -> Event<Instruction> {
let pages = [
&Page::from((["Rust Boilerplate", "(c) 2023 Ledger"], true)),
Expand All @@ -43,7 +43,7 @@ fn ui_about_menu(comm: &mut Comm) -> Event<Instruction> {
}
}

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {
const APP_ICON: Glyph = Glyph::from_include(include_gif!("crab.gif"));
let pages = [
Expand All @@ -64,14 +64,14 @@ pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {
}
}

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
pub fn ui_menu_main(comm: &mut Comm) -> Event<Instruction> {
// Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph.
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL));
// Display the home screen.
NbglHome::new(comm)
.app_name("Boilerplate")
.info_contents(env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_AUTHORS"))
.glyph(&FERRIS)
// .app_name("Boilerplate")
.infos("Boilerplate", env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_AUTHORS"))
.show()
}
12 changes: 6 additions & 6 deletions src/app_ui/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use crate::handlers::sign_tx::Tx;
use crate::utils::concatenate;
use crate::AppSW;

#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::bitmaps::{CROSSMARK, EYE, VALIDATE_14};
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::gadgets::{Field, MultiFieldReview};

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
use include_gif::include_gif;
#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
use ledger_device_sdk::nbgl::{Field, NbglGlyph, NbglReview};

use numtoa::NumToA;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn ui_display_tx(tx: &Tx) -> Result<bool, AppSW> {
];

// Create transaction review
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
{
let my_review = MultiFieldReview::new(
&my_fields,
Expand All @@ -88,7 +88,7 @@ pub fn ui_display_tx(tx: &Tx) -> Result<bool, AppSW> {
Ok(my_review.show())
}

#[cfg(target_os = "stax")]
#[cfg(any(target_os = "stax", target_os = "flex"))]
{
// Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph.
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL));
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ use handlers::{
};
use ledger_device_sdk::io::{ApduHeader, Comm, Event, Reply, StatusWords};
#[cfg(feature = "pending_review_screen")]
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
use ledger_device_sdk::ui::gadgets::display_pending_review;
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
ledger_device_sdk::set_panic!(ledger_device_sdk::exiting_panic);

// P2 for last APDU to receive.
Expand Down Expand Up @@ -128,7 +128,7 @@ extern "C" fn sample_main() {
// Developer mode / pending review popup
// must be cleared with user interaction
#[cfg(feature = "pending_review_screen")]
#[cfg(not(target_os = "stax"))]
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
display_pending_review(&mut comm);

let mut tx_ctx = TxContext::new();
Expand Down
Binary file added tests/snapshots/flex/test_app_mainmenu/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_app_mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/snapshots/flex/test_app_mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/stax/test_app_mainmenu/00000.png
Binary file modified tests/snapshots/stax/test_app_mainmenu/00002.png
Binary file modified tests/snapshots/stax/test_get_public_key_confirm_refused/00002.png
Binary file modified tests/snapshots/stax/test_sign_tx_long_tx/00005.png
Binary file modified tests/snapshots/stax/test_sign_tx_refused/00005.png
Binary file modified tests/snapshots/stax/test_sign_tx_short_tx/00004.png

0 comments on commit 7f82152

Please sign in to comment.