Restructure dispatch macro related exports (#1162)

* 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>
This commit is contained in:
Juan
2023-08-31 13:08:44 +02:00
committed by GitHub
parent d6af073aa5
commit bdbe982970
84 changed files with 195 additions and 244 deletions
+6 -18
View File
@@ -18,30 +18,18 @@
//! Dispatch system. Contains a macro for defining runtime modules and
//! generating values representing lazy module function calls.
pub use crate::traits::{
CallMetadata, GetCallIndex, GetCallMetadata, GetCallName, GetStorageVersion,
UnfilteredDispatchable,
};
pub use codec::{
Codec, Decode, Encode, EncodeAsRef, EncodeLike, HasCompact, Input, MaxEncodedLen, Output,
};
pub use scale_info::TypeInfo;
pub use sp_runtime::{
traits::Dispatchable, transaction_validity::TransactionPriority, DispatchError, RuntimeDebug,
};
pub use sp_std::{
fmt, marker,
prelude::{Clone, Eq, PartialEq, Vec},
result,
};
pub use sp_weights::Weight;
use crate::traits::UnfilteredDispatchable;
use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen};
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_runtime::{
generic::{CheckedExtrinsic, UncheckedExtrinsic},
traits::SignedExtension,
DispatchError, RuntimeDebug,
};
use sp_std::fmt;
use sp_weights::Weight;
/// The return type of a `Dispatchable` in frame. When returned explicitly from
/// a dispatchable function it allows overriding the default `PostDispatchInfo`
@@ -26,11 +26,11 @@
//!
//! # FRAME integration
//!
//! The FRAME macros implement [`UnfilteredDispatchable`](crate::traits::UnfilteredDispatchable) for
//! each pallet `Call` enum. Part of this implementation is the call to [`run_in_context`], so that
//! each call to
//! The FRAME macros implement
//! [`UnfilteredDispatchable`](frame_support::traits::UnfilteredDispatchable) for each pallet `Call`
//! enum. Part of this implementation is the call to [`run_in_context`], so that each call to
//! [`UnfilteredDispatchable::dispatch_bypass_filter`](crate::traits::UnfilteredDispatchable::dispatch_bypass_filter)
//! or [`Dispatchable::dispatch`](crate::dispatch::Dispatchable::dispatch) will run in a dispatch
//! or [`Dispatchable::dispatch`](sp_runtime::traits::Dispatchable::dispatch) will run in a dispatch
//! context.
//!
//! # Example
+6 -8
View File
@@ -49,7 +49,7 @@ pub mod __private {
pub use sp_metadata_ir as metadata_ir;
#[cfg(feature = "std")]
pub use sp_runtime::{bounded_btree_map, bounded_vec};
pub use sp_runtime::{RuntimeDebug, StateVersion};
pub use sp_runtime::{traits::Dispatchable, RuntimeDebug, StateVersion};
#[cfg(feature = "std")]
pub use sp_state_machine::BasicExternalities;
pub use sp_std;
@@ -806,10 +806,7 @@ pub mod testing_prelude {
/// Prelude to be used alongside pallet macro, for ease of use.
pub mod pallet_prelude {
pub use crate::{
dispatch::{
DispatchClass, DispatchError, DispatchResult, DispatchResultWithPostInfo, Parameter,
Pays,
},
dispatch::{DispatchClass, DispatchResult, DispatchResultWithPostInfo, Parameter, Pays},
ensure,
inherent::{InherentData, InherentIdentifier, ProvideInherent},
storage,
@@ -855,7 +852,7 @@ pub mod pallet_prelude {
TransactionTag, TransactionValidity, TransactionValidityError, UnknownTransaction,
ValidTransaction,
},
RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE,
DispatchError, RuntimeDebug, MAX_MODULE_ERROR_ENCODED_SIZE,
};
pub use sp_std::marker::PhantomData;
pub use sp_weights::Weight;
@@ -1266,8 +1263,9 @@ pub mod pallet_prelude {
/// Field types in enum variants must also implement [`PalletError`](traits::PalletError),
/// otherwise the pallet will fail to compile. Rust primitive types have already implemented
/// the [`PalletError`](traits::PalletError) trait along with some commonly used stdlib types
/// such as [`Option`] and [`PhantomData`](`frame_support::dispatch::marker::PhantomData`), and
/// hence in most use cases, a manual implementation is not necessary and is discouraged.
/// such as [`Option`] and
/// [`PhantomData`](`frame_support::__private::sp_std::marker::PhantomData`), and hence in most
/// use cases, a manual implementation is not necessary and is discouraged.
///
/// The generic `T` must not bound anything and a `where` clause is not allowed. That said,
/// bounds and/or a where clause should not needed for any use-case.
@@ -21,11 +21,8 @@ use super::{
imbalance::{Imbalance, SignedImbalance},
misc::{Balance, ExistenceRequirement, WithdrawReasons},
};
use crate::{
dispatch::{DispatchError, DispatchResult},
traits::Get,
};
use sp_runtime::traits::MaybeSerializeDeserialize;
use crate::{dispatch::DispatchResult, traits::Get};
use sp_runtime::{traits::MaybeSerializeDeserialize, DispatchError};
mod reservable;
pub use reservable::{NamedReservableCurrency, ReservableCurrency};
@@ -22,9 +22,10 @@ use sp_core::Get;
use super::{super::misc::BalanceStatus, Currency};
use crate::{
dispatch::{DispatchError, DispatchResult},
dispatch::DispatchResult,
traits::{ExistenceRequirement, SignedImbalance, WithdrawReasons},
};
use sp_runtime::DispatchError;
/// A currency where funds can be reserved from the user.
pub trait ReservableCurrency<AccountId>: Currency<AccountId> {
@@ -18,7 +18,6 @@
//! `Inspect` and `Mutate` traits for working with regular balances.
use crate::{
dispatch::DispatchError,
ensure,
traits::{
tokens::{
@@ -36,7 +35,7 @@ use crate::{
},
};
use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One};
use sp_runtime::{traits::Saturating, ArithmeticError, TokenError};
use sp_runtime::{traits::Saturating, ArithmeticError, DispatchError, TokenError};
use sp_std::marker::PhantomData;
use super::{Credit, Debt, HandleImbalanceDrop, Imbalance};
@@ -20,7 +20,6 @@
use sp_std::marker::PhantomData;
use crate::{
dispatch::DispatchError,
ensure,
traits::{
tokens::{
@@ -38,7 +37,7 @@ use crate::{
},
};
use sp_arithmetic::traits::{CheckedAdd, CheckedSub, One};
use sp_runtime::{traits::Saturating, ArithmeticError, TokenError};
use sp_runtime::{traits::Saturating, ArithmeticError, DispatchError, TokenError};
use super::{Credit, Debt, HandleImbalanceDrop, Imbalance};
@@ -27,9 +27,9 @@
//! Implementations of these traits may be converted to implementations of corresponding
//! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter.
use crate::dispatch::{DispatchError, DispatchResult};
use crate::dispatch::DispatchResult;
use codec::{Decode, Encode};
use sp_runtime::TokenError;
use sp_runtime::{DispatchError, TokenError};
use sp_std::prelude::*;
/// Trait for providing an interface to many read-only NFT-like sets of items.
@@ -27,9 +27,9 @@
//! Implementations of these traits may be converted to implementations of corresponding
//! `nonfungible` traits by using the `nonfungible::ItemOf` type adapter.
use crate::dispatch::{DispatchError, DispatchResult, Parameter};
use crate::dispatch::{DispatchResult, Parameter};
use codec::{Decode, Encode};
use sp_runtime::TokenError;
use sp_runtime::{DispatchError, TokenError};
use sp_std::prelude::*;
/// Trait for providing an interface to many read-only NFT-like sets of items.
+2 -2
View File
@@ -18,10 +18,10 @@
//! Traits and associated data structures concerned with voting, and moving between tokens and
//! votes.
use crate::dispatch::{DispatchError, Parameter};
use crate::dispatch::Parameter;
use codec::{HasCompact, MaxEncodedLen};
use sp_arithmetic::Perbill;
use sp_runtime::traits::Member;
use sp_runtime::{traits::Member, DispatchError};
use sp_std::prelude::*;
pub trait VoteTally<Votes, Class> {