diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d4e8aa..50c2736 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,21 +25,32 @@ jobs: rustc --version cargo --version - - uses: taiki-e/install-action@cargo-hack - uses: taiki-e/install-action@cargo-nextest + - name: Run tests + run: make test + + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: taiki-e/install-action@cargo-hack + + - name: Install latest nightly + run: rustup toolchain install nightly --component rustfmt --allow-downgrade + - name: feature compatibility run: make check-features - name: rustfmt - run: cargo fmt -- --check + run: cargo +nightly fmt -- --check - name: clippy run: make clippy - - name: Run tests - run: make test - - name: rustdoc run: make doc 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/dprint.json b/dprint.json new file mode 100644 index 0000000..f18a8fe --- /dev/null +++ b/dprint.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://dprint.dev/schemas/v0.json", + "incremental": true, + "includes": [ + "**/*.{toml}", + "**/*.{md}", + "**/*.{yml,yaml}" + ], + "excludes": [ + "**/CHANGELOG.md", + "**/target/", + "**/build/", + "**/pnpm-lock.yaml", + ], + "toml": { + "lineWidth": 80 + }, + "plugins": [ + "https://plugins.dprint.dev/toml-0.6.2.wasm", + "https://plugins.dprint.dev/markdown-0.17.1.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.4.0.wasm" + ] +} \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..4dc6b95 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,8 @@ +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