Skip to content

Commit

Permalink
Restructure dispatch macro related exports (#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 <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: ordian <[email protected]>
  • Loading branch information
3 people committed Aug 31, 2023
1 parent d6af073 commit bdbe982
Show file tree
Hide file tree
Showing 84 changed files with 195 additions and 244 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use bp_messages::{
use bp_runtime::messages::MessageDispatchResult;
use bp_xcm_bridge_hub_router::XcmChannelStatusProvider;
use codec::{Decode, Encode};
use frame_support::{dispatch::Weight, traits::Get, CloneNoBound, EqNoBound, PartialEqNoBound};
use frame_support::{traits::Get, weights::Weight, CloneNoBound, EqNoBound, PartialEqNoBound};
use pallet_bridge_messages::{
Config as MessagesConfig, OutboundLanesCongestedSignals, Pallet as MessagesPallet,
WeightInfoExt as MessagesPalletWeights,
Expand Down
4 changes: 2 additions & 2 deletions cumulus/bridges/bin/runtime-common/src/priority_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ mod integrity_tests {
use bp_messages::MessageNonce;
use bp_runtime::PreComputedSize;
use frame_support::{
dispatch::{DispatchClass, DispatchInfo, Dispatchable, Pays, PostDispatchInfo},
dispatch::{DispatchClass, DispatchInfo, Pays, PostDispatchInfo},
traits::Get,
};
use pallet_bridge_messages::WeightInfoExt;
use pallet_transaction_payment::OnChargeTransaction;
use sp_runtime::{
traits::{UniqueSaturatedInto, Zero},
traits::{Dispatchable, UniqueSaturatedInto, Zero},
transaction_validity::TransactionPriority,
FixedPointOperand, SaturatedConversion, Saturating,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider};
use codec::{Decode, Encode};
use frame_support::{
dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo},
dispatch::{CallableCallFor, DispatchInfo, PostDispatchInfo},
traits::IsSubType,
weights::Weight,
CloneNoBound, DefaultNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
Expand All @@ -47,7 +47,7 @@ use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTra
use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{DispatchInfoOf, Get, PostDispatchInfoOf, SignedExtension, Zero},
traits::{DispatchInfoOf, Dispatchable, Get, PostDispatchInfoOf, SignedExtension, Zero},
transaction_validity::{
TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransactionBuilder,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ use crate::{Bridge, Call};

use bp_xcm_bridge_hub_router::{BridgeState, MINIMAL_DELIVERY_FEE_FACTOR};
use frame_benchmarking::benchmarks_instance_pallet;
use frame_support::{
dispatch::UnfilteredDispatchable,
traits::{EnsureOrigin, Get, Hooks},
};
use frame_support::traits::{EnsureOrigin, Get, Hooks, UnfilteredDispatchable};
use sp_runtime::traits::Zero;
use xcm::prelude::*;

Expand Down
4 changes: 2 additions & 2 deletions cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use cumulus_primitives_core::{
};
use cumulus_primitives_parachain_inherent::{MessageQueueChain, ParachainInherentData};
use frame_support::{
dispatch::{DispatchError, DispatchResult, Pays, PostDispatchInfo},
dispatch::{DispatchResult, Pays, PostDispatchInfo},
ensure,
inherent::{InherentData, InherentIdentifier, ProvideInherent},
storage,
Expand All @@ -52,7 +52,7 @@ use sp_runtime::{
InvalidTransaction, TransactionLongevity, TransactionSource, TransactionValidity,
ValidTransaction,
},
RuntimeDebug,
DispatchError, RuntimeDebug,
};
use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*};
use xcm::latest::XcmHash;
Expand Down
3 changes: 1 addition & 2 deletions cumulus/pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ use cumulus_primitives_core::{
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use frame_support::{
assert_ok,
dispatch::UnfilteredDispatchable,
inherent::{InherentData, ProvideInherent},
parameter_types,
traits::{OnFinalize, OnInitialize},
traits::{OnFinalize, OnInitialize, UnfilteredDispatchable},
weights::Weight,
};
use frame_system::{
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use codec::{Decode, DecodeLimit, Encode};
use cumulus_primitives_core::{
relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler, ParaId,
};
use frame_support::dispatch::Weight;
use frame_support::weights::Weight;
pub use pallet::*;
use scale_info::TypeInfo;
use sp_runtime::{traits::BadOrigin, RuntimeDebug};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use frame_support::{
pallet_prelude::DispatchError,
traits::{
fungibles::{Balanced, Create, HandleImbalanceDrop, Inspect, Mutate, Unbalanced},
tokens::{
DepositConsequence, Fortitude, Precision, Preservation, Provenance, WithdrawConsequence,
},
AccountTouch, Contains, ContainsPair, Get, PalletInfoAccess,
use frame_support::traits::{
fungibles::{Balanced, Create, HandleImbalanceDrop, Inspect, Mutate, Unbalanced},
tokens::{
DepositConsequence, Fortitude, Precision, Preservation, Provenance, WithdrawConsequence,
},
AccountTouch, Contains, ContainsPair, Get, PalletInfoAccess,
};
use pallet_asset_conversion::{MultiAssetIdConversionResult, MultiAssetIdConverter};
use parachains_common::AccountId;
use sp_runtime::{traits::MaybeEquivalence, DispatchResult};
use sp_runtime::{traits::MaybeEquivalence, DispatchError, DispatchResult};
use sp_std::{boxed::Box, marker::PhantomData};
use xcm::latest::MultiLocation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

use crate::OriginCaller;
use frame_support::{
dispatch::{DispatchError, DispatchResultWithPostInfo},
dispatch::DispatchResultWithPostInfo,
traits::{Currency, Get, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp},
weights::Weight,
};
use log;
use pallet_alliance::{ProposalIndex, ProposalProvider};
use parachains_common::impls::NegativeImbalance;
use sp_runtime::DispatchError;
use sp_std::{cmp::Ordering, marker::PhantomData, prelude::*};
use xcm::latest::{Fungibility, Junction, Parent};

Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use cumulus_primitives_core::{
use cumulus_primitives_parachain_inherent::ParachainInherentData;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use frame_support::{
dispatch::{DispatchResult, RawOrigin, UnfilteredDispatchable},
dispatch::{DispatchResult, RawOrigin},
inherent::{InherentData, ProvideInherent},
traits::{OnFinalize, OnInitialize, OriginTrait},
traits::{OnFinalize, OnInitialize, OriginTrait, UnfilteredDispatchable},
weights::Weight,
};
use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor};
Expand Down
2 changes: 1 addition & 1 deletion cumulus/primitives/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ mod tests {
use cumulus_primitives_core::UpwardMessage;
use frame_support::{
assert_ok,
dispatch::DispatchError,
traits::tokens::{
DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence,
},
};
use sp_runtime::DispatchError;
use xcm_executor::{traits::Error, Assets};

/// Validates [`validate`] for required Some(destination) and Some(message)
Expand Down
3 changes: 1 addition & 2 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

pub use codec::{Decode, Encode};
pub use codec::{Decode, Encode, EncodeLike};
pub use lazy_static::lazy_static;
pub use log;
pub use paste;
Expand All @@ -32,7 +32,6 @@ pub use std::{
// Substrate
pub use frame_support::{
assert_ok,
dispatch::EncodeLike,
sp_runtime::{AccountId32, DispatchResult},
traits::{
tokens::currency::Currency, EnqueueMessage, Get, Hooks, OriginTrait, ProcessMessage,
Expand Down
5 changes: 1 addition & 4 deletions polkadot/runtime/common/src/assigned_slots/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pallet, LOG_TARGET};
use frame_support::{
dispatch::GetStorageVersion,
traits::{Get, OnRuntimeUpgrade},
};
use frame_support::traits::{Get, GetStorageVersion, OnRuntimeUpgrade};

#[cfg(feature = "try-runtime")]
use frame_support::ensure;
Expand Down
5 changes: 2 additions & 3 deletions polkadot/runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,7 @@ mod tests {
use crate::{auctions, mock::TestRegistrar};
use ::test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code};
use frame_support::{
assert_noop, assert_ok, assert_storage_noop,
dispatch::DispatchError::BadOrigin,
ord_parameter_types, parameter_types,
assert_noop, assert_ok, assert_storage_noop, ord_parameter_types, parameter_types,
traits::{ConstU32, EitherOfDiverse, OnFinalize, OnInitialize},
};
use frame_system::{EnsureRoot, EnsureSignedBy};
Expand All @@ -689,6 +687,7 @@ mod tests {
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
DispatchError::BadOrigin,
};
use std::{cell::RefCell, collections::BTreeMap};

Expand Down
8 changes: 5 additions & 3 deletions polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,15 +711,17 @@ mod tests {
use claims::Call as ClaimsCall;
use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays},
dispatch::{GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ConstU32, ExistenceRequirement, WithdrawReasons},
};
use pallet_balances;
use sp_runtime::{
traits::{BlakeTwo256, Identity, IdentityLookup},
transaction_validity::TransactionLongevity,
BuildStorage, TokenError,
BuildStorage,
DispatchError::BadOrigin,
TokenError,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down Expand Up @@ -1470,7 +1472,7 @@ mod benchmarking {
use super::*;
use crate::claims::Call;
use frame_benchmarking::{account, benchmarks};
use frame_support::dispatch::UnfilteredDispatchable;
use frame_support::traits::UnfilteredDispatchable;
use frame_system::RawOrigin;
use secp_utils::*;
use sp_runtime::{traits::ValidateUnsigned, DispatchResult};
Expand Down
3 changes: 1 addition & 2 deletions polkadot/runtime/common/src/crowdloan/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

use super::*;
use frame_support::{
dispatch::GetStorageVersion,
storage_alias,
traits::{OnRuntimeUpgrade, StorageVersion},
traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion},
Twox64Concat,
};

Expand Down
7 changes: 2 additions & 5 deletions polkadot/runtime/common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
//! Mocking utilities for testing.

use crate::traits::Registrar;
use frame_support::{
dispatch::{DispatchError, DispatchResult},
weights::Weight,
};
use frame_support::{dispatch::DispatchResult, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use parity_scale_codec::{Decode, Encode};
use primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode};
use runtime_parachains::paras;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{traits::SaturatedConversion, Permill};
use sp_runtime::{traits::SaturatedConversion, DispatchError, Permill};
use std::{cell::RefCell, collections::HashMap};

thread_local! {
Expand Down
8 changes: 4 additions & 4 deletions polkadot/runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,14 @@ mod tests {
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::purchase;
use frame_support::{
assert_noop, assert_ok,
dispatch::DispatchError::BadOrigin,
ord_parameter_types, parameter_types,
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{Currency, WithdrawReasons},
};
use sp_runtime::{
traits::{BlakeTwo256, Dispatchable, IdentifyAccount, Identity, IdentityLookup, Verify},
ArithmeticError, BuildStorage, MultiSignature,
ArithmeticError, BuildStorage,
DispatchError::BadOrigin,
MultiSignature,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down
6 changes: 2 additions & 4 deletions polkadot/xcm/pallet-xcm-benchmarks/src/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ mod mock;
#[frame_support::pallet]
pub mod pallet {
use frame_benchmarking::BenchmarkError;
use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo},
pallet_prelude::Encode,
};
use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::Encode};
use sp_runtime::traits::Dispatchable;
use xcm::latest::{
InteriorMultiLocation, Junction, MultiAsset, MultiAssets, MultiLocation, NetworkId,
Response,
Expand Down
11 changes: 5 additions & 6 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ use frame_support::traits::{
use scale_info::TypeInfo;
use sp_runtime::{
traits::{
AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Hash, Saturating, Zero,
AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Dispatchable, Hash,
Saturating, Zero,
},
RuntimeDebug,
};
Expand All @@ -43,10 +44,7 @@ use xcm::{latest::QueryResponseInfo, prelude::*};
use xcm_executor::traits::{ConvertOrigin, Properties};

use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo},
pallet_prelude::*,
traits::WithdrawReasons,
PalletId,
dispatch::GetDispatchInfo, pallet_prelude::*, traits::WithdrawReasons, PalletId,
};
use frame_system::pallet_prelude::*;
pub use pallet::*;
Expand Down Expand Up @@ -149,11 +147,12 @@ impl WeightInfo for TestWeightInfo {
pub mod pallet {
use super::*;
use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo},
dispatch::{GetDispatchInfo, PostDispatchInfo},
parameter_types,
};
use frame_system::Config as SysConfig;
use sp_core::H256;
use sp_runtime::traits::Dispatchable;
use xcm_executor::traits::{MatchesFungible, WeightBounds};

parameter_types! {
Expand Down
5 changes: 2 additions & 3 deletions polkadot/xcm/xcm-builder/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ pub use crate::{
use frame_support::traits::{ContainsPair, Everything};
pub use frame_support::{
dispatch::{
DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
Parameter, PostDispatchInfo,
DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, Parameter, PostDispatchInfo,
},
ensure, match_types, parameter_types,
sp_runtime::DispatchErrorWithPostInfo,
sp_runtime::{traits::Dispatchable, DispatchError, DispatchErrorWithPostInfo},
traits::{ConstU32, Contains, Get, IsInVec},
};
pub use parity_scale_codec::{Decode, Encode};
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/xcm-executor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ use crate::traits::{
WeightTrader,
};
use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo, Parameter, PostDispatchInfo},
dispatch::{GetDispatchInfo, Parameter, PostDispatchInfo},
traits::{Contains, ContainsPair, Get, PalletsInfoAccess},
};
use sp_runtime::traits::Dispatchable;
use xcm::prelude::*;

/// The trait to parameterize the `XcmExecutor`.
Expand Down
6 changes: 2 additions & 4 deletions polkadot/xcm/xcm-executor/src/traits/on_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

use crate::Xcm;
use core::result;
use frame_support::{
dispatch::fmt::Debug,
pallet_prelude::{Get, TypeInfo},
};
use frame_support::pallet_prelude::{Get, TypeInfo};
use parity_scale_codec::{FullCodec, MaxEncodedLen};
use sp_arithmetic::traits::Zero;
use sp_std::fmt::Debug;
use xcm::latest::{
Error as XcmError, InteriorMultiLocation, MultiLocation, QueryId, Response,
Result as XcmResult, Weight, XcmContext,
Expand Down
Loading

0 comments on commit bdbe982

Please sign in to comment.