Skip to content

Commit 15023da

Browse files
committed
fix: use variables directly in format! string
Clippy will complain if the variables are not used directly in the string.
1 parent 4028c36 commit 15023da

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

examples/btc_miniscript.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async fn get_bitbox02() -> bitbox_api::PairedBitBox<bitbox_api::runtime::TokioRu
1212
.unwrap();
1313
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1414
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
15-
println!("Pairing code\n{}", pairing_code);
15+
println!("Pairing code\n{pairing_code}");
1616
}
1717
pairing_bitbox.wait_confirm().await.unwrap()
1818
}

examples/btc_sign_msg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn signmsg<R: bitbox_api::runtime::Runtime>() {
1010
.unwrap();
1111
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1212
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
13-
println!("Pairing code\n{}", pairing_code);
13+
println!("Pairing code\n{pairing_code}");
1414
}
1515
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();
1616

@@ -27,7 +27,7 @@ async fn signmsg<R: bitbox_api::runtime::Runtime>() {
2727
.btc_sign_message(pb::BtcCoin::Btc, script_config_sign_msg, b"message")
2828
.await
2929
.unwrap();
30-
println!("Signature: {:?}", signature);
30+
println!("Signature: {signature:?}");
3131
}
3232

3333
#[tokio::main(flavor = "current_thread")]

examples/btc_sign_psbt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async fn sign_psbt<R: bitbox_api::runtime::Runtime>(psbt: &mut bitcoin::psbt::Ps
1111
.unwrap();
1212
let pairing_device = d.unlock_and_pair().await.unwrap();
1313
if let Some(pairing_code) = pairing_device.get_pairing_code().as_ref() {
14-
println!("Pairing code\n{}", pairing_code);
14+
println!("Pairing code\n{pairing_code}");
1515
}
1616
let paired = pairing_device.wait_confirm().await.unwrap();
1717
paired
@@ -33,5 +33,5 @@ async fn main() {
3333
let mut psbt = bitcoin::psbt::Psbt::from_str(buffer.trim()).unwrap();
3434
sign_psbt::<bitbox_api::runtime::TokioRuntime>(&mut psbt).await;
3535
println!("signed:");
36-
println!("{}", psbt);
36+
println!("{psbt}");
3737
}

examples/btc_signtx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn signtx<R: bitbox_api::runtime::Runtime>() {
1010
.unwrap();
1111
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1212
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
13-
println!("Pairing code\n{}", pairing_code);
13+
println!("Pairing code\n{pairing_code}");
1414
}
1515
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();
1616

examples/cardano.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
1010
.unwrap();
1111
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1212
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
13-
println!("Pairing code\n{}", pairing_code);
13+
println!("Pairing code\n{pairing_code}");
1414
}
1515
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();
1616

@@ -22,7 +22,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
2222
])
2323
.await
2424
.unwrap();
25-
println!("Xpubs: {:?}", xpubs);
25+
println!("Xpubs: {xpubs:?}");
2626

2727
println!("Getting an address...");
2828
let address = paired_bitbox
@@ -36,7 +36,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
3636
)
3737
.await
3838
.unwrap();
39-
println!("Address: {}", address);
39+
println!("Address: {address}");
4040

4141
println!("Signing a transaction with tokens...");
4242
let change_config = bitbox_api::cardano::make_script_config_pkh_skh(
@@ -101,7 +101,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
101101
.cardano_sign_transaction(transaction)
102102
.await
103103
.unwrap();
104-
println!("Witness: {:?}", witness);
104+
println!("Witness: {witness:?}");
105105

106106
println!("Delegating to a staking pool...");
107107
let transaction = pb::CardanoSignTransactionRequest {
@@ -156,7 +156,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
156156
.cardano_sign_transaction(transaction)
157157
.await
158158
.unwrap();
159-
println!("Witness: {:?}", witness);
159+
println!("Witness: {witness:?}");
160160

161161
println!("Withdrawing staking rewards...");
162162
let transaction = pb::CardanoSignTransactionRequest {
@@ -194,7 +194,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
194194
.cardano_sign_transaction(transaction)
195195
.await
196196
.unwrap();
197-
println!("Witness: {:?}", witness);
197+
println!("Witness: {witness:?}");
198198
}
199199

200200
#[tokio::main(flavor = "current_thread")]

examples/eth.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async fn eth_demo<R: bitbox_api::runtime::Runtime>() {
5656
.unwrap();
5757
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
5858
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
59-
println!("Pairing code\n{}", pairing_code);
59+
println!("Pairing code\n{pairing_code}");
6060
}
6161
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();
6262

@@ -65,14 +65,14 @@ async fn eth_demo<R: bitbox_api::runtime::Runtime>() {
6565
.eth_xpub(&"m/44'/60'/0'/0".try_into().unwrap())
6666
.await
6767
.unwrap();
68-
println!("Xpub: {}", xpub);
68+
println!("Xpub: {xpub}");
6969

7070
println!("Verifying address...");
7171
let address = paired_bitbox
7272
.eth_address(1, &"m/44'/60'/0'/0/0".try_into().unwrap(), true)
7373
.await
7474
.unwrap();
75-
println!("Address: {}", address);
75+
println!("Address: {address}");
7676

7777
println!("Signing a tx...");
7878
let raw_tx = hex::decode("f86e821fdc850165a0bc008252089404f264cf34440313b4a0192a352814fbe927b88588075cf1259e9c40008025a015c94c1a3da0abc0a9124d2837809ccc493c41504e4571bcc340eeb68a91f641a03599011d4cda2c33dd3b00071ec145335e5d2dd5ed812d5eebeecba5264ed1bf").unwrap();

examples/multithreaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async fn demo<R: bitbox_api::runtime::Runtime + Sync + Send>() {
1010
.unwrap();
1111
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1212
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
13-
println!("Pairing code\n{}", pairing_code);
13+
println!("Pairing code\n{pairing_code}");
1414
}
1515
multithreading_type_check(&pairing_bitbox);
1616
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();

examples/singlethreaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async fn demo<R: bitbox_api::runtime::Runtime>() {
88
.unwrap();
99
let pairing_bitbox = bitbox.unlock_and_pair().await.unwrap();
1010
if let Some(pairing_code) = pairing_bitbox.get_pairing_code().as_ref() {
11-
println!("Pairing code\n{}", pairing_code);
11+
println!("Pairing code\n{pairing_code}");
1212
}
1313
let paired_bitbox = pairing_bitbox.wait_confirm().await.unwrap();
1414
println!(

src/eth.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ fn parse_type(
205205
if typ.ends_with(']') {
206206
let index = typ
207207
.rfind('[')
208-
.ok_or(format!("Invalid type format: {}", typ))?;
208+
.ok_or(format!("Invalid type format: {typ}"))?;
209209
let (rest, size) = (&typ[..index], &typ[index + 1..typ.len() - 1]);
210210
let size_int = if !size.is_empty() {
211-
u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))?
211+
u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))?
212212
} else {
213213
0
214214
};
@@ -221,7 +221,7 @@ fn parse_type(
221221
})
222222
} else if let Some(size) = typ.strip_prefix("bytes") {
223223
let size_int = if !size.is_empty() {
224-
u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))?
224+
u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))?
225225
} else {
226226
0
227227
};
@@ -235,7 +235,7 @@ fn parse_type(
235235
if size.is_empty() {
236236
return Err("uint must be sized".to_string());
237237
}
238-
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))? / 8;
238+
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))? / 8;
239239
Ok(MemberType {
240240
r#type: DataType::Uint.into(),
241241
size: size_int,
@@ -246,7 +246,7 @@ fn parse_type(
246246
if size.is_empty() {
247247
return Err("int must be sized".to_string());
248248
}
249-
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {}", e))? / 8;
249+
let size_int = u32::from_str(size).map_err(|e| format!("Error parsing size: {e}"))? / 8;
250250
Ok(MemberType {
251251
r#type: DataType::Int.into(),
252252
size: size_int,
@@ -282,7 +282,7 @@ fn parse_type(
282282
array_type: None,
283283
})
284284
} else {
285-
Err(format!("Can't recognize type: {}", typ))
285+
Err(format!("Can't recognize type: {typ}"))
286286
}
287287
}
288288

@@ -303,7 +303,7 @@ fn encode_value(typ: &MemberType, value: &Value) -> Result<Vec<u8>, String> {
303303
Value::String(v) => {
304304
if v.starts_with("0x") || v.starts_with("0X") {
305305
Ok(BigUint::parse_bytes(&v.as_bytes()[2..], 16)
306-
.ok_or(format!("could not parse {} as hex", v))?
306+
.ok_or(format!("could not parse {v} as hex"))?
307307
.to_bytes_be())
308308
} else {
309309
Ok(BigUint::from_str(v)

src/wasm/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl TryFrom<TsCardanoTransaction> for crate::pb::CardanoSignTransactionRequest
330330

331331
fn try_from(value: TsCardanoTransaction) -> Result<Self, Self::Error> {
332332
serde_wasm_bindgen::from_value(value.into())
333-
.map_err(|e| JavascriptError::Foo(format!("wrong type for CardanoTransaction {:?}", e)))
333+
.map_err(|e| JavascriptError::Foo(format!("wrong type for CardanoTransaction {e:?}")))
334334
}
335335
}
336336

tests/util/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Server {
5858
let reader = std::io::BufReader::new(stdout);
5959
for line in reader.lines() {
6060
match line {
61-
Ok(line) => println!("\t\t{}", line),
62-
Err(e) => eprintln!("Error reading line: {}", e),
61+
Ok(line) => println!("\t\t{line}"),
62+
Err(e) => eprintln!("Error reading line: {e}"),
6363
}
6464
}
6565
});
@@ -127,7 +127,7 @@ async fn download_simulators() -> Result<Vec<String>, ()> {
127127
.await
128128
.map_err(|_| ())?
129129
{
130-
println!("Downloading simulator: {}", sim_url);
130+
println!("Downloading simulator: {sim_url}");
131131
download_file(&simulator.url, &filename)
132132
.await
133133
.map_err(|_| ())?;
@@ -168,7 +168,7 @@ pub async fn test_simulators_after_pairing(
168168
};
169169
for simulator_filename in simulator_filenames {
170170
println!();
171-
println!("\tSimulator tests using {}", simulator_filename);
171+
println!("\tSimulator tests using {simulator_filename}");
172172
let _server = Server::launch(&simulator_filename);
173173
let noise_config = Box::new(bitbox_api::NoiseConfigNoCache {});
174174
let bitbox = bitbox_api::BitBox::<bitbox_api::runtime::TokioRuntime>::from_simulator(

0 commit comments

Comments
 (0)