Skip to content

Commit 5ce4a18

Browse files
authored
Merge pull request #1328 from NickeZ/rustfmt
rustfmt
2 parents f26ccf0 + 8162e4f commit 5ce4a18

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,9 @@ mod tests {
759759
}
760760
2 => {
761761
assert_eq!(params.title, "Cardano");
762-
assert!(params.body.starts_with(
763-
"Delegate voting for account #1 to type Always Abstain?"
764-
));
762+
assert!(params
763+
.body
764+
.starts_with("Delegate voting for account #1 to type Always Abstain?"));
765765
true
766766
}
767767
3 => {

src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/cbor.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,25 @@ pub fn encode_transaction_body<W: Write>(
172172
}) => {
173173
encoder.array(3)?.u8(9)?;
174174
encode_stake_credential(&mut encoder, keypath)?;
175-
let drep_type = certificate::vote_delegation::CardanoDRepType::try_from(*r#type)?;
175+
let drep_type =
176+
certificate::vote_delegation::CardanoDRepType::try_from(*r#type)?;
176177
match drep_type {
177178
certificate::vote_delegation::CardanoDRepType::KeyHash => {
178179
encoder.array(2)?.u8(0)?;
179180
match drep_credhash {
180-
Some(hash) if hash.len() == 28 => { encoder.bytes(hash)?;}
181+
Some(hash) if hash.len() == 28 => {
182+
encoder.bytes(hash)?;
183+
}
181184
Some(_hash) => return Err(Error::InvalidInput),
182185
None => return Err(Error::InvalidInput),
183186
}
184187
}
185188
certificate::vote_delegation::CardanoDRepType::ScriptHash => {
186189
encoder.array(2)?.u8(1)?;
187190
match drep_credhash {
188-
Some(hash) if hash.len() == 28 => { encoder.bytes(hash)?;}
191+
Some(hash) if hash.len() == 28 => {
192+
encoder.bytes(hash)?;
193+
}
189194
Some(_hash) => return Err(Error::InvalidInput),
190195
None => return Err(Error::InvalidInput),
191196
}

src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction/certificates.rs

+40-32
Original file line numberDiff line numberDiff line change
@@ -95,40 +95,48 @@ pub async fn verify<'a>(
9595
}) => {
9696
validate_address_shelley_stake(keypath, Some(bip44_account))?;
9797
signing_keypaths.push(keypath);
98-
let drep_type_name = match certificate::vote_delegation::CardanoDRepType::try_from(*r#type)? {
99-
certificate::vote_delegation::CardanoDRepType::KeyHash => "Key Hash",
100-
certificate::vote_delegation::CardanoDRepType::ScriptHash => "Script Hash",
101-
certificate::vote_delegation::CardanoDRepType::AlwaysAbstain => "Always Abstain",
102-
certificate::vote_delegation::CardanoDRepType::AlwaysNoConfidence => "Always No Confidence",
103-
};
98+
let drep_type_name =
99+
match certificate::vote_delegation::CardanoDRepType::try_from(*r#type)? {
100+
certificate::vote_delegation::CardanoDRepType::KeyHash => "Key Hash",
101+
certificate::vote_delegation::CardanoDRepType::ScriptHash => "Script Hash",
102+
certificate::vote_delegation::CardanoDRepType::AlwaysAbstain => {
103+
"Always Abstain"
104+
}
105+
certificate::vote_delegation::CardanoDRepType::AlwaysNoConfidence => {
106+
"Always No Confidence"
107+
}
108+
};
104109
match drep_credhash {
105-
Some(hash) => { confirm::confirm(&confirm::Params {
106-
title: params.name,
107-
body: &format!(
108-
"Delegate voting for account #{} to type {} and drep {}?",
109-
keypath[2] + 1 - HARDENED,
110-
drep_type_name,
111-
hex::encode(hash),
112-
),
113-
scrollable: true,
114-
accept_is_nextarrow: true,
115-
..Default::default()
116-
})
117-
.await?; }
118-
None => { confirm::confirm(&confirm::Params {
119-
title: params.name,
120-
body: &format!(
121-
"Delegate voting for account #{} to type {}?",
122-
keypath[2] + 1 - HARDENED,
123-
drep_type_name,
124-
),
125-
scrollable: true,
126-
accept_is_nextarrow: true,
127-
..Default::default()
128-
})
129-
.await?; }
110+
Some(hash) => {
111+
confirm::confirm(&confirm::Params {
112+
title: params.name,
113+
body: &format!(
114+
"Delegate voting for account #{} to type {} and drep {}?",
115+
keypath[2] + 1 - HARDENED,
116+
drep_type_name,
117+
hex::encode(hash),
118+
),
119+
scrollable: true,
120+
accept_is_nextarrow: true,
121+
..Default::default()
122+
})
123+
.await?;
124+
}
125+
None => {
126+
confirm::confirm(&confirm::Params {
127+
title: params.name,
128+
body: &format!(
129+
"Delegate voting for account #{} to type {}?",
130+
keypath[2] + 1 - HARDENED,
131+
drep_type_name,
132+
),
133+
scrollable: true,
134+
accept_is_nextarrow: true,
135+
..Default::default()
136+
})
137+
.await?;
138+
}
130139
}
131-
132140
}
133141
};
134142
}

0 commit comments

Comments
 (0)