From 5b80cfbc6e5ed0985caaaa9a3be3c5be712deaa8 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Wed, 15 May 2024 09:14:39 +0200 Subject: [PATCH] restructure imports --- distance-oracle/src/lib.rs | 6 ++-- end2end-tests/tests/common/balances.rs | 4 +-- end2end-tests/tests/common/cert.rs | 4 +-- end2end-tests/tests/common/distance.rs | 12 ++++---- end2end-tests/tests/common/identity.rs | 7 ++--- end2end-tests/tests/common/mod.rs | 24 ++++++++-------- end2end-tests/tests/common/oneshot.rs | 15 ++++++---- end2end-tests/tests/cucumber_tests.rs | 15 +++++----- live-tests/tests/sanity_gdev.rs | 9 ++---- node/src/chain_spec/gdev.rs | 5 +--- node/src/chain_spec/gen_genesis_data.rs | 31 +++++++++++++-------- node/src/chain_spec/gtest.rs | 10 ++----- node/src/command.rs | 10 ++++--- node/src/rpc.rs | 6 ++-- node/src/service.rs | 8 +++--- node/src/service/client.rs | 4 +-- pallets/authority-members/src/impls.rs | 9 ++---- pallets/authority-members/src/lib.rs | 10 +++---- pallets/authority-members/src/mock.rs | 6 ++-- pallets/authority-members/src/tests.rs | 3 +- pallets/certification/src/lib.rs | 3 +- pallets/certification/src/tests.rs | 3 +- pallets/distance/src/benchmarking.rs | 3 +- pallets/distance/src/lib.rs | 6 ++-- pallets/distance/src/mock.rs | 3 +- pallets/distance/src/tests.rs | 6 ++-- pallets/duniter-account/src/lib.rs | 6 ++-- pallets/duniter-test-parameters/src/lib.rs | 3 +- pallets/duniter-wot/src/mock.rs | 2 +- pallets/duniter-wot/src/tests.rs | 3 +- pallets/identity/src/benchmarking.rs | 6 ++-- pallets/identity/src/lib.rs | 6 ++-- pallets/identity/src/mock.rs | 3 +- pallets/identity/src/tests.rs | 9 ++---- pallets/membership/src/lib.rs | 9 ++---- pallets/membership/src/tests.rs | 7 ++--- pallets/offences/src/mock.rs | 6 ++-- pallets/oneshot-account/src/benchmarking.rs | 6 ++-- pallets/oneshot-account/src/check_nonce.rs | 3 +- pallets/oneshot-account/src/lib.rs | 14 ++++++---- pallets/provide-randomness/src/lib.rs | 16 +++++++---- pallets/quota/src/benchmarking.rs | 3 +- pallets/quota/src/lib.rs | 9 +++--- pallets/quota/src/mock.rs | 7 ++--- pallets/quota/src/tests.rs | 3 +- pallets/smith-members/src/lib.rs | 26 +++++++---------- pallets/smith-members/src/mock.rs | 5 ++-- pallets/universal-dividend/src/lib.rs | 8 ++++-- pallets/upgrade-origin/src/lib.rs | 3 +- primitives/membership/src/lib.rs | 3 +- resources/weight_analyzer/src/lib.rs | 22 +++++++-------- runtime/common/src/handlers.rs | 6 ++-- runtime/g1/src/lib.rs | 15 ++++------ runtime/g1/src/parameters.rs | 6 ++-- runtime/gdev/src/lib.rs | 15 ++++------ runtime/gdev/src/parameters.rs | 6 ++-- runtime/gdev/tests/balance_tests.rs | 3 +- runtime/gdev/tests/common/mod.rs | 19 ++++++------- runtime/gdev/tests/integration_tests.rs | 12 ++++---- runtime/gdev/tests/offences_tests.rs | 7 +++-- runtime/gdev/tests/xt_tests.rs | 13 ++++----- runtime/gtest/src/lib.rs | 15 ++++------ runtime/gtest/src/parameters.rs | 3 +- rustfmt.toml | 1 + xtask/src/gen_doc.rs | 10 +++---- xtask/src/main.rs | 8 ++++-- 66 files changed, 246 insertions(+), 303 deletions(-) diff --git a/distance-oracle/src/lib.rs b/distance-oracle/src/lib.rs index c59d89b7c..53a7503ea 100644 --- a/distance-oracle/src/lib.rs +++ b/distance-oracle/src/lib.rs @@ -29,10 +29,8 @@ use api::{AccountId, IdtyIndex}; use codec::Encode; use fnv::{FnvHashMap, FnvHashSet}; use log::{debug, error, info, warn}; -use rayon::iter::IntoParallelRefIterator; -use rayon::iter::ParallelIterator; -use std::io::Write; -use std::path::PathBuf; +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; +use std::{io::Write, path::PathBuf}; // TODO select metadata file using features #[subxt::subxt(runtime_metadata_path = "../resources/metadata.scale")] diff --git a/end2end-tests/tests/common/balances.rs b/end2end-tests/tests/common/balances.rs index 9329a5fe1..e7b703736 100644 --- a/end2end-tests/tests/common/balances.rs +++ b/end2end-tests/tests/common/balances.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use super::gdev; -use super::gdev::runtime_types::pallet_balances; -use super::*; +use super::{gdev, gdev::runtime_types::pallet_balances, *}; use sp_keyring::AccountKeyring; use subxt::{tx::PairSigner, utils::MultiAddress}; diff --git a/end2end-tests/tests/common/cert.rs b/end2end-tests/tests/common/cert.rs index 86efaed68..8ca1d080a 100644 --- a/end2end-tests/tests/common/cert.rs +++ b/end2end-tests/tests/common/cert.rs @@ -14,9 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use super::gdev; -use super::gdev::runtime_types::pallet_certification; -use super::*; +use super::{gdev, gdev::runtime_types::pallet_certification, *}; use sp_keyring::AccountKeyring; use subxt::{tx::PairSigner, utils::MultiAddress}; diff --git a/end2end-tests/tests/common/distance.rs b/end2end-tests/tests/common/distance.rs index 97add31a3..29a3a12c9 100644 --- a/end2end-tests/tests/common/distance.rs +++ b/end2end-tests/tests/common/distance.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use super::gdev; -use super::gdev::runtime_types::pallet_identity; -use super::*; +use super::{gdev, gdev::runtime_types::pallet_identity, *}; use crate::DuniterWorld; use sp_keyring::AccountKeyring; -use subxt::backend::rpc::RpcClient; -use subxt::tx::{PairSigner, Signer}; -use subxt::utils::AccountId32; +use subxt::{ + backend::rpc::RpcClient, + tx::{PairSigner, Signer}, + utils::AccountId32, +}; pub async fn request_evaluation(client: &FullClient, origin: AccountKeyring) -> Result<()> { let origin = PairSigner::new(origin.pair()); diff --git a/end2end-tests/tests/common/identity.rs b/end2end-tests/tests/common/identity.rs index ab42cff02..da532a67e 100644 --- a/end2end-tests/tests/common/identity.rs +++ b/end2end-tests/tests/common/identity.rs @@ -14,11 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. -use super::gdev; -use super::gdev::runtime_types::pallet_identity; -use super::*; -use crate::gdev::runtime_types::pallet_identity::types::IdtyName; -use crate::DuniterWorld; +use super::{gdev, gdev::runtime_types::pallet_identity, *}; +use crate::{gdev::runtime_types::pallet_identity::types::IdtyName, DuniterWorld}; use sp_keyring::AccountKeyring; use subxt::tx::PairSigner; diff --git a/end2end-tests/tests/common/mod.rs b/end2end-tests/tests/common/mod.rs index 87df5c301..6ed0e8375 100644 --- a/end2end-tests/tests/common/mod.rs +++ b/end2end-tests/tests/common/mod.rs @@ -33,17 +33,19 @@ use codec::Encode; use notify_debouncer_mini::new_debouncer; use serde_json::Value; use sp_keyring::AccountKeyring; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; -use std::process::Command; -use std::str::FromStr; -use std::time::{Duration, Instant}; -use subxt::backend::rpc::RpcClient; -use subxt::backend::rpc::RpcParams; -use subxt::config::substrate::SubstrateExtrinsicParamsBuilder; -use subxt::config::SubstrateExtrinsicParams; -use subxt::ext::{sp_core, sp_runtime}; -use subxt::rpc_params; +use std::{ + io::prelude::*, + path::{Path, PathBuf}, + process::Command, + str::FromStr, + time::{Duration, Instant}, +}; +use subxt::{ + backend::rpc::{RpcClient, RpcParams}, + config::{substrate::SubstrateExtrinsicParamsBuilder, SubstrateExtrinsicParams}, + ext::{sp_core, sp_runtime}, + rpc_params, +}; pub type Client = subxt::OnlineClient<GdevConfig>; pub type Event = gdev::Event; diff --git a/end2end-tests/tests/common/oneshot.rs b/end2end-tests/tests/common/oneshot.rs index 51478d129..bcfe65dc8 100644 --- a/end2end-tests/tests/common/oneshot.rs +++ b/end2end-tests/tests/common/oneshot.rs @@ -14,13 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use super::gdev; -use super::gdev::runtime_types::pallet_balances; -use super::gdev::runtime_types::pallet_oneshot_account; -use super::*; +use super::{ + gdev, + gdev::runtime_types::{pallet_balances, pallet_oneshot_account}, + *, +}; use sp_keyring::AccountKeyring; -use subxt::utils::AccountId32; -use subxt::{tx::PairSigner, utils::MultiAddress}; +use subxt::{ + tx::PairSigner, + utils::{AccountId32, MultiAddress}, +}; pub enum Account { Normal(AccountKeyring), diff --git a/end2end-tests/tests/cucumber_tests.rs b/end2end-tests/tests/cucumber_tests.rs index 5c174c954..4b35e0242 100644 --- a/end2end-tests/tests/cucumber_tests.rs +++ b/end2end-tests/tests/cucumber_tests.rs @@ -17,14 +17,15 @@ mod common; use common::*; -use cucumber::StatsWriter; -use cucumber::{given, then, when, World}; +use cucumber::{given, then, when, StatsWriter, World}; use sp_keyring::AccountKeyring; -use std::path::PathBuf; -use std::str::FromStr; -use std::sync::{ - atomic::{AtomicBool, Ordering}, - Arc, +use std::{ + path::PathBuf, + str::FromStr, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, }; use subxt::backend::rpc::RpcClient; diff --git a/live-tests/tests/sanity_gdev.rs b/live-tests/tests/sanity_gdev.rs index 28a9a0387..ca6ded3e8 100644 --- a/live-tests/tests/sanity_gdev.rs +++ b/live-tests/tests/sanity_gdev.rs @@ -18,11 +18,9 @@ pub mod gdev {} use countmap::CountMap; -use sp_core::crypto::AccountId32; -use sp_core::{blake2_128, ByteArray, H256}; +use sp_core::{blake2_128, crypto::AccountId32, ByteArray, H256}; use std::collections::{HashMap, HashSet}; -use subxt::backend::rpc::RpcClient; -use subxt::config::SubstrateConfig as GdevConfig; +use subxt::{backend::rpc::RpcClient, config::SubstrateConfig as GdevConfig}; const DEFAULT_ENDPOINT: &str = "ws://localhost:9944"; @@ -48,8 +46,7 @@ type IdtyIndex = u32; type IdtyValue = gdev::runtime_types::pallet_identity::types::IdtyValue<BlockNumber, AccountId32, IdtyData>; type MembershipData = gdev::runtime_types::sp_membership::MembershipData<BlockNumber>; -use gdev::runtime_types::pallet_identity::types::IdtyName; -use gdev::runtime_types::pallet_identity::types::IdtyStatus; +use gdev::runtime_types::pallet_identity::types::{IdtyName, IdtyStatus}; struct Storage { accounts: HashMap<AccountId32, AccountInfo>, diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 45a6f0514..370da7b0b 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -18,10 +18,7 @@ use super::*; use crate::chain_spec::gen_genesis_data::{ AuthorityKeys, CommonParameters, GenesisIdentity, SessionKeysProvider, }; -use common_runtime::constants::*; -use common_runtime::entities::IdtyData; -use common_runtime::GenesisIdty; -use common_runtime::IdtyStatus; +use common_runtime::{constants::*, entities::IdtyData, GenesisIdty, IdtyStatus}; use gdev_runtime::{ opaque::SessionKeys, pallet_universal_dividend, parameters, Runtime, RuntimeGenesisConfig, WASM_BINARY, diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs index b6ce08e5f..8807e1453 100644 --- a/node/src/chain_spec/gen_genesis_data.rs +++ b/node/src/chain_spec/gen_genesis_data.rs @@ -15,8 +15,10 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use crate::chain_spec::{get_account_id_from_seed, get_from_seed, AccountPublic}; -use common_runtime::constants::{DAYS, MILLISECS_PER_BLOCK}; -use common_runtime::*; +use common_runtime::{ + constants::{DAYS, MILLISECS_PER_BLOCK}, + *, +}; use log::{error, warn}; use num_format::{Locale, ToFormattedString}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -24,14 +26,17 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize}; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::crypto::AccountId32; -use sp_core::{ed25519, sr25519, Decode, Encode}; -use sp_runtime::traits::{IdentifyAccount, Verify}; -use sp_runtime::{MultiSignature, Perbill}; -use std::collections::{BTreeMap, HashMap}; -use std::fmt::{Display, Formatter}; -use std::fs; -use std::ops::{Add, Sub}; +use sp_core::{crypto::AccountId32, ed25519, sr25519, Decode, Encode}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature, Perbill, +}; +use std::{ + collections::{BTreeMap, HashMap}, + fmt::{Display, Formatter}, + fs, + ops::{Add, Sub}, +}; static G1_DUNITER_V1_EXISTENTIAL_DEPOSIT: u64 = 100; static G1_DUNITER_V1_DECIMALS: usize = 2; @@ -2064,8 +2069,10 @@ fn seconds_to_blocs(seconds: u32) -> u32 { #[cfg(test)] mod tests { use super::*; - use sp_core::crypto::{Ss58AddressFormat, Ss58Codec}; - use sp_core::ByteArray; + use sp_core::{ + crypto::{Ss58AddressFormat, Ss58Codec}, + ByteArray, + }; use std::str::FromStr; #[test] diff --git a/node/src/chain_spec/gtest.rs b/node/src/chain_spec/gtest.rs index 018b130b0..3154b76cf 100644 --- a/node/src/chain_spec/gtest.rs +++ b/node/src/chain_spec/gtest.rs @@ -16,14 +16,10 @@ use super::*; use crate::chain_spec::gen_genesis_data::{CommonParameters, GenesisIdentity, SessionKeysProvider}; -use common_runtime::constants::*; -use common_runtime::entities::IdtyData; -use common_runtime::GenesisIdty; -use common_runtime::IdtyStatus; -use gtest_runtime::ImOnlineId; +use common_runtime::{constants::*, entities::IdtyData, GenesisIdty, IdtyStatus}; use gtest_runtime::{ - opaque::SessionKeys, pallet_universal_dividend, parameters, AccountId, Perbill, Runtime, - RuntimeGenesisConfig, WASM_BINARY, + opaque::SessionKeys, pallet_universal_dividend, parameters, AccountId, ImOnlineId, Perbill, + Runtime, RuntimeGenesisConfig, WASM_BINARY, }; use jsonrpsee::core::JsonValue; use sc_consensus_grandpa::AuthorityId as GrandpaId; diff --git a/node/src/command.rs b/node/src/command.rs index 3303d99b0..9b0f335c3 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -20,10 +20,12 @@ pub mod key; pub mod utils; -use crate::cli::{Cli, Subcommand}; -use crate::service::runtime_executor::Executor; -use crate::service::RuntimeType; -use crate::{chain_spec, service}; +use crate::{ + chain_spec, + cli::{Cli, Subcommand}, + service, + service::{runtime_executor::Executor, RuntimeType}, +}; use clap::CommandFactory; #[cfg(feature = "runtime-benchmarks")] use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 301d4ce9f..e61d608f5 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -23,11 +23,9 @@ pub use sc_rpc_api::DenyUnsafe; -use common_runtime::Block; -use common_runtime::{AccountId, Balance, Index}; +use common_runtime::{AccountId, Balance, Block, Index}; use jsonrpsee::RpcModule; -use sc_consensus_babe::BabeApi; -use sc_consensus_babe::BabeWorkerHandle; +use sc_consensus_babe::{BabeApi, BabeWorkerHandle}; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; diff --git a/node/src/service.rs b/node/src/service.rs index e71e3709f..8ce3d3c2b 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -22,12 +22,12 @@ use self::client::{Client, ClientHandle, RuntimeApiCollection}; use async_io::Timer; use common_runtime::Block; use futures::{Stream, StreamExt}; -use sc_client_api::client::BlockBackend; -use sc_client_api::Backend; +use sc_client_api::{client::BlockBackend, Backend}; use sc_consensus_grandpa::SharedVoterState; use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams}; -use sc_service::WarpSyncParams; -use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; +use sc_service::{ + error::Error as ServiceError, Configuration, PartialComponents, TaskManager, WarpSyncParams, +}; use sc_telemetry::{Telemetry, TelemetryWorker}; use sp_consensus_babe::inherents::InherentDataProvider; use sp_core::H256; diff --git a/node/src/service/client.rs b/node/src/service/client.rs index d9019c682..34fbea16a 100644 --- a/node/src/service/client.rs +++ b/node/src/service/client.rs @@ -15,9 +15,9 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use common_runtime::{AccountId, Balance, Block, BlockNumber, Hash, Header, Index}; -use sc_client_api::MerkleValue; use sc_client_api::{ - AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, PairsIter, UsageProvider, + AuxStore, Backend as BackendT, BlockchainEvents, KeysIter, MerkleValue, PairsIter, + UsageProvider, }; use sp_api::{CallApiAt, ProvideRuntimeApi}; use sp_blockchain::{HeaderBackend, HeaderMetadata}; diff --git a/pallets/authority-members/src/impls.rs b/pallets/authority-members/src/impls.rs index 6a1930e3f..337f46895 100644 --- a/pallets/authority-members/src/impls.rs +++ b/pallets/authority-members/src/impls.rs @@ -23,13 +23,10 @@ #![allow(clippy::type_complexity)] use super::pallet::*; -use frame_support::pallet_prelude::Weight; -use frame_support::traits::Get; -use pallet_offences::traits::OnOffenceHandler; -use pallet_offences::SlashStrategy; +use frame_support::{pallet_prelude::Weight, traits::Get}; +use pallet_offences::{traits::OnOffenceHandler, SlashStrategy}; use sp_runtime::traits::Convert; -use sp_staking::offence::OffenceDetails; -use sp_staking::SessionIndex; +use sp_staking::{offence::OffenceDetails, SessionIndex}; impl<T: Config> OnOffenceHandler<T::AccountId, pallet_session::historical::IdentificationTuple<T>, Weight> diff --git a/pallets/authority-members/src/lib.rs b/pallets/authority-members/src/lib.rs index 963a180b5..052d4130a 100644 --- a/pallets/authority-members/src/lib.rs +++ b/pallets/authority-members/src/lib.rs @@ -45,13 +45,13 @@ use sp_std::prelude::*; #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::ValidatorRegistration; - use frame_support::traits::{StorageVersion, UnfilteredDispatchable}; + use frame_support::{ + pallet_prelude::*, + traits::{StorageVersion, UnfilteredDispatchable, ValidatorRegistration}, + }; use frame_system::pallet_prelude::*; use sp_runtime::traits::{Convert, IsMember}; - use sp_std::collections::btree_map::BTreeMap; - use sp_std::vec; + use sp_std::{collections::btree_map::BTreeMap, vec}; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); diff --git a/pallets/authority-members/src/mock.rs b/pallets/authority-members/src/mock.rs index 34b26a922..15db413e5 100644 --- a/pallets/authority-members/src/mock.rs +++ b/pallets/authority-members/src/mock.rs @@ -18,16 +18,14 @@ use super::*; use crate::{self as pallet_authority_members}; use frame_support::{pallet_prelude::*, parameter_types, traits::Everything}; use frame_system as system; -use pallet_offences::traits::OnOffenceHandler; -use pallet_offences::SlashStrategy; +use pallet_offences::{traits::OnOffenceHandler, SlashStrategy}; use pallet_session::ShouldEndSession; use sp_core::{crypto::key_types::DUMMY, H256}; -use sp_runtime::BuildStorage; use sp_runtime::{ impl_opaque_keys, testing::UintAuthorityId, traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys}, - KeyTypeId, + BuildStorage, KeyTypeId, }; use sp_staking::offence::OffenceDetails; use sp_state_machine::BasicExternalities; diff --git a/pallets/authority-members/src/tests.rs b/pallets/authority-members/src/tests.rs index 12e1d13dd..35dbced54 100644 --- a/pallets/authority-members/src/tests.rs +++ b/pallets/authority-members/src/tests.rs @@ -18,8 +18,7 @@ use super::*; use crate::mock::*; use frame_support::{assert_err, assert_noop, assert_ok}; use frame_system::RawOrigin; -use sp_runtime::testing::UintAuthorityId; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{testing::UintAuthorityId, traits::BadOrigin}; use sp_staking::offence::OffenceDetails; const EMPTY: Vec<u64> = Vec::new(); diff --git a/pallets/certification/src/lib.rs b/pallets/certification/src/lib.rs index b2061d396..01df96349 100644 --- a/pallets/certification/src/lib.rs +++ b/pallets/certification/src/lib.rs @@ -37,8 +37,7 @@ pub use weights::WeightInfo; use crate::traits::*; use codec::Codec; use duniter_primitives::Idty; -use frame_support::pallet_prelude::*; -use frame_support::traits::StorageVersion; +use frame_support::{pallet_prelude::*, traits::StorageVersion}; use sp_runtime::traits::AtLeast32BitUnsigned; use sp_std::{fmt::Debug, vec::Vec}; diff --git a/pallets/certification/src/tests.rs b/pallets/certification/src/tests.rs index 0bde9557b..fc8d4fb65 100644 --- a/pallets/certification/src/tests.rs +++ b/pallets/certification/src/tests.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::{Error, Event}; +use crate::{mock::*, Error, Event}; use frame_support::{assert_noop, assert_ok}; use maplit::btreemap; use sp_std::collections::btree_map::BTreeMap; diff --git a/pallets/distance/src/benchmarking.rs b/pallets/distance/src/benchmarking.rs index bf1a6a519..06e2637fc 100644 --- a/pallets/distance/src/benchmarking.rs +++ b/pallets/distance/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use codec::Encode; use frame_benchmarking::v2::*; use frame_support::traits::{Get, OnFinalize, OnInitialize}; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::Perbill; use crate::Pallet; diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index 06e58088f..b52e2bb08 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -41,8 +41,10 @@ use frame_support::traits::{ }; use sp_distance::{InherentError, INHERENT_IDENTIFIER}; use sp_inherents::{InherentData, InherentIdentifier}; -use sp_runtime::traits::{One, Zero}; -use sp_runtime::Saturating; +use sp_runtime::{ + traits::{One, Zero}, + Saturating, +}; use sp_std::{convert::TryInto, prelude::*}; type IdtyIndex = u32; diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index 7b2391ce4..0f232b82d 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -25,13 +25,12 @@ use frame_system as system; use pallet_balances::AccountData; use pallet_session::ShouldEndSession; use sp_core::{ConstU32, H256}; -use sp_runtime::BuildStorage; use sp_runtime::{ impl_opaque_keys, key_types::DUMMY, testing::{TestSignature, UintAuthorityId}, traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember, OpaqueKeys}, - KeyTypeId, Perbill, + BuildStorage, KeyTypeId, Perbill, }; type Balance = u64; diff --git a/pallets/distance/src/tests.rs b/pallets/distance/src/tests.rs index 18302be75..4ec3087cb 100644 --- a/pallets/distance/src/tests.rs +++ b/pallets/distance/src/tests.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::*; -use frame_support::traits::Currency; -use frame_support::{assert_noop, assert_ok}; +use crate::{mock::*, *}; +use frame_support::{assert_noop, assert_ok, traits::Currency}; // allow request distance evaluation for oneself #[test] diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 2e131264a..514084f87 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -28,8 +28,10 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::pallet_prelude::*; -use frame_support::traits::{fungible, fungible::Credit, IsSubType, StorageVersion, StoredMap}; +use frame_support::{ + pallet_prelude::*, + traits::{fungible, fungible::Credit, IsSubType, StorageVersion, StoredMap}, +}; use frame_system::pallet_prelude::*; use pallet_quota::traits::RefundFee; use pallet_transaction_payment::OnChargeTransaction; diff --git a/pallets/duniter-test-parameters/src/lib.rs b/pallets/duniter-test-parameters/src/lib.rs index 98db19954..39775e7c4 100644 --- a/pallets/duniter-test-parameters/src/lib.rs +++ b/pallets/duniter-test-parameters/src/lib.rs @@ -65,8 +65,7 @@ pub mod types { #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::StorageVersion; + use frame_support::{pallet_prelude::*, traits::StorageVersion}; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index f73248cc6..60148e0ec 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -19,10 +19,10 @@ use crate::{self as pallet_duniter_wot}; use frame_support::{parameter_types, traits::Everything}; use frame_system as system; use sp_core::H256; -use sp_runtime::BuildStorage; use sp_runtime::{ testing::{TestSignature, UintAuthorityId}, traits::{BlakeTwo256, IdentityLookup}, + BuildStorage, }; use sp_state_machine::BasicExternalities; use std::collections::BTreeMap; diff --git a/pallets/duniter-wot/src/tests.rs b/pallets/duniter-wot/src/tests.rs index 515827526..c82be3514 100644 --- a/pallets/duniter-wot/src/tests.rs +++ b/pallets/duniter-wot/src/tests.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::pallet as pallet_duniter_wot; +use crate::{mock::*, pallet as pallet_duniter_wot}; use codec::Encode; use frame_support::{assert_noop, assert_ok}; use pallet_identity::{ diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index 734707ae0..20e746213 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -19,11 +19,9 @@ use super::*; use codec::Encode; -use frame_benchmarking::account; -use frame_benchmarking::v2::*; +use frame_benchmarking::{account, v2::*}; use frame_support::traits::OnInitialize; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_core::Get; use sp_io::crypto::{sr25519_generate, sr25519_sign}; use sp_runtime::{AccountId32, MultiSigner}; diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 3ff6fde96..886e62586 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -38,8 +38,7 @@ use crate::traits::*; use codec::Codec; use frame_support::pallet_prelude::Weight; use sp_runtime::traits::{AtLeast32BitUnsigned, IdentifyAccount, One, Saturating, Verify, Zero}; -use sp_std::fmt::Debug; -use sp_std::prelude::*; +use sp_std::{fmt::Debug, prelude::*}; // icok = identity change owner key pub const NEW_OWNER_KEY_PAYLOAD_PREFIX: [u8; 4] = [b'i', b'c', b'o', b'k']; @@ -51,8 +50,7 @@ pub const LINK_IDTY_PAYLOAD_PREFIX: [u8; 4] = [b'l', b'i', b'n', b'k']; #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::StorageVersion; + use frame_support::{pallet_prelude::*, traits::StorageVersion}; use frame_system::pallet_prelude::*; /// The current storage version. diff --git a/pallets/identity/src/mock.rs b/pallets/identity/src/mock.rs index 81a0dc356..e13c48b21 100644 --- a/pallets/identity/src/mock.rs +++ b/pallets/identity/src/mock.rs @@ -23,10 +23,9 @@ use frame_support::{ use frame_system as system; use sp_core::{Pair, H256}; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; -use sp_runtime::BuildStorage; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, - MultiSignature, MultiSigner, + BuildStorage, MultiSignature, MultiSigner, }; use sp_state_machine::BasicExternalities; use std::sync::Arc; diff --git a/pallets/identity/src/tests.rs b/pallets/identity/src/tests.rs index 63ae3b5c6..9bc2205eb 100644 --- a/pallets/identity/src/tests.rs +++ b/pallets/identity/src/tests.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::*; +use crate::{mock::*, *}; use codec::Encode; -use frame_support::dispatch::DispatchResultWithPostInfo; -use frame_support::{assert_noop, assert_ok}; -use sp_core::sr25519::Pair as KeyPair; -use sp_core::Pair; +use frame_support::{assert_noop, assert_ok, dispatch::DispatchResultWithPostInfo}; +use sp_core::{sr25519::Pair as KeyPair, Pair}; use sp_runtime::{MultiSignature, MultiSigner}; type IdtyVal = IdtyValue<u64, AccountId, ()>; diff --git a/pallets/membership/src/lib.rs b/pallets/membership/src/lib.rs index 4119fcb9c..714d4bb09 100644 --- a/pallets/membership/src/lib.rs +++ b/pallets/membership/src/lib.rs @@ -31,13 +31,10 @@ pub mod weights; pub use pallet::*; pub use weights::WeightInfo; -use frame_support::pallet_prelude::Weight; -use frame_support::pallet_prelude::*; -use sp_membership::traits::*; -use sp_membership::MembershipData; +use frame_support::pallet_prelude::{Weight, *}; +use sp_membership::{traits::*, MembershipData}; use sp_runtime::traits::Zero; -use sp_std::collections::btree_map::BTreeMap; -use sp_std::prelude::*; +use sp_std::{collections::btree_map::BTreeMap, prelude::*}; #[cfg(feature = "runtime-benchmarks")] pub trait SetupBenchmark<IdtyId, AccountId> { diff --git a/pallets/membership/src/tests.rs b/pallets/membership/src/tests.rs index 4f22c3213..c9b04c0a2 100644 --- a/pallets/membership/src/tests.rs +++ b/pallets/membership/src/tests.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::MembershipRemovalReason; -use crate::{Error, Event}; +use crate::{mock::*, Error, Event, MembershipRemovalReason}; use frame_support::{assert_noop, assert_ok}; use maplit::btreemap; -use sp_membership::traits::*; -use sp_membership::MembershipData; +use sp_membership::{traits::*, MembershipData}; fn default_gen_conf() -> MembershipConfig { MembershipConfig { diff --git a/pallets/offences/src/mock.rs b/pallets/offences/src/mock.rs index 76fb2218f..62cd5150d 100644 --- a/pallets/offences/src/mock.rs +++ b/pallets/offences/src/mock.rs @@ -16,8 +16,7 @@ #![cfg(test)] -use crate::Config; -use crate::{self as pallet_offences, SlashStrategy}; +use crate::{self as pallet_offences, Config, SlashStrategy}; use codec::Encode; use frame_support::{ parameter_types, @@ -25,10 +24,9 @@ use frame_support::{ weights::{constants::RocksDbWeight, Weight}, }; use sp_core::H256; -use sp_runtime::BuildStorage; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, - Perbill, + BuildStorage, Perbill, }; use sp_staking::{ offence::{Kind, OffenceDetails}, diff --git a/pallets/oneshot-account/src/benchmarking.rs b/pallets/oneshot-account/src/benchmarking.rs index ed38c4377..1a9360587 100644 --- a/pallets/oneshot-account/src/benchmarking.rs +++ b/pallets/oneshot-account/src/benchmarking.rs @@ -19,10 +19,8 @@ use super::*; -use frame_benchmarking::v2::*; -use frame_benchmarking::{account, whitelisted_caller}; -use frame_support::pallet_prelude::IsType; -use frame_support::traits::fungible::Mutate; +use frame_benchmarking::{account, v2::*, whitelisted_caller}; +use frame_support::{pallet_prelude::IsType, traits::fungible::Mutate}; use frame_system::RawOrigin; use pallet_balances::Pallet as Balances; diff --git a/pallets/oneshot-account/src/check_nonce.rs b/pallets/oneshot-account/src/check_nonce.rs index 83bd7494f..3f3654531 100644 --- a/pallets/oneshot-account/src/check_nonce.rs +++ b/pallets/oneshot-account/src/check_nonce.rs @@ -17,8 +17,7 @@ use crate::Config; use codec::{Decode, Encode}; -use frame_support::dispatch::DispatchInfo; -use frame_support::traits::IsSubType; +use frame_support::{dispatch::DispatchInfo, traits::IsSubType}; //use frame_system::Config; use scale_info::TypeInfo; use sp_runtime::{ diff --git a/pallets/oneshot-account/src/lib.rs b/pallets/oneshot-account/src/lib.rs index a22e897a9..f1bff130b 100644 --- a/pallets/oneshot-account/src/lib.rs +++ b/pallets/oneshot-account/src/lib.rs @@ -28,12 +28,14 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::pallet_prelude::*; -use frame_support::traits::fungible; -use frame_support::traits::{ - fungible::{Balanced, Credit, Inspect}, - tokens::{Fortitude, Precision, Preservation}, - Imbalance, IsSubType, +use frame_support::{ + pallet_prelude::*, + traits::{ + fungible, + fungible::{Balanced, Credit, Inspect}, + tokens::{Fortitude, Precision, Preservation}, + Imbalance, IsSubType, + }, }; use frame_system::pallet_prelude::*; use pallet_transaction_payment::OnChargeTransaction; diff --git a/pallets/provide-randomness/src/lib.rs b/pallets/provide-randomness/src/lib.rs index 608197496..159be9f87 100644 --- a/pallets/provide-randomness/src/lib.rs +++ b/pallets/provide-randomness/src/lib.rs @@ -23,10 +23,12 @@ mod benchmarking; mod types; pub mod weights; -use frame_support::pallet_prelude::Weight; -use frame_support::traits::{ - fungible::{self, Balanced, Credit}, - tokens::{Fortitude, Precision, Preservation}, +use frame_support::{ + pallet_prelude::Weight, + traits::{ + fungible::{self, Balanced, Credit}, + tokens::{Fortitude, Precision, Preservation}, + }, }; use sp_core::H256; use sp_std::prelude::*; @@ -49,8 +51,10 @@ impl OnFilledRandomness for () { #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::{OnUnbalanced, Randomness, StorageVersion}; + use frame_support::{ + pallet_prelude::*, + traits::{OnUnbalanced, Randomness, StorageVersion}, + }; use frame_system::pallet_prelude::*; use sp_core::H256; diff --git a/pallets/quota/src/benchmarking.rs b/pallets/quota/src/benchmarking.rs index 834268d9c..24dcd895e 100644 --- a/pallets/quota/src/benchmarking.rs +++ b/pallets/quota/src/benchmarking.rs @@ -17,8 +17,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::account; -use frame_benchmarking::v2::*; +use frame_benchmarking::{account, v2::*}; use sp_runtime::traits::One; fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { diff --git a/pallets/quota/src/lib.rs b/pallets/quota/src/lib.rs index 7c25f1fe7..79772ba8c 100644 --- a/pallets/quota/src/lib.rs +++ b/pallets/quota/src/lib.rs @@ -29,13 +29,14 @@ mod tests; pub mod benchmarking; use crate::traits::*; -use frame_support::pallet_prelude::*; -use frame_support::traits::{Currency, ExistenceRequirement}; +use frame_support::{ + pallet_prelude::*, + traits::{Currency, ExistenceRequirement}, +}; use frame_system::pallet_prelude::*; pub use pallet::*; use sp_runtime::traits::Zero; -use sp_std::fmt::Debug; -use sp_std::vec::Vec; +use sp_std::{fmt::Debug, vec::Vec}; pub use weights::WeightInfo; #[frame_support::pallet] diff --git a/pallets/quota/src/mock.rs b/pallets/quota/src/mock.rs index 06aa1acbe..fac5bad20 100644 --- a/pallets/quota/src/mock.rs +++ b/pallets/quota/src/mock.rs @@ -24,12 +24,9 @@ use frame_support::{ }; use frame_system as system; use sp_core::{Pair, H256}; -use sp_runtime::traits::IdentifyAccount; -use sp_runtime::traits::Verify; -use sp_runtime::BuildStorage; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, - MultiSignature, MultiSigner, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + BuildStorage, MultiSignature, MultiSigner, }; type BlockNumber = u64; diff --git a/pallets/quota/src/tests.rs b/pallets/quota/src/tests.rs index 81f65b8bf..40f746928 100644 --- a/pallets/quota/src/tests.rs +++ b/pallets/quota/src/tests.rs @@ -14,8 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use crate::mock::*; -use crate::Weight; +use crate::{mock::*, Weight}; use frame_support::traits::Currency; use sp_core::Get; diff --git a/pallets/smith-members/src/lib.rs b/pallets/smith-members/src/lib.rs index 61edcd6f6..883ed202d 100644 --- a/pallets/smith-members/src/lib.rs +++ b/pallets/smith-members/src/lib.rs @@ -32,18 +32,15 @@ mod benchmarking; use codec::{Codec, Decode, Encode}; use duniter_primitives::Idty; -use frame_support::dispatch::DispatchResultWithPostInfo; -use frame_support::ensure; -use frame_support::pallet_prelude::Get; -use frame_support::pallet_prelude::RuntimeDebug; -use frame_support::pallet_prelude::Weight; -use frame_system::ensure_signed; -use frame_system::pallet_prelude::OriginFor; +use frame_support::{ + dispatch::DispatchResultWithPostInfo, + ensure, + pallet_prelude::{Get, RuntimeDebug, Weight}, +}; +use frame_system::{ensure_signed, pallet_prelude::OriginFor}; use scale_info::TypeInfo; -use sp_runtime::traits::AtLeast32BitUnsigned; -use sp_runtime::traits::IsMember; -use sp_std::fmt::Debug; -use sp_std::prelude::*; +use sp_runtime::traits::{AtLeast32BitUnsigned, IsMember}; +use sp_std::{fmt::Debug, prelude::*}; use crate::traits::OnSmithDelete; pub use crate::weights::WeightInfo; @@ -73,13 +70,10 @@ pub enum SmithStatus { #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::StorageVersion; + use frame_support::{pallet_prelude::*, traits::StorageVersion}; use pallet_authority_members::SessionIndex; use sp_runtime::traits::{Convert, IsMember}; - use sp_std::collections::btree_map::BTreeMap; - use sp_std::vec; - use sp_std::vec::Vec; + use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec}; const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); diff --git a/pallets/smith-members/src/mock.rs b/pallets/smith-members/src/mock.rs index 804b7d49f..fa181f3bf 100644 --- a/pallets/smith-members/src/mock.rs +++ b/pallets/smith-members/src/mock.rs @@ -17,16 +17,15 @@ #![cfg(test)] use crate::{self as pallet_smith_members}; -use frame_support::pallet_prelude::Hooks; use frame_support::{ + pallet_prelude::Hooks, parameter_types, traits::{ConstU32, ConstU64}, weights::{constants::RocksDbWeight, Weight}, }; use sp_core::H256; -use sp_runtime::traits::{ConvertInto, IsMember}; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, ConvertInto, IdentityLookup, IsMember}, BuildStorage, Perbill, }; diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index 0b6360055..4609384d4 100644 --- a/pallets/universal-dividend/src/lib.rs +++ b/pallets/universal-dividend/src/lib.rs @@ -33,9 +33,9 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::traits::tokens::{Precision, Preservation}; use frame_support::traits::{ fungible::{self, Balanced, Mutate}, + tokens::{Precision, Preservation}, OnTimestampSet, }; use sp_arithmetic::{ @@ -47,8 +47,10 @@ use sp_runtime::traits::{Get, MaybeSerializeDeserialize, StaticLookup}; #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::pallet_prelude::*; - use frame_support::traits::{StorageVersion, StoredMap}; + use frame_support::{ + pallet_prelude::*, + traits::{StorageVersion, StoredMap}, + }; use frame_system::pallet_prelude::*; use sp_runtime::traits::Convert; diff --git a/pallets/upgrade-origin/src/lib.rs b/pallets/upgrade-origin/src/lib.rs index 15ebd1ae9..bcd8ad688 100644 --- a/pallets/upgrade-origin/src/lib.rs +++ b/pallets/upgrade-origin/src/lib.rs @@ -24,8 +24,7 @@ pub use pallet::*; pub use weights::WeightInfo; use frame_support::{ - dispatch::GetDispatchInfo, - dispatch::PostDispatchInfo, + dispatch::{GetDispatchInfo, PostDispatchInfo}, traits::{IsSubType, UnfilteredDispatchable}, }; use sp_runtime::traits::Dispatchable; diff --git a/primitives/membership/src/lib.rs b/primitives/membership/src/lib.rs index 49756dda2..c98121711 100644 --- a/primitives/membership/src/lib.rs +++ b/primitives/membership/src/lib.rs @@ -22,8 +22,7 @@ pub mod traits; use codec::{Decode, Encode}; -use frame_support::pallet_prelude::RuntimeDebug; -use frame_support::pallet_prelude::Weight; +use frame_support::pallet_prelude::{RuntimeDebug, Weight}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; diff --git a/resources/weight_analyzer/src/lib.rs b/resources/weight_analyzer/src/lib.rs index 83a43093c..4f0682466 100644 --- a/resources/weight_analyzer/src/lib.rs +++ b/resources/weight_analyzer/src/lib.rs @@ -1,15 +1,16 @@ use convert_case::{Case, Casing}; use glob::glob; use serde::Serialize; -use std::collections::HashMap; -use std::ops::Div; -use std::path::Path; -use subweight_core::parse::overhead::Weight; -use subweight_core::parse::pallet::ChromaticExtrinsic; -use subweight_core::parse::pallet::ComponentRange; -use subweight_core::parse::storage::Weights; -use subweight_core::scope::Scope; -use subweight_core::term::Term; +use std::{collections::HashMap, ops::Div, path::Path}; +use subweight_core::{ + parse::{ + overhead::Weight, + pallet::{ChromaticExtrinsic, ComponentRange}, + storage::Weights, + }, + scope::Scope, + term::Term, +}; // Substrate default maximum weight of a block in nanoseconds. // Since the maximum block weight is one-third of the execution time, @@ -171,8 +172,7 @@ fn process( #[cfg(test)] mod tests { - use crate::analyze_weight; - use crate::MaxBlockWeight; + use crate::{analyze_weight, MaxBlockWeight}; use std::path::Path; #[test] fn should_works() { diff --git a/runtime/common/src/handlers.rs b/runtime/common/src/handlers.rs index c12f6d3d5..e8518fd1c 100644 --- a/runtime/common/src/handlers.rs +++ b/runtime/common/src/handlers.rs @@ -14,10 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -use super::entities::*; -use super::{AccountId, IdtyIndex}; -use frame_support::pallet_prelude::Weight; -use frame_support::traits::UnfilteredDispatchable; +use super::{entities::*, AccountId, IdtyIndex}; +use frame_support::{pallet_prelude::Weight, traits::UnfilteredDispatchable}; use pallet_smith_members::SmithRemovalReason; /// OnNewSession handler for the runtime calling all the implementation diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 20c078caa..a8c6ba1c0 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -33,8 +33,7 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; -use frame_support::traits::fungible::Balanced; -use frame_support::traits::Imbalance; +use frame_support::traits::{fungible::Balanced, Imbalance}; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_identity::{IdtyStatus, IdtyValue}; @@ -48,18 +47,16 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; -use frame_support::traits::Contains; -use frame_support::PalletId; +use frame_support::{traits::Contains, PalletId}; use frame_system::EnsureRoot; -use pallet_grandpa::fg_primitives; -use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use pallet_grandpa::{ + fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, +}; use sp_api::impl_runtime_apis; use sp_core::OpaqueMetadata; -use sp_runtime::traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys, -}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs index 966982a79..280a9f728 100644 --- a/runtime/g1/src/parameters.rs +++ b/runtime/g1/src/parameters.rs @@ -15,10 +15,8 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use crate::*; -use common_runtime::constants::*; -use common_runtime::Moment; -use frame_support::parameter_types; -use frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND; +use common_runtime::{constants::*, Moment}; +use frame_support::{parameter_types, weights::constants::WEIGHT_REF_TIME_PER_SECOND}; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index b7f63c3e3..f2955b841 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -33,8 +33,7 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; -use frame_support::traits::fungible::Balanced; -use frame_support::traits::Imbalance; +use frame_support::traits::{fungible::Balanced, Imbalance}; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_duniter_test_parameters::Parameters as GenesisParameters; @@ -48,18 +47,16 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; -use frame_support::traits::Contains; -use frame_support::PalletId; +use frame_support::{traits::Contains, PalletId}; use frame_system::EnsureRoot; -use pallet_grandpa::fg_primitives; -use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use pallet_grandpa::{ + fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, +}; use sp_api::impl_runtime_apis; use sp_core::OpaqueMetadata; -use sp_runtime::traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys, -}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index b78a2de4c..6ff9b244d 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -16,9 +16,9 @@ use crate::*; use common_runtime::constants::*; -use frame_support::parameter_types; -use frame_support::traits::EitherOfDiverse; -use frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND; +use frame_support::{ + parameter_types, traits::EitherOfDiverse, weights::constants::WEIGHT_REF_TIME_PER_SECOND, +}; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { diff --git a/runtime/gdev/tests/balance_tests.rs b/runtime/gdev/tests/balance_tests.rs index 85c3b0ae3..0d3955c54 100644 --- a/runtime/gdev/tests/balance_tests.rs +++ b/runtime/gdev/tests/balance_tests.rs @@ -19,8 +19,7 @@ mod common; use common::*; -use frame_support::traits::StoredMap; -use frame_support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok, traits::StoredMap}; use gdev_runtime::*; use sp_core::Encode; use sp_keyring::AccountKeyring; diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 95933e525..109d30c45 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -16,23 +16,20 @@ #![allow(dead_code, unused_imports)] -use common_runtime::constants::*; -use common_runtime::*; +use common_runtime::{constants::*, *}; use frame_support::traits::{OnFinalize, OnInitialize}; -use gdev_runtime::opaque::SessionKeys; -use gdev_runtime::*; +use gdev_runtime::{opaque::SessionKeys, *}; use pallet_authority_members::OnNewSession; use pallet_smith_members::SmithMeta; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; -use sp_consensus_babe::{AuthorityId as BabeId, Slot}; -use sp_consensus_babe::{VrfInput, VrfProof}; +use sp_consensus_babe::{AuthorityId as BabeId, Slot, VrfInput, VrfProof}; use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::crypto::IsWrappedBy; -use sp_core::sr25519; -use sp_core::{Encode, Pair, Public, H256}; +use sp_core::{crypto::IsWrappedBy, sr25519, Encode, Pair, Public, H256}; use sp_membership::MembershipData; -use sp_runtime::testing::{Digest, DigestItem}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_runtime::{ + testing::{Digest, DigestItem}, + traits::{IdentifyAccount, Verify}, +}; use std::collections::BTreeMap; pub type AccountPublic = <Signature as Verify>::Signer; diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 0b52fc7a6..df3f1d85a 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -17,16 +17,16 @@ mod common; use common::*; -use frame_support::traits::StoredMap; -use frame_support::traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait}; -use frame_support::{assert_err, assert_noop, assert_ok}; -use frame_support::{StorageHasher, Twox128}; +use frame_support::{ + assert_err, assert_noop, assert_ok, + traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait, StoredMap}, + StorageHasher, Twox128, +}; use gdev_runtime::*; use pallet_identity::{RevocationPayload, REVOCATION_PAYLOAD_PREFIX}; use pallet_membership::MembershipRemovalReason; use pallet_smith_members::{SmithMeta, SmithStatus}; -use sp_core::Encode; -use sp_core::Pair; +use sp_core::{Encode, Pair}; use sp_keyring::AccountKeyring; use sp_runtime::MultiAddress; diff --git a/runtime/gdev/tests/offences_tests.rs b/runtime/gdev/tests/offences_tests.rs index fbfbb9d30..67321d19d 100644 --- a/runtime/gdev/tests/offences_tests.rs +++ b/runtime/gdev/tests/offences_tests.rs @@ -17,9 +17,10 @@ mod common; use common::*; -use frame_support::assert_ok; -use frame_support::traits::ValidatorSet; -use frame_support::traits::ValidatorSetWithIdentification; +use frame_support::{ + assert_ok, + traits::{ValidatorSet, ValidatorSetWithIdentification}, +}; use gdev_runtime::*; use pallet_im_online as im_online; use pallet_im_online::UnresponsivenessOffence; diff --git a/runtime/gdev/tests/xt_tests.rs b/runtime/gdev/tests/xt_tests.rs index bfa840a54..9fa7f5259 100644 --- a/runtime/gdev/tests/xt_tests.rs +++ b/runtime/gdev/tests/xt_tests.rs @@ -20,15 +20,14 @@ mod common; use common::*; -use frame_support::assert_ok; -use frame_support::traits::OnIdle; -use frame_support::traits::StoredMap; +use frame_support::{ + assert_ok, + traits::{OnIdle, StoredMap}, +}; use gdev_runtime::*; -use sp_core::Encode; -use sp_core::Pair; +use sp_core::{Encode, Pair}; use sp_keyring::AccountKeyring; -use sp_runtime::generic::SignedPayload; -use sp_runtime::traits::Extrinsic; +use sp_runtime::{generic::SignedPayload, traits::Extrinsic}; /// get extrinsic for given call fn get_unchecked_extrinsic( diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 9a39989c6..5d35e67fb 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -33,8 +33,7 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; -use frame_support::traits::fungible::Balanced; -use frame_support::traits::Imbalance; +use frame_support::traits::{fungible::Balanced, Imbalance}; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -47,18 +46,16 @@ pub use sp_runtime::BuildStorage; pub use sp_runtime::{KeyTypeId, Perbill, Permill}; use common_runtime::IdtyNameValidatorImpl; -use frame_support::traits::Contains; -use frame_support::PalletId; +use frame_support::{traits::Contains, PalletId}; use frame_system::EnsureRoot; -use pallet_grandpa::fg_primitives; -use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; +use pallet_grandpa::{ + fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, +}; use sp_api::impl_runtime_apis; use sp_core::OpaqueMetadata; -use sp_runtime::traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys, -}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, NumberFor, One, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs index c183502c8..c32a78c25 100644 --- a/runtime/gtest/src/parameters.rs +++ b/runtime/gtest/src/parameters.rs @@ -16,8 +16,7 @@ use crate::*; use common_runtime::constants::*; -use frame_support::parameter_types; -use frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND; +use frame_support::{parameter_types, weights::constants::WEIGHT_REF_TIME_PER_SECOND}; use sp_runtime::transaction_validity::TransactionPriority; parameter_types! { diff --git a/rustfmt.toml b/rustfmt.toml index b7ac0b727..f2abd1253 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ +imports_granularity = "Crate" reorder_impl_items = true diff --git a/xtask/src/gen_doc.rs b/xtask/src/gen_doc.rs index 9b94cca95..88d99dc61 100644 --- a/xtask/src/gen_doc.rs +++ b/xtask/src/gen_doc.rs @@ -19,17 +19,15 @@ use codec::Decode; use core::hash::Hash; use scale_info::form::PortableForm; use serde::Serialize; -use std::collections::HashMap; -use std::path::Path; -use std::process::Command; use std::{ + collections::HashMap, fs::File, io::{Read, Write}, + path::Path, + process::Command, }; use tera::Tera; -use weightanalyzer::analyze_weight; -use weightanalyzer::MaxBlockWeight; -use weightanalyzer::WeightInfo; +use weightanalyzer::{analyze_weight, MaxBlockWeight, WeightInfo}; fn rename_key<K, V>(h: &mut HashMap<K, V>, old_key: &K, new_key: K) where diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c6b201b9d..d22c237fe 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -21,9 +21,11 @@ mod release_runtime; use anyhow::{Context, Result}; use clap::Parser; -use std::io::{BufReader, BufWriter}; -use std::path::{Path, PathBuf}; -use std::process::Command; +use std::{ + io::{BufReader, BufWriter}, + path::{Path, PathBuf}, + process::Command, +}; const MIN_RUST_VERSION: &str = "1.58.0"; -- GitLab