Skip to content

Commit ff3786b

Browse files
committed
Fix CI: Run cargo fmt --all
1 parent b0bca94 commit ff3786b

File tree

6 files changed

+37
-39
lines changed

6 files changed

+37
-39
lines changed

src/app_ui/menu.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ pub fn ui_menu_main(_: &mut Comm) -> NbglHomeAndSettings {
2828
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("icons/ae_14.gif", NBGL));
2929

3030
// Display the home screen.
31-
NbglHomeAndSettings::new()
32-
.glyph(&FERRIS)
33-
.infos(
34-
"Aeternity",
35-
env!("CARGO_PKG_VERSION"),
36-
env!("CARGO_PKG_AUTHORS"),
37-
)
31+
NbglHomeAndSettings::new().glyph(&FERRIS).infos(
32+
"Aeternity",
33+
env!("CARGO_PKG_VERSION"),
34+
env!("CARGO_PKG_AUTHORS"),
35+
)
3836
}

src/app_ui/sign_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloc::{borrow::ToOwned, vec::Vec, string::String};
1+
use alloc::{borrow::ToOwned, string::String, vec::Vec};
22

33
use include_gif::include_gif;
44
use ledger_device_sdk::nbgl::{Field, NbglGlyph, NbglReview};

src/app_ui/sign_msg.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@ use crate::AppSW;
66
pub fn ui_display_msg(message_bytes: &[u8]) -> Result<bool, AppSW> {
77
let message = core::str::from_utf8(message_bytes).unwrap();
88

9-
let my_fields = [
10-
Field {
11-
name: "Message",
12-
value: message,
13-
},
14-
];
9+
let my_fields = [Field {
10+
name: "Message",
11+
value: message,
12+
}];
1513

1614
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("icons/ae_64.gif", NBGL));
1715
// Create NBGL review. Maximum number of fields and string buffer length can be customised
1816
// with constant generic parameters of NbglReview. Default values are 32 and 1024 respectively.
1917
let review: NbglReview = NbglReview::new()
20-
.titles(
21-
"Review message",
22-
"",
23-
"Sign message",
24-
)
18+
.titles("Review message", "", "Sign message")
2519
.glyph(&FERRIS);
2620

2721
Ok(review.show(&my_fields))

src/app_ui/sign_tx.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ pub fn ui_display_tx(tx: &TxFirstChunk) -> Result<bool, AppSW> {
5959
]);
6060

6161
if !tx.payload.is_empty() {
62-
my_fields.push(
63-
Field {
64-
name: "Payload",
65-
value: tx.payload.as_str(),
66-
}
67-
);
62+
my_fields.push(Field {
63+
name: "Payload",
64+
value: tx.payload.as_str(),
65+
});
6866
}
6967

7068
// Create transaction review
@@ -88,7 +86,7 @@ pub fn ui_display_tx(tx: &TxFirstChunk) -> Result<bool, AppSW> {
8886
}
8987

9088
/// Convert an amount in Aettos to an amount in AE.
91-
///
89+
///
9290
/// Since there's no need to deal with floating-point numbers, the conversion
9391
/// is done by converting the amount to String and moving the decimal point 18
9492
/// places to left.

src/handlers/sign_msg.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ const SIGN_MAGIC_LEN: u8 = SIGN_MAGIC.len() as u8;
1414
pub fn handler_sign_message(comm: &mut Comm) -> Result<(), AppSW> {
1515
let data = comm.get_data().map_err(|_| AppSW::WrongApduLength)?;
1616

17-
let (account_number_bytes, rest) = data
18-
.split_first_chunk::<4>()
19-
.ok_or(AppSW::MsgWrongLength)?;
17+
let (account_number_bytes, rest) =
18+
data.split_first_chunk::<4>().ok_or(AppSW::MsgWrongLength)?;
2019
let account_number = u32::from_be_bytes(*account_number_bytes);
2120

22-
let (message_length_bytes, message) = rest
23-
.split_first_chunk::<4>()
24-
.ok_or(AppSW::MsgWrongLength)?;
21+
let (message_length_bytes, message) =
22+
rest.split_first_chunk::<4>().ok_or(AppSW::MsgWrongLength)?;
2523
let message_length = usize::from_be_bytes(*message_length_bytes);
2624

2725
if message_length != message.len() {
@@ -46,10 +44,14 @@ fn sign_message(account_number: u32, message: &[u8]) -> Result<[u8; 64], AppSW>
4644
data_to_sign.extend(message);
4745

4846
let hash: [u8; 32] = {
49-
let mut blake2b = Blake2b_256::new();
47+
let mut blake2b = Blake2b_256::new();
5048
let mut output = [0; 32];
51-
blake2b.update(&data_to_sign).map_err(|_| AppSW::MsgHashFail)?;
52-
blake2b.finalize(&mut output).map_err(|_| AppSW::MsgHashFail)?;
49+
blake2b
50+
.update(&data_to_sign)
51+
.map_err(|_| AppSW::MsgHashFail)?;
52+
blake2b
53+
.finalize(&mut output)
54+
.map_err(|_| AppSW::MsgHashFail)?;
5355
output
5456
};
5557

src/handlers/sign_tx.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ impl TxContext {
5858
}
5959

6060
fn parse_header_data<'a>(&mut self, data: &'a [u8]) -> Result<&'a [u8], AppSW> {
61-
let (account_number_bytes, rest) = data.split_first_chunk::<4>().ok_or(AppSW::TxParsingFail)?;
61+
let (account_number_bytes, rest) =
62+
data.split_first_chunk::<4>().ok_or(AppSW::TxParsingFail)?;
6263
let (tx_len_bytes, rest) = rest.split_first_chunk::<4>().ok_or(AppSW::TxParsingFail)?;
6364
let (network_id_len_byte, rest) = rest.split_first().ok_or(AppSW::TxParsingFail)?;
6465

@@ -96,7 +97,8 @@ impl TxContext {
9697
}
9798
let _ = parse_address(&list[2].byte_array().map_err(|_| AppSW::TxParsingFail)?)?;
9899
let recipient = parse_address(&list[3].byte_array().map_err(|_| AppSW::TxParsingFail)?)?;
99-
let amount = U256::from_big_endian(&list[4].byte_array().map_err(|_| AppSW::TxParsingFail)?);
100+
let amount =
101+
U256::from_big_endian(&list[4].byte_array().map_err(|_| AppSW::TxParsingFail)?);
100102
let fee = U256::from_big_endian(&list[5].byte_array().map_err(|_| AppSW::TxParsingFail)?);
101103
let payload =
102104
core::str::from_utf8(&list[8].byte_array().map_err(|_| AppSW::TxParsingFail)?)
@@ -127,15 +129,19 @@ pub fn handler_sign_tx(
127129
ctx.reset();
128130
let tx_bytes = ctx.parse_header_data(data)?;
129131
ctx.parse_tx_first_chunk(tx_bytes)?;
130-
ctx.blake2b.update(tx_bytes).map_err(|_| AppSW::TxHashFail)?;
132+
ctx.blake2b
133+
.update(tx_bytes)
134+
.map_err(|_| AppSW::TxHashFail)?;
131135
} else {
132136
ctx.blake2b.update(data).map_err(|_| AppSW::TxHashFail)?;
133137
return Ok(());
134138
}
135139

136140
if ui_display_tx(&ctx.tx)? {
137141
let mut hash: [u8; 32] = [0; 32];
138-
ctx.blake2b.finalize(&mut hash).map_err(|_| AppSW::TxHashFail)?;
142+
ctx.blake2b
143+
.finalize(&mut hash)
144+
.map_err(|_| AppSW::TxHashFail)?;
139145
let data_to_sign = [&ctx.network_id[..], &hash].concat();
140146
let sig = utils::sign(ctx.account_number, &data_to_sign).ok_or(AppSW::TxSignFail)?;
141147
comm.append(&sig);

0 commit comments

Comments
 (0)