Skip to content

Commit 9bec263

Browse files
committed
Added SetAssetClaimer instruction
1 parent 1f031ec commit 9bec263

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

polkadot/xcm/src/v5/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,15 @@ pub enum Instruction<Call> {
737737
/// Errors: None.
738738
ClearError,
739739

740+
/// Set asset claimer for all the trapped assets during the execution.
741+
///
742+
/// - `location`: The claimer of the assets; it might be an arbitrary location, not necessarily the caller or origin.
743+
///
744+
/// Kind: *Command*
745+
///
746+
/// Errors: None.
747+
SetAssetClaimer {location: Location},
748+
740749
/// Create some assets which are being held on behalf of the origin.
741750
///
742751
/// - `assets`: The assets which are to be claimed. This must match exactly with the assets

polkadot/xcm/xcm-executor/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use frame_support::{
2929
use sp_core::defer;
3030
use sp_io::hashing::blake2_128;
3131
use sp_weights::Weight;
32-
use xcm::latest::prelude::*;
32+
use xcm::{latest::prelude::*, v3::MultiLocation};
3333

3434
pub mod traits;
3535
use traits::{
@@ -84,6 +84,7 @@ pub struct XcmExecutor<Config: config::Config> {
8484
transact_status: MaybeErrorCode,
8585
fees_mode: FeesMode,
8686
_config: PhantomData<Config>,
87+
assetClaimer: Option<Location>,
8788
}
8889

8990
#[cfg(feature = "runtime-benchmarks")]
@@ -342,7 +343,11 @@ impl<Config: config::Config> XcmExecutor<Config> {
342343
original_origin = ?self.original_origin,
343344
"Trapping assets in holding register",
344345
);
345-
let effective_origin = self.context.origin.as_ref().unwrap_or(&self.original_origin);
346+
let effective_orgin = if let Some(assetClaimer) = self.assetClaimer {
347+
assetClaimer.as_ref().unwrap_or(&self.original_origin)
348+
} else {
349+
self.context.origin.as_ref().unwrap_or(&self.original_origin)
350+
};
346351
let trap_weight =
347352
Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context);
348353
weight_used.saturating_accrue(trap_weight);
@@ -1003,6 +1008,10 @@ impl<Config: config::Config> XcmExecutor<Config> {
10031008
self.error = None;
10041009
Ok(())
10051010
},
1011+
SetAssetClaimer { location } => {
1012+
self.assetClaimer = Some(location);
1013+
Ok(())
1014+
}
10061015
ClaimAsset { assets, ticket } => {
10071016
let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?;
10081017
self.ensure_can_subsume_assets(assets.len())?;

0 commit comments

Comments
 (0)