diff --git a/pallets/quota/src/lib.rs b/pallets/quota/src/lib.rs index f72ac44b91e180ae93de3598430bedbda18614a9..eff611f21653cebc441ef6dba6d76fd4b772abfd 100644 --- a/pallets/quota/src/lib.rs +++ b/pallets/quota/src/lib.rs @@ -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 { diff --git a/pallets/quota/src/traits.rs b/pallets/quota/src/traits.rs index 53259cb67adabaa49eec1e641b09407a0254c897..fb2e377fd0fed6a6718703a0a3b893ad62e6b332 100644 --- a/pallets/quota/src/traits.rs +++ b/pallets/quota/src/traits.rs @@ -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