Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
NickeZ committed Nov 26, 2024
1 parent f26ccf0 commit 8162e4f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,25 @@ pub fn encode_transaction_body<W: Write>(
}) => {
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),
}
}
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),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}

}
};
}
Expand Down

0 comments on commit 8162e4f

Please sign in to comment.