mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
XCMv4 (#1230)
# Note for reviewer
Most changes are just syntax changes necessary for the new version.
Most important files should be the ones under the `xcm` folder.
# Description
Added XCMv4.
## Removed `Multi` prefix
The following types have been renamed:
- MultiLocation -> Location
- MultiAsset -> Asset
- MultiAssets -> Assets
- InteriorMultiLocation -> InteriorLocation
- MultiAssetFilter -> AssetFilter
- VersionedMultiAsset -> VersionedAsset
- WildMultiAsset -> WildAsset
- VersionedMultiLocation -> VersionedLocation
In order to fix a name conflict, the `Assets` in `xcm-executor` were
renamed to `HoldingAssets`, as they represent assets in holding.
## Removed `Abstract` asset id
It was not being used anywhere and this simplifies the code.
Now assets are just constructed as follows:
```rust
let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
```
No need for specifying `Concrete` anymore.
## Outcome is now a named fields struct
Instead of
```rust
pub enum Outcome {
Complete(Weight),
Incomplete(Weight, Error),
Error(Error),
}
```
we now have
```rust
pub enum Outcome {
Complete { used: Weight },
Incomplete { used: Weight, error: Error },
Error { error: Error },
}
```
## Added Reanchorable trait
Now both locations and assets implement this trait, making it easier to
reanchor both.
## New syntax for building locations and junctions
Now junctions are built using the following methods:
```rust
let location = Location {
parents: 1,
interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
};
```
or
```rust
let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
```
And they are matched like so:
```rust
match location.unpack() {
(1, [Parachain(id)]) => ...
(0, Here) => ...,
(1, [_]) => ...,
}
```
This syntax is mandatory in v4, and has been also implemented for v2 and
v3 for easier migration.
This was needed to make all sizes smaller.
# TODO
- [x] Scaffold v4
- [x] Port github.com/paritytech/polkadot/pull/7236
- [x] Remove `Multi` prefix
- [x] Remove `Abstract` asset id
---------
Co-authored-by: command-bot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ec7bfae00a
commit
8428f678fe
+1
-1
@@ -26,7 +26,7 @@ pub use frame_support::{
|
||||
// Polkadot
|
||||
pub use xcm::{
|
||||
prelude::{AccountId32 as AccountId32Junction, *},
|
||||
v3::{Error, NetworkId::Rococo as RococoId},
|
||||
v3::{self, Error, NetworkId::Rococo as RococoId},
|
||||
};
|
||||
|
||||
// Cumulus
|
||||
|
||||
+9
-9
@@ -30,7 +30,7 @@ fn relay_to_para_sender_assertions(t: RelayToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == Rococo::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -53,7 +53,7 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -130,7 +130,7 @@ fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
asset_id: *asset_id == ASSET_ID,
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -190,10 +190,10 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa
|
||||
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
|
||||
let signed_origin = <Rococo as Chain>::RuntimeOrigin::signed(RococoSender::get().into());
|
||||
let destination = Rococo::child_location_of(AssetHubRococo::para_id());
|
||||
let beneficiary: MultiLocation =
|
||||
let beneficiary: Location =
|
||||
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
|
||||
let amount_to_send: Balance = ROCOCO_ED * 1000;
|
||||
let assets: MultiAssets = (Here, amount_to_send).into();
|
||||
let assets: Assets = (Here, amount_to_send).into();
|
||||
let fee_asset_item = 0;
|
||||
|
||||
// this should fail
|
||||
@@ -225,11 +225,11 @@ fn reserve_transfer_native_asset_from_system_para_to_relay_fails() {
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
|
||||
let destination = AssetHubRococo::parent_location();
|
||||
let beneficiary_id = RococoReceiver::get();
|
||||
let beneficiary: MultiLocation =
|
||||
let beneficiary: Location =
|
||||
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
||||
let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000;
|
||||
|
||||
let assets: MultiAssets = (Parent, amount_to_send).into();
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let fee_asset_item = 0;
|
||||
|
||||
// this should fail
|
||||
@@ -418,9 +418,9 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
let beneficiary_id = PenpalAReceiver::get();
|
||||
let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000;
|
||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||
let assets: MultiAssets = vec![
|
||||
let assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), asset_amount_to_send)
|
||||
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], asset_amount_to_send)
|
||||
.into(),
|
||||
]
|
||||
.into();
|
||||
|
||||
+3
-4
@@ -19,14 +19,13 @@ use crate::*;
|
||||
fn relay_sets_system_para_xcm_supported_version() {
|
||||
// Init tests variables
|
||||
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
|
||||
let system_para_destination: MultiLocation =
|
||||
Rococo::child_location_of(AssetHubRococo::para_id());
|
||||
let system_para_destination: Location = Rococo::child_location_of(AssetHubRococo::para_id());
|
||||
|
||||
// Relay Chain sets supported version for Asset Parachain
|
||||
Rococo::execute_with(|| {
|
||||
assert_ok!(<Rococo as RococoPallet>::XcmPallet::force_xcm_version(
|
||||
sudo_origin,
|
||||
bx!(system_para_destination),
|
||||
bx!(system_para_destination.clone()),
|
||||
XCM_V3
|
||||
));
|
||||
|
||||
@@ -52,7 +51,7 @@ fn system_para_sets_relay_xcm_supported_version() {
|
||||
<AssetHubRococo as Chain>::RuntimeCall::PolkadotXcm(pallet_xcm::Call::<
|
||||
<AssetHubRococo as Chain>::Runtime,
|
||||
>::force_xcm_version {
|
||||
location: bx!(parent_location),
|
||||
location: bx!(parent_location.clone()),
|
||||
version: XCM_V3,
|
||||
})
|
||||
.encode()
|
||||
|
||||
+38
-30
@@ -15,16 +15,19 @@
|
||||
|
||||
use crate::*;
|
||||
use parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
|
||||
use rococo_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
|
||||
use rococo_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
|
||||
use sp_runtime::ModuleError;
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_local_assets() {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
||||
let asset_one = MultiLocation {
|
||||
parents: 0,
|
||||
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
|
||||
};
|
||||
let asset_native = Box::new(asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get());
|
||||
let asset_one = Box::new(v3::Location::new(
|
||||
0,
|
||||
[
|
||||
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
||||
v3::Junction::GeneralIndex(ASSET_ID.into()),
|
||||
],
|
||||
));
|
||||
|
||||
AssetHubRococo::execute_with(|| {
|
||||
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
|
||||
@@ -46,8 +49,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native.clone(),
|
||||
asset_one.clone(),
|
||||
));
|
||||
|
||||
assert_expected_events!(
|
||||
@@ -59,8 +62,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native.clone(),
|
||||
asset_one.clone(),
|
||||
1_000_000_000_000,
|
||||
2_000_000_000_000,
|
||||
0,
|
||||
@@ -75,7 +78,7 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
]
|
||||
);
|
||||
|
||||
let path = vec![Box::new(asset_native), Box::new(asset_one)];
|
||||
let path = vec![asset_native.clone(), asset_one.clone()];
|
||||
|
||||
assert_ok!(
|
||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||
@@ -100,8 +103,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::remove_liquidity(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native,
|
||||
asset_one,
|
||||
1414213562273 - EXISTENTIAL_DEPOSIT * 2, // all but the 2 EDs can't be retrieved.
|
||||
0,
|
||||
0,
|
||||
@@ -112,16 +115,16 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_foreign_assets() {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
||||
let asset_native = Box::new(asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get());
|
||||
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubRococo::para_id());
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(GeneralIndex(id)) => *id as u32,
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_owner_on_penpal = PenpalASender::get();
|
||||
let foreign_asset_at_asset_hub_rococo =
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(PenpalA::para_id().into())) }
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
|
||||
@@ -167,7 +170,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 4. Create pool:
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||
));
|
||||
|
||||
@@ -181,7 +184,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 5. Add liquidity:
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahr.clone()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||
1_000_000_000_000,
|
||||
2_000_000_000_000,
|
||||
@@ -200,7 +203,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
);
|
||||
|
||||
// 6. Swap!
|
||||
let path = vec![Box::new(asset_native), Box::new(foreign_asset_at_asset_hub_rococo)];
|
||||
let path = vec![asset_native.clone(), Box::new(foreign_asset_at_asset_hub_rococo)];
|
||||
|
||||
assert_ok!(
|
||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||
@@ -226,7 +229,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 7. Remove liquidity
|
||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::remove_liquidity(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahr.clone()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||
0,
|
||||
@@ -238,9 +241,11 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
|
||||
#[test]
|
||||
fn cannot_create_pool_from_pool_assets() {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
||||
let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
||||
let asset_native = Box::new(asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get());
|
||||
let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||
asset_one
|
||||
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||
.expect("pool assets");
|
||||
|
||||
AssetHubRococo::execute_with(|| {
|
||||
let pool_owner_account_id = asset_hub_rococo_runtime::AssetConversionOrigin::get();
|
||||
@@ -263,7 +268,7 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
assert_matches::assert_matches!(
|
||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||
Box::new(asset_native),
|
||||
asset_native,
|
||||
Box::new(asset_one),
|
||||
),
|
||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||
@@ -273,10 +278,14 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
|
||||
#[test]
|
||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
||||
let asset_one = MultiLocation {
|
||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get();
|
||||
let asset_one = xcm::v3::Location {
|
||||
parents: 0,
|
||||
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
|
||||
interior: [
|
||||
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
||||
xcm::v3::Junction::GeneralIndex(ASSET_ID.into()),
|
||||
]
|
||||
.into(),
|
||||
};
|
||||
let penpal = AssetHubRococo::sovereign_account_id_of(AssetHubRococo::sibling_location_of(
|
||||
PenpalA::para_id(),
|
||||
@@ -365,8 +374,7 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let penpal_root = <PenpalA as Chain>::RuntimeOrigin::root();
|
||||
let fee_amount = 4_000_000_000_000u128;
|
||||
let asset_one =
|
||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount)
|
||||
.into();
|
||||
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
|
||||
let asset_hub_location = PenpalA::sibling_location_of(AssetHubRococo::para_id()).into();
|
||||
let xcm = xcm_transact_paid_execution(
|
||||
call,
|
||||
|
||||
+18
-13
@@ -17,7 +17,7 @@ use crate::*;
|
||||
use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig;
|
||||
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
||||
use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig;
|
||||
use rococo_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
|
||||
use rococo_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
|
||||
|
||||
fn relay_origin_assertions(t: RelayToSystemParaTest) {
|
||||
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
|
||||
@@ -143,6 +143,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
||||
);
|
||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();
|
||||
assert_expected_events!(
|
||||
AssetHubRococo,
|
||||
vec![
|
||||
@@ -157,7 +158,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
||||
who: *who == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
||||
asset_id: *asset_id == expected_foreign_asset_id,
|
||||
asset_id: *asset_id == expected_foreign_asset_id_v3,
|
||||
owner: *owner == t.receiver.account_id,
|
||||
amount: *amount == expected_foreign_asset_amount,
|
||||
},
|
||||
@@ -174,6 +175,7 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
AssetHubRococo::assert_xcm_pallet_attempted_complete(None);
|
||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();
|
||||
assert_expected_events!(
|
||||
AssetHubRococo,
|
||||
vec![
|
||||
@@ -183,13 +185,13 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
// foreign asset is burned locally as part of teleportation
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
|
||||
asset_id: *asset_id == expected_foreign_asset_id,
|
||||
asset_id: *asset_id == expected_foreign_asset_id_v3,
|
||||
owner: *owner == t.sender.account_id,
|
||||
balance: *balance == expected_foreign_asset_amount,
|
||||
},
|
||||
@@ -542,7 +544,7 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
|
||||
#[test]
|
||||
fn teleport_to_other_system_parachains_works() {
|
||||
let amount = ASSET_HUB_ROCOCO_ED * 100;
|
||||
let native_asset: MultiAssets = (Parent, amount).into();
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
test_parachain_is_trusted_teleporter!(
|
||||
AssetHubRococo, // Origin
|
||||
@@ -557,20 +559,20 @@ fn teleport_to_other_system_parachains_works() {
|
||||
#[test]
|
||||
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubRococo::para_id());
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(GeneralIndex(id)) => *id as u32,
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_owner_on_penpal = PenpalASender::get();
|
||||
let foreign_asset_at_asset_hub_rococo =
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(PenpalA::para_id().into())) }
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
super::penpal_create_foreign_asset_on_asset_hub(
|
||||
asset_id_on_penpal,
|
||||
foreign_asset_at_asset_hub_rococo,
|
||||
ah_as_seen_by_penpal,
|
||||
ah_as_seen_by_penpal.clone(),
|
||||
false,
|
||||
asset_owner_on_penpal,
|
||||
ASSET_MIN_BALANCE * 1_000_000,
|
||||
@@ -580,9 +582,10 @@ fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000;
|
||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||
|
||||
let penpal_assets: MultiAssets = vec![
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let penpal_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = penpal_assets
|
||||
@@ -670,11 +673,13 @@ fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
));
|
||||
});
|
||||
|
||||
let foreign_asset_at_asset_hub_rococo_latest: Location =
|
||||
foreign_asset_at_asset_hub_rococo.try_into().unwrap();
|
||||
let ah_to_penpal_beneficiary_id = PenpalAReceiver::get();
|
||||
let penpal_as_seen_by_ah = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
||||
let ah_assets: MultiAssets = vec![
|
||||
let ah_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_rococo, asset_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_rococo_latest, asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = ah_assets
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ pub use frame_support::{
|
||||
// Polkadot
|
||||
pub use xcm::{
|
||||
prelude::{AccountId32 as AccountId32Junction, *},
|
||||
v3::{Error, NetworkId::Westend as WestendId},
|
||||
v3::{self, Error, NetworkId::Westend as WestendId},
|
||||
};
|
||||
|
||||
// Cumulus
|
||||
|
||||
+6
-8
@@ -24,22 +24,20 @@ fn create_and_claim_treasury_spend() {
|
||||
const ASSET_ID: u32 = 1984;
|
||||
const SPEND_AMOUNT: u128 = 1_000_000;
|
||||
// treasury location from a sibling parachain.
|
||||
let treasury_location: MultiLocation = MultiLocation::new(
|
||||
1,
|
||||
X2(Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)),
|
||||
);
|
||||
let treasury_location: Location =
|
||||
Location::new(1, [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)]);
|
||||
// treasury account on a sibling parachain.
|
||||
let treasury_account =
|
||||
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
||||
&treasury_location,
|
||||
)
|
||||
.unwrap();
|
||||
let asset_hub_location = MultiLocation::new(1, Parachain(AssetHubWestend::para_id().into()));
|
||||
let asset_hub_location = Location::new(1, [Parachain(AssetHubWestend::para_id().into())]);
|
||||
let root = <CollectivesWestend as Chain>::RuntimeOrigin::root();
|
||||
// asset kind to be spent from the treasury.
|
||||
let asset_kind = VersionedLocatableAsset::V3 {
|
||||
let asset_kind = VersionedLocatableAsset::V4 {
|
||||
location: asset_hub_location,
|
||||
asset_id: AssetId::Concrete((PalletInstance(50), GeneralIndex(ASSET_ID.into())).into()),
|
||||
asset_id: AssetId((PalletInstance(50), GeneralIndex(ASSET_ID.into())).into()),
|
||||
};
|
||||
// treasury spend beneficiary.
|
||||
let alice: AccountId = Westend::account_id_of(ALICE);
|
||||
@@ -75,7 +73,7 @@ fn create_and_claim_treasury_spend() {
|
||||
root,
|
||||
Box::new(asset_kind),
|
||||
SPEND_AMOUNT,
|
||||
Box::new(MultiLocation::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
|
||||
Box::new(Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
|
||||
None,
|
||||
));
|
||||
// claim the spend.
|
||||
|
||||
+9
-9
@@ -32,7 +32,7 @@ fn relay_to_para_sender_assertions(t: RelayToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == Westend::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -57,7 +57,7 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -140,7 +140,7 @@ fn system_para_to_para_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
asset_id: *asset_id == ASSET_ID,
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
@@ -200,10 +200,10 @@ fn para_to_system_para_reserve_transfer_assets(t: ParaToSystemParaTest) -> Dispa
|
||||
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
|
||||
let signed_origin = <Westend as Chain>::RuntimeOrigin::signed(WestendSender::get().into());
|
||||
let destination = Westend::child_location_of(AssetHubWestend::para_id());
|
||||
let beneficiary: MultiLocation =
|
||||
let beneficiary: Location =
|
||||
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
|
||||
let amount_to_send: Balance = WESTEND_ED * 1000;
|
||||
let assets: MultiAssets = (Here, amount_to_send).into();
|
||||
let assets: Assets = (Here, amount_to_send).into();
|
||||
let fee_asset_item = 0;
|
||||
|
||||
// this should fail
|
||||
@@ -235,10 +235,10 @@ fn reserve_transfer_native_asset_from_system_para_to_relay_fails() {
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
|
||||
let destination = AssetHubWestend::parent_location();
|
||||
let beneficiary_id = WestendReceiver::get();
|
||||
let beneficiary: MultiLocation =
|
||||
let beneficiary: Location =
|
||||
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
||||
let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
|
||||
let assets: MultiAssets = (Parent, amount_to_send).into();
|
||||
let assets: Assets = (Parent, amount_to_send).into();
|
||||
let fee_asset_item = 0;
|
||||
|
||||
// this should fail
|
||||
@@ -428,9 +428,9 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
||||
let beneficiary_id = PenpalBReceiver::get();
|
||||
let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
|
||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||
let assets: MultiAssets = vec![
|
||||
let assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), asset_amount_to_send)
|
||||
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], asset_amount_to_send)
|
||||
.into(),
|
||||
]
|
||||
.into();
|
||||
|
||||
+3
-4
@@ -19,14 +19,13 @@ use crate::*;
|
||||
fn relay_sets_system_para_xcm_supported_version() {
|
||||
// Init tests variables
|
||||
let sudo_origin = <Westend as Chain>::RuntimeOrigin::root();
|
||||
let system_para_destination: MultiLocation =
|
||||
Westend::child_location_of(AssetHubWestend::para_id());
|
||||
let system_para_destination: Location = Westend::child_location_of(AssetHubWestend::para_id());
|
||||
|
||||
// Relay Chain sets supported version for Asset Parachain
|
||||
Westend::execute_with(|| {
|
||||
assert_ok!(<Westend as WestendPallet>::XcmPallet::force_xcm_version(
|
||||
sudo_origin,
|
||||
bx!(system_para_destination),
|
||||
bx!(system_para_destination.clone()),
|
||||
XCM_V3
|
||||
));
|
||||
|
||||
@@ -52,7 +51,7 @@ fn system_para_sets_relay_xcm_supported_version() {
|
||||
<AssetHubWestend as Chain>::RuntimeCall::PolkadotXcm(pallet_xcm::Call::<
|
||||
<AssetHubWestend as Chain>::Runtime,
|
||||
>::force_xcm_version {
|
||||
location: bx!(parent_location),
|
||||
location: bx!(parent_location.clone()),
|
||||
version: XCM_V3,
|
||||
})
|
||||
.encode()
|
||||
|
||||
+38
-29
@@ -14,15 +14,19 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::*;
|
||||
use westend_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
|
||||
use westend_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_local_assets() {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
||||
let asset_one = MultiLocation {
|
||||
let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocationV3::get());
|
||||
let asset_one = Box::new(v3::Location {
|
||||
parents: 0,
|
||||
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
|
||||
};
|
||||
interior: [
|
||||
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
||||
v3::Junction::GeneralIndex(ASSET_ID.into()),
|
||||
]
|
||||
.into(),
|
||||
});
|
||||
|
||||
AssetHubWestend::execute_with(|| {
|
||||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
||||
@@ -44,8 +48,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native.clone(),
|
||||
asset_one.clone(),
|
||||
));
|
||||
|
||||
assert_expected_events!(
|
||||
@@ -57,8 +61,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native.clone(),
|
||||
asset_one.clone(),
|
||||
1_000_000_000_000,
|
||||
2_000_000_000_000,
|
||||
0,
|
||||
@@ -73,7 +77,7 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
]
|
||||
);
|
||||
|
||||
let path = vec![Box::new(asset_native), Box::new(asset_one)];
|
||||
let path = vec![asset_native.clone(), asset_one.clone()];
|
||||
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
@@ -96,8 +100,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::remove_liquidity(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
Box::new(asset_native),
|
||||
Box::new(asset_one),
|
||||
asset_native.clone(),
|
||||
asset_one.clone(),
|
||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||
0,
|
||||
0,
|
||||
@@ -108,16 +112,16 @@ fn swap_locally_on_chain_using_local_assets() {
|
||||
|
||||
#[test]
|
||||
fn swap_locally_on_chain_using_foreign_assets() {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
||||
let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocationV3::get());
|
||||
let ah_as_seen_by_penpal = PenpalB::sibling_location_of(AssetHubWestend::para_id());
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(GeneralIndex(id)) => *id as u32,
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_owner_on_penpal = PenpalBSender::get();
|
||||
let foreign_asset_at_asset_hub_westend =
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(PenpalB::para_id().into())) }
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalB::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
|
||||
@@ -163,7 +167,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 4. Create pool:
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_westend),
|
||||
));
|
||||
|
||||
@@ -177,7 +181,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 5. Add liquidity:
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahw.clone()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_westend),
|
||||
1_000_000_000_000,
|
||||
2_000_000_000_000,
|
||||
@@ -196,7 +200,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
);
|
||||
|
||||
// 6. Swap!
|
||||
let path = vec![Box::new(asset_native), Box::new(foreign_asset_at_asset_hub_westend)];
|
||||
let path = vec![asset_native.clone(), Box::new(foreign_asset_at_asset_hub_westend)];
|
||||
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
@@ -220,7 +224,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
// 7. Remove liquidity
|
||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::remove_liquidity(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahw.clone()),
|
||||
Box::new(asset_native),
|
||||
asset_native.clone(),
|
||||
Box::new(foreign_asset_at_asset_hub_westend),
|
||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||
0,
|
||||
@@ -232,9 +236,11 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
||||
|
||||
#[test]
|
||||
fn cannot_create_pool_from_pool_assets() {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
||||
let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
||||
let asset_native = Box::new(asset_hub_westend_runtime::xcm_config::WestendLocationV3::get());
|
||||
let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||
asset_one
|
||||
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||
.expect("pool assets");
|
||||
|
||||
AssetHubWestend::execute_with(|| {
|
||||
let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get();
|
||||
@@ -257,7 +263,7 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
assert_matches::assert_matches!(
|
||||
<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||
Box::new(asset_native),
|
||||
asset_native,
|
||||
Box::new(asset_one),
|
||||
),
|
||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||
@@ -267,10 +273,14 @@ fn cannot_create_pool_from_pool_assets() {
|
||||
|
||||
#[test]
|
||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
||||
let asset_one = MultiLocation {
|
||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocationV3::get();
|
||||
let asset_one = xcm::v3::Location {
|
||||
parents: 0,
|
||||
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
|
||||
interior: [
|
||||
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
||||
xcm::v3::Junction::GeneralIndex(ASSET_ID.into()),
|
||||
]
|
||||
.into(),
|
||||
};
|
||||
let penpal = AssetHubWestend::sovereign_account_id_of(AssetHubWestend::sibling_location_of(
|
||||
PenpalB::para_id(),
|
||||
@@ -359,8 +369,7 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||
let penpal_root = <PenpalB as Chain>::RuntimeOrigin::root();
|
||||
let fee_amount = 4_000_000_000_000u128;
|
||||
let asset_one =
|
||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount)
|
||||
.into();
|
||||
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
|
||||
let asset_hub_location = PenpalB::sibling_location_of(AssetHubWestend::para_id()).into();
|
||||
let xcm = xcm_transact_paid_execution(
|
||||
call,
|
||||
|
||||
+18
-13
@@ -17,7 +17,7 @@ use crate::*;
|
||||
use asset_hub_westend_runtime::xcm_config::XcmConfig as AssetHubWestendXcmConfig;
|
||||
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
||||
use westend_runtime::xcm_config::XcmConfig as WestendXcmConfig;
|
||||
use westend_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub;
|
||||
use westend_system_emulated_network::penpal_emulated_chain::LocalTeleportableToAssetHubV3 as PenpalLocalTeleportableToAssetHubV3;
|
||||
|
||||
fn relay_origin_assertions(t: RelayToSystemParaTest) {
|
||||
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
|
||||
@@ -143,6 +143,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
||||
);
|
||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();
|
||||
assert_expected_events!(
|
||||
AssetHubWestend,
|
||||
vec![
|
||||
@@ -157,7 +158,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
||||
who: *who == t.receiver.account_id,
|
||||
},
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
||||
asset_id: *asset_id == expected_foreign_asset_id,
|
||||
asset_id: *asset_id == expected_foreign_asset_id_v3,
|
||||
owner: *owner == t.receiver.account_id,
|
||||
amount: *amount == expected_foreign_asset_amount,
|
||||
},
|
||||
@@ -174,6 +175,7 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
AssetHubWestend::assert_xcm_pallet_attempted_complete(None);
|
||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
||||
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();
|
||||
assert_expected_events!(
|
||||
AssetHubWestend,
|
||||
vec![
|
||||
@@ -183,13 +185,13 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
||||
) => {
|
||||
from: *from == t.sender.account_id,
|
||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||
t.args.dest
|
||||
t.args.dest.clone()
|
||||
),
|
||||
amount: *amount == t.args.amount,
|
||||
},
|
||||
// foreign asset is burned locally as part of teleportation
|
||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
|
||||
asset_id: *asset_id == expected_foreign_asset_id,
|
||||
asset_id: *asset_id == expected_foreign_asset_id_v3,
|
||||
owner: *owner == t.sender.account_id,
|
||||
balance: *balance == expected_foreign_asset_amount,
|
||||
},
|
||||
@@ -542,7 +544,7 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
|
||||
#[test]
|
||||
fn teleport_to_other_system_parachains_works() {
|
||||
let amount = ASSET_HUB_WESTEND_ED * 100;
|
||||
let native_asset: MultiAssets = (Parent, amount).into();
|
||||
let native_asset: Assets = (Parent, amount).into();
|
||||
|
||||
test_parachain_is_trusted_teleporter!(
|
||||
AssetHubWestend, // Origin
|
||||
@@ -557,20 +559,20 @@ fn teleport_to_other_system_parachains_works() {
|
||||
#[test]
|
||||
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
let ah_as_seen_by_penpal = PenpalB::sibling_location_of(AssetHubWestend::para_id());
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHub::get();
|
||||
let asset_location_on_penpal = PenpalLocalTeleportableToAssetHubV3::get();
|
||||
let asset_id_on_penpal = match asset_location_on_penpal.last() {
|
||||
Some(GeneralIndex(id)) => *id as u32,
|
||||
Some(v3::Junction::GeneralIndex(id)) => *id as u32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let asset_owner_on_penpal = PenpalBSender::get();
|
||||
let foreign_asset_at_asset_hub_westend =
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(PenpalB::para_id().into())) }
|
||||
v3::Location::new(1, [v3::Junction::Parachain(PenpalB::para_id().into())])
|
||||
.appended_with(asset_location_on_penpal)
|
||||
.unwrap();
|
||||
super::penpal_create_foreign_asset_on_asset_hub(
|
||||
asset_id_on_penpal,
|
||||
foreign_asset_at_asset_hub_westend,
|
||||
ah_as_seen_by_penpal,
|
||||
ah_as_seen_by_penpal.clone(),
|
||||
false,
|
||||
asset_owner_on_penpal,
|
||||
ASSET_MIN_BALANCE * 1_000_000,
|
||||
@@ -580,9 +582,10 @@ fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
|
||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||
|
||||
let penpal_assets: MultiAssets = vec![
|
||||
let asset_location_on_penpal_latest: Location = asset_location_on_penpal.try_into().unwrap();
|
||||
let penpal_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(asset_location_on_penpal, asset_amount_to_send).into(),
|
||||
(asset_location_on_penpal_latest, asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = penpal_assets
|
||||
@@ -670,11 +673,13 @@ fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||
));
|
||||
});
|
||||
|
||||
let foreign_asset_at_asset_hub_westend_latest: Location =
|
||||
foreign_asset_at_asset_hub_westend.try_into().unwrap();
|
||||
let ah_to_penpal_beneficiary_id = PenpalBReceiver::get();
|
||||
let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalB::para_id());
|
||||
let ah_assets: MultiAssets = vec![
|
||||
let ah_assets: Assets = vec![
|
||||
(Parent, fee_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_westend, asset_amount_to_send).into(),
|
||||
(foreign_asset_at_asset_hub_westend_latest, asset_amount_to_send).into(),
|
||||
]
|
||||
.into();
|
||||
let fee_asset_index = ah_assets
|
||||
|
||||
+5
-5
@@ -24,19 +24,19 @@ fn create_and_claim_treasury_spend() {
|
||||
const ASSET_ID: u32 = 1984;
|
||||
const SPEND_AMOUNT: u128 = 1_000_000;
|
||||
// treasury location from a sibling parachain.
|
||||
let treasury_location: MultiLocation = MultiLocation::new(1, PalletInstance(37));
|
||||
let treasury_location: Location = Location::new(1, PalletInstance(37));
|
||||
// treasury account on a sibling parachain.
|
||||
let treasury_account =
|
||||
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
||||
&treasury_location,
|
||||
)
|
||||
.unwrap();
|
||||
let asset_hub_location = MultiLocation::new(0, Parachain(AssetHubWestend::para_id().into()));
|
||||
let asset_hub_location = Location::new(0, Parachain(AssetHubWestend::para_id().into()));
|
||||
let root = <Westend as Chain>::RuntimeOrigin::root();
|
||||
// asset kind to be spend from the treasury.
|
||||
let asset_kind = VersionedLocatableAsset::V3 {
|
||||
let asset_kind = VersionedLocatableAsset::V4 {
|
||||
location: asset_hub_location,
|
||||
asset_id: AssetId::Concrete((PalletInstance(50), GeneralIndex(ASSET_ID.into())).into()),
|
||||
asset_id: AssetId([PalletInstance(50), GeneralIndex(ASSET_ID.into())].into()),
|
||||
};
|
||||
// treasury spend beneficiary.
|
||||
let alice: AccountId = Westend::account_id_of(ALICE);
|
||||
@@ -71,7 +71,7 @@ fn create_and_claim_treasury_spend() {
|
||||
root,
|
||||
Box::new(asset_kind),
|
||||
SPEND_AMOUNT,
|
||||
Box::new(MultiLocation::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
|
||||
Box::new(Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
|
||||
None,
|
||||
));
|
||||
// claim the spend.
|
||||
|
||||
Reference in New Issue
Block a user