Skip to content

Commit 1970475

Browse files
committed
chore: clippy fixes
Signed-off-by: aeryz <[email protected]>
1 parent 5e62ede commit 1970475

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

lib/sui-light-client-types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ unionlabs-primitives = { workspace = true, features = ["base58"] }
2828

2929
[dev-dependencies]
3030
hex-literal = { workspace = true }
31+
serde = { workspace = true }
3132
serde_json = { workspace = true }
3233

3334
[features]

lib/sui-light-client-types/src/checkpoint_summary.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl CheckpointContents {
103103
inner
104104
}
105105

106+
#[cfg(feature = "serde")]
106107
pub fn digest(&self) -> Digest {
107108
let mut hasher = Blake2b::<typenum::U32>::new();
108109
hasher.update("CheckpointContents::");

lib/sui-light-client-types/src/crypto.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ impl<'de> serde::Deserialize<'de> for SuiBitmap {
4545
D: serde::Deserializer<'de>,
4646
{
4747
let bytes: Vec<u8> = Vec::<u8>::deserialize(deserializer)?;
48-
Ok(Self::deserialize_from_bytes(&bytes).map_err(|e| {
48+
Self::deserialize_from_bytes(&bytes).map_err(|e| {
4949
serde::de::Error::custom(format!("byte deserialization failed, cause by: {:?}", e))
50-
})?)
50+
})
5151
}
5252
}
5353

@@ -87,8 +87,8 @@ impl<Context> bincode::Decode<Context> for SuiBitmap {
8787
) -> Result<Self, bincode::error::DecodeError> {
8888
let bytes = Vec::<u8>::decode(decoder)?;
8989

90-
Ok(Self::deserialize_from_bytes(&bytes)
91-
.map_err(|e| bincode::error::DecodeError::OtherString(e.to_string()))?)
90+
Self::deserialize_from_bytes(&bytes)
91+
.map_err(|e| bincode::error::DecodeError::OtherString(e.to_string()))
9292
}
9393
}
9494

lib/sui-light-client-types/src/object.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct ObjectInner {
1414
}
1515

1616
impl ObjectInner {
17+
#[cfg(feature = "serde")]
1718
pub fn digest(&self) -> Digest {
1819
let mut hasher = Blake2b::<typenum::U32>::new();
1920
hasher.update("Object::");

lib/sui-light-client-types/src/transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub enum TransactionData {
1515
}
1616

1717
impl TransactionData {
18+
#[cfg(feature = "serde")]
1819
pub fn digest(&self) -> Bytes<Base58> {
1920
let mut hasher = Blake2b::<typenum::U32>::new();
2021
hasher.update("TransactionData::");

lib/sui-light-client-types/src/transaction_effects.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use crate::{checkpoint_summary::GasCostSummary, digest::Digest, ObjectID, Object
66
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
77
#[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))]
88
pub enum TransactionEffects {
9-
V1(TransactionEffectsV1),
10-
V2(TransactionEffectsV2),
9+
V1(Box<TransactionEffectsV1>),
10+
V2(Box<TransactionEffectsV2>),
1111
}
1212

1313
/// The response from processing a transaction or a certified transaction
@@ -165,6 +165,7 @@ pub enum ExecutionStatus {
165165
}
166166

167167
impl TransactionEffects {
168+
#[cfg(feature = "serde")]
168169
pub fn digest(&self) -> Digest {
169170
let mut hasher = Blake2b::<typenum::U32>::new();
170171
hasher.update("TransactionEffects::");
@@ -175,21 +176,7 @@ impl TransactionEffects {
175176

176177
#[cfg(test)]
177178
mod tests {
178-
use std::str::FromStr;
179-
180-
use blake2::{Blake2b, Digest as _};
181-
use hex_literal::hex;
182-
use unionlabs_primitives::{encoding::Base58, Bytes, FixedBytes};
183-
184179
use super::*;
185-
use crate::U64;
186-
187-
fn digest<T: Serialize>(effects: &T) -> Bytes<Base58> {
188-
let mut hasher = Blake2b::<typenum::U32>::new();
189-
hasher.update("TransactionEffects::");
190-
bcs::serialize_into(&mut hasher, effects).unwrap();
191-
Bytes::new(hasher.finalize().to_vec())
192-
}
193180

194181
#[test]
195182
fn effects_digest() {
@@ -261,8 +248,9 @@ mod tests {
261248
.unwrap();
262249

263250
assert_eq!(
264-
Bytes::<Base58>::from_str("Fm3buiyN4vxDhnLiwvwDCJ1ZiohH3QCsVGiPCpC96RdR").unwrap(),
265-
digest(&TransactionEffects::V2(effect))
251+
serde_json::from_str::<Digest>("\"Fm3buiyN4vxDhnLiwvwDCJ1ZiohH3QCsVGiPCpC96RdR\"")
252+
.unwrap(),
253+
TransactionEffects::V2(Box::new(effect)).digest()
266254
);
267255
}
268256
}

0 commit comments

Comments
 (0)