From ed05ecbb914e21b4154946c9efd45fee32c97e35 Mon Sep 17 00:00:00 2001 From: Nicolas Fernandez Date: Thu, 19 Oct 2023 15:44:50 +0200 Subject: [PATCH] WIP --- substrate/frame/assets/src/impl_fungibles.rs | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/substrate/frame/assets/src/impl_fungibles.rs b/substrate/frame/assets/src/impl_fungibles.rs index 93f184ee199e9..0af256a8c1e7c 100644 --- a/substrate/frame/assets/src/impl_fungibles.rs +++ b/substrate/frame/assets/src/impl_fungibles.rs @@ -345,20 +345,21 @@ impl, I: 'static> fungibles::InspectHold for Pallet bool { - let asset_details = Asset::::get(asset.clone()).unwrap(); - let holds = Holds::::get(who, asset); - if !holds.is_full() && asset_details.is_sufficient == true { - return true; - } + let asset_details = match Asset::::get(&asset) { + Some(details) => details, + None => return false, + }; - if frame_system::Pallet::::providers(who) == 0 { - return false; - } + let holds = Holds::::get(who, &asset); - if holds.is_full() && !holds.iter().any(|x| &x.id == reason) { - return false; + if !holds.is_full() && asset_details.is_sufficient { + return true; } - true + + // Return true only if there are providers for the given 'who' + // and either holds is not full or there's a hold with the given reason. + frame_system::Pallet::::providers(who) > 0 + && (!holds.is_full() || holds.iter().any(|x| &x.id == reason)) } }