Browse Source

satisfy clippy

develop
Kyrylo Stepanov 2 years ago
parent
commit
fddc20125b

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

@@ -80,7 +80,7 @@ impl From<&Ed25519SecretKey> for Ed25519PublicKey {
80 80
 
81 81
 // This `Hash` implementation is safe since it retains the property
82 82
 // `k1 == k2 ⇒ hash(k1) == hash(k2)`.
83
-#[allow(clippy::derive_hash_xor_eq)]
83
+#[allow(clippy::derived_hash_with_manual_eq)]
84 84
 impl Hash for Ed25519PublicKey {
85 85
     fn hash<H: Hasher>(&self, state: &mut H) {
86 86
         state.write_u8(0u8);
@@ -197,7 +197,7 @@ impl BorshSerialize for Ed25519Signature {
197 197
     }
198 198
 }
199 199
 
200
-#[allow(clippy::derive_hash_xor_eq)]
200
+#[allow(clippy::derived_hash_with_manual_eq)]
201 201
 impl Hash for Ed25519Signature {
202 202
     fn hash<H: Hasher>(&self, state: &mut H) {
203 203
         self.to_bytes().hash(state);

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

@@ -257,9 +257,10 @@ impl Borrow<CryptoHash> for SignedTransaction {
257 257
 }
258 258
 
259 259
 /// The status of execution for a transaction or a receipt.
260
-#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
260
+#[derive(Default, BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
261 261
 pub enum ExecutionStatus {
262 262
     /// The execution is pending or unknown.
263
+    #[default]
263 264
     Unknown,
264 265
     /// The execution has failed with the given execution error.
265 266
     Failure(Box<TxExecutionError>),
@@ -285,12 +286,6 @@ impl fmt::Debug for ExecutionStatus {
285 286
     }
286 287
 }
287 288
 
288
-impl Default for ExecutionStatus {
289
-    fn default() -> Self {
290
-        ExecutionStatus::Unknown
291
-    }
292
-}
293
-
294 289
 /// ExecutionOutcome for proof. Excludes logs and metadata
295 290
 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Clone)]
296 291
 pub struct PartialExecutionOutcome {
@@ -371,21 +366,16 @@ impl Default for ExecutionOutcome {
371 366
     }
372 367
 }
373 368
 
374
-#[derive(BorshSerialize, BorshDeserialize, PartialEq, Clone, Eq, Debug)]
369
+#[derive(Default, BorshSerialize, BorshDeserialize, PartialEq, Clone, Eq, Debug)]
375 370
 pub enum ExecutionMetadata {
376 371
     // V1: Empty Metadata
372
+    #[default]
377 373
     V1,
378 374
 
379 375
     // V2: With ProfileData
380 376
     V2(ProfileData),
381 377
 }
382 378
 
383
-impl Default for ExecutionMetadata {
384
-    fn default() -> Self {
385
-        ExecutionMetadata::V1
386
-    }
387
-}
388
-
389 379
 impl fmt::Debug for ExecutionOutcome {
390 380
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
391 381
         f.debug_struct("ExecutionOutcome")

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

@@ -12,22 +12,17 @@ use serde::{Deserialize, Serialize};
12 12
 pub type StateRoot = CryptoHash;
13 13
 
14 14
 /// Different types of finality.
15
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
15
+#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
16 16
 pub enum Finality {
17 17
     #[serde(rename = "optimistic")]
18 18
     None,
19 19
     #[serde(rename = "near-final")]
20 20
     DoomSlug,
21
+    #[default]
21 22
     #[serde(rename = "final")]
22 23
     Final,
23 24
 }
24 25
 
25
-impl Default for Finality {
26
-    fn default() -> Self {
27
-        Finality::Final
28
-    }
29
-}
30
-
31 26
 #[derive(Debug, Serialize, Deserialize)]
32 27
 pub struct AccountWithPublicKey {
33 28
     pub account_id: AccountId,

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

@@ -596,9 +596,12 @@ impl From<SignedTransaction> for SignedTransactionView {
596 596
 }
597 597
 
598 598
 #[allow(clippy::large_enum_variant)]
599
-#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Clone)]
599
+#[derive(
600
+    Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Clone,
601
+)]
600 602
 pub enum FinalExecutionStatus {
601 603
     /// The execution has not yet started.
604
+    #[default]
602 605
     NotStarted,
603 606
     /// The execution has started and still going.
604 607
     Started,
@@ -621,12 +624,6 @@ impl fmt::Debug for FinalExecutionStatus {
621 624
     }
622 625
 }
623 626
 
624
-impl Default for FinalExecutionStatus {
625
-    fn default() -> Self {
626
-        FinalExecutionStatus::NotStarted
627
-    }
628
-}
629
-
630 627
 #[allow(clippy::large_enum_variant)]
631 628
 #[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
632 629
 pub enum ServerError {

Loading…
Cancel
Save