From 5766fe79327c6e835ce2b560729f3a08c3390eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:23:43 -0300 Subject: [PATCH 1/3] Derive extra traits for fungibles::Imbalance --- .../src/traits/tokens/fungibles/imbalance.rs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs index 349d9d7c65e89..f4ecece79d92a 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs @@ -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; @@ -45,7 +48,16 @@ pub trait HandleImbalanceDrop { /// /// 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, From fd822cbb408b7738d757b6d15652c4975cbb675f Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 22:31:27 +0000 Subject: [PATCH 2/3] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_10587.prdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 prdoc/pr_10587.prdoc diff --git a/prdoc/pr_10587.prdoc b/prdoc/pr_10587.prdoc new file mode 100644 index 0000000000000..e89a28e58c0be --- /dev/null +++ b/prdoc/pr_10587.prdoc @@ -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 From dcd515a3f2b875ad98803deb623666a09c776ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20Stu=CC=88ber?= <15174476+TorstenStueber@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:15:55 -0300 Subject: [PATCH 3/3] Implement Default for fungibles::Imbalance --- .../support/src/traits/tokens/fungibles/imbalance.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs index f4ecece79d92a..3c4bd149d5472 100644 --- a/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs +++ b/substrate/frame/support/src/traits/tokens/fungibles/imbalance.rs @@ -96,6 +96,18 @@ impl< } } +impl< + A: AssetId + Default, + B: Balance, + OnDrop: HandleImbalanceDrop, + OppositeOnDrop: HandleImbalanceDrop, + > Default for Imbalance +{ + fn default() -> Self { + Self::zero(Default::default()) + } +} + impl< A: AssetId, B: Balance,