Restructure macro-related exports into private mods for frame (#14375)

* minor refactor

* Update frame/election-provider-support/src/lib.rs

* Update frame/election-provider-support/solution-type/src/lib.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

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

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
This commit is contained in:
Guillaume Yu Thiolliere
2023-06-14 21:44:01 +09:00
committed by GitHub
parent b78473d28a
commit 7db4d74c43
8 changed files with 94 additions and 102 deletions
@@ -58,22 +58,22 @@ pub fn expand_outer_inherent(
trait InherentDataExt {
fn create_extrinsics(&self) ->
#scrate::inherent::Vec<<#block as #scrate::inherent::BlockT>::Extrinsic>;
#scrate::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>;
fn check_extrinsics(&self, block: &#block) -> #scrate::inherent::CheckInherentsResult;
}
impl InherentDataExt for #scrate::inherent::InherentData {
fn create_extrinsics(&self) ->
#scrate::inherent::Vec<<#block as #scrate::inherent::BlockT>::Extrinsic>
#scrate::sp_std::vec::Vec<<#block as #scrate::sp_runtime::traits::Block>::Extrinsic>
{
use #scrate::inherent::ProvideInherent;
let mut inherents = Vec::new();
let mut inherents = #scrate::sp_std::vec::Vec::new();
#(
#pallet_attrs
if let Some(inherent) = #pallet_names::create_inherent(self) {
let inherent = <#unchecked_extrinsic as #scrate::inherent::Extrinsic>::new(
let inherent = <#unchecked_extrinsic as #scrate::sp_runtime::traits::Extrinsic>::new(
inherent.into(),
None,
).expect("Runtime UncheckedExtrinsic is not Opaque, so it has to return \
@@ -96,7 +96,7 @@ pub fn expand_outer_inherent(
for xt in block.extrinsics() {
// Inherents are before any other extrinsics.
// And signed extrinsics are not inherents.
if #scrate::inherent::Extrinsic::is_signed(xt).unwrap_or(false) {
if #scrate::sp_runtime::traits::Extrinsic::is_signed(xt).unwrap_or(false) {
break
}
@@ -134,7 +134,7 @@ pub fn expand_outer_inherent(
match #pallet_names::is_inherent_required(self) {
Ok(Some(e)) => {
let found = block.extrinsics().iter().any(|xt| {
let is_signed = #scrate::inherent::Extrinsic::is_signed(xt)
let is_signed = #scrate::sp_runtime::traits::Extrinsic::is_signed(xt)
.unwrap_or(false);
if !is_signed {
@@ -186,7 +186,8 @@ pub fn expand_outer_inherent(
let mut first_signed_observed = false;
for (i, xt) in block.extrinsics().iter().enumerate() {
let is_signed = #scrate::inherent::Extrinsic::is_signed(xt).unwrap_or(false);
let is_signed = #scrate::sp_runtime::traits::Extrinsic::is_signed(xt)
.unwrap_or(false);
let is_inherent = if is_signed {
// Signed extrinsics are not inherents.
-5
View File
@@ -15,11 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[doc(hidden)]
pub use crate::sp_runtime::traits::{Block as BlockT, Extrinsic};
#[doc(hidden)]
pub use crate::sp_std::vec::Vec;
pub use sp_inherents::{
CheckInherentsResult, InherentData, InherentIdentifier, IsFatalError, MakeFatalError,
};
+2 -10
View File
@@ -96,15 +96,6 @@ impl<T> InstanceFilter<T> for () {
}
}
/// Re-expected for the macro.
#[doc(hidden)]
pub use sp_std::{
boxed::Box,
cell::RefCell,
mem::{swap, take},
vec::Vec,
};
#[macro_export]
macro_rules! impl_filter_stack {
($target:ty, $base:ty, $call:ty, $module:ident) => {
@@ -112,7 +103,8 @@ macro_rules! impl_filter_stack {
mod $module {
#[allow(unused_imports)]
use super::*;
use $crate::traits::filter::{swap, take, RefCell, Vec, Box, Contains, FilterStack};
use $crate::sp_std::{boxed::Box, cell::RefCell, mem::{swap, take}, vec::Vec};
use $crate::traits::filter::{Contains, FilterStack};
thread_local! {
static FILTER: RefCell<Vec<Box<dyn Fn(&$call) -> bool + 'static>>> = RefCell::new(Vec::new());
+2 -5
View File
@@ -814,13 +814,10 @@ fn instance_expand() {
#[test]
fn inherent_expand() {
use frame_support::{
inherent::{BlockT, InherentData},
traits::EnsureInherentsAreFirst,
};
use frame_support::{inherent::InherentData, traits::EnsureInherentsAreFirst};
use sp_core::Hasher;
use sp_runtime::{
traits::{BlakeTwo256, Header},
traits::{BlakeTwo256, Block as _, Header},
Digest,
};