Browse Source

Fix clippy lint issues

develop
Silvestr Predko 2 years ago
parent
commit
c0ab3cac7b

+ 2
- 2
common-api/src/crypto/mod.rs View File

170
     fn split_encoded() {
170
     fn split_encoded() {
171
         let bs58_str = bs58::encode(vec![0, 0, 0]).into_string();
171
         let bs58_str = bs58::encode(vec![0, 0, 0]).into_string();
172
         assert!(matches!(
172
         assert!(matches!(
173
-                split_encoded_str(&format!("ed25519:{}", bs58_str)),
173
+                split_encoded_str(&format!("ed25519:{bs58_str}")),
174
                 Ok((key_type, s)) if key_type == ED25519 && s == bs58_str));
174
                 Ok((key_type, s)) if key_type == ED25519 && s == bs58_str));
175
         assert!(matches!(
175
         assert!(matches!(
176
-                split_encoded_str(&format!("x25519:{}", bs58_str)),
176
+                split_encoded_str(&format!("x25519:{bs58_str}")),
177
                 Ok((key_type, s)) if key_type == X25519 && s == bs58_str));
177
                 Ok((key_type, s)) if key_type == X25519 && s == bs58_str));
178
         assert!(matches!(
178
         assert!(matches!(
179
             split_encoded_str(&bs58_str),
179
             split_encoded_str(&bs58_str),

+ 60
- 90
near-primitives-light/src/errors.rs View File

25
 impl Display for TxExecutionError {
25
 impl Display for TxExecutionError {
26
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
26
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
27
         match self {
27
         match self {
28
-            TxExecutionError::ActionError(e) => write!(f, "{}", e),
29
-            TxExecutionError::InvalidTxError(e) => write!(f, "{}", e),
28
+            TxExecutionError::ActionError(e) => write!(f, "{e}"),
29
+            TxExecutionError::InvalidTxError(e) => write!(f, "{e}"),
30
         }
30
         }
31
     }
31
     }
32
 }
32
 }
64
 
64
 
65
 impl std::fmt::Display for RuntimeError {
65
 impl std::fmt::Display for RuntimeError {
66
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
66
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
67
-        f.write_str(&format!("{:?}", self))
67
+        f.write_str(&format!("{self:?}"))
68
     }
68
     }
69
 }
69
 }
70
 
70
 
89
 
89
 
90
 impl std::fmt::Display for StorageError {
90
 impl std::fmt::Display for StorageError {
91
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
91
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
92
-        f.write_str(&format!("{:?}", self))
92
+        f.write_str(&format!("{self:?}"))
93
     }
93
     }
94
 }
94
 }
95
 
95
 
232
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
232
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
233
         match self {
233
         match self {
234
             ReceiptValidationError::InvalidPredecessorId { account_id } => {
234
             ReceiptValidationError::InvalidPredecessorId { account_id } => {
235
-                write!(f, "The predecessor_id `{}` of a Receipt is not valid.", account_id)
235
+                write!(f, "The predecessor_id `{account_id}` of a Receipt is not valid.")
236
             }
236
             }
237
             ReceiptValidationError::InvalidReceiverId { account_id } => {
237
             ReceiptValidationError::InvalidReceiverId { account_id } => {
238
-                write!(f, "The receiver_id `{}` of a Receipt is not valid.", account_id)
238
+                write!(f, "The receiver_id `{account_id}` of a Receipt is not valid.")
239
             }
239
             }
240
             ReceiptValidationError::InvalidSignerId { account_id } => {
240
             ReceiptValidationError::InvalidSignerId { account_id } => {
241
-                write!(f, "The signer_id `{}` of an ActionReceipt is not valid.", account_id)
241
+                write!(f, "The signer_id `{account_id}` of an ActionReceipt is not valid.")
242
             }
242
             }
243
             ReceiptValidationError::InvalidDataReceiverId { account_id } => write!(
243
             ReceiptValidationError::InvalidDataReceiverId { account_id } => write!(
244
                 f,
244
                 f,
245
-                "The receiver_id `{}` of a DataReceiver within an ActionReceipt is not valid.",
246
-                account_id
245
+                "The receiver_id `{account_id}` of a DataReceiver within an ActionReceipt is not valid."
247
             ),
246
             ),
248
             ReceiptValidationError::ReturnedValueLengthExceeded { length, limit } => write!(
247
             ReceiptValidationError::ReturnedValueLengthExceeded { length, limit } => write!(
249
                 f,
248
                 f,
250
-                "The length of the returned data {} exceeded the limit {} in a DataReceipt",
251
-                length, limit
249
+                "The length of the returned data {length} exceeded the limit {limit} in a DataReceipt"
252
             ),
250
             ),
253
             ReceiptValidationError::NumberInputDataDependenciesExceeded { number_of_input_data_dependencies, limit } => write!(
251
             ReceiptValidationError::NumberInputDataDependenciesExceeded { number_of_input_data_dependencies, limit } => write!(
254
                 f,
252
                 f,
255
-                "The number of input data dependencies {} exceeded the limit {} in an ActionReceipt",
256
-                number_of_input_data_dependencies, limit
253
+                "The number of input data dependencies {number_of_input_data_dependencies} exceeded the limit {limit} in an ActionReceipt"
257
             ),
254
             ),
258
-            ReceiptValidationError::ActionsValidation(e) => write!(f, "{}", e),
255
+            ReceiptValidationError::ActionsValidation(e) => write!(f, "{e}"),
259
         }
256
         }
260
     }
257
     }
261
 }
258
 }
269
                 write!(f, "The delete action must be the last action in transaction")
266
                 write!(f, "The delete action must be the last action in transaction")
270
             }
267
             }
271
             ActionsValidationError::TotalPrepaidGasExceeded { total_prepaid_gas, limit } => {
268
             ActionsValidationError::TotalPrepaidGasExceeded { total_prepaid_gas, limit } => {
272
-                write!(f, "The total prepaid gas {} exceeds the limit {}", total_prepaid_gas, limit)
269
+                write!(f, "The total prepaid gas {total_prepaid_gas} exceeds the limit {limit}")
273
             }
270
             }
274
             ActionsValidationError::TotalNumberOfActionsExceeded {total_number_of_actions, limit } => {
271
             ActionsValidationError::TotalNumberOfActionsExceeded {total_number_of_actions, limit } => {
275
                 write!(
272
                 write!(
276
                     f,
273
                     f,
277
-                    "The total number of actions {} exceeds the limit {}",
278
-                    total_number_of_actions, limit
274
+                    "The total number of actions {total_number_of_actions} exceeds the limit {limit}"
279
                 )
275
                 )
280
             }
276
             }
281
             ActionsValidationError::AddKeyMethodNamesNumberOfBytesExceeded { total_number_of_bytes, limit } => write!(
277
             ActionsValidationError::AddKeyMethodNamesNumberOfBytesExceeded { total_number_of_bytes, limit } => write!(
282
                 f,
278
                 f,
283
-                "The total number of bytes in allowed method names {} exceeds the maximum allowed number {} in a AddKey action",
284
-                total_number_of_bytes, limit
279
+                "The total number of bytes in allowed method names {total_number_of_bytes} exceeds the maximum allowed number {limit} in a AddKey action"
285
             ),
280
             ),
286
             ActionsValidationError::AddKeyMethodNameLengthExceeded { length, limit } => write!(
281
             ActionsValidationError::AddKeyMethodNameLengthExceeded { length, limit } => write!(
287
                 f,
282
                 f,
288
-                "The length of some method name {} exceeds the maximum allowed length {} in a AddKey action",
289
-                length, limit
283
+                "The length of some method name {length} exceeds the maximum allowed length {limit} in a AddKey action"
290
             ),
284
             ),
291
             ActionsValidationError::IntegerOverflow => write!(
285
             ActionsValidationError::IntegerOverflow => write!(
292
                 f,
286
                 f,
294
             ),
288
             ),
295
             ActionsValidationError::InvalidAccountId { account_id } => write!(
289
             ActionsValidationError::InvalidAccountId { account_id } => write!(
296
                 f,
290
                 f,
297
-                "Invalid account ID `{}`",
298
-                account_id
291
+                "Invalid account ID `{account_id}`"
299
             ),
292
             ),
300
             ActionsValidationError::ContractSizeExceeded { size, limit } => write!(
293
             ActionsValidationError::ContractSizeExceeded { size, limit } => write!(
301
                 f,
294
                 f,
302
-                "The length of the contract size {} exceeds the maximum allowed size {} in a DeployContract action",
303
-                size, limit
295
+                "The length of the contract size {size} exceeds the maximum allowed size {limit} in a DeployContract action"
304
             ),
296
             ),
305
             ActionsValidationError::FunctionCallMethodNameLengthExceeded { length, limit } => write!(
297
             ActionsValidationError::FunctionCallMethodNameLengthExceeded { length, limit } => write!(
306
                 f,
298
                 f,
307
-                "The length of the method name {} exceeds the maximum allowed length {} in a FunctionCall action",
308
-                length, limit
299
+                "The length of the method name {length} exceeds the maximum allowed length {limit} in a FunctionCall action"
309
             ),
300
             ),
310
             ActionsValidationError::FunctionCallArgumentsLengthExceeded { length, limit } => write!(
301
             ActionsValidationError::FunctionCallArgumentsLengthExceeded { length, limit } => write!(
311
                 f,
302
                 f,
312
-                "The length of the arguments {} exceeds the maximum allowed length {} in a FunctionCall action",
313
-                length, limit
303
+                "The length of the arguments {length} exceeds the maximum allowed length {limit} in a FunctionCall action"
314
             ),
304
             ),
315
             ActionsValidationError::UnsuitableStakingKey { public_key } => write!(
305
             ActionsValidationError::UnsuitableStakingKey { public_key } => write!(
316
                 f,
306
                 f,
317
-                "The staking key must be ristretto compatible ED25519 key. {} is provided instead.",
318
-                public_key,
307
+                "The staking key must be ristretto compatible ED25519 key. {public_key} is provided instead."
319
             ),
308
             ),
320
             ActionsValidationError::FunctionCallZeroAttachedGas => write!(
309
             ActionsValidationError::FunctionCallZeroAttachedGas => write!(
321
                 f,
310
                 f,
429
             InvalidTxError::InvalidSignerId { signer_id } => {
418
             InvalidTxError::InvalidSignerId { signer_id } => {
430
                 write!(
419
                 write!(
431
                     f,
420
                     f,
432
-                    "Invalid signer account ID {:?} according to requirements",
433
-                    signer_id
421
+                    "Invalid signer account ID {signer_id:?} according to requirements"
434
                 )
422
                 )
435
             }
423
             }
436
             InvalidTxError::SignerDoesNotExist { signer_id } => {
424
             InvalidTxError::SignerDoesNotExist { signer_id } => {
437
-                write!(f, "Signer {:?} does not exist", signer_id)
425
+                write!(f, "Signer {signer_id:?} does not exist")
438
             }
426
             }
439
             InvalidTxError::InvalidAccessKeyError(access_key_error) => {
427
             InvalidTxError::InvalidAccessKeyError(access_key_error) => {
440
                 Display::fmt(&access_key_error, f)
428
                 Display::fmt(&access_key_error, f)
441
             }
429
             }
442
             InvalidTxError::InvalidNonce { tx_nonce, ak_nonce } => write!(
430
             InvalidTxError::InvalidNonce { tx_nonce, ak_nonce } => write!(
443
                 f,
431
                 f,
444
-                "Transaction nonce {} must be larger than nonce of the used access key {}",
445
-                tx_nonce, ak_nonce
432
+                "Transaction nonce {tx_nonce} must be larger than nonce of the used access key {ak_nonce}"
446
             ),
433
             ),
447
             InvalidTxError::InvalidReceiverId { receiver_id } => {
434
             InvalidTxError::InvalidReceiverId { receiver_id } => {
448
                 write!(
435
                 write!(
449
                     f,
436
                     f,
450
-                    "Invalid receiver account ID {:?} according to requirements",
451
-                    receiver_id
437
+                    "Invalid receiver account ID {receiver_id:?} according to requirements"
452
                 )
438
                 )
453
             }
439
             }
454
             InvalidTxError::InvalidSignature => {
440
             InvalidTxError::InvalidSignature => {
460
                 cost,
446
                 cost,
461
             } => write!(
447
             } => write!(
462
                 f,
448
                 f,
463
-                "Sender {:?} does not have enough balance {} for operation costing {}",
464
-                signer_id, balance, cost
449
+                "Sender {signer_id:?} does not have enough balance {balance} for operation costing {cost}"
465
             ),
450
             ),
466
             InvalidTxError::LackBalanceForState { signer_id, amount } => {
451
             InvalidTxError::LackBalanceForState { signer_id, amount } => {
467
-                write!(f, "Failed to execute, because the account {:?} wouldn't have enough balance to cover storage, required to have {} yoctoNEAR more", signer_id, amount)
452
+                write!(f, "Failed to execute, because the account {signer_id:?} wouldn't have enough balance to cover storage, required to have {amount} yoctoNEAR more")
468
             }
453
             }
469
             InvalidTxError::CostOverflow => {
454
             InvalidTxError::CostOverflow => {
470
                 write!(f, "Transaction gas or balance cost is too high")
455
                 write!(f, "Transaction gas or balance cost is too high")
479
                 write!(f, "Transaction has expired")
464
                 write!(f, "Transaction has expired")
480
             }
465
             }
481
             InvalidTxError::ActionsValidation(error) => {
466
             InvalidTxError::ActionsValidation(error) => {
482
-                write!(f, "Transaction actions validation error: {}", error)
467
+                write!(f, "Transaction actions validation error: {error}")
483
             }
468
             }
484
             InvalidTxError::NonceTooLarge {
469
             InvalidTxError::NonceTooLarge {
485
                 tx_nonce,
470
                 tx_nonce,
487
             } => {
472
             } => {
488
                 write!(
473
                 write!(
489
                     f,
474
                     f,
490
-                    "Transaction nonce {} must be smaller than the access key nonce upper bound {}",
491
-                    tx_nonce, upper_bound
475
+                    "Transaction nonce {tx_nonce} must be smaller than the access key nonce upper bound {upper_bound}"
492
                 )
476
                 )
493
             }
477
             }
494
             InvalidTxError::TransactionSizeExceeded { size, limit } => {
478
             InvalidTxError::TransactionSizeExceeded { size, limit } => {
495
                 write!(
479
                 write!(
496
                     f,
480
                     f,
497
-                    "Size of serialized transaction {} exceeded the limit {}",
498
-                    size, limit
481
+                    "Size of serialized transaction {size} exceeded the limit {limit}"
499
                 )
482
                 )
500
             }
483
             }
501
         }
484
         }
516
                 public_key,
499
                 public_key,
517
             } => write!(
500
             } => write!(
518
                 f,
501
                 f,
519
-                "Signer {:?} doesn't have access key with the given public_key {}",
520
-                account_id, public_key
502
+                "Signer {account_id:?} doesn't have access key with the given public_key {public_key}"
521
             ),
503
             ),
522
             InvalidAccessKeyError::ReceiverMismatch {
504
             InvalidAccessKeyError::ReceiverMismatch {
523
                 tx_receiver,
505
                 tx_receiver,
524
                 ak_receiver,
506
                 ak_receiver,
525
             } => write!(
507
             } => write!(
526
                 f,
508
                 f,
527
-                "Transaction receiver_id {:?} doesn't match the access key receiver_id {:?}",
528
-                tx_receiver, ak_receiver
509
+                "Transaction receiver_id {tx_receiver:?} doesn't match the access key receiver_id {ak_receiver:?}",
529
             ),
510
             ),
530
             InvalidAccessKeyError::MethodNameMismatch { method_name } => write!(
511
             InvalidAccessKeyError::MethodNameMismatch { method_name } => write!(
531
                 f,
512
                 f,
532
-                "Transaction method name {:?} isn't allowed by the access key",
533
-                method_name
513
+                "Transaction method name {method_name:?} isn't allowed by the access key"
534
             ),
514
             ),
535
             InvalidAccessKeyError::RequiresFullAccess => {
515
             InvalidAccessKeyError::RequiresFullAccess => {
536
                 write!(f, "Invalid access key type. Full-access keys are required for transactions that have multiple or non-function-call actions")
516
                 write!(f, "Invalid access key type. Full-access keys are required for transactions that have multiple or non-function-call actions")
542
                 cost,
522
                 cost,
543
             } => write!(
523
             } => write!(
544
                 f,
524
                 f,
545
-                "Access Key {:?}:{} does not have enough balance {} for transaction costing {}",
546
-                account_id, public_key, allowance, cost
525
+                "Access Key {account_id:?}:{public_key} does not have enough balance {allowance} for transaction costing {cost}"
547
             ),
526
             ),
548
             InvalidAccessKeyError::DepositWithFunctionCall => {
527
             InvalidAccessKeyError::DepositWithFunctionCall => {
549
                 write!(f, "Having a deposit with a function call action is not allowed with a function call access key.")
528
                 write!(f, "Having a deposit with a function call action is not allowed with a function call access key.")
644
 
623
 
645
 impl std::fmt::Display for IntegerOverflowError {
624
 impl std::fmt::Display for IntegerOverflowError {
646
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
625
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
647
-        f.write_str(&format!("{:?}", self))
626
+        f.write_str(&format!("{self:?}"))
648
     }
627
     }
649
 }
628
 }
650
 
629
 
701
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
680
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
702
         match self {
681
         match self {
703
             ActionErrorKind::AccountAlreadyExists { account_id } => {
682
             ActionErrorKind::AccountAlreadyExists { account_id } => {
704
-                write!(f, "Can't create a new account {:?}, because it already exists", account_id)
683
+                write!(f, "Can't create a new account {account_id:?}, because it already exists")
705
             }
684
             }
706
             ActionErrorKind::AccountDoesNotExist { account_id } => write!(
685
             ActionErrorKind::AccountDoesNotExist { account_id } => write!(
707
                 f,
686
                 f,
708
-                "Can't complete the action because account {:?} doesn't exist",
709
-                account_id
687
+                "Can't complete the action because account {account_id:?} doesn't exist"
710
             ),
688
             ),
711
             ActionErrorKind::ActorNoPermission { actor_id, account_id } => write!(
689
             ActionErrorKind::ActorNoPermission { actor_id, account_id } => write!(
712
                 f,
690
                 f,
713
-                "Actor {:?} doesn't have permission to account {:?} to complete the action",
714
-                actor_id, account_id
691
+                "Actor {actor_id:?} doesn't have permission to account {account_id:?} to complete the action"
715
             ),
692
             ),
716
             ActionErrorKind::LackBalanceForState { account_id, amount } => write!(
693
             ActionErrorKind::LackBalanceForState { account_id, amount } => write!(
717
                 f,
694
                 f,
718
-                "The account {} wouldn't have enough balance to cover storage, required to have {} yoctoNEAR more",
719
-                account_id, amount
695
+                "The account {account_id} wouldn't have enough balance to cover storage, required to have {amount} yoctoNEAR more"
720
             ),
696
             ),
721
             ActionErrorKind::TriesToUnstake { account_id } => {
697
             ActionErrorKind::TriesToUnstake { account_id } => {
722
-                write!(f, "Account {:?} is not yet staked, but tries to unstake", account_id)
698
+                write!(f, "Account {account_id:?} is not yet staked, but tries to unstake")
723
             }
699
             }
724
             ActionErrorKind::TriesToStake { account_id, stake, locked, balance } => write!(
700
             ActionErrorKind::TriesToStake { account_id, stake, locked, balance } => write!(
725
                 f,
701
                 f,
726
-                "Account {:?} tries to stake {}, but has staked {} and only has {}",
727
-                account_id, stake, locked, balance
702
+                "Account {account_id:?} tries to stake {stake}, but has staked {locked} and only has {balance}"
728
             ),
703
             ),
729
             ActionErrorKind::CreateAccountOnlyByRegistrar { account_id, registrar_account_id, predecessor_id } => write!(
704
             ActionErrorKind::CreateAccountOnlyByRegistrar { account_id, registrar_account_id, predecessor_id } => write!(
730
                 f,
705
                 f,
731
-                "A top-level account ID {:?} can't be created by {:?}, short top-level account IDs can only be created by {:?}",
732
-                account_id, predecessor_id, registrar_account_id,
706
+                "A top-level account ID {account_id:?} can't be created by {predecessor_id:?}, short top-level account IDs can only be created by {registrar_account_id:?}"
733
             ),
707
             ),
734
             ActionErrorKind::CreateAccountNotAllowed { account_id, predecessor_id } => write!(
708
             ActionErrorKind::CreateAccountNotAllowed { account_id, predecessor_id } => write!(
735
                 f,
709
                 f,
736
-                "A sub-account ID {:?} can't be created by account {:?}",
737
-                account_id, predecessor_id,
710
+                "A sub-account ID {account_id:?} can't be created by account {predecessor_id:?}"
738
             ),
711
             ),
739
             ActionErrorKind::DeleteKeyDoesNotExist { account_id, .. } => write!(
712
             ActionErrorKind::DeleteKeyDoesNotExist { account_id, .. } => write!(
740
                 f,
713
                 f,
741
-                "Account {:?} tries to remove an access key that doesn't exist",
742
-                account_id
714
+                "Account {account_id:?} tries to remove an access key that doesn't exist"
743
             ),
715
             ),
744
             ActionErrorKind::AddKeyAlreadyExists { public_key, .. } => write!(
716
             ActionErrorKind::AddKeyAlreadyExists { public_key, .. } => write!(
745
                 f,
717
                 f,
746
-                "The public key {:?} is already used for an existing access key",
747
-                public_key
718
+                "The public key {public_key:?} is already used for an existing access key"
748
             ),
719
             ),
749
             ActionErrorKind::DeleteAccountStaking { account_id } => {
720
             ActionErrorKind::DeleteAccountStaking { account_id } => {
750
-                write!(f, "Account {:?} is staking and can not be deleted", account_id)
721
+                write!(f, "Account {account_id:?} is staking and can not be deleted")
751
             }
722
             }
752
-            ActionErrorKind::FunctionCallError(s) => write!(f, "{:?}", s),
723
+            ActionErrorKind::FunctionCallError(s) => write!(f, "{s:?}"),
753
             ActionErrorKind::NewReceiptValidationError(e) => {
724
             ActionErrorKind::NewReceiptValidationError(e) => {
754
-                write!(f, "An new action receipt created during a FunctionCall is not valid: {}", e)
725
+                write!(f, "An new action receipt created during a FunctionCall is not valid: {e}")
755
             }
726
             }
756
-            ActionErrorKind::InsufficientStake { account_id, stake, minimum_stake } => write!(f, "Account {} tries to stake {} but minimum required stake is {}", account_id, stake, minimum_stake),
757
-            ActionErrorKind::OnlyImplicitAccountCreationAllowed { account_id } => write!(f, "CreateAccount action is called on hex-characters account of length 64 {}", account_id),
758
-            ActionErrorKind::DeleteAccountWithLargeState { account_id } => write!(f, "The state of account {} is too large and therefore cannot be deleted", account_id),
727
+            ActionErrorKind::InsufficientStake { account_id, stake, minimum_stake } => write!(f, "Account {account_id} tries to stake {stake} but minimum required stake is {minimum_stake}"),
728
+            ActionErrorKind::OnlyImplicitAccountCreationAllowed { account_id } => write!(f, "CreateAccount action is called on hex-characters account of length 64 {account_id}"),
729
+            ActionErrorKind::DeleteAccountWithLargeState { account_id } => write!(f, "The state of account {account_id} is too large and therefore cannot be deleted"),
759
         }
730
         }
760
     }
731
     }
761
 }
732
 }
787
                 num_seats,
758
                 num_seats,
788
             } => write!(
759
             } => write!(
789
                 f,
760
                 f,
790
-                "Total stake {} must be higher than the number of seats {}",
791
-                stake_sum, num_seats
761
+                "Total stake {stake_sum} must be higher than the number of seats {num_seats}"
792
             ),
762
             ),
793
-            EpochError::MissingBlock(hash) => write!(f, "Missing block {}", hash),
794
-            EpochError::IOErr(err) => write!(f, "IO: {}", err),
795
-            EpochError::ShardingError(err) => write!(f, "Sharding Error: {}", err),
763
+            EpochError::MissingBlock(hash) => write!(f, "Missing block {hash}"),
764
+            EpochError::IOErr(err) => write!(f, "IO: {err}"),
765
+            EpochError::ShardingError(err) => write!(f, "Sharding Error: {err}"),
796
             EpochError::NotEnoughValidators {
766
             EpochError::NotEnoughValidators {
797
                 num_shards,
767
                 num_shards,
798
                 num_validators,
768
                 num_validators,
799
             } => {
769
             } => {
800
-                write!(f, "There were not enough validator proposals to fill all shards. num_proposals: {}, num_shards: {}", num_validators, num_shards)
770
+                write!(f, "There were not enough validator proposals to fill all shards. num_proposals: {num_validators}, num_shards: {num_shards}")
801
             }
771
             }
802
         }
772
         }
803
     }
773
     }
810
                 stake_sum,
780
                 stake_sum,
811
                 num_seats,
781
                 num_seats,
812
             } => {
782
             } => {
813
-                write!(f, "ThresholdError({}, {})", stake_sum, num_seats)
783
+                write!(f, "ThresholdError({stake_sum}, {num_seats})")
814
             }
784
             }
815
-            EpochError::MissingBlock(hash) => write!(f, "MissingBlock({})", hash),
816
-            EpochError::IOErr(err) => write!(f, "IOErr({})", err),
817
-            EpochError::ShardingError(err) => write!(f, "ShardingError({})", err),
785
+            EpochError::MissingBlock(hash) => write!(f, "MissingBlock({hash})"),
786
+            EpochError::IOErr(err) => write!(f, "IOErr({err})"),
787
+            EpochError::ShardingError(err) => write!(f, "ShardingError({err})"),
818
             EpochError::NotEnoughValidators {
788
             EpochError::NotEnoughValidators {
819
                 num_shards,
789
                 num_shards,
820
                 num_validators,
790
                 num_validators,
821
             } => {
791
             } => {
822
-                write!(f, "NotEnoughValidators({}, {})", num_validators, num_shards)
792
+                write!(f, "NotEnoughValidators({num_validators}, {num_shards})")
823
             }
793
             }
824
         }
794
         }
825
     }
795
     }

+ 2
- 2
near-primitives-light/src/transaction.rs View File

274
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
274
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
275
         match self {
275
         match self {
276
             ExecutionStatus::Unknown => f.write_str("Unknown"),
276
             ExecutionStatus::Unknown => f.write_str("Unknown"),
277
-            ExecutionStatus::Failure(e) => f.write_fmt(format_args!("Failure({})", e)),
277
+            ExecutionStatus::Failure(e) => f.write_fmt(format_args!("Failure({e})")),
278
             ExecutionStatus::SuccessValue(v) => {
278
             ExecutionStatus::SuccessValue(v) => {
279
                 f.write_fmt(format_args!("SuccessValue({})", to_base58(v)))
279
                 f.write_fmt(format_args!("SuccessValue({})", to_base58(v)))
280
             }
280
             }
281
             ExecutionStatus::SuccessReceiptId(receipt_id) => {
281
             ExecutionStatus::SuccessReceiptId(receipt_id) => {
282
-                f.write_fmt(format_args!("SuccessReceiptId({})", receipt_id))
282
+                f.write_fmt(format_args!("SuccessReceiptId({receipt_id})"))
283
             }
283
             }
284
         }
284
         }
285
     }
285
     }

+ 7
- 7
near-primitives-light/src/views.rs View File

613
         match self {
613
         match self {
614
             FinalExecutionStatus::NotStarted => f.write_str("NotStarted"),
614
             FinalExecutionStatus::NotStarted => f.write_str("NotStarted"),
615
             FinalExecutionStatus::Started => f.write_str("Started"),
615
             FinalExecutionStatus::Started => f.write_str("Started"),
616
-            FinalExecutionStatus::Failure(e) => f.write_fmt(format_args!("Failure({:?})", e)),
616
+            FinalExecutionStatus::Failure(e) => f.write_fmt(format_args!("Failure({e:?})")),
617
             FinalExecutionStatus::SuccessValue(v) => {
617
             FinalExecutionStatus::SuccessValue(v) => {
618
-                f.write_fmt(format_args!("SuccessValue({:?})", v))
618
+                f.write_fmt(format_args!("SuccessValue({v:?})"))
619
             }
619
             }
620
         }
620
         }
621
     }
621
     }
653
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
653
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
654
         match self {
654
         match self {
655
             ExecutionStatusView::Unknown => f.write_str("Unknown"),
655
             ExecutionStatusView::Unknown => f.write_str("Unknown"),
656
-            ExecutionStatusView::Failure(e) => f.write_fmt(format_args!("Failure({:?})", e)),
656
+            ExecutionStatusView::Failure(e) => f.write_fmt(format_args!("Failure({e:?})")),
657
             ExecutionStatusView::SuccessValue(v) => {
657
             ExecutionStatusView::SuccessValue(v) => {
658
-                f.write_fmt(format_args!("SuccessValue({:?})", v))
658
+                f.write_fmt(format_args!("SuccessValue({v:?})"))
659
             }
659
             }
660
             ExecutionStatusView::SuccessReceiptId(receipt_id) => {
660
             ExecutionStatusView::SuccessReceiptId(receipt_id) => {
661
-                f.write_fmt(format_args!("SuccessReceiptId({})", receipt_id))
661
+                f.write_fmt(format_args!("SuccessReceiptId({receipt_id})"))
662
             }
662
             }
663
         }
663
         }
664
     }
664
     }
715
                         cost: match cost {
715
                         cost: match cost {
716
                             Cost::ActionCost {
716
                             Cost::ActionCost {
717
                                 action_cost_kind: action_cost,
717
                                 action_cost_kind: action_cost,
718
-                            } => format!("{:?}", action_cost).to_ascii_uppercase(),
718
+                            } => format!("{action_cost:?}").to_ascii_uppercase(),
719
                             Cost::ExtCost {
719
                             Cost::ExtCost {
720
                                 ext_cost_kind: ext_cost,
720
                                 ext_cost_kind: ext_cost,
721
-                            } => format!("{:?}", ext_cost).to_ascii_uppercase(),
721
+                            } => format!("{ext_cost:?}").to_ascii_uppercase(),
722
                             Cost::WasmInstruction => "WASM_INSTRUCTION".to_string(),
722
                             Cost::WasmInstruction => "WASM_INSTRUCTION".to_string(),
723
                         },
723
                         },
724
                         gas_used: profile_data[cost],
724
                         gas_used: profile_data[cost],

+ 1
- 0
near-rpc/src/client.rs View File

343
         serde_json::from_slice::<T>(&self.data).map_err(Error::DeserializeTransactionOutput)
343
         serde_json::from_slice::<T>(&self.data).map_err(Error::DeserializeTransactionOutput)
344
     }
344
     }
345
 
345
 
346
+    #[allow(clippy::misnamed_getters)]
346
     /// Returns a transaction id
347
     /// Returns a transaction id
347
     pub fn id(&self) -> CryptoHash {
348
     pub fn id(&self) -> CryptoHash {
348
         self.transaction.block_hash
349
         self.transaction.block_hash

+ 1
- 1
near-rpc/src/rpc/mod.rs View File

70
 impl Display for Cause {
70
 impl Display for Cause {
71
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
72
         if let Some(info) = &self.info {
72
         if let Some(info) = &self.info {
73
-            return write!(f, "{}", info);
73
+            return write!(f, "{info}");
74
         }
74
         }
75
 
75
 
76
         Ok(())
76
         Ok(())

+ 1
- 1
near-rpc/tests/rpc.rs View File

59
 async fn clone_and_compile_wasm() -> Vec<u8> {
59
 async fn clone_and_compile_wasm() -> Vec<u8> {
60
     let tmp_path = temp_dir().into_path();
60
     let tmp_path = temp_dir().into_path();
61
     let repo_path = format!("{}/near-smartcontracts", tmp_path.to_string_lossy());
61
     let repo_path = format!("{}/near-smartcontracts", tmp_path.to_string_lossy());
62
-    let target_path = format!("{}/test-contract", repo_path);
62
+    let target_path = format!("{repo_path}/test-contract");
63
     let repo_url = "git@github.com:Relayz-io/near-smartcontracts.git";
63
     let repo_url = "git@github.com:Relayz-io/near-smartcontracts.git";
64
 
64
 
65
     // Prepare callbacks.
65
     // Prepare callbacks.

Loading…
Cancel
Save