Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Restructure frame_support macro related exports (#14745)
Browse files Browse the repository at this point in the history
* make reexports private

* make reexports private 2

* make reexports private for runtime-benchmarking

* make reexports private for try-runtime

* fix for try-runtime

* make reexports private for tests

* fmt

* make reexports private for tests

* make reexports private for experimental

* fix beefy

* fix ui test

* fix ui test

* fix benches

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

* fix contracts use

* wip

* wip

* do not reexport sp_api::metadata_ir

* fix CI checks

* fix support tests

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

* Update frame/support/src/lib.rs

Co-authored-by: Bastian Köcher <[email protected]>

* import codec directly

* fmt

* fix node-cli tests

---------

Co-authored-by: command-bot <>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
juangirini and bkchr authored Aug 23, 2023
1 parent 1631c8e commit df383f2
Show file tree
Hide file tree
Showing 125 changed files with 449 additions and 398 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use frame_support::{
},
ConstantMultiplier, IdentityFee, Weight,
},
BoundedVec, PalletId, RuntimeDebug,
BoundedVec, PalletId,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
Expand Down Expand Up @@ -78,6 +78,7 @@ use sp_runtime::{
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Percent, Permill, Perquintill,
RuntimeDebug,
};
use sp_std::prelude::*;
#[cfg(any(feature = "std", test))]
Expand Down
4 changes: 2 additions & 2 deletions frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub mod migration;
mod types;
pub mod weights;

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_runtime::{
Expand All @@ -103,20 +104,19 @@ use sp_runtime::{
use sp_std::{convert::TryInto, prelude::*};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
PostDispatchInfo,
},
ensure,
scale_info::TypeInfo,
traits::{
ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced,
ReservableCurrency,
},
weights::Weight,
};
use pallet_identity::IdentityField;
use scale_info::TypeInfo;

pub use pallet::*;
pub use types::*;
Expand Down
1 change: 1 addition & 0 deletions frame/asset-rate/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use sp_core::crypto::FromEntropy;
use sp_std::vec;

/// Trait describing the factory function for the `AssetKind` parameter.
pub trait AssetKindFactory<AssetKind> {
Expand Down
2 changes: 2 additions & 0 deletions frame/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
# Needed for various traits. In our case, `OnFinalize`.
Expand All @@ -34,6 +35,7 @@ pallet-balances = { version = "4.0.0-dev", path = "../balances" }
default = ["std"]
std = [
"codec/std",
"log/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
Expand Down
3 changes: 2 additions & 1 deletion frame/assets/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// limitations under the License.

use super::*;
use frame_support::{log, traits::OnRuntimeUpgrade};
use frame_support::traits::OnRuntimeUpgrade;
use log;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;
Expand Down
2 changes: 2 additions & 0 deletions frame/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
Expand All @@ -31,6 +32,7 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" }
default = ["std"]
std = [
"codec/std",
"log/std",
"frame-support/std",
"frame-system/std",
"pallet-timestamp/std",
Expand Down
2 changes: 1 addition & 1 deletion frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
log,
traits::{DisabledValidators, FindAuthor, Get, OnTimestampSet, OneSessionHandler},
BoundedSlice, BoundedVec, ConsensusEngineId, Parameter,
};
use log;
use sp_consensus_aura::{AuthorityIndex, ConsensusLog, Slot, AURA_ENGINE_ID};
use sp_runtime::{
generic::DigestItem,
Expand Down
4 changes: 2 additions & 2 deletions frame/balances/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use frame_support::{
StorageMapShim, StoredMap, WhitelistedStorageKeys,
},
weights::{IdentityFee, Weight},
RuntimeDebug,
};
use frame_system::{self as system, RawOrigin};
use pallet_transaction_payment::{ChargeTransactionPayment, CurrencyAdapter, Multiplier};
Expand All @@ -39,7 +38,8 @@ use sp_core::{hexdisplay::HexDisplay, H256};
use sp_io;
use sp_runtime::{
traits::{BadOrigin, IdentityLookup, SignedExtension, Zero},
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError,
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, RuntimeDebug,
TokenError,
};
use std::collections::BTreeSet;

Expand Down
7 changes: 2 additions & 5 deletions frame/balances/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@
use crate::{Config, CreditOf, Event, Pallet};
use codec::{Decode, Encode, MaxEncodedLen};
use core::ops::BitOr;
use frame_support::{
traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons},
RuntimeDebug,
};
use frame_support::traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons};
use scale_info::TypeInfo;
use sp_runtime::Saturating;
use sp_runtime::{RuntimeDebug, Saturating};

/// Simplified reasons for withdrawing balance.
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
Expand Down
4 changes: 3 additions & 1 deletion frame/beefy-mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" }
sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" }

[dev-dependencies]
array-bytes = "6.1"
Expand All @@ -51,7 +52,8 @@ std = [
"sp-runtime/std",
"sp-std/std",
"sp-api/std",
"sp-staking/std"
"sp-staking/std",
"sp-state-machine/std"
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
4 changes: 2 additions & 2 deletions frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ use std::vec;
use codec::Encode;
use frame_support::{
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64},
BasicExternalities,
};
use sp_consensus_beefy::mmr::MmrLeafVersion;
use sp_core::H256;
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
impl_opaque_keys,
traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys},
BuildStorage,
};
use sp_state_machine::BasicExternalities;

use crate as pallet_beefy_mmr;

Expand Down
6 changes: 5 additions & 1 deletion frame/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://substrate.io"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] }
serde = { version = "1.0.163", optional = true }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
Expand All @@ -32,11 +33,13 @@ pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" }
sp-core = { version = "21.0.0", path = "../../primitives/core" }
sp-io = { version = "23.0.0", path = "../../primitives/io" }
sp-staking = { version = "4.0.0-dev", path = "../../primitives/staking" }
sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" }

[features]
default = ["std"]
std = [
"codec/std",
"log/std",
"frame-support/std",
"frame-system/std",
"pallet-authorship/std",
Expand All @@ -54,7 +57,8 @@ std = [
"pallet-staking/std",
"pallet-timestamp/std",
"sp-core/std",
"sp-io/std"
"sp-io/std",
"sp-state-machine/std"
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
5 changes: 1 addition & 4 deletions frame/beefy/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
//! definition.
use codec::{self as codec, Decode, Encode};
use frame_support::{
log,
traits::{Get, KeyOwnerProofSystem},
};
use frame_support::traits::{Get, KeyOwnerProofSystem};
use frame_system::pallet_prelude::BlockNumberFor;
use log::{error, info};
use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE as BEEFY_KEY_TYPE};
Expand Down
2 changes: 1 addition & 1 deletion frame/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use codec::{Encode, MaxEncodedLen};

use frame_support::{
dispatch::{DispatchResultWithPostInfo, Pays},
log,
pallet_prelude::*,
traits::{Get, OneSessionHandler},
weights::Weight,
Expand All @@ -31,6 +30,7 @@ use frame_system::{
ensure_none, ensure_signed,
pallet_prelude::{BlockNumberFor, OriginFor},
};
use log;
use sp_runtime::{
generic::DigestItem,
traits::{IsMember, Member},
Expand Down
4 changes: 2 additions & 2 deletions frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ use frame_election_provider_support::{
};
use frame_support::{
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize},
BasicExternalities,
};
use pallet_session::historical as pallet_session_historical;
use sp_core::{crypto::KeyTypeId, ConstU128, H256};
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
curve::PiecewiseLinear,
Expand All @@ -38,6 +37,7 @@ use sp_runtime::{
BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_state_machine::BasicExternalities;

use crate as pallet_beefy;

Expand Down
4 changes: 2 additions & 2 deletions frame/benchmarking/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ macro_rules! benchmarks_iter {
>:: [< new_call_variant_ $dispatch >] (
$($arg),*
);
let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode(
let __benchmarked_call_encoded = $crate::frame_support::__private::codec::Encode::encode(
&__call
);
}: {
let __call_decoded = <
Call<T $(, $instance )?>
as $crate::frame_support::codec::Decode
as $crate::frame_support::__private::codec::Decode
>::decode(&mut &__benchmarked_call_encoded[..])
.expect("call is encoded above, encoding must be correct");
let __origin = $crate::to_origin!($origin $(, $origin_type)?);
Expand Down
2 changes: 1 addition & 1 deletion frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "128"]

use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_io::storage;
use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_std::{marker::PhantomData, prelude::*, result};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
Pays, PostDispatchInfo,
Expand Down
Loading

0 comments on commit df383f2

Please sign in to comment.