You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
so my workaround was to copy the parachains_common implementations of ToStakingPot and DealWithFees structs into my own codebase, with the basic modification of:
/// Implementation of `OnUnbalanced` that deals with the fees by combining tip and fee and passing
/// the result on to `ToStakingPot`.
pub struct DealWithFees<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
- AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,+ AccountIdOf<R>: From<fp_account::AccountId20> + Into<fp_account::AccountId20>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
if let Some(mut fees) = fees_then_tips.next() {
if let Some(tips) = fees_then_tips.next() {
tips.merge_into(&mut fees);
}
<ToStakingPot<R> as OnUnbalanced<_>>::on_unbalanced(fees);
}
}
}
/// Implementation of `OnUnbalanced` that deposits the fees into a staking pot for later payout.
pub struct ToStakingPot<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToStakingPot<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
- AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,+ AccountIdOf<R>: From<fp_account::AccountId20> + Into<fp_account::AccountId20>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
let staking_pot = <pallet_collator_selection::Pallet<R>>::account_id();
<pallet_balances::Pallet<R>>::resolve_creating(&staking_pot, amount);
}
}
but that feels quite dirty.
wouldn't it make sense to make ToStakingPot and DealWithFees structs generic over account formats, so that runtimes could import them from parachains_common::impls without having to re-implement them?
I'm working on a project where we're using
AccountId20instead ofAccountId32I was having a hard time getting
parachains_common::impls::DealWithFeesandparachains_common::impls::ToStakingPotto compile with this account format.so my workaround was to copy the
parachains_commonimplementations ofToStakingPotandDealWithFeesstructs into my own codebase, with the basic modification of:but that feels quite dirty.
wouldn't it make sense to make
ToStakingPotandDealWithFeesstructs generic over account formats, so that runtimes could import them fromparachains_common::implswithout having to re-implement them?