Skip to content
Snippets Groups Projects
Commit 3e9b8b47 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Introduce hard limit on XCM assets (#3579)

parent 68c03f66
No related merge requests found
......@@ -81,6 +81,9 @@ pub mod pallet {
type LocationInverter: InvertLocation;
}
/// The maximum number of distinct assets allowed to be transferred in a single helper extrinsic.
const MAX_ASSETS_FOR_TRANSFER: usize = 2;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
......@@ -100,6 +103,8 @@ pub mod pallet {
Empty,
/// Could not reanchor the assets to declare the fees for the destination chain.
CannotReanchor,
/// Too many assets have been attempted for transfer.
TooManyAssets,
}
#[pallet::hooks]
......@@ -152,6 +157,7 @@ pub mod pallet {
dest_weight: Weight,
) -> DispatchResult {
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::<T>::TooManyAssets);
let value = (origin_location, assets);
ensure!(T::XcmTeleportFilter::contains(&value), Error::<T>::Filtered);
let (origin_location, assets) = value;
......@@ -214,6 +220,7 @@ pub mod pallet {
dest_weight: Weight,
) -> DispatchResult {
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::<T>::TooManyAssets);
let value = (origin_location, assets);
ensure!(T::XcmReserveTransferFilter::contains(&value), Error::<T>::Filtered);
let (origin_location, assets) = value;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment