Skip to content

Commit

Permalink
chore: rustfmt (#3)
Browse files Browse the repository at this point in the history
* chore: rustfmt

* chore: add dprint config

* Format with nightly

* fix CI

* checkout

* install nightly

* reformat

* remove ignore external-crates

---------

Co-authored-by: Chloe Martin <[email protected]>
Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent 1af0e3c commit be2b0fc
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 27 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rust-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions crates/iota-rust-sdk/src/types/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions crates/iota-rust-sdk/src/types/crypto/multisig.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{
zklogin::{ZkLoginAuthenticator, ZkLoginPublicIdentifier},
Ed25519PublicKey, Ed25519Signature, Secp256k1PublicKey, Secp256k1Signature, Secp256r1PublicKey,
Secp256r1Signature, SignatureScheme,
zklogin::{ZkLoginAuthenticator, ZkLoginPublicIdentifier},
};

pub type WeightUnit = u8;
Expand Down Expand Up @@ -166,8 +166,8 @@ mod serialization {

use super::*;
use crate::types::{
crypto::{Base64Array33, Base64Array34},
Ed25519PublicKey, Secp256k1PublicKey, Secp256r1PublicKey, SignatureScheme,
crypto::{Base64Array33, Base64Array34},
};

pub struct Base64MultisigMemberPublicKey;
Expand Down
6 changes: 1 addition & 5 deletions crates/iota-rust-sdk/src/types/crypto/zklogin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rust-sdk/src/types/effects/v1.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rust-sdk/src/types/effects/v2.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions crates/iota-rust-sdk/src/types/transaction/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -967,8 +967,8 @@ mod signed_transaction {

use super::*;
use crate::types::{
transaction::{SignedTransaction, Transaction},
UserSignature,
transaction::{SignedTransaction, Transaction},
};

/// Intents are defined as:
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rust-sdk/src/types/transaction/unresolved.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rust-sdk/src/types/type_tag/parse.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
4 changes: 2 additions & 2 deletions crates/iota-rust-sdk/src/types/type_tag/serialization.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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::*;
Expand Down
23 changes: 23 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
8 changes: 8 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit be2b0fc

Please sign in to comment.