Skip to content
Snippets Groups Projects
Commit bfdfaa5d authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

make eligibility more explicit

parent bd982b39
No related branches found
No related tags found
No related merge requests found
Pipeline #34050 waiting for manual action
......@@ -318,15 +318,24 @@ pub mod pallet {
// implement quota traits
impl<T: Config> RefundFee<T> for Pallet<T> {
fn request_refund(account: T::AccountId, identity: IdtyId<T>, amount: BalanceOf<T>) {
// TODO only queue refund if identity is eligible for refund
Self::queue_refund(Refund {
account,
identity,
amount,
})
if is_eligible_for_refund::<T>(identity) {
Self::queue_refund(Refund {
account,
identity,
amount,
})
}
}
}
/// tells whether an identity is eligible for refund
fn is_eligible_for_refund<T: pallet_identity::Config>(_identity: IdtyId<T>) -> bool {
// all identities are eligible for refund, no matter their status
// if the identity has no quotas or has been deleted, the refund request is still queued
// but when handeled, no refund will be issued (and `NoQuotaForIdty` may be raised)
true
}
// implement identity event handler
impl<T: Config> pallet_identity::traits::OnIdtyChange<T> for Pallet<T> {
fn on_idty_change(idty_id: IdtyId<T>, idty_event: &IdtyEvent<T>) -> Weight {
......
......@@ -18,7 +18,7 @@ use crate::*;
/// trait used to request refund of a fee
pub trait RefundFee<T: Config> {
/// request refund
/// request refund for the account `account` using the quotas of identity `identity`
fn request_refund(account: T::AccountId, identity: IdtyId<T>, amount: BalanceOf<T>);
}
// dummy impl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment