diff --git a/.changelog/unreleased/improvements/4218-normal-mode-display-tx-fees.md b/.changelog/unreleased/improvements/4218-normal-mode-display-tx-fees.md new file mode 100644 index 0000000000..2b6f860f26 --- /dev/null +++ b/.changelog/unreleased/improvements/4218-normal-mode-display-tx-fees.md @@ -0,0 +1,2 @@ +- Require the hardware wallet to display transaction fees in normal mode. + ([\#4218](https://github.com/anoma/namada/pull/4218)) \ No newline at end of file diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 7b175d79c5..76579ce7e8 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -1037,8 +1037,8 @@ pub mod testing { } prop_compose! { - /// Generate an arbitrary wrapper transaction - pub fn arb_wrapper_tx()( + /// Generate an arbitrary wrapper transaction. Do not check fee validity + pub fn arb_unchecked_wrapper_tx()( fee in arb_fee(), pk in arb_common_pk(), gas_limit in arb_gas_limit(), @@ -1051,6 +1051,18 @@ pub mod testing { } } + prop_compose! { + /// Generate an arbitrary wrapper transaction with valid fees + pub fn arb_wrapper_tx()( + wrapper in arb_unchecked_wrapper_tx().prop_filter( + "wrapper fees overflow", + |x| x.get_tx_fee().is_ok(), + ), + ) -> WrapperTx { + wrapper + } + } + prop_compose! { /// Generate an arbitrary transaction type pub fn arb_tx_type()(tx_type in prop_oneof![ diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index c3cb2427dc..b4be3c5e49 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -2079,6 +2079,12 @@ pub async fn to_ledger_vector( if let Some(wrapper) = tx.header.wrapper() { let fee_amount_per_gas_unit = to_ledger_decimal(&wrapper.fee.amount_per_gas_unit.to_string()); + let fee_limit = to_ledger_decimal( + &wrapper + .get_tx_fee() + .map_err(|e| Error::Other(format!("{}", e)))? + .to_string(), + ); tv.output_expert.extend(vec![ format!( "Timestamp : {}", @@ -2088,12 +2094,21 @@ pub async fn to_ledger_vector( format!("Gas limit : {}", u64::from(wrapper.gas_limit)), ]); if let Some(token) = tokens.get(&wrapper.fee.token) { + tv.output.push(format!( + "Fee : {} {}", + token.to_uppercase(), + fee_limit + )); tv.output_expert.push(format!( "Fees/gas unit : {} {}", token.to_uppercase(), fee_amount_per_gas_unit, )); } else { + tv.output.extend(vec![ + format!("Fee token : {}", wrapper.fee.token), + format!("Fee : {}", fee_limit), + ]); tv.output_expert.extend(vec![ format!("Fee token : {}", wrapper.fee.token), format!("Fees/gas unit : {}", fee_amount_per_gas_unit),