Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure dispatch macro related exports #1162

Merged
merged 14 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -14,7 +14,6 @@
// limitations under the License.

use frame_support::{
pallet_prelude::DispatchError,
traits::{
fungibles::{Balanced, Create, HandleImbalanceDrop, Inspect, Mutate, Unbalanced},
tokens::{
Expand All @@ -25,7 +24,7 @@ use frame_support::{
};
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
2 changes: 1 addition & 1 deletion polkadot/runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ mod benchmarking {
use super::*;
use crate::claims::Call;
use frame_benchmarking::{account, benchmarks};
use frame_support::dispatch::UnfilteredDispatchable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we just need 1 MR instead of three, what a breeze 😌

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
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
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
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
Loading
Loading