Skip to content

Commit 4591986

Browse files
committed
Fix clippy warnings in stacks signer
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent c86013a commit 4591986

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

stacks-signer/src/cli.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ impl TryFrom<&str> for Vote {
222222
match input.to_lowercase().as_str() {
223223
"yes" => Ok(Vote::Yes),
224224
"no" => Ok(Vote::No),
225-
_ => Err(format!("Invalid vote: {}. Must be `yes` or `no`.", input)),
225+
_ => Err(format!("Invalid vote: {input}. Must be `yes` or `no`.")),
226226
}
227227
}
228228
}
229229

230230
impl TryFrom<u8> for Vote {
231231
type Error = String;
232232
fn try_from(input: u8) -> Result<Vote, Self::Error> {
233-
Vote::from_u8(input).ok_or_else(|| format!("Invalid vote: {}. Must be 0 or 1.", input))
233+
Vote::from_u8(input).ok_or_else(|| format!("Invalid vote: {input}. Must be 0 or 1."))
234234
}
235235
}
236236

@@ -287,7 +287,7 @@ impl ValueEnum for StackingSignatureMethod {
287287
method => match Pox4SignatureTopic::lookup_by_name(method) {
288288
Some(topic) => topic,
289289
None => {
290-
return Err(format!("Invalid topic: {}", input));
290+
return Err(format!("Invalid topic: {input}"));
291291
}
292292
},
293293
};
@@ -328,7 +328,7 @@ pub struct GenerateStackingSignatureArgs {
328328

329329
/// Parse the contract ID
330330
fn parse_contract(contract: &str) -> Result<QualifiedContractIdentifier, String> {
331-
QualifiedContractIdentifier::parse(contract).map_err(|e| format!("Invalid contract: {}", e))
331+
QualifiedContractIdentifier::parse(contract).map_err(|e| format!("Invalid contract: {e}"))
332332
}
333333

334334
/// Parse a BTC address argument and return a `PoxAddress`.
@@ -355,12 +355,12 @@ pub fn parse_pox_addr(pox_address_literal: &str) -> Result<PoxAddress, String> {
355355

356356
/// Parse the hexadecimal Stacks private key
357357
fn parse_private_key(private_key: &str) -> Result<StacksPrivateKey, String> {
358-
StacksPrivateKey::from_hex(private_key).map_err(|e| format!("Invalid private key: {}", e))
358+
StacksPrivateKey::from_hex(private_key).map_err(|e| format!("Invalid private key: {e}"))
359359
}
360360

361361
/// Parse the hexadecimal Stacks public key
362362
fn parse_public_key(public_key: &str) -> Result<StacksPublicKey, String> {
363-
StacksPublicKey::from_hex(public_key).map_err(|e| format!("Invalid public key: {}", e))
363+
StacksPublicKey::from_hex(public_key).map_err(|e| format!("Invalid public key: {e}"))
364364
}
365365

366366
/// Parse the vote
@@ -370,7 +370,7 @@ fn parse_vote(vote: &str) -> Result<Vote, String> {
370370

371371
/// Parse the hexadecimal encoded message signature
372372
fn parse_message_signature(signature: &str) -> Result<MessageSignature, String> {
373-
MessageSignature::from_hex(signature).map_err(|e| format!("Invalid message signature: {}", e))
373+
MessageSignature::from_hex(signature).map_err(|e| format!("Invalid message signature: {e}"))
374374
}
375375

376376
/// Parse the input data
@@ -384,7 +384,7 @@ fn parse_data(data: &str) -> Result<Vec<u8>, String> {
384384
data.to_string()
385385
};
386386
let data =
387-
b58::from(&encoded_data).map_err(|e| format!("Failed to decode provided data: {}", e))?;
387+
b58::from(&encoded_data).map_err(|e| format!("Failed to decode provided data: {e}"))?;
388388
Ok(data)
389389
}
390390

stacks-signer/src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub(crate) mod tests {
346346
stackerdbs: Some(
347347
stackerdb_contract_ids
348348
.into_iter()
349-
.map(|cid| format!("{}", cid))
349+
.map(|cid| cid.to_string())
350350
.collect(),
351351
),
352352
};

stacks-signer/src/client/stacks_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl StacksClient {
115115
let stacks_address = StacksAddress::p2pkh(mainnet, &pubkey);
116116
Self {
117117
stacks_address,
118-
http_origin: format!("http://{}", node_host),
118+
http_origin: format!("http://{node_host}"),
119119
tx_version,
120120
chain_id,
121121
stacks_node_client: reqwest::blocking::Client::new(),
@@ -751,7 +751,7 @@ impl StacksClient {
751751
}
752752

753753
fn tenure_tip_path(&self, consensus_hash: &ConsensusHash) -> String {
754-
format!("{}/v3/tenures/tip/{}", self.http_origin, consensus_hash)
754+
format!("{}/v3/tenures/tip/{consensus_hash}", self.http_origin)
755755
}
756756
}
757757

stacks-signer/src/config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ pub fn build_signer_config_tomls(
564564
let mut signer_config_tomls = vec![];
565565

566566
for stacks_private_key in stacks_private_keys {
567-
let endpoint = format!("localhost:{}", port_start);
567+
let endpoint = format!("localhost:{port_start}");
568568
port_start += 1;
569569

570570
let stacks_public_key = StacksPublicKey::from_private(stacks_private_key).to_hex();
@@ -615,7 +615,7 @@ tx_fee_ustx = {tx_fee_ustx}
615615
}
616616

617617
if let Some(metrics_port) = metrics_port_start {
618-
let metrics_endpoint = format!("localhost:{}", metrics_port);
618+
let metrics_endpoint = format!("localhost:{metrics_port}");
619619
signer_config_toml = format!(
620620
r#"
621621
{signer_config_toml}
@@ -709,8 +709,7 @@ Dry run: false
709709

710710
assert!(
711711
config_str == expected_str_v4 || config_str == expected_str_v6,
712-
"Config string does not match expected output. Actual:\n{}",
713-
config_str
712+
"Config string does not match expected output. Actual:\n{config_str}",
714713
);
715714
}
716715

stacks-signer/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn handle_list_chunks(args: StackerDBArgs) {
8484
let chunk_list = session.list_chunks().unwrap();
8585
let chunk_list_json = serde_json::to_string(&chunk_list).unwrap();
8686
let hexed_json = to_hex(chunk_list_json.as_bytes());
87-
println!("{}", hexed_json);
87+
println!("{hexed_json}");
8888
}
8989

9090
fn handle_put_chunk(args: PutChunkArgs) {
@@ -148,15 +148,15 @@ fn handle_generate_stacking_signature(
148148
};
149149

150150
if do_print {
151-
println!("{}", output_str);
151+
println!("{output_str}");
152152
}
153153

154154
signature
155155
}
156156

157157
fn handle_check_config(args: RunSignerArgs) {
158158
let config = GlobalConfig::try_from(&args.config).unwrap();
159-
println!("Signer version: {}\nConfig: \n{}", *VERSION_STRING, config);
159+
println!("Signer version: {}\nConfig: \n{config}", *VERSION_STRING);
160160
}
161161

162162
fn handle_generate_vote(args: GenerateVoteArgs, do_print: bool) -> MessageSignature {

stacks-signer/src/signerdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Display for BlockState {
148148
BlockState::GloballyAccepted => "GloballyAccepted",
149149
BlockState::GloballyRejected => "GloballyRejected",
150150
};
151-
write!(f, "{}", state)
151+
write!(f, "{state}")
152152
}
153153
}
154154

0 commit comments

Comments
 (0)