Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
darkforest0202 committed Oct 19, 2023
1 parent a6e3d81 commit ed05ecb
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions substrate/frame/assets/src/impl_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,20 +345,21 @@ impl<T: Config<I>, I: 'static> fungibles::InspectHold<T::AccountId> for Pallet<T
.map_or_else(Zero::zero, |x| x.amount)
}
fn hold_available(asset: T::AssetId, reason: &Self::Reason, who: &T::AccountId) -> bool {
let asset_details = Asset::<T, I>::get(asset.clone()).unwrap();
let holds = Holds::<T, I>::get(who, asset);
if !holds.is_full() && asset_details.is_sufficient == true {
return true;
}
let asset_details = match Asset::<T, I>::get(&asset) {
Some(details) => details,
None => return false,
};

if frame_system::Pallet::<T>::providers(who) == 0 {
return false;
}
let holds = Holds::<T, I>::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::<T>::providers(who) > 0
&& (!holds.is_full() || holds.iter().any(|x| &x.id == reason))
}
}

Expand Down

0 comments on commit ed05ecb

Please sign in to comment.