Skip to content

Commit

Permalink
Set all MaxHolds = RuntimeHoldReason and `MaxFreezes = RuntimeFreez…
Browse files Browse the repository at this point in the history
…eReason`
  • Loading branch information
bkontur committed Jan 5, 2024
1 parent 80c685c commit a2b272a
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 38 deletions.
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 @@ -213,10 +213,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
// We allow each account to have holds on it from:
// - `NftFractionalization`: 1
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
// We allow each account to have holds on it from:
// - `NftFractionalization`: 1
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type RuntimeHoldReason = RuntimeHoldReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

impl pallet_transaction_payment::Config for Runtime {
Expand Down
8 changes: 4 additions & 4 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ impl pallet_balances::Config for Runtime {
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type MaxHolds = ConstU32<2>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down Expand Up @@ -1163,8 +1163,8 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<2>;
type MaxFreezes = ConstU32<1>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ impl pallet_balances::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = RuntimeFreezeReason;
type MaxFreezes = ConstU32<1>;
type MaxHolds = ConstU32<1>;
type MaxHolds = RuntimeHoldReason;
type MaxFreezes = RuntimeFreezeReason;
}

parameter_types! {
Expand Down
2 changes: 0 additions & 2 deletions substrate/frame/support/src/traits/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub const DEFENSIVE_OP_PUBLIC_ERROR: &str = "a defensive failure has been trigge
pub const DEFENSIVE_OP_INTERNAL_ERROR: &str = "Defensive failure has been triggered!";

/// Trait to get the number of variants in any enum.
///
/// NOTE: can be removed once <https://doc.rust-lang.org/std/mem/fn.variant_count.html> is stable.
pub trait VariantCount {
/// Get the number of variants.
const VARIANT_COUNT: u32;
Expand Down
4 changes: 3 additions & 1 deletion substrate/frame/support/test/tests/composite_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use codec::Encode;
use frame_support::derive_impl;
use frame_support::traits::VariantCount;
use frame_support::traits::{Get, VariantCount};
use sp_core::sr25519;
use sp_runtime::{
generic,
Expand Down Expand Up @@ -226,11 +226,13 @@ fn list_all_freeze_reason_variants() -> Vec<RuntimeFreezeReason> {

#[test]
fn runtime_hold_reason_variant_count_works() {
assert_eq!(RuntimeHoldReason::VARIANT_COUNT, RuntimeHoldReason::get());
assert_eq!(RuntimeHoldReason::VARIANT_COUNT as usize, list_all_hold_reason_variants().len());
}

#[test]
fn runtime_freeze_reason_variant_count_works() {
assert_eq!(RuntimeFreezeReason::VARIANT_COUNT, RuntimeFreezeReason::get());
assert_eq!(RuntimeFreezeReason::VARIANT_COUNT as usize, list_all_freeze_reason_variants().len());
}

Expand Down

0 comments on commit a2b272a

Please sign in to comment.