Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix arithmetic
  • Loading branch information
kalaninja committed May 10, 2023
commit cff6385721e21003a3a41b559fe427d52fae044c
11 changes: 5 additions & 6 deletions primitives/xcm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{
sp_runtime::SaturatedConversion,
sp_runtime::{SaturatedConversion, Saturating},
traits::{fungibles::Inspect, Currency},
};
use sp_std::{borrow::Borrow, marker::PhantomData};
Expand Down Expand Up @@ -115,15 +115,15 @@ impl<AssetId, AssetIdInfoGetter, AssetsPallet, BalancesPallet, XcmPallet, Accoun
if let Concrete(location) = id {
match AssetIdInfoGetter::get_asset_id(location) {
Some(asset_id) => {
weight += Weigher::fungible();
weight.saturating_accrue(Weigher::fungible());

// only trap if amount ≥ min_balance
// do nothing otherwise (asset is lost)
amount.saturated_into::<AssetsPallet::Balance>() >=
AssetsPallet::minimum_balance(asset_id)
},
None => {
weight += Weigher::native();
weight.saturating_accrue(Weigher::native());

// only trap if native token and amount ≥ min_balance
// do nothing otherwise (asset is lost)
Expand All @@ -133,14 +133,13 @@ impl<AssetId, AssetIdInfoGetter, AssetsPallet, BalancesPallet, XcmPallet, Accoun
},
}
} else {
weight += Weigher::default();
weight.saturating_accrue(Weigher::default());
false
}
});

// we have filtered out non-compliant assets
// insert valid assets into the asset trap implemented by XcmPallet
weight += XcmPallet::drop_assets(origin, assets);
weight
weight.saturating_add(XcmPallet::drop_assets(origin, assets))
}
}