mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 20:31:04 +00:00
Add field names to pallet Event variants (#9993)
* convert pallet-assets events to struct types * updated events of a couple pallets * updated pallet event field names * update pallet event field names * updated events in test files * cargo fmt * minorfixes * fix assertion error * minor fix * formatting fix * fmt
This commit is contained in:
@@ -346,7 +346,7 @@ pub mod pallet {
|
||||
|
||||
(account.free, account.reserved)
|
||||
})?;
|
||||
Self::deposit_event(Event::BalanceSet(who, free, reserved));
|
||||
Self::deposit_event(Event::BalanceSet { who, free, reserved });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
@@ -454,31 +454,33 @@ pub mod pallet {
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
/// An account was created with some free balance. \[account, free_balance\]
|
||||
Endowed(T::AccountId, T::Balance),
|
||||
/// An account was created with some free balance.
|
||||
Endowed { account: T::AccountId, free_balance: T::Balance },
|
||||
/// An account was removed whose balance was non-zero but below ExistentialDeposit,
|
||||
/// resulting in an outright loss. \[account, balance\]
|
||||
DustLost(T::AccountId, T::Balance),
|
||||
/// Transfer succeeded. \[from, to, value\]
|
||||
Transfer(T::AccountId, T::AccountId, T::Balance),
|
||||
/// A balance was set by root. \[who, free, reserved\]
|
||||
BalanceSet(T::AccountId, T::Balance, T::Balance),
|
||||
/// Some balance was reserved (moved from free to reserved). \[who, value\]
|
||||
Reserved(T::AccountId, T::Balance),
|
||||
/// Some balance was unreserved (moved from reserved to free). \[who, value\]
|
||||
Unreserved(T::AccountId, T::Balance),
|
||||
/// resulting in an outright loss.
|
||||
DustLost { account: T::AccountId, amount: T::Balance },
|
||||
/// Transfer succeeded.
|
||||
Transfer { from: T::AccountId, to: T::AccountId, amount: T::Balance },
|
||||
/// A balance was set by root.
|
||||
BalanceSet { who: T::AccountId, free: T::Balance, reserved: T::Balance },
|
||||
/// Some balance was reserved (moved from free to reserved).
|
||||
Reserved { who: T::AccountId, amount: T::Balance },
|
||||
/// Some balance was unreserved (moved from reserved to free).
|
||||
Unreserved { who: T::AccountId, amount: T::Balance },
|
||||
/// Some balance was moved from the reserve of the first account to the second account.
|
||||
/// Final argument indicates the destination balance type.
|
||||
/// \[from, to, balance, destination_status\]
|
||||
ReserveRepatriated(T::AccountId, T::AccountId, T::Balance, Status),
|
||||
/// Some amount was deposited into the account (e.g. for transaction fees). \[who,
|
||||
/// deposit\]
|
||||
Deposit(T::AccountId, T::Balance),
|
||||
/// Some amount was withdrawn from the account (e.g. for transaction fees). \[who, value\]
|
||||
Withdraw(T::AccountId, T::Balance),
|
||||
/// Some amount was removed from the account (e.g. for misbehavior). \[who,
|
||||
/// amount_slashed\]
|
||||
Slashed(T::AccountId, T::Balance),
|
||||
ReserveRepatriated {
|
||||
from: T::AccountId,
|
||||
to: T::AccountId,
|
||||
amount: T::Balance,
|
||||
destination_status: Status,
|
||||
},
|
||||
/// Some amount was deposited (e.g. for transaction fees).
|
||||
Deposit { who: T::AccountId, amount: T::Balance },
|
||||
/// Some amount was withdrawn from the account (e.g. for transaction fees).
|
||||
Withdraw { who: T::AccountId, amount: T::Balance },
|
||||
/// Some amount was removed from the account (e.g. for misbehavior).
|
||||
Slashed { who: T::AccountId, amount: T::Balance },
|
||||
}
|
||||
|
||||
/// Old name generated by `decl_event`.
|
||||
@@ -742,7 +744,7 @@ pub struct DustCleaner<T: Config<I>, I: 'static = ()>(
|
||||
impl<T: Config<I>, I: 'static> Drop for DustCleaner<T, I> {
|
||||
fn drop(&mut self) {
|
||||
if let Some((who, dust)) = self.0.take() {
|
||||
Pallet::<T, I>::deposit_event(Event::DustLost(who, dust.peek()));
|
||||
Pallet::<T, I>::deposit_event(Event::DustLost { account: who, amount: dust.peek() });
|
||||
T::DustRemoval::on_unbalanced(dust);
|
||||
}
|
||||
}
|
||||
@@ -939,7 +941,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
});
|
||||
result.map(|(maybe_endowed, maybe_dust, result)| {
|
||||
if let Some(endowed) = maybe_endowed {
|
||||
Self::deposit_event(Event::Endowed(who.clone(), endowed));
|
||||
Self::deposit_event(Event::Endowed { account: who.clone(), free_balance: endowed });
|
||||
}
|
||||
let dust_cleaner = DustCleaner(maybe_dust.map(|dust| (who.clone(), dust)));
|
||||
(result, dust_cleaner)
|
||||
@@ -1051,12 +1053,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
},
|
||||
)?;
|
||||
|
||||
Self::deposit_event(Event::ReserveRepatriated(
|
||||
slashed.clone(),
|
||||
beneficiary.clone(),
|
||||
actual,
|
||||
status,
|
||||
));
|
||||
Self::deposit_event(Event::ReserveRepatriated {
|
||||
from: slashed.clone(),
|
||||
to: beneficiary.clone(),
|
||||
amount: actual,
|
||||
destination_status: status,
|
||||
});
|
||||
Ok(actual)
|
||||
}
|
||||
}
|
||||
@@ -1109,7 +1111,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
|
||||
Ok(())
|
||||
})?;
|
||||
TotalIssuance::<T, I>::mutate(|t| *t += amount);
|
||||
Self::deposit_event(Event::Deposit(who.clone(), amount));
|
||||
Self::deposit_event(Event::Deposit { who: who.clone(), amount });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1130,7 +1132,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
|
||||
},
|
||||
)?;
|
||||
TotalIssuance::<T, I>::mutate(|t| *t -= actual);
|
||||
Self::deposit_event(Event::Withdraw(who.clone(), amount));
|
||||
Self::deposit_event(Event::Withdraw { who: who.clone(), amount });
|
||||
Ok(actual)
|
||||
}
|
||||
}
|
||||
@@ -1151,7 +1153,11 @@ impl<T: Config<I>, I: 'static> fungible::Unbalanced<T::AccountId> for Pallet<T,
|
||||
fn set_balance(who: &T::AccountId, amount: Self::Balance) -> DispatchResult {
|
||||
Self::mutate_account(who, |account| {
|
||||
account.free = amount;
|
||||
Self::deposit_event(Event::BalanceSet(who.clone(), account.free, account.reserved));
|
||||
Self::deposit_event(Event::BalanceSet {
|
||||
who: who.clone(),
|
||||
free: account.free,
|
||||
reserved: account.reserved,
|
||||
});
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -1531,7 +1537,11 @@ where
|
||||
)?;
|
||||
|
||||
// Emit transfer event.
|
||||
Self::deposit_event(Event::Transfer(transactor.clone(), dest.clone(), value));
|
||||
Self::deposit_event(Event::Transfer {
|
||||
from: transactor.clone(),
|
||||
to: dest.clone(),
|
||||
amount: value,
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1595,10 +1605,10 @@ where
|
||||
},
|
||||
) {
|
||||
Ok((imbalance, not_slashed)) => {
|
||||
Self::deposit_event(Event::Slashed(
|
||||
who.clone(),
|
||||
value.saturating_sub(not_slashed),
|
||||
));
|
||||
Self::deposit_event(Event::Slashed {
|
||||
who: who.clone(),
|
||||
amount: value.saturating_sub(not_slashed),
|
||||
});
|
||||
return (imbalance, not_slashed)
|
||||
},
|
||||
Err(_) => (),
|
||||
@@ -1625,7 +1635,7 @@ where
|
||||
|account, is_new| -> Result<Self::PositiveImbalance, DispatchError> {
|
||||
ensure!(!is_new, Error::<T, I>::DeadAccount);
|
||||
account.free = account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?;
|
||||
Self::deposit_event(Event::Deposit(who.clone(), value));
|
||||
Self::deposit_event(Event::Deposit { who: who.clone(), amount: value });
|
||||
Ok(PositiveImbalance::new(value))
|
||||
},
|
||||
)
|
||||
@@ -1658,7 +1668,7 @@ where
|
||||
None => return Ok(Self::PositiveImbalance::zero()),
|
||||
};
|
||||
|
||||
Self::deposit_event(Event::Deposit(who.clone(), value));
|
||||
Self::deposit_event(Event::Deposit { who: who.clone(), amount: value });
|
||||
Ok(PositiveImbalance::new(value))
|
||||
},
|
||||
)
|
||||
@@ -1696,7 +1706,7 @@ where
|
||||
|
||||
account.free = new_free_account;
|
||||
|
||||
Self::deposit_event(Event::Withdraw(who.clone(), value));
|
||||
Self::deposit_event(Event::Withdraw { who: who.clone(), amount: value });
|
||||
Ok(NegativeImbalance::new(value))
|
||||
},
|
||||
)
|
||||
@@ -1729,7 +1739,11 @@ where
|
||||
SignedImbalance::Negative(NegativeImbalance::new(account.free - value))
|
||||
};
|
||||
account.free = value;
|
||||
Self::deposit_event(Event::BalanceSet(who.clone(), account.free, account.reserved));
|
||||
Self::deposit_event(Event::BalanceSet {
|
||||
who: who.clone(),
|
||||
free: account.free,
|
||||
reserved: account.reserved,
|
||||
});
|
||||
Ok(imbalance)
|
||||
},
|
||||
)
|
||||
@@ -1773,7 +1787,7 @@ where
|
||||
Self::ensure_can_withdraw(&who, value.clone(), WithdrawReasons::RESERVE, account.free)
|
||||
})?;
|
||||
|
||||
Self::deposit_event(Event::Reserved(who.clone(), value));
|
||||
Self::deposit_event(Event::Reserved { who: who.clone(), amount: value });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1805,7 +1819,7 @@ where
|
||||
},
|
||||
};
|
||||
|
||||
Self::deposit_event(Event::Unreserved(who.clone(), actual.clone()));
|
||||
Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual.clone() });
|
||||
value - actual
|
||||
}
|
||||
|
||||
@@ -1846,10 +1860,10 @@ where
|
||||
(NegativeImbalance::new(actual), value - actual)
|
||||
}) {
|
||||
Ok((imbalance, not_slashed)) => {
|
||||
Self::deposit_event(Event::Slashed(
|
||||
who.clone(),
|
||||
value.saturating_sub(not_slashed),
|
||||
));
|
||||
Self::deposit_event(Event::Slashed {
|
||||
who: who.clone(),
|
||||
amount: value.saturating_sub(not_slashed),
|
||||
});
|
||||
return (imbalance, not_slashed)
|
||||
},
|
||||
Err(_) => (),
|
||||
@@ -1992,7 +2006,7 @@ where
|
||||
// `actual <= to_change` and `to_change <= amount`; qed;
|
||||
reserves[index].amount -= actual;
|
||||
|
||||
Self::deposit_event(Event::Slashed(who.clone(), actual));
|
||||
Self::deposit_event(Event::Slashed { who: who.clone(), amount: actual });
|
||||
(imb, value - actual)
|
||||
},
|
||||
Err(_) => (NegativeImbalance::zero(), value),
|
||||
|
||||
Reference in New Issue
Block a user