Skip to content

Commit

Permalink
Merge pull request #77 from LedgerHQ/y333/settings_management
Browse files Browse the repository at this point in the history
Y333/settings management
  • Loading branch information
yogh333 authored Oct 1, 2024
2 parents 5718519 + 1181357 commit ef33289
Show file tree
Hide file tree
Showing 121 changed files with 23 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "app-boilerplate-rust"
version = "1.6.1"
version = "1.6.2"
authors = ["yhql", "agrojean-ledger"]
edition = "2021"

[dependencies]
ledger_device_sdk = { version="1.16.1" }
ledger_device_sdk = "1.17.2"
include_gif = "1.2.0"
serde = {version="1.0.192", default_features = false, features = ["derive"]}
serde-json-core = { git = "https://github.com/rust-embedded-community/serde-json-core"}
Expand Down
2 changes: 1 addition & 1 deletion src/app_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn ui_menu_main(_: &mut Comm) -> NbglHomeAndSettings {
// Display the home screen.
NbglHomeAndSettings::new()
.glyph(&FERRIS)
.settings(settings.get_mut_ref(), &settings_strings)
.settings(settings.get_mut(), &settings_strings)
.infos(
"Boilerplate",
env!("CARGO_PKG_VERSION"),
Expand Down
2 changes: 1 addition & 1 deletion src/app_ui/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn ui_display_tx(tx: &Tx) -> Result<bool, AppSW> {
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("crab_64x64.gif", NBGL));
// Create NBGL review. Maximum number of fields and string buffer length can be customised
// with constant generic parameters of NbglReview. Default values are 32 and 1024 respectively.
let mut review: NbglReview = NbglReview::new()
let review: NbglReview = NbglReview::new()
.titles(
"Review transaction\nto send CRAB",
"",
Expand Down
20 changes: 14 additions & 6 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ledger_device_sdk::NVMData;
const SETTINGS_SIZE: usize = 10;
#[link_section = ".nvm_data"]
static mut DATA: NVMData<AtomicStorage<[u8; SETTINGS_SIZE]>> =
NVMData::new(AtomicStorage::new(&[0u8; 10]));
NVMData::new(AtomicStorage::new(&[0u8; SETTINGS_SIZE]));

#[derive(Clone, Copy)]
pub struct Settings;
Expand All @@ -19,23 +19,31 @@ impl Default for Settings {
impl Settings {
#[inline(never)]
#[allow(unused)]
pub fn get_mut_ref(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> {
pub fn get_mut(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> {
return unsafe { DATA.get_mut() };
}

#[inline(never)]
#[allow(unused)]
pub fn get_ref(&mut self) -> &AtomicStorage<[u8; SETTINGS_SIZE]> {
return unsafe { DATA.get_ref() };
}

#[allow(unused)]
pub fn get_element(&self, index: usize) -> u8 {
let settings = unsafe { DATA.get_mut() };
settings.get_ref()[index]
let storage = unsafe { DATA.get_ref() };
let settings = storage.get_ref();
settings[index]
}

#[allow(unused)]
// Not used in this boilerplate, but can be used to set a value in the settings
pub fn set_element(&self, index: usize, value: u8) {
let mut updated_data: [u8; SETTINGS_SIZE] = unsafe { *DATA.get_mut().get_ref() };
let storage = unsafe { DATA.get_mut() };
let mut updated_data = *storage.get_ref();
updated_data[index] = value;
unsafe {
DATA.get_mut().update(&updated_data);
storage.update(&updated_data);
}
}
}
Binary file added tests/.DS_Store
Binary file not shown.
Binary file modified 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.
Binary file modified tests/snapshots/flex/test_sign_tx_long_tx/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 modified tests/snapshots/flex/test_sign_tx_long_tx/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 modified tests/snapshots/flex/test_sign_tx_refused/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 modified tests/snapshots/flex/test_sign_tx_refused/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 modified tests/snapshots/flex/test_sign_tx_short_tx/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 modified tests/snapshots/flex/test_sign_tx_short_tx/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 modified tests/snapshots/flex/test_sign_tx_short_tx_no_memo/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 modified tests/snapshots/flex/test_sign_tx_short_tx_no_memo/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 removed tests/snapshots/nanos/test_app_mainmenu/00000.png
Binary file not shown.
Binary file removed tests/snapshots/nanos/test_app_mainmenu/00001.png
Binary file not shown.
Binary file removed tests/snapshots/nanos/test_app_mainmenu/00002.png
Binary file not shown.
Binary file removed tests/snapshots/nanos/test_app_mainmenu/00003.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00000.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00001.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00002.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00003.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00004.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00005.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00006.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00007.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00008.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00009.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00010.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00011.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00012.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00013.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00014.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00015.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00016.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00017.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00018.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00019.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00020.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00021.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00022.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00023.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00024.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00025.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00026.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00027.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00028.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00029.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_long_tx/00030.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00000.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00001.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00002.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00003.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00004.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00005.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00006.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00007.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00008.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_refused/00009.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00000.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00001.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00002.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00003.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00004.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00005.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00006.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00007.png
Diff not rendered.
Binary file removed tests/snapshots/nanos/test_sign_tx_short_tx/00008.png
Diff not rendered.
Binary file modified tests/snapshots/nanosp/test_app_mainmenu/00001.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00000.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00011.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_long_tx/00012.png
Binary file removed tests/snapshots/nanosp/test_sign_tx_long_tx/00013.png
Diff not rendered.
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00000.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00004.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_refused/00005.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00000.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00004.png
Binary file modified tests/snapshots/nanosp/test_sign_tx_short_tx/00005.png
Binary file modified tests/snapshots/nanox/test_app_mainmenu/00001.png
Binary file modified tests/snapshots/nanox/test_sign_tx_long_tx/00000.png
Binary file modified tests/snapshots/nanox/test_sign_tx_long_tx/00011.png
Binary file modified tests/snapshots/nanox/test_sign_tx_long_tx/00012.png
Binary file removed tests/snapshots/nanox/test_sign_tx_long_tx/00013.png
Diff not rendered.
Binary file modified tests/snapshots/nanox/test_sign_tx_refused/00000.png
Binary file modified tests/snapshots/nanox/test_sign_tx_refused/00004.png
Binary file modified tests/snapshots/nanox/test_sign_tx_refused/00005.png
Binary file modified tests/snapshots/nanox/test_sign_tx_short_tx/00000.png
Binary file modified tests/snapshots/nanox/test_sign_tx_short_tx/00004.png
Binary file modified tests/snapshots/nanox/test_sign_tx_short_tx/00005.png
Binary file modified tests/snapshots/stax/test_app_mainmenu/00002.png

0 comments on commit ef33289

Please sign in to comment.