Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions prdoc/pr_10587.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Derive extra traits for fungibles::Imbalance
doc:
- audience: Runtime Dev
description: |-
This PR adds the same derived traits to `fungibles::Imbalance` that are already derived for `fungible::Imbalance`.

This is required so that the `OnChargeTransaction` configuration of `pallet_transaction_payment` can work for the `fungibles` version of types/traits (it already works for `fungible`).
crates:
- name: frame-support
bump: patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
//! See the [`crate::traits::fungibles`] doc for more information about fungibles traits.

use super::*;
use crate::traits::{
fungible,
misc::{SameOrOther, TryDrop},
tokens::{
imbalance::{Imbalance as ImbalanceT, TryMerge},
AssetId, Balance,
use crate::{
pallet_prelude::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen, TypeInfo},
traits::{
fungible,
misc::{SameOrOther, TryDrop},
tokens::{
imbalance::{Imbalance as ImbalanceT, TryMerge},
AssetId, Balance,
},
},
};
use core::marker::PhantomData;
Expand All @@ -45,7 +48,16 @@ pub trait HandleImbalanceDrop<AssetId, Balance> {
///
/// Importantly, it has a special `Drop` impl, and cannot be created outside of this module.
#[must_use]
#[derive(EqNoBound, PartialEqNoBound, RuntimeDebugNoBound)]
#[derive(
EqNoBound,
PartialEqNoBound,
RuntimeDebugNoBound,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
TypeInfo,
)]
pub struct Imbalance<
A: AssetId,
B: Balance,
Expand Down Expand Up @@ -84,6 +96,18 @@ impl<
}
}

impl<
A: AssetId + Default,
B: Balance,
OnDrop: HandleImbalanceDrop<A, B>,
OppositeOnDrop: HandleImbalanceDrop<A, B>,
> Default for Imbalance<A, B, OnDrop, OppositeOnDrop>
{
fn default() -> Self {
Self::zero(Default::default())
}
}

impl<
A: AssetId,
B: Balance,
Expand Down
Loading