Skip to content

Commit eaef977

Browse files
authored
refactor: format imports using cargo fmt (#258)
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent 6af1add commit eaef977

File tree

19 files changed

+100
-84
lines changed

19 files changed

+100
-84
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ jobs:
1111
fmt:
1212
name: cargo fmt
1313
runs-on: ubuntu-latest
14-
container:
15-
image: rust:1.83-bookworm
1614
steps:
17-
- uses: actions/checkout@v3
18-
- run: |
19-
rustup component add rustfmt
20-
cargo fmt --all -- --check
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
16+
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1
17+
with:
18+
# Imports formatting is an unstable feature, so we need to use nightly
19+
toolchain: nightly
20+
components: rustfmt
21+
cache: false
22+
- run: cargo +nightly fmt --all -- --check
2123

2224
clippy:
2325
name: cargo clippy

rustfmt.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
edition = "2021"
2+
3+
# Enable nightly features required for formatting imports
4+
unstable_features = true
5+
imports_granularity = "Crate"
6+
group_imports = "StdExternalCrate"
7+
reorder_modules = true

tap_aggregator/src/aggregator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ mod tests {
137137

138138
use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
139139
use rstest::*;
140+
use tap_core::{receipt::Receipt, signed_message::EIP712SignedMessage, tap_eip712_domain};
140141

141142
use crate::aggregator;
142-
use tap_core::{receipt::Receipt, signed_message::EIP712SignedMessage, tap_eip712_domain};
143143

144144
#[fixture]
145145
fn keys() -> (PrivateKeySigner, Address) {

tap_aggregator/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateK
99
use anyhow::Result;
1010
use clap::Parser;
1111
use log::{debug, info};
12-
use tap_core::tap_eip712_domain;
13-
1412
use tap_aggregator::{metrics, server};
13+
use tap_core::tap_eip712_domain;
1514

1615
#[derive(Parser, Debug)]
1716
#[command(author, version, about, long_about = None)]

tap_aggregator/src/server.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,19 @@ fn create_json_rpc_service(
388388
#[cfg(test)]
389389
#[allow(clippy::too_many_arguments)]
390390
mod tests {
391-
use std::collections::HashSet;
392-
use std::str::FromStr;
391+
use std::{collections::HashSet, str::FromStr};
393392

394393
use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
395394
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params};
396-
use rand::prelude::*;
397-
use rand::seq::SliceRandom;
395+
use rand::{prelude::*, seq::SliceRandom};
398396
use rstest::*;
399-
400-
use crate::server;
401397
use tap_core::{
402398
rav::ReceiptAggregateVoucher, receipt::Receipt, signed_message::EIP712SignedMessage,
403399
tap_eip712_domain,
404400
};
405401

402+
use crate::server;
403+
406404
#[derive(Clone)]
407405
struct Keys {
408406
wallet: PrivateKeySigner,

tap_aggregator/tests/aggregate_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::{collections::HashSet, str::FromStr};
55

66
use alloy::{primitives::Address, signers::local::PrivateKeySigner};
7-
87
use jsonrpsee::{core::client::ClientT, http_client::HttpClientBuilder, rpc_params};
98
use tap_aggregator::{
109
grpc::{tap_aggregator_client::TapAggregatorClient, RavRequest},

tap_core/benches/timeline_aggretion_protocol_benchmark.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
1111
use std::str::FromStr;
1212

13-
use alloy::dyn_abi::Eip712Domain;
14-
use alloy::primitives::Address;
15-
use alloy::signers::local::PrivateKeySigner;
13+
use alloy::{dyn_abi::Eip712Domain, primitives::Address, signers::local::PrivateKeySigner};
1614
use criterion::{black_box, criterion_group, criterion_main, Criterion};
17-
use tap_core::tap_eip712_domain;
1815
use tap_core::{
1916
rav::ReceiptAggregateVoucher, receipt::Receipt, signed_message::EIP712SignedMessage,
17+
tap_eip712_domain,
2018
};
2119

2220
pub fn create_and_sign_receipt(

tap_core/src/error.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
//! Module containing Error type and Result typedef
55
//!
66
7-
use crate::{rav::ReceiptAggregateVoucher, receipt::ReceiptError};
8-
use alloy::primitives::{Address, SignatureError};
97
use std::result::Result as StdResult;
8+
9+
use alloy::primitives::{Address, SignatureError};
1010
use thiserror::Error as ThisError;
1111

12+
use crate::{rav::ReceiptAggregateVoucher, receipt::ReceiptError};
13+
1214
/// Error type for the TAP protocol
1315
#[derive(ThisError, Debug)]
1416
pub enum Error {

tap_core/src/manager/context/memory.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
//! This module provides an in-memory implementation of the TAP manager context.
77
//! It is useful for testing and development purposes.
88
9+
use std::{
10+
collections::HashMap,
11+
ops::RangeBounds,
12+
sync::{Arc, RwLock},
13+
};
14+
15+
use alloy::primitives::Address;
16+
use async_trait::async_trait;
17+
918
use crate::{
1019
manager::adapters::*,
1120
rav::SignedRAV,
1221
receipt::{checks::StatefulTimestampCheck, state::Checking, ReceiptWithState},
1322
signed_message::MessageId,
1423
};
15-
use alloy::primitives::Address;
16-
use async_trait::async_trait;
17-
use std::ops::RangeBounds;
18-
use std::sync::RwLock;
19-
use std::{collections::HashMap, sync::Arc};
2024

2125
pub type EscrowStorage = Arc<RwLock<HashMap<Address, u128>>>;
2226
pub type QueryAppraisals = Arc<RwLock<HashMap<MessageId, u128>>>;
@@ -259,6 +263,13 @@ impl EscrowHandler for InMemoryContext {
259263
}
260264

261265
pub mod checks {
266+
use std::{
267+
collections::{HashMap, HashSet},
268+
sync::{Arc, RwLock},
269+
};
270+
271+
use alloy::{dyn_abi::Eip712Domain, primitives::Address};
272+
262273
use crate::{
263274
receipt::{
264275
checks::{Check, CheckError, CheckResult, ReceiptCheck},
@@ -267,11 +278,6 @@ pub mod checks {
267278
},
268279
signed_message::MessageId,
269280
};
270-
use alloy::{dyn_abi::Eip712Domain, primitives::Address};
271-
use std::{
272-
collections::{HashMap, HashSet},
273-
sync::{Arc, RwLock},
274-
};
275281

276282
pub fn get_full_list_of_checks(
277283
domain_separator: Eip712Domain,

tap_core/src/rav.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ mod request;
4141

4242
use std::cmp;
4343

44-
use alloy::primitives::Address;
45-
use alloy::sol;
44+
use alloy::{primitives::Address, sol};
4645
use serde::{Deserialize, Serialize};
4746

48-
use crate::Error;
49-
use crate::{receipt::Receipt, signed_message::EIP712SignedMessage};
47+
use crate::{receipt::Receipt, signed_message::EIP712SignedMessage, Error};
5048

5149
/// EIP712 signed message for ReceiptAggregateVoucher
5250
pub type SignedRAV = EIP712SignedMessage<ReceiptAggregateVoucher>;

0 commit comments

Comments
 (0)