Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fee handlers composable #386

Open
olanod opened this issue May 7, 2024 · 0 comments
Open

Make fee handlers composable #386

olanod opened this issue May 7, 2024 · 0 comments

Comments

@olanod
Copy link
Member

olanod commented May 7, 2024

Instead of "the fee handler" we should be able to define several fee handlers that each focus on different things and can later be composed together with a tuple similar to how other Substrate traits allow composition.

Changing the FeeHandler trait to receive a mutable Fees object would make it easier for implementers.

pub trait FeeHandler<T: Config> {
    fn apply_fees(
        fees: &mut Fees<T>,
        amount: (&BalanceOf<T>, &AssetIdOf<T>),
        sender: &T::AccountId,
        beneficiary: &T::AccountId,
        detail: Option<&T::PaymentDetail>,
    ) ;
}
struct FeeA;
impl FeeHandler<Runtime> for FeeA {...}
struct FeeB;
impl FeeHandler<Runtime> for FeeB {...}
struct FeeC;
impl FeeHandler<Runtime> for FeeC {...}

impl pallet_payments::Config for Runtime {
    // ...
    type FeeHandler = (FeeA, FeeB, FeeC,),
    // ...
}
@olanod olanod added this to Kreivo Q3 Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant