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

HoldReason: Improve usage #13869

Merged
merged 5 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
15 changes: 2 additions & 13 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ use pallet_nis::WithMaximumOf;
use pallet_session::historical as pallet_session_historical;
pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use scale_info::TypeInfo;
use sp_api::impl_runtime_apis;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
Expand Down Expand Up @@ -436,15 +435,6 @@ parameter_types! {
pub const MaxReserves: u32 = 50;
}

/// A reason for placing a hold on funds.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo,
)]
pub enum HoldReason {
/// The NIS Pallet has reserved it for a non-fungible receipt.
Nis,
}

impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
Expand All @@ -457,7 +447,7 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = HoldReason;
type RuntimeHoldReason = RuntimeHoldReason;
type MaxHolds = ConstU32<1>;
}

Expand Down Expand Up @@ -1500,7 +1490,6 @@ parameter_types! {
pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
pub Target: Perquintill = Perquintill::zero();
pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
pub const NisHoldReason: HoldReason = HoldReason::Nis;
}

impl pallet_nis::Config for Runtime {
Expand All @@ -1524,7 +1513,7 @@ impl pallet_nis::Config for Runtime {
type IntakePeriod = IntakePeriod;
type MaxIntakeWeight = MaxIntakeWeight;
type ThawThrottle = ThawThrottle;
type HoldReason = NisHoldReason;
type RuntimeHoldReason = RuntimeHoldReason;
}

parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type FreezeIdentifier = ();
type MaxHolds = ();
type MaxFreezes = ();
Expand Down
2 changes: 1 addition & 1 deletion frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/impl_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::MutateHold<T::AccountId> for Pallet<T, I> {}

impl<T: Config<I>, I: 'static> fungible::InspectHold<T::AccountId> for Pallet<T, I> {
type Reason = T::HoldIdentifier;
type Reason = T::RuntimeHoldReason;

fn total_balance_on_hold(who: &T::AccountId) -> T::Balance {
Self::account(who).reserved
Expand Down
6 changes: 3 additions & 3 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ pub mod pallet {
/// Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/`
type ReserveIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy;

/// The ID type for holds.
type HoldIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy;
/// The overarching hold reason.
type RuntimeHoldReason: Parameter + Member + MaxEncodedLen + Ord + Copy;

/// The ID type for freezes.
type FreezeIdentifier: Parameter + Member + MaxEncodedLen + Ord + Copy;
Expand Down Expand Up @@ -430,7 +430,7 @@ pub mod pallet {
_,
Blake2_128Concat,
T::AccountId,
BoundedVec<IdAmount<T::HoldIdentifier, T::Balance>, T::MaxHolds>,
BoundedVec<IdAmount<T::RuntimeHoldReason, T::Balance>, T::MaxHolds>,
ValueQuery,
>;

Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Config for Test {
type MaxReserves = ConstU32<2>;
type ReserveIdentifier = TestId;
type WeightInfo = ();
type HoldIdentifier = TestId;
type RuntimeHoldReason = TestId;
type FreezeIdentifier = TestId;
type MaxFreezes = ConstU32<2>;
type MaxHolds = ConstU32<2>;
Expand Down
2 changes: 1 addition & 1 deletion frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl pallet_balances::Config for Test {
type ExistentialDeposit = ConstU128<1>;
type AccountStore = System;
type WeightInfo = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
Expand Down
2 changes: 1 addition & 1 deletion frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}
parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}
parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/conviction-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}
parameter_types! {
Expand Down
2 changes: 1 addition & 1 deletion frame/election-provider-multi-phase/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ mod tests {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/examples/basic/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ mod tests {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<1>;
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ConstU32<1>;
}

Expand Down
2 changes: 1 addition & 1 deletion frame/fast-unstake/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/identity/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/indices/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/lottery/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/multisig/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/nfts/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test {
type ReserveIdentifier = [u8; 8];
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
2 changes: 1 addition & 1 deletion frame/nicks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mod tests {
type WeightInfo = ();
type FreezeIdentifier = ();
type MaxFreezes = ();
type HoldIdentifier = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
}

Expand Down
Loading