diff --git a/Cargo.toml b/Cargo.toml index a7ffaab..806c533 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ rustc-hex = { version = "2.1.0", default-features = false } opt-level = 'z' lto = true -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] } - [features] default = ["pending_review_screen"] pending_review_screen = [] @@ -45,3 +42,6 @@ icon = "icons/cfx_32.gif" [package.metadata.ledger.flex] icon = "icons/cfx_40.gif" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] } diff --git a/docs/how-to-use/readme.md b/docs/how-to-use/readme.md index aad3ddd..8587eab 100644 --- a/docs/how-to-use/readme.md +++ b/docs/how-to-use/readme.md @@ -21,7 +21,8 @@ A Ledger Device is a hardware wallet that is considered one of the most secure w 2. The latest firmware is installed (Ledger Nano S Plus). 3. Ledger Live is ready to use. 4. Install the latest version of [Conflux Fluent Wallet](https://fluentwallet.com/) (above 2.8.0) - ![](./imgs/fluent-home.jpg) + +![](./imgs/fluent-home.jpg) ## Video Guide @@ -48,16 +49,25 @@ https://youtu.be/QaDE8k57dGQ ![](./imgs/ledger-conflux-ready.jpg) 3. Open the Conflux Fluent Wallet Application. 4. Open settings(top right) and choose the "Account Management" option. - ![](./imgs/account-management.jpg) + +![](./imgs/account-management.jpg) + 5. Click the "Add Account" button. - ![](./imgs/account-add.jpg) + +![](./imgs/account-add.jpg) + 6. Choose hardware wallet and make your hardware wallet ready. - ![](./imgs/account-add-choose-hardware.jpg) - ![](./imgs/account-add-ledger-guide.jpg) + +![](./imgs/account-add-choose-hardware.jpg) +![](./imgs/account-add-ledger-guide.jpg) + 7. Choose address and Click Import button - ![](./imgs/fluent-import-choose-address.jpg) + +![](./imgs/fluent-import-choose-address.jpg) + 8. Success - ![](./imgs/account-add-success.jpg) + +![](./imgs/account-add-success.jpg) ## View Account Balance @@ -75,7 +85,9 @@ The copy icon and QR code icon are located on the right side of the address. 1. Click the `Send` button on the Fluent Wallet. 2. Fill in the recipient address, choose token to send and fill in amount to send. - ![](./imgs/fluent-send-tx.jpg) + +![](./imgs/fluent-send-tx.jpg) + 3. Click the `Next` button. And confirm the transaction on your Ledger Device. ![](./imgs/ledger-review-tx1.jpg) ![](./imgs/ledger-review-tx-amount.jpg) @@ -86,14 +98,16 @@ The copy icon and QR code icon are located on the right side of the address. ![](./imgs/ledger-review-tx-reject.jpg) 4. If everything is correct, in the `Approve` page, click both left and right buttons on your Ledger Device to confirm the transaction. 5. The transaction is now sent and you can view it in the transaction history. - ![](./imgs/tx-history-entry.jpg) - ![](./imgs/tx-history.jpg) + +![](./imgs/tx-history-entry.jpg) +![](./imgs/tx-history.jpg) + 6. If you are sending tokens, you need to enable the "Blind Signing" in the Ledger Device. - ![](./imgs/ledger-setting-2.jpg) - Click both left and right buttons on your Ledger Device to enable the "Blind Signing". - ![](./imgs/ledger-setting-1.jpg) +![](./imgs/ledger-setting-2.jpg) +Click both left and right buttons on your Ledger Device to enable the "Blind Signing". +![](./imgs/ledger-setting-1.jpg) 7. A blind signing warning will appear when you send tokens. - ![](./imgs/ledger-review-tx-blind-sign.jpg) +![](./imgs/ledger-review-tx-blind-sign.jpg) ## FAQs diff --git a/src/app_ui/sign.rs b/src/app_ui/sign.rs index 7e657a4..0ace3b4 100644 --- a/src/app_ui/sign.rs +++ b/src/app_ui/sign.rs @@ -15,6 +15,7 @@ * limitations under the License. *****************************************************************************/ use crate::cfx_addr::{cfx_addr_encode, Network}; +use crate::handlers::sign_tx::TxContext; use crate::settings::Settings; use crate::types::{Transaction, U256}; use crate::AppSW; @@ -28,7 +29,7 @@ use ledger_device_sdk::ui::{ #[cfg(any(target_os = "stax", target_os = "flex"))] use include_gif::include_gif; #[cfg(any(target_os = "stax", target_os = "flex"))] -use ledger_device_sdk::nbgl::{Field, NbglChoice, NbglGlyph, NbglReview}; +use ledger_device_sdk::nbgl::{Field, NbglChoice, NbglGlyph, NbglReview, PageIndex}; use alloc::{format, vec}; @@ -39,7 +40,8 @@ use alloc::{format, vec}; /// # Arguments /// /// * `tx` - Transaction to be displayed for validation -pub fn ui_display_tx(tx: &Transaction) -> Result { +#[allow(unused_variables)] +pub fn ui_display_tx(tx: &Transaction, ctx: &mut TxContext) -> Result { let fully_decoded = tx.fully_decoded(); let value_str = tx.value.cfx_str().ok_or(AppSW::TxDisplayFail)?; @@ -122,13 +124,20 @@ pub fn ui_display_tx(tx: &Transaction) -> Result { #[cfg(any(target_os = "stax", target_os = "flex"))] { if !fully_decoded && settings.get_element(0)? == 0 { - let _confirmed = NbglChoice::new().show( + let confirmed = NbglChoice::new().show( "This transaction cannot be clear-signed", "Enable blind signing in the settings to sign this transaction.", "Go to settings", "Reject transaction", ); + + if confirmed { + ctx.home.set_start_page(PageIndex::Settings(0)); + } + return Ok(false); + } else { + ctx.home.set_start_page(PageIndex::Home); } // Load glyph from 64x64 4bpp gif file with include_gif macro. Creates an NBGL compatible glyph. const CFX: NbglGlyph = NbglGlyph::from_include(include_gif!("icons/cfx_64.gif", NBGL)); diff --git a/src/handlers/sign_tx.rs b/src/handlers/sign_tx.rs index 4d6dcef..291b190 100644 --- a/src/handlers/sign_tx.rs +++ b/src/handlers/sign_tx.rs @@ -99,7 +99,7 @@ pub fn handler_sign_tx( // Display transaction. If user approves // the transaction, sign it. Otherwise, // return a "deny" status word. - if ui_display_tx(&tx)? { + if ui_display_tx(&tx, ctx)? { ctx.review_finished = true; compute_signature_and_append(comm, ctx) } else { diff --git a/src/main.rs b/src/main.rs index 66a312f..b4acd97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,6 @@ #![no_std] #![no_main] -#![allow(static_mut_refs)] -#![allow(unexpected_cfgs)] mod utils; mod app_ui { diff --git a/src/settings.rs b/src/settings.rs index e6e608e..afa28c8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -21,13 +21,15 @@ impl Settings { #[inline(never)] #[allow(unused)] pub fn get_mut(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> { - unsafe { DATA.get_mut() } + let data = &raw mut DATA; + unsafe { (*data).get_mut() } } #[inline(never)] #[allow(unused)] pub fn get_ref(&mut self) -> &AtomicStorage<[u8; SETTINGS_SIZE]> { - unsafe { DATA.get_ref() } + let data = &raw const DATA; + unsafe { (*data).get_ref() } } #[allow(unused)] @@ -35,7 +37,8 @@ impl Settings { if index >= SETTINGS_SIZE { return Err(AppSW::InternalError); } - let storage = unsafe { DATA.get_ref() }; + let data = &raw const DATA; + let storage = unsafe { (*data).get_ref() }; let settings = storage.get_ref(); Ok(settings[index]) } @@ -46,7 +49,8 @@ impl Settings { if index >= SETTINGS_SIZE { return Err(AppSW::InternalError); } - let storage = unsafe { DATA.get_mut() }; + let data = &raw mut DATA; + let storage = unsafe { (*data).get_mut() }; let mut updated_data = *storage.get_ref(); updated_data[index] = value; storage.update(&updated_data);