Skip to content

Commit eac8b4f

Browse files
paritytech-release-backport-bot[bot]franciscoaguirreEgorPopelyaev
authored
[stable2409] Backport #9137 (#9197)
Backport #9137 into `stable2409` from franciscoaguirre. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: Egor_P <[email protected]>
1 parent 6ef884d commit eac8b4f

File tree

12 files changed

+574
-24
lines changed

12 files changed

+574
-24
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/parachains/integration-tests/emulated/common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ xcm.workspace = true
4242
xcm.default-features = true
4343
pallet-xcm.workspace = true
4444
pallet-xcm.default-features = true
45+
xcm-executor.workspace = true
46+
xcm-executor.default-features = true
4547
parachains-common.workspace = true
4648
parachains-common.default-features = true
4749
cumulus-primitives-core.workspace = true

cumulus/parachains/integration-tests/emulated/common/src/macros.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ pub use pallet_xcm;
2626
pub use xcm::{
2727
prelude::{
2828
AccountId32, All, Asset, AssetId, BuyExecution, DepositAsset, ExpectTransactStatus,
29-
Fungible, Here, Location, MaybeErrorCode, OriginKind, RefundSurplus, Transact, Unlimited,
30-
VersionedAssets, VersionedXcm, WeightLimit, WithdrawAsset, Xcm,
29+
Fungible, Here, Junction, Location, MaybeErrorCode, OriginKind, Parent, RefundSurplus,
30+
Transact, Unlimited, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
31+
WeightLimit, WithdrawAsset, Xcm,
3132
},
3233
v3::Location as V3Location,
3334
};
3435

36+
pub use xcm_executor::traits::TransferType;
37+
3538
// Cumulus
3639
pub use asset_test_utils;
3740
pub use cumulus_pallet_xcmp_queue;
@@ -429,17 +432,21 @@ macro_rules! test_dry_run_transfer_across_pk_bridge {
429432
// Give some initial funds.
430433
<Balances as fungible::Mutate<_>>::set_balance(&who, initial_balance);
431434

432-
let call = RuntimeCall::PolkadotXcm(pallet_xcm::Call::transfer_assets {
433-
dest: Box::new(VersionedLocation::from($destination)),
434-
beneficiary: Box::new(VersionedLocation::from(Junction::AccountId32 {
435+
let beneficiary: $crate::macros::Location = $crate::macros::Junction::AccountId32 {
435436
id: who.clone().into(),
436437
network: None,
437-
})),
438-
assets: Box::new(VersionedAssets::from(vec![
439-
(Parent, transfer_amount).into(),
438+
}.into();
439+
440+
let call = RuntimeCall::PolkadotXcm($crate::macros::pallet_xcm::Call::transfer_assets_using_type_and_then {
441+
dest: Box::new($crate::macros::VersionedLocation::from($destination)),
442+
assets: Box::new($crate::macros::VersionedAssets::from(vec![
443+
($crate::macros::Parent, transfer_amount).into(),
440444
])),
441-
fee_asset_item: 0,
442-
weight_limit: Unlimited,
445+
assets_transfer_type: Box::new($crate::macros::TransferType::LocalReserve),
446+
remote_fees_id: Box::new($crate::macros::VersionedAssetId::from($crate::macros::AssetId(Location::new(1, [])))),
447+
fees_transfer_type: Box::new($crate::macros::TransferType::LocalReserve),
448+
custom_xcm_on_dest: Box::new($crate::macros::VersionedXcm::<()>::from($crate::macros::Xcm::<()>::builder_unsafe().deposit_asset(AllCounted(1), beneficiary).build())),
449+
weight_limit: $crate::macros::Unlimited,
443450
});
444451
let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call, XCM_VERSION).unwrap();
445452
// We assert the dry run succeeds and sends only one message to the local bridge hub.

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/teleport.rs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,57 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu
179179
}
180180

181181
fn para_to_system_para_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
182-
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets(
182+
type Runtime = <PenpalA as Chain>::Runtime;
183+
let remote_fee_id: AssetId = t
184+
.args
185+
.assets
186+
.clone()
187+
.into_inner()
188+
.get(t.args.fee_asset_item as usize)
189+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
190+
.clone()
191+
.id;
192+
193+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
183194
t.signed_origin,
184195
bx!(t.args.dest.into()),
185-
bx!(t.args.beneficiary.into()),
186196
bx!(t.args.assets.into()),
187-
t.args.fee_asset_item,
197+
bx!(TransferType::Teleport),
198+
bx!(remote_fee_id.into()),
199+
bx!(TransferType::DestinationReserve),
200+
bx!(VersionedXcm::from(
201+
Xcm::<()>::builder_unsafe()
202+
.deposit_asset(AllCounted(2), t.args.beneficiary)
203+
.build()
204+
)),
188205
t.args.weight_limit,
189206
)
190207
}
191208

192209
fn system_para_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
193-
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets(
210+
type Runtime = <AssetHubRococo as Chain>::Runtime;
211+
let remote_fee_id: AssetId = t
212+
.args
213+
.assets
214+
.clone()
215+
.into_inner()
216+
.get(t.args.fee_asset_item as usize)
217+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
218+
.clone()
219+
.id;
220+
221+
<AssetHubRococo as AssetHubRococoPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
194222
t.signed_origin,
195223
bx!(t.args.dest.into()),
196-
bx!(t.args.beneficiary.into()),
197224
bx!(t.args.assets.into()),
198-
t.args.fee_asset_item,
225+
bx!(TransferType::Teleport),
226+
bx!(remote_fee_id.into()),
227+
bx!(TransferType::LocalReserve),
228+
bx!(VersionedXcm::from(
229+
Xcm::<()>::builder_unsafe()
230+
.deposit_asset(AllCounted(2), t.args.beneficiary)
231+
.build()
232+
)),
199233
t.args.weight_limit,
200234
)
201235
}

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod send;
2222
mod set_xcm_versions;
2323
mod swap;
2424
mod teleport;
25+
mod transfer_assets_validation;
2526
mod treasury;
2627
mod xcm_fee_estimation;
2728

cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/teleport.rs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,57 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu
179179
}
180180

181181
fn para_to_system_para_transfer_assets(t: ParaToSystemParaTest) -> DispatchResult {
182-
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets(
182+
type Runtime = <PenpalA as Chain>::Runtime;
183+
let remote_fee_id: AssetId = t
184+
.args
185+
.assets
186+
.clone()
187+
.into_inner()
188+
.get(t.args.fee_asset_item as usize)
189+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
190+
.clone()
191+
.id;
192+
193+
<PenpalA as PenpalAPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
183194
t.signed_origin,
184195
bx!(t.args.dest.into()),
185-
bx!(t.args.beneficiary.into()),
186196
bx!(t.args.assets.into()),
187-
t.args.fee_asset_item,
197+
bx!(TransferType::Teleport),
198+
bx!(remote_fee_id.into()),
199+
bx!(TransferType::DestinationReserve),
200+
bx!(VersionedXcm::from(
201+
Xcm::<()>::builder_unsafe()
202+
.deposit_asset(AllCounted(2), t.args.beneficiary)
203+
.build()
204+
)),
188205
t.args.weight_limit,
189206
)
190207
}
191208

192209
fn system_para_to_para_transfer_assets(t: SystemParaToParaTest) -> DispatchResult {
193-
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets(
210+
type Runtime = <AssetHubWestend as Chain>::Runtime;
211+
let remote_fee_id: AssetId = t
212+
.args
213+
.assets
214+
.clone()
215+
.into_inner()
216+
.get(t.args.fee_asset_item as usize)
217+
.ok_or(pallet_xcm::Error::<Runtime>::Empty)?
218+
.clone()
219+
.id;
220+
221+
<AssetHubWestend as AssetHubWestendPallet>::PolkadotXcm::transfer_assets_using_type_and_then(
194222
t.signed_origin,
195223
bx!(t.args.dest.into()),
196-
bx!(t.args.beneficiary.into()),
197224
bx!(t.args.assets.into()),
198-
t.args.fee_asset_item,
225+
bx!(TransferType::Teleport),
226+
bx!(remote_fee_id.into()),
227+
bx!(TransferType::LocalReserve),
228+
bx!(VersionedXcm::from(
229+
Xcm::<()>::builder_unsafe()
230+
.deposit_asset(AllCounted(2), t.args.beneficiary)
231+
.build()
232+
)),
199233
t.args.weight_limit,
200234
)
201235
}

0 commit comments

Comments
 (0)