Do not assume AssetIds are Copy (companion for substrate#14158) (#2586)

* Do not assume `AssetId`s are `Copy`

* update lockfile for {"substrate", "polkadot"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Koute
2023-05-23 21:09:45 +09:00
committed by GitHub
parent 93b30fe8d8
commit afd1192898
4 changed files with 209 additions and 208 deletions
+193 -193
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -91,7 +91,7 @@ where
Assets: fungibles::Inspect<AccountId>, Assets: fungibles::Inspect<AccountId>,
{ {
fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool { fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
!Assets::total_issuance(*id).is_zero() !Assets::total_issuance(id.clone()).is_zero()
} }
} }
@@ -103,7 +103,7 @@ where
Assets: fungibles::Inspect<AccountId>, Assets: fungibles::Inspect<AccountId>,
{ {
fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool { fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
Assets::asset_exists(*id) Assets::asset_exists(id.clone())
} }
} }
@@ -197,7 +197,7 @@ where
Assets: fungibles::Inspect<AccountId>, Assets: fungibles::Inspect<AccountId>,
{ {
fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool { fn contains(id: &<Assets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
!Assets::total_issuance(*id).is_zero() !Assets::total_issuance(id.clone()).is_zero()
} }
} }
+13 -12
View File
@@ -168,17 +168,18 @@ impl<
// Calculate how much we should charge in the asset_id for such amount of weight // Calculate how much we should charge in the asset_id for such amount of weight
// Require at least a payment of minimum_balance // Require at least a payment of minimum_balance
// Necessary for fully collateral-backed assets // Necessary for fully collateral-backed assets
let asset_balance: u128 = FeeCharger::charge_weight_in_fungibles(local_asset_id, weight) let asset_balance: u128 =
.map(|amount| { FeeCharger::charge_weight_in_fungibles(local_asset_id.clone(), weight)
let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); .map(|amount| {
if amount < minimum_balance { let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id);
minimum_balance if amount < minimum_balance {
} else { minimum_balance
amount } else {
} amount
})? }
.try_into() })?
.map_err(|_| XcmError::Overflow)?; .try_into()
.map_err(|_| XcmError::Overflow)?;
// Convert to the same kind of multiasset, with the required fungible balance // Convert to the same kind of multiasset, with the required fungible balance
let required = first.id.into_multiasset(asset_balance.into()); let required = first.id.into_multiasset(asset_balance.into());
@@ -206,7 +207,7 @@ impl<
let (local_asset_id, outstanding_balance) = let (local_asset_id, outstanding_balance) =
Matcher::matches_fungibles(&(id, fun).into()).ok()?; Matcher::matches_fungibles(&(id, fun).into()).ok()?;
let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id.clone());
// Calculate asset_balance // Calculate asset_balance
// This read should have already be cached in buy_weight // This read should have already be cached in buy_weight