Skip to content

Commit 490de0b

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

File tree

16 files changed

+40
-54
lines changed

16 files changed

+40
-54
lines changed

cosmwasm/ibc-union/lightclient/sui/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl From<Error> for IbcClientError<SuiLightClient> {
2626
}
2727
}
2828

29-
impl Into<sui_verifier::Error> for Error {
30-
fn into(self) -> sui_verifier::Error {
31-
sui_verifier::Error::Client(Box::new(self))
29+
impl From<Error> for sui_verifier::Error {
30+
fn from(value: Error) -> Self {
31+
sui_verifier::Error::Client(Box::new(value))
3232
}
3333
}

cosmwasm/ibc-union/lightclient/sui/src/verifier.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ impl<'a> SignatureVerification for Verifier<'a> {
1616
msg: &[u8],
1717
signature: &sui_light_client_types::crypto::AggregateAuthoritySignature,
1818
) -> Result<(), Self::Error> {
19-
let pubkeys = public_keys
20-
.into_iter()
21-
.flat_map(|x| x.0)
22-
.collect::<Vec<u8>>();
19+
let pubkeys = public_keys.iter().flat_map(|x| x.0).collect::<Vec<u8>>();
2320

2421
let aggregate_pubkey = self.deps.api.bls12_381_aggregate_g2(&pubkeys)?;
2522

2623
let hashed_msg =
2724
self.deps
2825
.api
29-
.bls12_381_hash_to_g1(HashFunction::Sha256, &msg, Self::BLS_DST)?;
26+
.bls12_381_hash_to_g1(HashFunction::Sha256, msg, Self::BLS_DST)?;
3027

3128
let valid = self.deps.api.bls12_381_pairing_equality(
3229
signature.0.as_ref(),

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
}

lib/sui-verifier/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ fn find_write_effect(effects: &TransactionEffects, object: ObjectID) -> Option<D
162162
TransactionEffects::V2(effects) => effects.changed_objects.iter().find_map(|eff| {
163163
if eff.0 == object {
164164
match &eff.1.output_state {
165-
ObjectOut::ObjectWrite(write) => Some(write.0.clone()),
165+
ObjectOut::ObjectWrite(write) => Some(write.0),
166166
_ => None,
167167
}
168168
} else {

voyager/modules/client-bootstrap/sui/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl ClientBootstrapModule for Module {
5656

5757
let chain_id = sui_client.read_api().get_chain_identifier().await?;
5858

59-
info.ensure_chain_id(chain_id.to_string())?;
59+
info.ensure_chain_id(&chain_id)?;
6060
info.ensure_client_type(ClientType::SUI)?;
6161

6262
Ok(Self {

0 commit comments

Comments
 (0)