Skip to content

Commit

Permalink
Restructure dispatch macro related exports (paritytech#1162)
Browse files Browse the repository at this point in the history
* restructure dispatch macro related exports

* moved Dispatchable to lib.rs

* fix .gitignore final newline

* ".git/.scripts/commands/fmt/fmt.sh"

* fix rustdocs

* wip

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
Co-authored-by: command-bot <>
Co-authored-by: ordian <write@reusable.software>
  • Loading branch information
3 people authored Aug 31, 2023
1 parent 6e8135d commit 733208a
Show file tree
Hide file tree
Showing 60 changed files with 145 additions and 175 deletions.
9 changes: 3 additions & 6 deletions substrate/frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,13 @@ use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_runtime::{
traits::{Saturating, StaticLookup, Zero},
RuntimeDebug,
traits::{Dispatchable, Saturating, StaticLookup, Zero},
DispatchError, RuntimeDebug,
};
use sp_std::{convert::TryInto, prelude::*};

use frame_support::{
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
PostDispatchInfo,
},
dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo},
ensure,
traits::{
ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced,
Expand Down
5 changes: 1 addition & 4 deletions substrate/frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ use super::*;
use frame_benchmarking::v1::{
account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError,
};
use frame_support::{
dispatch::UnfilteredDispatchable,
traits::{EnsureOrigin, Get},
};
use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
use frame_system::RawOrigin as SystemOrigin;
use sp_runtime::traits::Bounded;
use sp_std::prelude::*;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ pub use types::*;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero},
ArithmeticError, TokenError,
ArithmeticError, DispatchError, TokenError,
};
use sp_std::prelude::*;

use frame_support::{
dispatch::{DispatchError, DispatchResult},
dispatch::DispatchResult,
ensure,
pallet_prelude::DispatchResultWithPostInfo,
storage::KeyPrefixIterator,
Expand Down
8 changes: 2 additions & 6 deletions substrate/frame/benchmarking/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@

//! Interfaces, types and utils for benchmarking a FRAME runtime.
use codec::{Decode, Encode};
use frame_support::{
dispatch::{DispatchError, DispatchErrorWithPostInfo},
pallet_prelude::*,
traits::StorageInfo,
};
use frame_support::{dispatch::DispatchErrorWithPostInfo, pallet_prelude::*, traits::StorageInfo};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_io::hashing::blake2_256;
use sp_runtime::traits::TrailingZeroInput;
use sp_runtime::{traits::TrailingZeroInput, DispatchError};
use sp_std::{prelude::Box, vec::Vec};
use sp_storage::TrackedStorageKey;

Expand Down
8 changes: 5 additions & 3 deletions substrate/frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_io::storage;
use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_runtime::{
traits::{Dispatchable, Hash},
DispatchError, RuntimeDebug,
};
use sp_std::{marker::PhantomData, prelude::*, result};

use frame_support::{
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
Pays, PostDispatchInfo,
DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, Pays, PostDispatchInfo,
},
ensure, impl_ensure_origin_with_arg_ignoring_arg,
traits::{
Expand Down
11 changes: 6 additions & 5 deletions substrate/frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ use crate::{
};
use frame_support::{
crypto::ecdsa::ECDSAExt,
dispatch::{
fmt::Debug, DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable,
},
dispatch::{DispatchResult, DispatchResultWithPostInfo},
ensure,
storage::{with_transaction, TransactionOutcome},
traits::{
Expand All @@ -47,8 +45,11 @@ use sp_core::{
Get,
};
use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256};
use sp_runtime::traits::{Convert, Hash, Zero};
use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec};
use sp_runtime::{
traits::{Convert, Dispatchable, Hash, Zero},
DispatchError,
};
use sp_std::{fmt::Debug, marker::PhantomData, mem, prelude::*, vec::Vec};

pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
pub type MomentOf<T> = <<T as Config>::Time as Time>::Moment;
Expand Down
6 changes: 2 additions & 4 deletions substrate/frame/contracts/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

use crate::{exec::ExecError, Config, Error};
use frame_support::{
dispatch::{
DispatchError, DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo,
},
dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo},
weights::Weight,
DefaultNoBound,
};
use sp_core::Get;
use sp_runtime::traits::Zero;
use sp_runtime::{traits::Zero, DispatchError};
use sp_std::marker::PhantomData;

#[cfg(test)]
Expand Down
9 changes: 3 additions & 6 deletions substrate/frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ use crate::{
use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen};
use environmental::*;
use frame_support::{
dispatch::{
DispatchError, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin,
WithPostDispatchInfo,
},
dispatch::{GetDispatchInfo, Pays, PostDispatchInfo, RawOrigin, WithPostDispatchInfo},
ensure,
error::BadOrigin,
traits::{
Expand All @@ -137,8 +134,8 @@ use pallet_contracts_primitives::{
use scale_info::TypeInfo;
use smallvec::Array;
use sp_runtime::{
traits::{Convert, Hash, Saturating, StaticLookup, Zero},
RuntimeDebug,
traits::{Convert, Dispatchable, Hash, Saturating, StaticLookup, Zero},
DispatchError, RuntimeDebug,
};
use sp_std::{fmt::Debug, prelude::*};

Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/contracts/src/migration/v15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::{
AccountIdOf, BalanceOf, CodeHash, Config, HoldReason, Pallet, TrieId, Weight, LOG_TARGET,
};
#[cfg(feature = "try-runtime")]
use frame_support::{dispatch::Vec, traits::fungible::InspectHold};
use frame_support::traits::fungible::InspectHold;
use frame_support::{
pallet_prelude::*,
storage_alias,
Expand All @@ -43,6 +43,8 @@ use sp_core::hexdisplay::HexDisplay;
#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;
use sp_runtime::{traits::Zero, Saturating};
#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;

mod old {
use super::*;
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/contracts/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use crate::{
};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::DispatchError,
storage::child::{self, ChildInfo},
weights::Weight,
CloneNoBound, DefaultNoBound,
Expand All @@ -37,7 +36,7 @@ use sp_core::Get;
use sp_io::KillStorageResult;
use sp_runtime::{
traits::{Hash, Saturating, Zero},
BoundedBTreeMap, DispatchResult, RuntimeDebug,
BoundedBTreeMap, DispatchError, DispatchResult, RuntimeDebug,
};
use sp_std::{marker::PhantomData, prelude::*};

Expand Down
5 changes: 2 additions & 3 deletions substrate/frame/contracts/src/storage/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::{
};

use frame_support::{
dispatch::{fmt::Debug, DispatchError},
ensure,
traits::{
fungible::{Mutate, MutateHold},
Expand All @@ -37,9 +36,9 @@ use frame_support::{
use sp_api::HashT;
use sp_runtime::{
traits::{Saturating, Zero},
FixedPointNumber, FixedU128,
DispatchError, FixedPointNumber, FixedU128,
};
use sp_std::{marker::PhantomData, vec, vec::Vec};
use sp_std::{fmt::Debug, marker::PhantomData, vec, vec::Vec};

/// Deposit that uses the native fungible's balance type.
pub type DepositOf<T> = Deposit<BalanceOf<T>>;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use assert_matches::assert_matches;
use codec::Encode;
use frame_support::{
assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok,
dispatch::{DispatchError, DispatchErrorWithPostInfo, PostDispatchInfo},
dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
parameter_types,
storage::child,
traits::{
Expand All @@ -61,7 +61,7 @@ use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
use sp_runtime::{
testing::H256,
traits::{BlakeTwo256, Convert, Hash, IdentityLookup},
AccountId32, BuildStorage, Perbill, TokenError,
AccountId32, BuildStorage, DispatchError, Perbill, TokenError,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/contracts/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ use crate::{
};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dispatch::{DispatchError, DispatchResult},
dispatch::DispatchResult,
ensure,
traits::{fungible::MutateHold, tokens::Precision::BestEffort},
};
use sp_core::Get;
use sp_runtime::RuntimeDebug;
use sp_runtime::{DispatchError, RuntimeDebug};
use sp_std::prelude::*;
use wasmi::{Instance, Linker, Memory, MemoryType, StackLimits, Store};

Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/contracts/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ use crate::{

use bitflags::bitflags;
use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen};
use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weight};
use frame_support::{ensure, traits::Get, weights::Weight};
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags};
use pallet_contracts_proc_macro::define_env;
use sp_io::hashing::{blake2_128, blake2_256, keccak_256, sha2_256};
use sp_runtime::{
traits::{Bounded, Zero},
RuntimeDebug,
DispatchError, RuntimeDebug,
};
use sp_std::{fmt, prelude::*};
use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store};
Expand Down
13 changes: 10 additions & 3 deletions substrate/frame/conviction-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{
dispatch::{DispatchError, DispatchResult},
dispatch::DispatchResult,
ensure,
traits::{
fungible, Currency, Get, LockIdentifier, LockableCurrency, PollStatus, Polling,
Expand All @@ -38,7 +38,7 @@ use frame_support::{
use frame_system::pallet_prelude::BlockNumberFor;
use sp_runtime::{
traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero},
ArithmeticError, Perbill,
ArithmeticError, DispatchError, Perbill,
};
use sp_std::prelude::*;

Expand Down Expand Up @@ -86,8 +86,15 @@ type ClassOf<T, I = ()> = <<T as Config<I>>::Polls as Polling<TallyOf<T, I>>>::C
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{pallet_prelude::*, traits::ClassCountOf};
use frame_support::{
pallet_prelude::{
DispatchResultWithPostInfo, IsType, StorageDoubleMap, StorageMap, ValueQuery,
},
traits::ClassCountOf,
Twox64Concat,
};
use frame_system::pallet_prelude::*;
use sp_runtime::BoundedVec;

#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/election-provider-multi-phase/src/unsigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,12 @@ mod tests {
};
use codec::Decode;
use frame_election_provider_support::IndexAssignment;
use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::OffchainWorker};
use frame_support::{assert_noop, assert_ok, traits::OffchainWorker};
use sp_npos_elections::ElectionScore;
use sp_runtime::{
bounded_vec,
offchain::storage_lock::{BlockAndTime, StorageLock},
traits::{ValidateUnsigned, Zero},
traits::{Dispatchable, ValidateUnsigned, Zero},
ModuleError, PerU16, Perbill,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#![allow(dead_code)]

use frame_support::{
assert_ok, dispatch::UnfilteredDispatchable, parameter_types, traits, traits::Hooks,
assert_ok, parameter_types, traits,
traits::{Hooks, UnfilteredDispatchable},
weights::constants,
};
use frame_system::EnsureRoot;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/lottery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub mod weights;

use codec::{Decode, Encode};
use frame_support::{
dispatch::{DispatchResult, Dispatchable, GetDispatchInfo},
dispatch::{DispatchResult, GetDispatchInfo},
ensure,
pallet_prelude::MaxEncodedLen,
storage::bounded_vec::BoundedVec,
Expand All @@ -65,7 +65,7 @@ use frame_support::{
};
pub use pallet::*;
use sp_runtime::{
traits::{AccountIdConversion, Saturating, Zero},
traits::{AccountIdConversion, Dispatchable, Saturating, Zero},
ArithmeticError, DispatchError, RuntimeDebug,
};
use sp_std::prelude::*;
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/multisig/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

use super::*;
use frame_support::{
dispatch::GetStorageVersion,
traits::{OnRuntimeUpgrade, WrapperKeepOpaque},
traits::{GetStorageVersion, OnRuntimeUpgrade, WrapperKeepOpaque},
Identity,
};

Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/nfts/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
frame-support = { path = "../../support", default-features = false}
pallet-nfts = { path = "..", default-features = false}
sp-api = { path = "../../../primitives/api", default-features = false}

[features]
default = [ "std" ]
std = [ "codec/std", "frame-support/std", "pallet-nfts/std", "sp-api/std" ]
std = [ "codec/std", "pallet-nfts/std", "sp-api/std" ]
2 changes: 1 addition & 1 deletion substrate/frame/nfts/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};
use frame_support::dispatch::Vec;
use sp_api::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait NftsApi<AccountId, CollectionId, ItemId>
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/nfts/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use frame_benchmarking::v1::{
};
use frame_support::{
assert_ok,
dispatch::UnfilteredDispatchable,
traits::{EnsureOrigin, Get},
traits::{EnsureOrigin, Get, UnfilteredDispatchable},
BoundedVec,
};
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin};
Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ use crate::{mock::*, Event, *};
use enumflags2::BitFlags;
use frame_support::{
assert_noop, assert_ok,
dispatch::Dispatchable,
traits::{
tokens::nonfungibles_v2::{Create, Destroy, Mutate},
Currency, Get,
},
};
use pallet_balances::Error as BalancesError;
use sp_core::{bounded::BoundedVec, Pair};
use sp_runtime::{traits::IdentifyAccount, MultiSignature, MultiSigner};
use sp_runtime::{
traits::{Dispatchable, IdentifyAccount},
MultiSignature, MultiSigner,
};
use sp_std::prelude::*;

type AccountIdOf<Test> = <Test as frame_system::Config>::AccountId;
Expand Down
Loading

0 comments on commit 733208a

Please sign in to comment.