diff --git a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs index 09cb6f80f..a7e88c360 100644 --- a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs +++ b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs @@ -759,9 +759,9 @@ mod tests { } 2 => { assert_eq!(params.title, "Cardano"); - assert!(params.body.starts_with( - "Delegate voting for account #1 to type Always Abstain?" - )); + assert!(params + .body + .starts_with("Delegate voting for account #1 to type Always Abstain?")); true } 3 => { diff --git a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs index 225becf74..0e53e5dc9 100644 --- a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs +++ b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs @@ -172,12 +172,15 @@ pub fn encode_transaction_body( }) => { encoder.array(3)?.u8(9)?; encode_stake_credential(&mut encoder, keypath)?; - let drep_type = certificate::vote_delegation::CardanoDRepType::try_from(*r#type)?; + let drep_type = + certificate::vote_delegation::CardanoDRepType::try_from(*r#type)?; match drep_type { certificate::vote_delegation::CardanoDRepType::KeyHash => { encoder.array(2)?.u8(0)?; match drep_credhash { - Some(hash) if hash.len() == 28 => { encoder.bytes(hash)?;} + Some(hash) if hash.len() == 28 => { + encoder.bytes(hash)?; + } Some(_hash) => return Err(Error::InvalidInput), None => return Err(Error::InvalidInput), } @@ -185,7 +188,9 @@ pub fn encode_transaction_body( certificate::vote_delegation::CardanoDRepType::ScriptHash => { encoder.array(2)?.u8(1)?; match drep_credhash { - Some(hash) if hash.len() == 28 => { encoder.bytes(hash)?;} + Some(hash) if hash.len() == 28 => { + encoder.bytes(hash)?; + } Some(_hash) => return Err(Error::InvalidInput), None => return Err(Error::InvalidInput), } diff --git a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/certificates.rs b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/certificates.rs index 31f7f86f8..931905d8d 100644 --- a/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/certificates.rs +++ b/src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/certificates.rs @@ -95,40 +95,48 @@ pub async fn verify<'a>( }) => { validate_address_shelley_stake(keypath, Some(bip44_account))?; signing_keypaths.push(keypath); - let drep_type_name = match certificate::vote_delegation::CardanoDRepType::try_from(*r#type)? { - certificate::vote_delegation::CardanoDRepType::KeyHash => "Key Hash", - certificate::vote_delegation::CardanoDRepType::ScriptHash => "Script Hash", - certificate::vote_delegation::CardanoDRepType::AlwaysAbstain => "Always Abstain", - certificate::vote_delegation::CardanoDRepType::AlwaysNoConfidence => "Always No Confidence", - }; + let drep_type_name = + match certificate::vote_delegation::CardanoDRepType::try_from(*r#type)? { + certificate::vote_delegation::CardanoDRepType::KeyHash => "Key Hash", + certificate::vote_delegation::CardanoDRepType::ScriptHash => "Script Hash", + certificate::vote_delegation::CardanoDRepType::AlwaysAbstain => { + "Always Abstain" + } + certificate::vote_delegation::CardanoDRepType::AlwaysNoConfidence => { + "Always No Confidence" + } + }; match drep_credhash { - Some(hash) => { confirm::confirm(&confirm::Params { - title: params.name, - body: &format!( - "Delegate voting for account #{} to type {} and drep {}?", - keypath[2] + 1 - HARDENED, - drep_type_name, - hex::encode(hash), - ), - scrollable: true, - accept_is_nextarrow: true, - ..Default::default() - }) - .await?; } - None => { confirm::confirm(&confirm::Params { - title: params.name, - body: &format!( - "Delegate voting for account #{} to type {}?", - keypath[2] + 1 - HARDENED, - drep_type_name, - ), - scrollable: true, - accept_is_nextarrow: true, - ..Default::default() - }) - .await?; } + Some(hash) => { + confirm::confirm(&confirm::Params { + title: params.name, + body: &format!( + "Delegate voting for account #{} to type {} and drep {}?", + keypath[2] + 1 - HARDENED, + drep_type_name, + hex::encode(hash), + ), + scrollable: true, + accept_is_nextarrow: true, + ..Default::default() + }) + .await?; + } + None => { + confirm::confirm(&confirm::Params { + title: params.name, + body: &format!( + "Delegate voting for account #{} to type {}?", + keypath[2] + 1 - HARDENED, + drep_type_name, + ), + scrollable: true, + accept_is_nextarrow: true, + ..Default::default() + }) + .await?; + } } - } }; }