[Fix] Weight calculations for Wild -> affects teleports (#1639)

* [Fix] Weight calculations for Wild -> affects teleports

* introduce a separate asset limit for teleports

* fix deposit

* reshuffle abstractions

* fix imports

* little refactoring

* Update parachains/common/src/xcm_config.rs

Co-authored-by: Squirrel <gilescope@gmail.com>

* add comments

Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
Roman Useinov
2022-09-19 20:29:31 +02:00
committed by GitHub
parent 778d6bbe0b
commit 14115c82de
4 changed files with 68 additions and 33 deletions
+14
View File
@@ -119,3 +119,17 @@ impl<Location: Get<MultiLocation>> FilterAssetLocation for ConcreteNativeAssetFr
matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get())
}
}
/// A generic function to use for MultiAssetFilter implementations, currently used to differentiate
/// between reserve operations and the rest of them.
pub fn weigh_multi_assets_generic(
filter: &MultiAssetFilter,
weight: Weight,
max_assets: u32,
) -> XCMWeight {
let multiplier = match filter {
MultiAssetFilter::Definite(assets) => assets.len() as u64,
MultiAssetFilter::Wild(_) => max_assets as u64,
};
weight.saturating_mul(multiplier).ref_time()
}