Skip to content

Commit

Permalink
Merge pull request #16 from Conflux-Chain/updateDoc2
Browse files Browse the repository at this point in the history
update doc
  • Loading branch information
Pana authored Jan 7, 2025
2 parents 2be8d52 + 2c12380 commit c16e864
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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"))'] }
42 changes: 28 additions & 14 deletions docs/how-to-use/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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)
Expand All @@ -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

Expand Down
15 changes: 12 additions & 3 deletions src/app_ui/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};

Expand All @@ -39,7 +40,8 @@ use alloc::{format, vec};
/// # Arguments
///
/// * `tx` - Transaction to be displayed for validation
pub fn ui_display_tx(tx: &Transaction) -> Result<bool, AppSW> {
#[allow(unused_variables)]
pub fn ui_display_tx(tx: &Transaction, ctx: &mut TxContext) -> Result<bool, AppSW> {
let fully_decoded = tx.fully_decoded();

let value_str = tx.value.cfx_str().ok_or(AppSW::TxDisplayFail)?;
Expand Down Expand Up @@ -122,13 +124,20 @@ pub fn ui_display_tx(tx: &Transaction) -> Result<bool, AppSW> {
#[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));
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/sign_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

#![no_std]
#![no_main]
#![allow(static_mut_refs)]
#![allow(unexpected_cfgs)]

mod utils;
mod app_ui {
Expand Down
12 changes: 8 additions & 4 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@ 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)]
pub fn get_element(&self, index: usize) -> Result<u8, AppSW> {
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])
}
Expand All @@ -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);
Expand Down

0 comments on commit c16e864

Please sign in to comment.