mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Add support for tuples in OnNewAccount hook (#2765)
* Add support for tuples in `OnNewAccount` hook * Bump impl version * Use `for_each_tuple` with `OnNewAccount` hook * Update `OnFreeBalanceZero` to also use `for_each_tuple` * Fix spelling/typo * Bump spec again * Update srml/support/src/traits.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update srml/system/src/lib.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
4213fe15cf
commit
6ce7c1c8c8
@@ -24,6 +24,8 @@ use crate::runtime_primitives::traits::{
|
||||
MaybeSerializeDebug, SimpleArithmetic
|
||||
};
|
||||
|
||||
use super::for_each_tuple;
|
||||
|
||||
/// New trait for querying a single fixed value from a type.
|
||||
pub trait Get<T> {
|
||||
/// Return a constant value.
|
||||
@@ -36,20 +38,24 @@ pub trait OnFreeBalanceZero<AccountId> {
|
||||
fn on_free_balance_zero(who: &AccountId);
|
||||
}
|
||||
|
||||
impl<AccountId> OnFreeBalanceZero<AccountId> for () {
|
||||
fn on_free_balance_zero(_who: &AccountId) {}
|
||||
}
|
||||
impl<
|
||||
AccountId,
|
||||
X: OnFreeBalanceZero<AccountId>,
|
||||
Y: OnFreeBalanceZero<AccountId>,
|
||||
> OnFreeBalanceZero<AccountId> for (X, Y) {
|
||||
fn on_free_balance_zero(who: &AccountId) {
|
||||
X::on_free_balance_zero(who);
|
||||
Y::on_free_balance_zero(who);
|
||||
macro_rules! impl_on_free_balance_zero {
|
||||
() => (
|
||||
impl<AccountId> OnFreeBalanceZero<AccountId> for () {
|
||||
fn on_free_balance_zero(_: &AccountId) {}
|
||||
}
|
||||
);
|
||||
|
||||
( $($t:ident)* ) => {
|
||||
impl<AccountId, $($t: OnFreeBalanceZero<AccountId>),*> OnFreeBalanceZero<AccountId> for ($($t,)*) {
|
||||
fn on_free_balance_zero(who: &AccountId) {
|
||||
$($t::on_free_balance_zero(who);)*
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for_each_tuple!(impl_on_free_balance_zero);
|
||||
|
||||
/// Trait for a hook to get called when some balance has been minted, causing dilution.
|
||||
pub trait OnDilution<Balance> {
|
||||
/// Some `portion` of the total balance just "grew" by `minted`. `portion` is the pre-growth
|
||||
|
||||
Reference in New Issue
Block a user