From ae9365ea913be71a0f64a4f10d68c063e4fcb995 Mon Sep 17 00:00:00 2001 From: muXxer Date: Fri, 4 Oct 2024 18:13:45 +0200 Subject: [PATCH] chore: rustfmt --- crates/iota-rust-sdk/src/lib.rs | 2 +- crates/iota-rust-sdk/src/types/checkpoint.rs | 8 ++++---- crates/iota-rust-sdk/src/types/crypto/multisig.rs | 4 ++-- crates/iota-rust-sdk/src/types/crypto/zklogin.rs | 6 +----- crates/iota-rust-sdk/src/types/effects/v1.rs | 2 +- crates/iota-rust-sdk/src/types/effects/v2.rs | 2 +- .../iota-rust-sdk/src/types/transaction/serialization.rs | 8 ++++---- crates/iota-rust-sdk/src/types/transaction/unresolved.rs | 2 +- crates/iota-rust-sdk/src/types/type_tag/parse.rs | 2 +- crates/iota-rust-sdk/src/types/type_tag/serialization.rs | 4 ++-- rustfmt.toml | 9 +++++++++ 11 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 rustfmt.toml diff --git a/crates/iota-rust-sdk/src/lib.rs b/crates/iota-rust-sdk/src/lib.rs index 30bf517..71944cc 100644 --- a/crates/iota-rust-sdk/src/lib.rs +++ b/crates/iota-rust-sdk/src/lib.rs @@ -120,8 +120,8 @@ mod _serde { #[cfg(feature = "schemars")] mod _schemars { use schemars::{ - schema::{InstanceType, Metadata, SchemaObject}, JsonSchema, + schema::{InstanceType, Metadata, SchemaObject}, }; pub(crate) struct U64; diff --git a/crates/iota-rust-sdk/src/types/checkpoint.rs b/crates/iota-rust-sdk/src/types/checkpoint.rs index 2498ede..fc64a23 100644 --- a/crates/iota-rust-sdk/src/types/checkpoint.rs +++ b/crates/iota-rust-sdk/src/types/checkpoint.rs @@ -386,8 +386,8 @@ mod serialization { where S: Serializer, { - let mut seq = serializer.serialize_seq(Some(self.0 .0.len()))?; - for txn in &self.0 .0 { + let mut seq = serializer.serialize_seq(Some(self.0.0.len()))?; + for txn in &self.0.0 { let digests = Digests { transaction: &txn.transaction, effects: &txn.effects, @@ -404,8 +404,8 @@ mod serialization { where S: Serializer, { - let mut seq = serializer.serialize_seq(Some(self.0 .0.len()))?; - for txn in &self.0 .0 { + let mut seq = serializer.serialize_seq(Some(self.0.0.len()))?; + for txn in &self.0.0 { seq.serialize_element(&txn.signatures)?; } seq.end() diff --git a/crates/iota-rust-sdk/src/types/crypto/multisig.rs b/crates/iota-rust-sdk/src/types/crypto/multisig.rs index e43b0eb..90086a9 100644 --- a/crates/iota-rust-sdk/src/types/crypto/multisig.rs +++ b/crates/iota-rust-sdk/src/types/crypto/multisig.rs @@ -1,7 +1,7 @@ use super::{ - zklogin::{ZkLoginAuthenticator, ZkLoginPublicIdentifier}, Ed25519PublicKey, Ed25519Signature, Secp256k1PublicKey, Secp256k1Signature, Secp256r1PublicKey, Secp256r1Signature, SignatureScheme, + zklogin::{ZkLoginAuthenticator, ZkLoginPublicIdentifier}, }; pub type WeightUnit = u8; @@ -166,8 +166,8 @@ mod serialization { use super::*; use crate::types::{ - crypto::{Base64Array33, Base64Array34}, Ed25519PublicKey, Secp256k1PublicKey, Secp256r1PublicKey, SignatureScheme, + crypto::{Base64Array33, Base64Array34}, }; pub struct Base64MultisigMemberPublicKey; diff --git a/crates/iota-rust-sdk/src/types/crypto/zklogin.rs b/crates/iota-rust-sdk/src/types/crypto/zklogin.rs index 826c683..35b4e67 100644 --- a/crates/iota-rust-sdk/src/types/crypto/zklogin.rs +++ b/crates/iota-rust-sdk/src/types/crypto/zklogin.rs @@ -159,11 +159,7 @@ impl Bn254FieldElement { } // If the value is '0' then just return a slice of length 1 of the final byte - if buf.is_empty() { - &self.0[31..] - } else { - buf - } + if buf.is_empty() { &self.0[31..] } else { buf } } pub fn padded(&self) -> &[u8] { diff --git a/crates/iota-rust-sdk/src/types/effects/v1.rs b/crates/iota-rust-sdk/src/types/effects/v1.rs index 569ea82..16274fa 100644 --- a/crates/iota-rust-sdk/src/types/effects/v1.rs +++ b/crates/iota-rust-sdk/src/types/effects/v1.rs @@ -1,7 +1,7 @@ use crate::types::{ + EpochId, GasCostSummary, ObjectId, ObjectReference, TransactionDigest, TransactionEventsDigest, execution_status::ExecutionStatus, object::{Owner, Version}, - EpochId, GasCostSummary, ObjectId, ObjectReference, TransactionDigest, TransactionEventsDigest, }; /// The response from processing a transaction or a certified transaction diff --git a/crates/iota-rust-sdk/src/types/effects/v2.rs b/crates/iota-rust-sdk/src/types/effects/v2.rs index 2e4faa6..d8ae5a1 100644 --- a/crates/iota-rust-sdk/src/types/effects/v2.rs +++ b/crates/iota-rust-sdk/src/types/effects/v2.rs @@ -1,8 +1,8 @@ use crate::types::{ + EpochId, GasCostSummary, ObjectDigest, ObjectId, TransactionDigest, TransactionEventsDigest, digest::EffectsAuxiliaryDataDigest, execution_status::ExecutionStatus, object::{Owner, Version}, - EpochId, GasCostSummary, ObjectDigest, ObjectId, TransactionDigest, TransactionEventsDigest, }; /// The response from processing a transaction or a certified transaction diff --git a/crates/iota-rust-sdk/src/types/transaction/serialization.rs b/crates/iota-rust-sdk/src/types/transaction/serialization.rs index 95e7f0b..f6e9e7e 100644 --- a/crates/iota-rust-sdk/src/types/transaction/serialization.rs +++ b/crates/iota-rust-sdk/src/types/transaction/serialization.rs @@ -7,8 +7,8 @@ use crate::types::{ObjectId, ObjectReference}; mod transaction { use super::*; use crate::types::{ - transaction::{GasPayment, Transaction, TransactionExpiration, TransactionKind}, Address, + transaction::{GasPayment, Transaction, TransactionExpiration, TransactionKind}, }; #[derive(serde_derive::Serialize)] @@ -321,8 +321,8 @@ mod transaction_kind { mod end_of_epoch { use super::*; use crate::types::{ - transaction::{AuthenticatorStateExpire, ChangeEpoch, EndOfEpochTransactionKind}, CheckpointDigest, + transaction::{AuthenticatorStateExpire, ChangeEpoch, EndOfEpochTransactionKind}, }; #[derive(serde_derive::Serialize)] @@ -967,8 +967,8 @@ mod signed_transaction { use super::*; use crate::types::{ - transaction::{SignedTransaction, Transaction}, UserSignature, + transaction::{SignedTransaction, Transaction}, }; /// Intents are defined as: @@ -1235,8 +1235,8 @@ mod test { use wasm_bindgen_test::wasm_bindgen_test as test; use crate::types::{ - transaction::{Argument, InputArgument, Transaction}, ObjectDigest, ObjectId, ObjectReference, + transaction::{Argument, InputArgument, Transaction}, }; #[test] diff --git a/crates/iota-rust-sdk/src/types/transaction/unresolved.rs b/crates/iota-rust-sdk/src/types/transaction/unresolved.rs index e20bdf1..c1c1200 100644 --- a/crates/iota-rust-sdk/src/types/transaction/unresolved.rs +++ b/crates/iota-rust-sdk/src/types/transaction/unresolved.rs @@ -1,5 +1,5 @@ use super::{Command, TransactionExpiration}; -use crate::types::{object::Version, Address, ObjectDigest, ObjectId}; +use crate::types::{Address, ObjectDigest, ObjectId, object::Version}; // A potentially Unresolved user transaction #[cfg_attr( diff --git a/crates/iota-rust-sdk/src/types/type_tag/parse.rs b/crates/iota-rust-sdk/src/types/type_tag/parse.rs index 354693d..c558603 100644 --- a/crates/iota-rust-sdk/src/types/type_tag/parse.rs +++ b/crates/iota-rust-sdk/src/types/type_tag/parse.rs @@ -1,9 +1,9 @@ use winnow::{ + PResult, Parser, ascii::space0, combinator::{alt, delimited, eof, opt, separated}, stream::AsChar, token::{one_of, take_while}, - PResult, Parser, }; use super::{Address, Identifier, StructTag, TypeTag}; diff --git a/crates/iota-rust-sdk/src/types/type_tag/serialization.rs b/crates/iota-rust-sdk/src/types/type_tag/serialization.rs index eded71b..f2a72dd 100644 --- a/crates/iota-rust-sdk/src/types/type_tag/serialization.rs +++ b/crates/iota-rust-sdk/src/types/type_tag/serialization.rs @@ -1,4 +1,4 @@ -use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor}; use serde_with::{DeserializeAs, SerializeAs}; use super::*; @@ -243,8 +243,8 @@ impl<'de> Deserialize<'de> for StructTag { #[cfg(feature = "schemars")] mod json_schema { use schemars::{ - schema::{InstanceType, Metadata, SchemaObject, StringValidation}, JsonSchema, + schema::{InstanceType, Metadata, SchemaObject, StringValidation}, }; use super::*; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..38d99e3 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,9 @@ +edition = "2021" +style_edition = "2024" +format_code_in_doc_comments = true +group_imports = "StdExternalCrate" +imports_granularity = "Crate" +normalize_comments = true +normalize_doc_attributes = true +wrap_comments = true +ignore = ["external-crates"] \ No newline at end of file