Skip to content
Unverified Commit 6d0926e2 authored by Muharem Ismailov's avatar Muharem Ismailov Committed by GitHub
Browse files

Make `on_unbalanceds` work with `fungibles` `imbalances` (#4564)

Make `on_unbalanceds` work with `fungibles` `imbalances`.

The `fungibles` `imbalances` cannot be handled by the default
implementation of `on_unbalanceds` from the `OnUnbalanced` trait. This
is because the `fungibles` `imbalances` types do not implement the
`Imbalance` trait (and cannot with its current semantics). The
`on_unbalanceds` function requires only the `merge` function for the
imbalance type. In this PR, we provide the `TryMerge` trait, which can
be implemented by all imbalance types and make `OnUnbalanced` require it
instead `Imbalance`.

### Migration for `OnUnbalanced` trait implementations:
In case if you have a custom implementation of `on_unbalanceds` trait
function, remove it's `<B>` type argument.

### Migration for custom imbalance types:
If you have your own imbalance types implementations, implement the
`TryMerge` trait for it introduced with this update.
        
The applicability of the `on_unbalanceds` function to fungibles
imbalances is useful in cases like -
[link](https://github.com/paritytech/polkadot-sdk/blob/3a8e675e

/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs#L267)
from https://github.com/paritytech/polkadot-sdk/pull/4488.

---------

Co-authored-by: default avatarOliver Tale-Yazdi <[email protected]>
parent 2bd187f8
Pipeline #486056 waiting for manual action with stages
in 1 hour, 4 minutes, and 57 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment