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

Migrate pallet-indices to umbrella crate #6737

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 1 addition & 6 deletions Cargo.lock

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

23 changes: 4 additions & 19 deletions substrate/frame/indices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }
sp-keyring = { optional = true, workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
Expand All @@ -33,27 +28,17 @@ pallet-balances = { workspace = true, default-features = true }
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"pallet-balances/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-keyring",
"sp-keyring?/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"frame/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
5 changes: 1 addition & 4 deletions substrate/frame/indices/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
#![cfg(feature = "runtime-benchmarks")]

use crate::*;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
use sp_runtime::traits::Bounded;

use frame::benchmarking::prelude::*;
const SEED: u32 = 0;

#[benchmarks]
Expand Down
12 changes: 3 additions & 9 deletions substrate/frame/indices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ extern crate alloc;

use alloc::vec::Vec;
use codec::Codec;
use frame_support::traits::{BalanceStatus::Reserved, Currency, ReservableCurrency};
use sp_runtime::{
traits::{AtLeast32Bit, LookupError, Saturating, StaticLookup, Zero},
MultiAddress,
};
use frame::prelude::*;
pub use weights::WeightInfo;

type BalanceOf<T> =
Expand All @@ -42,11 +38,9 @@ type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup

pub use pallet::*;

#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;

/// The module's config trait.
#[pallet::config]
Expand Down Expand Up @@ -265,7 +259,7 @@ pub mod pallet {
StorageMap<_, Blake2_128Concat, T::AccountIndex, (T::AccountId, BalanceOf<T>, bool)>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub indices: Vec<(T::AccountIndex, T::AccountId)>,
}
Expand Down
7 changes: 3 additions & 4 deletions substrate/frame/indices/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
#![cfg(test)]

use crate::{self as pallet_indices, Config};
use frame_support::{derive_impl, traits::ConstU64};
use sp_runtime::BuildStorage;
use frame::testing_prelude::*;

type Block = frame_system::mocking::MockBlock<Test>;

frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand Down Expand Up @@ -55,7 +54,7 @@ impl Config for Test {
type WeightInfo = ();
}

pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/indices/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
#![cfg(test)]

use super::{mock::*, *};
use frame_support::{assert_noop, assert_ok};
use frame::testing_prelude::*;
use pallet_balances::Error as BalancesError;
use sp_runtime::MultiAddress::Id;

#[test]
fn claiming_should_work() {
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/indices/src/weights.rs

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

28 changes: 27 additions & 1 deletion substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,35 @@ pub mod prelude {
/// All hashing related things
pub use super::hashing::*;

/// All arithmetic types used for safe math.
pub use super::arithmetic::*;

/// Runtime traits
#[doc(no_inline)]
pub use sp_runtime::traits::{
BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion,
Saturating, StaticLookup, TrailingZeroInput,
};

/// Bounded storage related types.
pub use sp_runtime::{BoundedSlice, BoundedVec};

/// Currency related traits and types.
pub use frame_support::traits::{
BalanceStatus::{self, Reserved},
Currency,
ExistenceRequirement::KeepAlive,
ReservableCurrency,
};

pub use super::address::*;

/// Other error/result types for runtime
#[doc(no_inline)]
pub use sp_runtime::{DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError};
pub use sp_runtime::{
DispatchError::{self, BadOrigin},
DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError,
};
}

#[cfg(any(feature = "try-runtime", test))]
Expand Down Expand Up @@ -532,6 +551,13 @@ pub mod hashing {
pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256};
}

pub mod address {
pub use sp_runtime::{
traits::LookupError,
MultiAddress::{self, Id},
};
}

/// Access to all of the dependencies of this crate. In case the prelude re-exports are not enough,
/// this module can be used.
///
Expand Down
Loading