Skip to content

Commit acbcffe

Browse files
committed
clippy: uninlined_format_args
1 parent a7ebe41 commit acbcffe

File tree

9 files changed

+31
-41
lines changed

9 files changed

+31
-41
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
rust-version: [ 1.85.0 ]
19+
rust-version: [ 1.88.0 ]
2020

2121
steps:
2222
- name: Checkout code

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "anychain-solana"
33
description = "A Rust library for Solana-focused cryptocurrency wallets, enabling seamless transactions on the Solana blockchain"
4-
version = "0.1.14"
4+
version = "0.1.16"
55
keywords = ["solana", "blockchain", "wallet", "transactions"]
66
categories = ["cryptography::cryptocurrencies"]
77
authors = ["Shawndslee", "cregis.com"]
@@ -15,7 +15,7 @@ name = "create-account"
1515
path = "examples/create-account.rs"
1616

1717
[dependencies]
18-
anychain-core = { version = "0.1.7" }
18+
anychain-core = { version = "0.1.8" }
1919
curve25519-dalek = { version = "4.1.3", features = ["group"] }
2020
ed25519-dalek = "1.0.1"
2121
bs58 = { version = "0.5.1", default-features = false, features = ["check", "alloc"] }

examples/create-account.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ pub fn generate_keypair_from_mnemonic(mnemonic_str: &str) -> Keypair {
2323
let seed = Seed::new(&mnemonic, passphrase);
2424

2525
let derivation_path = None;
26-
let keypair = match derivation_path {
26+
match derivation_path {
2727
Some(_) => keypair_from_seed_and_derivation_path(seed.as_bytes(), derivation_path),
2828
None => keypair_from_seed(seed.as_bytes()),
2929
}
30-
.unwrap();
31-
keypair
30+
.unwrap()
3231
}
3332

3433
/// use a single invocation of SystemInstruction::CreateAccount to create a new account,
@@ -59,7 +58,7 @@ pub fn create_account(
5958
);
6059

6160
let sig = rpc_client.send_and_confirm_transaction(&transaction)?;
62-
println!("{}", sig);
61+
println!("{sig}");
6362

6463
Ok(())
6564
}
@@ -167,7 +166,7 @@ fn main() -> anyhow::Result<()> {
167166

168167
let res = rpc_client.get_account(&bob_pubkey);
169168
match res {
170-
Ok(account_info) => println!("Account found: {:?}", account_info),
169+
Ok(account_info) => println!("Account found: {account_info:?}"),
171170
Err(e) => match e.kind() {
172171
/*
173172
Bob Solana Account does not exist
@@ -185,7 +184,7 @@ fn main() -> anyhow::Result<()> {
185184
let _ =
186185
create_account(&rpc_client, &alice_keypair, blockhash, &bob_keypair, 0usize);
187186
}
188-
_ => println!("Error fetching account: {:?}", e),
187+
_ => println!("Error fetching account: {e:?}"),
189188
},
190189
}
191190

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[toolchain]
2-
channel = "1.85.0"
2+
channel = "1.88.0"
33
components = ["clippy", "rustfmt"]
44
targets = []
55
profile = "minimal"

src/address.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ pub struct SolanaAddress(pub String);
1818
impl SolanaAddress {
1919
pub fn associated_token_address(&self, token: String) -> Result<String, AddressError> {
2020
let address =
21-
Pubkey::from_str(&self.0).map_err(|e| AddressError::Message(format!("{}", e)))?;
22-
let token =
23-
Pubkey::from_str(&token).map_err(|e| AddressError::Message(format!("{}", e)))?;
21+
Pubkey::from_str(&self.0).map_err(|e| AddressError::Message(format!("{e}")))?;
22+
let token = Pubkey::from_str(&token).map_err(|e| AddressError::Message(format!("{e}")))?;
2423
let associated_token_address = get_associated_token_address(&address, &token);
2524
Ok(associated_token_address.to_string())
2625
}
@@ -61,7 +60,7 @@ impl FromStr for SolanaAddress {
6160
}
6261
let pubkey_vec = bs58::decode(addr)
6362
.into_vec()
64-
.map_err(|error| PublicKeyError::Crate("base58", format!("{:?}", error)))?;
63+
.map_err(|error| PublicKeyError::Crate("base58", format!("{error:?}")))?;
6564
if pubkey_vec.len() != PUBLIC_KEY_LENGTH {
6665
return Err(AddressError::InvalidAddress(addr.to_string()));
6766
}

src/amount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl SolanaAmount {
5151
pub fn from_u64_str(value: &str) -> Result<u64, AmountError> {
5252
match value.parse::<u64>() {
5353
Ok(lamports) => Ok(lamports),
54-
Err(error) => Err(AmountError::Crate("uint", format!("{:?}", error))),
54+
Err(error) => Err(AmountError::Crate("uint", format!("{error:?}"))),
5555
}
5656
}
5757
pub fn from_lamports(lamports_value: &str) -> Result<Self, AmountError> {

src/public_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ impl FromStr for SolanaPublicKey {
3939
}
4040
let pubkey_vec = bs58::decode(s)
4141
.into_vec()
42-
.map_err(|error| PublicKeyError::Crate("base58", format!("{:?}", error)))?;
42+
.map_err(|error| PublicKeyError::Crate("base58", format!("{error:?}")))?;
4343
if pubkey_vec.len() != PUBLIC_KEY_LENGTH {
4444
return Err(PublicKeyError::InvalidByteLength(pubkey_vec.len()));
4545
}
4646
let buffer: [u8; PUBLIC_KEY_LENGTH] = pubkey_vec.as_slice().try_into().unwrap();
4747
let verifying_key = ed25519_dalek::PublicKey::from_bytes(&buffer)
48-
.map_err(|error| PublicKeyError::Crate("base58", format!("{:?}", error)))?;
48+
.map_err(|error| PublicKeyError::Crate("base58", format!("{error:?}")))?;
4949
Ok(SolanaPublicKey(verifying_key))
5050
}
5151
}

src/transaction.rs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl FromStr for SolanaTransaction {
3939
fn from_str(tx: &str) -> Result<Self, Self::Err> {
4040
let tx = bs58::decode(tx)
4141
.into_vec()
42-
.map_err(|e| TransactionError::Message(format!("{}", e)))?;
42+
.map_err(|e| TransactionError::Message(format!("{e}")))?;
4343
SolanaTransaction::from_bytes(&tx)
4444
}
4545
}
@@ -158,7 +158,7 @@ impl Transaction for SolanaTransaction {
158158

159159
fn from_bytes(tx: &[u8]) -> Result<Self, TransactionError> {
160160
let tx = bincode::deserialize::<Tx>(tx)
161-
.map_err(|e| TransactionError::Message(format!("{}", e)))?;
161+
.map_err(|e| TransactionError::Message(format!("{e}")))?;
162162

163163
let sig = if !tx.signatures.is_empty() {
164164
let rs = tx.signatures[0];
@@ -178,13 +178,13 @@ impl Transaction for SolanaTransaction {
178178
let program = keys[ixs[0].program_id_index as usize];
179179
let account = &ixs[0].accounts;
180180
let data = &ixs[0].data;
181-
match format!("{}", program).as_str() {
181+
match format!("{program}").as_str() {
182182
"11111111111111111111111111111111" => {
183183
let from = keys[account[0] as usize];
184184
let to = keys[account[1] as usize];
185185

186186
let ix = bincode::deserialize::<SystemInstruction>(data)
187-
.map_err(|e| TransactionError::Message(format!("{}", e)))?;
187+
.map_err(|e| TransactionError::Message(format!("{e}")))?;
188188

189189
match ix {
190190
SystemInstruction::Transfer { lamports } => {
@@ -202,8 +202,7 @@ impl Transaction for SolanaTransaction {
202202
Ok(tx)
203203
}
204204
_ => Err(TransactionError::Message(format!(
205-
"Unsupported system instruction: {:?}",
206-
ix
205+
"Unsupported system instruction: {ix:?}"
207206
))),
208207
}
209208
}
@@ -213,7 +212,7 @@ impl Transaction for SolanaTransaction {
213212
let from = keys[account[3] as usize];
214213

215214
let ix = TokenInstruction::unpack(data)
216-
.map_err(|e| TransactionError::Message(format!("{}", e)))?;
215+
.map_err(|e| TransactionError::Message(format!("{e}")))?;
217216

218217
match ix {
219218
TokenInstruction::TransferChecked { amount, decimals } => {
@@ -231,35 +230,29 @@ impl Transaction for SolanaTransaction {
231230
Ok(tx)
232231
}
233232
_ => Err(TransactionError::Message(format!(
234-
"Unsupported token instruction: {:?}",
235-
ix
233+
"Unsupported token instruction: {ix:?}"
236234
))),
237235
}
238236
}
239237
_ => Err(TransactionError::Message(format!(
240-
"Unsupported program {}",
241-
program
238+
"Unsupported program {program}"
242239
))),
243240
}
244241
}
245242
2 => {
246243
let program1 = keys[ixs[0].program_id_index as usize];
247244
let program2 = keys[ixs[1].program_id_index as usize];
248245

249-
if format!("{}", program1).as_str()
250-
!= "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
246+
if format!("{program1}").as_str() != "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
251247
{
252248
return Err(TransactionError::Message(format!(
253-
"Unsupported first program {}",
254-
program1
249+
"Unsupported first program {program1}"
255250
)));
256251
}
257252

258-
if format!("{}", program2).as_str() != "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
259-
{
253+
if format!("{program2}").as_str() != "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" {
260254
return Err(TransactionError::Message(format!(
261-
"Unsupported second program {}",
262-
program2
255+
"Unsupported second program {program2}"
263256
)));
264257
}
265258

@@ -271,7 +264,7 @@ impl Transaction for SolanaTransaction {
271264
let token_address = keys[account[3] as usize];
272265

273266
let ix = TokenInstruction::unpack(data)
274-
.map_err(|e| TransactionError::Message(format!("{}", e)))?;
267+
.map_err(|e| TransactionError::Message(format!("{e}")))?;
275268

276269
match ix {
277270
TokenInstruction::TransferChecked { amount, decimals } => {
@@ -289,8 +282,7 @@ impl Transaction for SolanaTransaction {
289282
Ok(tx)
290283
}
291284
_ => Err(TransactionError::Message(format!(
292-
"Unsupported token instruction: {:?}",
293-
ix
285+
"Unsupported token instruction: {ix:?}"
294286
))),
295287
}
296288
}
@@ -320,5 +312,5 @@ fn test() {
320312
let tx = "BU8oN58NjvzGdbuQ8zGKF9cJ7N25iWRRgnLodf42gEVDnzcQ3g5y7eygBviCRQHH4sC335gt575JA2NfjpX3P7m1vZ5WYWxHem7wW3Pc4S6YYi4ftivYiGqTMr6eKtUVCbBZabwyMuZ7iGjUtTB6L7LnfQj6wGduNUqwpGPy2xD8aFps6zRfgwNAXe9tpoa3tQvTnyU8WgkpiZjkBFdfXFw8abhsUZLZsxaYra2CHmqrXwG6VFUfhTdYANPTXcBcZ2a75RmqC19d5rYJPexmpGJV529A4WXgE4Pm5Gk5AUB7LcNmAxfkKxJk3ikGohb9n3B7vJ3T9zJZg4i6xEGapobavsLwMuYkCjnRBQ69rouMCJEtz33XNuwx1ZN84cGimZV1KSbwQgcPDFzgdZR2ZisViDWAJUXkadfCfADNEME1jxmHDy7oX9gTYJvkeZAnoFjxVhKrVZft8FaADcRgNcdZJPdt9rMMSpCJXBFgBVsGaqo6iteJqg79qQrEoScRviUh6scB7iwCh";
321313
let tx = SolanaTransaction::from_str(tx).unwrap();
322314
let txid = tx.to_transaction_id().unwrap();
323-
println!("{}", txid);
315+
println!("{txid}");
324316
}

0 commit comments

Comments
 (0)