mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
Introduce hard limit on XCM assets (#3579)
This commit is contained in:
@@ -81,6 +81,9 @@ pub mod pallet {
|
|||||||
type LocationInverter: InvertLocation;
|
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::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
@@ -100,6 +103,8 @@ pub mod pallet {
|
|||||||
Empty,
|
Empty,
|
||||||
/// Could not reanchor the assets to declare the fees for the destination chain.
|
/// Could not reanchor the assets to declare the fees for the destination chain.
|
||||||
CannotReanchor,
|
CannotReanchor,
|
||||||
|
/// Too many assets have been attempted for transfer.
|
||||||
|
TooManyAssets,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::hooks]
|
#[pallet::hooks]
|
||||||
@@ -152,6 +157,7 @@ pub mod pallet {
|
|||||||
dest_weight: Weight,
|
dest_weight: Weight,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
||||||
|
ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::<T>::TooManyAssets);
|
||||||
let value = (origin_location, assets);
|
let value = (origin_location, assets);
|
||||||
ensure!(T::XcmTeleportFilter::contains(&value), Error::<T>::Filtered);
|
ensure!(T::XcmTeleportFilter::contains(&value), Error::<T>::Filtered);
|
||||||
let (origin_location, assets) = value;
|
let (origin_location, assets) = value;
|
||||||
@@ -214,6 +220,7 @@ pub mod pallet {
|
|||||||
dest_weight: Weight,
|
dest_weight: Weight,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?;
|
||||||
|
ensure!(assets.len() <= MAX_ASSETS_FOR_TRANSFER, Error::<T>::TooManyAssets);
|
||||||
let value = (origin_location, assets);
|
let value = (origin_location, assets);
|
||||||
ensure!(T::XcmReserveTransferFilter::contains(&value), Error::<T>::Filtered);
|
ensure!(T::XcmReserveTransferFilter::contains(&value), Error::<T>::Filtered);
|
||||||
let (origin_location, assets) = value;
|
let (origin_location, assets) = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user