1

I'm trying to change pallet_assets to pallet_assets::<Instance1> in preparation for more pallet instances. Commit here and compilation error here.

The trouble seems to come from the HandleCredit impl, which assumes some pallet_assets::Config, but doesn't reference any instance. I don't understand what it would need to do with an instance; it should take the assets from any configured Assets pallet (even if there are many). How can I fix this?

/// A `HandleCredit` implementation that naively transfers the fees to the block author.
/// Will drop and burn the assets in case the transfer fails.
pub struct AssetsToBlockAuthor<R>(PhantomData<R>);
impl<R> HandleCredit<AccountIdOf<R>, pallet_assets::Pallet<R>> for AssetsToBlockAuthor<R>
where
    R: pallet_authorship::Config + pallet_assets::Config,
    AccountIdOf<R>:
        From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
{
    fn handle_credit(credit: CreditOf<AccountIdOf<R>, pallet_assets::Pallet<R>>) {
        if let Some(author) = pallet_authorship::Pallet::<R>::author() {
            // In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
            let _ = pallet_assets::Pallet::<R>::resolve(&author, credit);
        }
    }
}

1 Answer 1

1

This should solve your problem:

/// A `HandleCredit` implementation that naively transfers the fees to the block author.
/// Will drop and burn the assets in case the transfer fails.
pub struct AssetsToBlockAuthor<R, I = ()>(PhantomData<(R, I)>);
impl<R, I> HandleCredit<AccountIdOf<R>, pallet_assets::Pallet<R, I>> for AssetsToBlockAuthor<R>
where
    I: 'static,
    R: pallet_authorship::Config + pallet_assets::Config<I>,
    AccountIdOf<R>:
        From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
{
    fn handle_credit(credit: CreditOf<AccountIdOf<R>, pallet_assets::Pallet<R, I>>) {
        if let Some(author) = pallet_authorship::Pallet::<R>::author() {
            // In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
            let _ = pallet_assets::Pallet::<R, I>::resolve(&author, credit);
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.