Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display transaction fees in normal mode #4218

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Require the hardware wallet to display transaction fees in normal mode.
([\#4218](https://github.com/anoma/namada/pull/4218))
16 changes: 14 additions & 2 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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![
Expand Down
15 changes: 15 additions & 0 deletions crates/sdk/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 : {}",
Expand All @@ -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),
Expand Down
Loading