Skip to content

Commit

Permalink
update stax ui logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Pana committed Jan 7, 2025
1 parent 833eefc commit 4ae9e07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 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,7 @@ use alloc::{format, vec};
/// # Arguments
///
/// * `tx` - Transaction to be displayed for validation
pub fn ui_display_tx(tx: &Transaction) -> Result<bool, AppSW> {
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 +123,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

0 comments on commit 4ae9e07

Please sign in to comment.