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
@@ -38,7 +38,7 @@ use frame_support::weights::Weight;
|
|||||||
use pallet_bridge_messages::benchmarking::{MessageDeliveryProofParams, MessageProofParams};
|
use pallet_bridge_messages::benchmarking::{MessageDeliveryProofParams, MessageProofParams};
|
||||||
use sp_runtime::traits::{Header, Zero};
|
use sp_runtime::traits::{Header, Zero};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::v3::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
|
|
||||||
/// Prepare inbound bridge message according to given message proof parameters.
|
/// Prepare inbound bridge message according to given message proof parameters.
|
||||||
fn prepare_inbound_message(
|
fn prepare_inbound_message(
|
||||||
@@ -266,19 +266,19 @@ where
|
|||||||
/// Returns callback which generates `BridgeMessage` from Polkadot XCM builder based on
|
/// Returns callback which generates `BridgeMessage` from Polkadot XCM builder based on
|
||||||
/// `expected_message_size` for benchmark.
|
/// `expected_message_size` for benchmark.
|
||||||
pub fn generate_xcm_builder_bridge_message_sample(
|
pub fn generate_xcm_builder_bridge_message_sample(
|
||||||
destination: InteriorMultiLocation,
|
destination: InteriorLocation,
|
||||||
) -> impl Fn(usize) -> MessagePayload {
|
) -> impl Fn(usize) -> MessagePayload {
|
||||||
move |expected_message_size| -> MessagePayload {
|
move |expected_message_size| -> MessagePayload {
|
||||||
// For XCM bridge hubs, it is the message that
|
// For XCM bridge hubs, it is the message that
|
||||||
// will be pushed further to some XCM queue (XCMP/UMP)
|
// will be pushed further to some XCM queue (XCMP/UMP)
|
||||||
let location = xcm::VersionedInteriorMultiLocation::V3(destination);
|
let location = xcm::VersionedInteriorLocation::V4(destination.clone());
|
||||||
let location_encoded_size = location.encoded_size();
|
let location_encoded_size = location.encoded_size();
|
||||||
|
|
||||||
// we don't need to be super-precise with `expected_size` here
|
// we don't need to be super-precise with `expected_size` here
|
||||||
let xcm_size = expected_message_size.saturating_sub(location_encoded_size);
|
let xcm_size = expected_message_size.saturating_sub(location_encoded_size);
|
||||||
let xcm_data_size = xcm_size.saturating_sub(
|
let xcm_data_size = xcm_size.saturating_sub(
|
||||||
// minus empty instruction size
|
// minus empty instruction size
|
||||||
xcm::v3::Instruction::<()>::ExpectPallet {
|
Instruction::<()>::ExpectPallet {
|
||||||
index: 0,
|
index: 0,
|
||||||
name: vec![],
|
name: vec![],
|
||||||
module_name: vec![],
|
module_name: vec![],
|
||||||
@@ -294,8 +294,8 @@ pub fn generate_xcm_builder_bridge_message_sample(
|
|||||||
expected_message_size, location_encoded_size, xcm_size, xcm_data_size,
|
expected_message_size, location_encoded_size, xcm_size, xcm_data_size,
|
||||||
);
|
);
|
||||||
|
|
||||||
let xcm = xcm::VersionedXcm::<()>::V3(
|
let xcm = xcm::VersionedXcm::<()>::V4(
|
||||||
vec![xcm::v3::Instruction::<()>::ExpectPallet {
|
vec![Instruction::<()>::ExpectPallet {
|
||||||
index: 0,
|
index: 0,
|
||||||
name: vec![42; xcm_data_size],
|
name: vec![42; xcm_data_size],
|
||||||
module_name: vec![],
|
module_name: vec![],
|
||||||
|
|||||||
@@ -123,14 +123,14 @@ impl<
|
|||||||
#[cfg_attr(feature = "std", derive(Debug, Eq, PartialEq))]
|
#[cfg_attr(feature = "std", derive(Debug, Eq, PartialEq))]
|
||||||
pub struct SenderAndLane {
|
pub struct SenderAndLane {
|
||||||
/// Sending chain relative location.
|
/// Sending chain relative location.
|
||||||
pub location: MultiLocation,
|
pub location: Location,
|
||||||
/// Message lane, used by the sending chain.
|
/// Message lane, used by the sending chain.
|
||||||
pub lane: LaneId,
|
pub lane: LaneId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SenderAndLane {
|
impl SenderAndLane {
|
||||||
/// Create new object using provided location and lane.
|
/// Create new object using provided location and lane.
|
||||||
pub fn new(location: MultiLocation, lane: LaneId) -> Self {
|
pub fn new(location: Location, lane: LaneId) -> Self {
|
||||||
SenderAndLane { location, lane }
|
SenderAndLane { location, lane }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ pub struct XcmBlobHaulerAdapter<XcmBlobHauler, Lanes>(
|
|||||||
|
|
||||||
impl<
|
impl<
|
||||||
H: XcmBlobHauler,
|
H: XcmBlobHauler,
|
||||||
Lanes: Get<sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))>>,
|
Lanes: Get<sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))>>,
|
||||||
> OnMessagesDelivered for XcmBlobHaulerAdapter<H, Lanes>
|
> OnMessagesDelivered for XcmBlobHaulerAdapter<H, Lanes>
|
||||||
{
|
{
|
||||||
fn on_messages_delivered(lane: LaneId, enqueued_messages: MessageNonce) {
|
fn on_messages_delivered(lane: LaneId, enqueued_messages: MessageNonce) {
|
||||||
@@ -288,7 +288,7 @@ impl<H: XcmBlobHauler> LocalXcmQueueManager<H> {
|
|||||||
/// Send congested signal to the `sending_chain_location`.
|
/// Send congested signal to the `sending_chain_location`.
|
||||||
fn send_congested_signal(sender_and_lane: &SenderAndLane) -> Result<(), SendError> {
|
fn send_congested_signal(sender_and_lane: &SenderAndLane) -> Result<(), SendError> {
|
||||||
if let Some(msg) = H::CongestedMessage::get() {
|
if let Some(msg) = H::CongestedMessage::get() {
|
||||||
send_xcm::<H::ToSourceChainSender>(sender_and_lane.location, msg)?;
|
send_xcm::<H::ToSourceChainSender>(sender_and_lane.location.clone(), msg)?;
|
||||||
OutboundLanesCongestedSignals::<H::Runtime, H::MessagesInstance>::insert(
|
OutboundLanesCongestedSignals::<H::Runtime, H::MessagesInstance>::insert(
|
||||||
sender_and_lane.lane,
|
sender_and_lane.lane,
|
||||||
true,
|
true,
|
||||||
@@ -300,7 +300,7 @@ impl<H: XcmBlobHauler> LocalXcmQueueManager<H> {
|
|||||||
/// Send `uncongested` signal to the `sending_chain_location`.
|
/// Send `uncongested` signal to the `sending_chain_location`.
|
||||||
fn send_uncongested_signal(sender_and_lane: &SenderAndLane) -> Result<(), SendError> {
|
fn send_uncongested_signal(sender_and_lane: &SenderAndLane) -> Result<(), SendError> {
|
||||||
if let Some(msg) = H::UncongestedMessage::get() {
|
if let Some(msg) = H::UncongestedMessage::get() {
|
||||||
send_xcm::<H::ToSourceChainSender>(sender_and_lane.location, msg)?;
|
send_xcm::<H::ToSourceChainSender>(sender_and_lane.location.clone(), msg)?;
|
||||||
OutboundLanesCongestedSignals::<H::Runtime, H::MessagesInstance>::remove(
|
OutboundLanesCongestedSignals::<H::Runtime, H::MessagesInstance>::remove(
|
||||||
sender_and_lane.lane,
|
sender_and_lane.lane,
|
||||||
);
|
);
|
||||||
@@ -315,10 +315,10 @@ impl<H: XcmBlobHauler> LocalXcmQueueManager<H> {
|
|||||||
pub struct XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>(
|
pub struct XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>(
|
||||||
sp_std::marker::PhantomData<(Version, RemoteBridge)>,
|
sp_std::marker::PhantomData<(Version, RemoteBridge)>,
|
||||||
);
|
);
|
||||||
impl<Version: GetVersion, RemoteBridge: Get<MultiLocation>> GetVersion
|
impl<Version: GetVersion, RemoteBridge: Get<Location>> GetVersion
|
||||||
for XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>
|
for XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>
|
||||||
{
|
{
|
||||||
fn get_version_for(dest: &MultiLocation) -> Option<XcmVersion> {
|
fn get_version_for(dest: &Location) -> Option<XcmVersion> {
|
||||||
let dest_version = Version::get_version_for(dest);
|
let dest_version = Version::get_version_for(dest);
|
||||||
let bridge_hub_version = Version::get_version_for(&RemoteBridge::get());
|
let bridge_hub_version = Version::get_version_for(&RemoteBridge::get());
|
||||||
|
|
||||||
@@ -342,11 +342,11 @@ mod tests {
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub TestSenderAndLane: SenderAndLane = SenderAndLane {
|
pub TestSenderAndLane: SenderAndLane = SenderAndLane {
|
||||||
location: MultiLocation::new(1, X1(Parachain(1000))),
|
location: Location::new(1, [Parachain(1000)]),
|
||||||
lane: TEST_LANE_ID,
|
lane: TEST_LANE_ID,
|
||||||
};
|
};
|
||||||
pub TestLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
pub TestLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||||
(TestSenderAndLane::get(), (NetworkId::ByGenesis([0; 32]), InteriorMultiLocation::Here))
|
(TestSenderAndLane::get(), (NetworkId::ByGenesis([0; 32]), InteriorLocation::Here))
|
||||||
];
|
];
|
||||||
pub DummyXcmMessage: Xcm<()> = Xcm::new();
|
pub DummyXcmMessage: Xcm<()> = Xcm::new();
|
||||||
}
|
}
|
||||||
@@ -363,7 +363,7 @@ mod tests {
|
|||||||
type Ticket = ();
|
type Ticket = ();
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
_destination: &mut Option<MultiLocation>,
|
_destination: &mut Option<Location>,
|
||||||
_message: &mut Option<Xcm<()>>,
|
_message: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
Ok(((), Default::default()))
|
Ok(((), Default::default()))
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ pub trait Config<I: 'static>: crate::Config<I> {
|
|||||||
/// Returns destination which is valid for this router instance.
|
/// Returns destination which is valid for this router instance.
|
||||||
/// (Needs to pass `T::Bridges`)
|
/// (Needs to pass `T::Bridges`)
|
||||||
/// Make sure that `SendXcm` will pass.
|
/// Make sure that `SendXcm` will pass.
|
||||||
fn ensure_bridged_target_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn ensure_bridged_target_destination() -> Result<Location, BenchmarkError> {
|
||||||
Ok(MultiLocation::new(
|
Ok(Location::new(
|
||||||
Self::UniversalLocation::get().len() as u8,
|
Self::UniversalLocation::get().len() as u8,
|
||||||
X1(GlobalConsensus(Self::BridgedNetworkId::get().unwrap())),
|
[GlobalConsensus(Self::BridgedNetworkId::get().unwrap())],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ pub mod pallet {
|
|||||||
type WeightInfo: WeightInfo;
|
type WeightInfo: WeightInfo;
|
||||||
|
|
||||||
/// Universal location of this runtime.
|
/// Universal location of this runtime.
|
||||||
type UniversalLocation: Get<InteriorMultiLocation>;
|
type UniversalLocation: Get<InteriorLocation>;
|
||||||
/// The bridged network that this config is for if specified.
|
/// The bridged network that this config is for if specified.
|
||||||
/// Also used for filtering `Bridges` by `BridgedNetworkId`.
|
/// Also used for filtering `Bridges` by `BridgedNetworkId`.
|
||||||
/// If not specified, allows all networks pass through.
|
/// If not specified, allows all networks pass through.
|
||||||
@@ -235,9 +235,9 @@ type ViaBridgeHubExporter<T, I> = SovereignPaidRemoteExporter<
|
|||||||
impl<T: Config<I>, I: 'static> ExporterFor for Pallet<T, I> {
|
impl<T: Config<I>, I: 'static> ExporterFor for Pallet<T, I> {
|
||||||
fn exporter_for(
|
fn exporter_for(
|
||||||
network: &NetworkId,
|
network: &NetworkId,
|
||||||
remote_location: &InteriorMultiLocation,
|
remote_location: &InteriorLocation,
|
||||||
message: &Xcm<()>,
|
message: &Xcm<()>,
|
||||||
) -> Option<(MultiLocation, Option<MultiAsset>)> {
|
) -> Option<(Location, Option<Asset>)> {
|
||||||
// ensure that the message is sent to the expected bridged network (if specified).
|
// ensure that the message is sent to the expected bridged network (if specified).
|
||||||
if let Some(bridged_network) = T::BridgedNetworkId::get() {
|
if let Some(bridged_network) = T::BridgedNetworkId::get() {
|
||||||
if *network != bridged_network {
|
if *network != bridged_network {
|
||||||
@@ -268,7 +268,7 @@ impl<T: Config<I>, I: 'static> ExporterFor for Pallet<T, I> {
|
|||||||
// take `base_fee` from `T::Brides`, but it has to be the same `T::FeeAsset`
|
// take `base_fee` from `T::Brides`, but it has to be the same `T::FeeAsset`
|
||||||
let base_fee = match maybe_payment {
|
let base_fee = match maybe_payment {
|
||||||
Some(payment) => match payment {
|
Some(payment) => match payment {
|
||||||
MultiAsset { fun: Fungible(amount), id } if id.eq(&T::FeeAsset::get()) => amount,
|
Asset { fun: Fungible(amount), id } if id.eq(&T::FeeAsset::get()) => amount,
|
||||||
invalid_asset => {
|
invalid_asset => {
|
||||||
log::error!(
|
log::error!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
@@ -318,7 +318,7 @@ impl<T: Config<I>, I: 'static> SendXcm for Pallet<T, I> {
|
|||||||
type Ticket = (u32, <T::ToBridgeHubSender as SendXcm>::Ticket);
|
type Ticket = (u32, <T::ToBridgeHubSender as SendXcm>::Ticket);
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
dest: &mut Option<MultiLocation>,
|
dest: &mut Option<Location>,
|
||||||
xcm: &mut Option<Xcm<()>>,
|
xcm: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
// `dest` and `xcm` are required here
|
// `dest` and `xcm` are required here
|
||||||
@@ -446,7 +446,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
send_xcm::<XcmBridgeHubRouter>(
|
send_xcm::<XcmBridgeHubRouter>(
|
||||||
MultiLocation::new(2, X2(GlobalConsensus(Rococo), Parachain(1000))),
|
Location::new(2, [GlobalConsensus(Rococo), Parachain(1000)]),
|
||||||
vec![].into(),
|
vec![].into(),
|
||||||
),
|
),
|
||||||
Err(SendError::NotApplicable),
|
Err(SendError::NotApplicable),
|
||||||
@@ -459,7 +459,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
send_xcm::<XcmBridgeHubRouter>(
|
send_xcm::<XcmBridgeHubRouter>(
|
||||||
MultiLocation::new(2, X2(GlobalConsensus(Rococo), Parachain(1000))),
|
Location::new(2, [GlobalConsensus(Rococo), Parachain(1000)]),
|
||||||
vec![ClearOrigin; HARD_MESSAGE_SIZE_LIMIT as usize].into(),
|
vec![ClearOrigin; HARD_MESSAGE_SIZE_LIMIT as usize].into(),
|
||||||
),
|
),
|
||||||
Err(SendError::ExceedsMaxMessageSize),
|
Err(SendError::ExceedsMaxMessageSize),
|
||||||
@@ -483,14 +483,14 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn returns_proper_delivery_price() {
|
fn returns_proper_delivery_price() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
let dest = MultiLocation::new(2, X1(GlobalConsensus(BridgedNetworkId::get())));
|
let dest = Location::new(2, [GlobalConsensus(BridgedNetworkId::get())]);
|
||||||
let xcm: Xcm<()> = vec![ClearOrigin].into();
|
let xcm: Xcm<()> = vec![ClearOrigin].into();
|
||||||
let msg_size = xcm.encoded_size();
|
let msg_size = xcm.encoded_size();
|
||||||
|
|
||||||
// initially the base fee is used: `BASE_FEE + BYTE_FEE * msg_size + HRMP_FEE`
|
// initially the base fee is used: `BASE_FEE + BYTE_FEE * msg_size + HRMP_FEE`
|
||||||
let expected_fee = BASE_FEE + BYTE_FEE * (msg_size as u128) + HRMP_FEE;
|
let expected_fee = BASE_FEE + BYTE_FEE * (msg_size as u128) + HRMP_FEE;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
XcmBridgeHubRouter::validate(&mut Some(dest), &mut Some(xcm.clone()))
|
XcmBridgeHubRouter::validate(&mut Some(dest.clone()), &mut Some(xcm.clone()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.1
|
.1
|
||||||
.get(0),
|
.get(0),
|
||||||
@@ -518,10 +518,7 @@ mod tests {
|
|||||||
run_test(|| {
|
run_test(|| {
|
||||||
let old_bridge = XcmBridgeHubRouter::bridge();
|
let old_bridge = XcmBridgeHubRouter::bridge();
|
||||||
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
||||||
MultiLocation::new(
|
Location::new(2, [GlobalConsensus(BridgedNetworkId::get()), Parachain(1000)]),
|
||||||
2,
|
|
||||||
X2(GlobalConsensus(BridgedNetworkId::get()), Parachain(1000))
|
|
||||||
),
|
|
||||||
vec![ClearOrigin].into(),
|
vec![ClearOrigin].into(),
|
||||||
)
|
)
|
||||||
.map(drop));
|
.map(drop));
|
||||||
@@ -538,10 +535,7 @@ mod tests {
|
|||||||
|
|
||||||
let old_bridge = XcmBridgeHubRouter::bridge();
|
let old_bridge = XcmBridgeHubRouter::bridge();
|
||||||
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
||||||
MultiLocation::new(
|
Location::new(2, [GlobalConsensus(BridgedNetworkId::get()), Parachain(1000)]),
|
||||||
2,
|
|
||||||
X2(GlobalConsensus(BridgedNetworkId::get()), Parachain(1000))
|
|
||||||
),
|
|
||||||
vec![ClearOrigin].into(),
|
vec![ClearOrigin].into(),
|
||||||
)
|
)
|
||||||
.map(drop));
|
.map(drop));
|
||||||
@@ -560,10 +554,7 @@ mod tests {
|
|||||||
|
|
||||||
let old_bridge = XcmBridgeHubRouter::bridge();
|
let old_bridge = XcmBridgeHubRouter::bridge();
|
||||||
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
assert_ok!(send_xcm::<XcmBridgeHubRouter>(
|
||||||
MultiLocation::new(
|
Location::new(2, [GlobalConsensus(BridgedNetworkId::get()), Parachain(1000)]),
|
||||||
2,
|
|
||||||
X2(GlobalConsensus(BridgedNetworkId::get()), Parachain(1000))
|
|
||||||
),
|
|
||||||
vec![ClearOrigin].into(),
|
vec![ClearOrigin].into(),
|
||||||
)
|
)
|
||||||
.map(drop));
|
.map(drop));
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ construct_runtime! {
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ThisNetworkId: NetworkId = Polkadot;
|
pub ThisNetworkId: NetworkId = Polkadot;
|
||||||
pub BridgedNetworkId: NetworkId = Kusama;
|
pub BridgedNetworkId: NetworkId = Kusama;
|
||||||
pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(ThisNetworkId::get()), Parachain(1000));
|
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ThisNetworkId::get()), Parachain(1000)].into();
|
||||||
pub SiblingBridgeHubLocation: MultiLocation = ParentThen(X1(Parachain(1002))).into();
|
pub SiblingBridgeHubLocation: Location = ParentThen([Parachain(1002)].into()).into();
|
||||||
pub BridgeFeeAsset: AssetId = MultiLocation::parent().into();
|
pub BridgeFeeAsset: AssetId = Location::parent().into();
|
||||||
pub BridgeTable: Vec<NetworkExportTableItem>
|
pub BridgeTable: Vec<NetworkExportTableItem>
|
||||||
= vec![
|
= vec![
|
||||||
NetworkExportTableItem::new(
|
NetworkExportTableItem::new(
|
||||||
@@ -61,7 +61,7 @@ parameter_types! {
|
|||||||
Some((BridgeFeeAsset::get(), BASE_FEE).into())
|
Some((BridgeFeeAsset::get(), BASE_FEE).into())
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
pub UnknownXcmVersionLocation: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(BridgedNetworkId::get()), Parachain(9999)));
|
pub UnknownXcmVersionLocation: Location = Location::new(2, [GlobalConsensus(BridgedNetworkId::get()), Parachain(9999)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
|
#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)]
|
||||||
@@ -87,11 +87,11 @@ impl pallet_xcm_bridge_hub_router::Config<()> for TestRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct LatestOrNoneForLocationVersionChecker<Location>(sp_std::marker::PhantomData<Location>);
|
pub struct LatestOrNoneForLocationVersionChecker<Location>(sp_std::marker::PhantomData<Location>);
|
||||||
impl<Location: Contains<MultiLocation>> GetVersion
|
impl<LocationValue: Contains<Location>> GetVersion
|
||||||
for LatestOrNoneForLocationVersionChecker<Location>
|
for LatestOrNoneForLocationVersionChecker<LocationValue>
|
||||||
{
|
{
|
||||||
fn get_version_for(dest: &MultiLocation) -> Option<XcmVersion> {
|
fn get_version_for(dest: &Location) -> Option<XcmVersion> {
|
||||||
if Location::contains(dest) {
|
if LocationValue::contains(dest) {
|
||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
Some(XCM_VERSION)
|
Some(XCM_VERSION)
|
||||||
@@ -110,7 +110,7 @@ impl SendXcm for TestToBridgeHubSender {
|
|||||||
type Ticket = ();
|
type Ticket = ();
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
_destination: &mut Option<MultiLocation>,
|
_destination: &mut Option<Location>,
|
||||||
_message: &mut Option<Xcm<()>>,
|
_message: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
Ok(((), (BridgeFeeAsset::get(), HRMP_FEE).into()))
|
Ok(((), (BridgeFeeAsset::get(), HRMP_FEE).into()))
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ where
|
|||||||
fn validate(
|
fn validate(
|
||||||
network: NetworkId,
|
network: NetworkId,
|
||||||
channel: u32,
|
channel: u32,
|
||||||
universal_source: &mut Option<InteriorMultiLocation>,
|
universal_source: &mut Option<InteriorLocation>,
|
||||||
destination: &mut Option<InteriorMultiLocation>,
|
destination: &mut Option<InteriorLocation>,
|
||||||
message: &mut Option<Xcm<()>>,
|
message: &mut Option<Xcm<()>>,
|
||||||
) -> Result<(Self::Ticket, MultiAssets), SendError> {
|
) -> Result<(Self::Ticket, Assets), SendError> {
|
||||||
// Find supported lane_id.
|
// Find supported lane_id.
|
||||||
let sender_and_lane = Self::lane_for(
|
let sender_and_lane = Self::lane_for(
|
||||||
universal_source.as_ref().ok_or(SendError::MissingArgument)?,
|
universal_source.as_ref().ok_or(SendError::MissingArgument)?,
|
||||||
@@ -137,11 +137,11 @@ mod tests {
|
|||||||
use frame_support::assert_ok;
|
use frame_support::assert_ok;
|
||||||
use xcm_executor::traits::export_xcm;
|
use xcm_executor::traits::export_xcm;
|
||||||
|
|
||||||
fn universal_source() -> InteriorMultiLocation {
|
fn universal_source() -> InteriorLocation {
|
||||||
X2(GlobalConsensus(RelayNetwork::get()), Parachain(SIBLING_ASSET_HUB_ID))
|
[GlobalConsensus(RelayNetwork::get()), Parachain(SIBLING_ASSET_HUB_ID)].into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn universal_destination() -> InteriorMultiLocation {
|
fn universal_destination() -> InteriorLocation {
|
||||||
BridgedDestination::get()
|
BridgedDestination::get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,25 +45,25 @@ pub mod pallet {
|
|||||||
BridgeMessagesConfig<Self::BridgeMessagesPalletInstance>
|
BridgeMessagesConfig<Self::BridgeMessagesPalletInstance>
|
||||||
{
|
{
|
||||||
/// Runtime's universal location.
|
/// Runtime's universal location.
|
||||||
type UniversalLocation: Get<InteriorMultiLocation>;
|
type UniversalLocation: Get<InteriorLocation>;
|
||||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1666 remove `ChainId` and
|
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1666 remove `ChainId` and
|
||||||
// replace it with the `NetworkId` - then we'll be able to use
|
// replace it with the `NetworkId` - then we'll be able to use
|
||||||
// `T as pallet_bridge_messages::Config<T::BridgeMessagesPalletInstance>::BridgedChain::NetworkId`
|
// `T as pallet_bridge_messages::Config<T::BridgeMessagesPalletInstance>::BridgedChain::NetworkId`
|
||||||
/// Bridged network as relative location of bridged `GlobalConsensus`.
|
/// Bridged network as relative location of bridged `GlobalConsensus`.
|
||||||
#[pallet::constant]
|
#[pallet::constant]
|
||||||
type BridgedNetwork: Get<MultiLocation>;
|
type BridgedNetwork: Get<Location>;
|
||||||
/// Associated messages pallet instance that bridges us with the
|
/// Associated messages pallet instance that bridges us with the
|
||||||
/// `BridgedNetworkId` consensus.
|
/// `BridgedNetworkId` consensus.
|
||||||
type BridgeMessagesPalletInstance: 'static;
|
type BridgeMessagesPalletInstance: 'static;
|
||||||
|
|
||||||
/// Price of single message export to the bridged consensus (`Self::BridgedNetworkId`).
|
/// Price of single message export to the bridged consensus (`Self::BridgedNetworkId`).
|
||||||
type MessageExportPrice: Get<MultiAssets>;
|
type MessageExportPrice: Get<Assets>;
|
||||||
/// Checks the XCM version for the destination.
|
/// Checks the XCM version for the destination.
|
||||||
type DestinationVersion: GetVersion;
|
type DestinationVersion: GetVersion;
|
||||||
|
|
||||||
/// Get point-to-point links with bridged consensus (`Self::BridgedNetworkId`).
|
/// Get point-to-point links with bridged consensus (`Self::BridgedNetworkId`).
|
||||||
/// (this will be replaced with dynamic on-chain bridges - `Bridges V2`)
|
/// (this will be replaced with dynamic on-chain bridges - `Bridges V2`)
|
||||||
type Lanes: Get<sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))>>;
|
type Lanes: Get<sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))>>;
|
||||||
/// Support for point-to-point links
|
/// Support for point-to-point links
|
||||||
/// (this will be replaced with dynamic on-chain bridges - `Bridges V2`)
|
/// (this will be replaced with dynamic on-chain bridges - `Bridges V2`)
|
||||||
type LanesSupport: XcmBlobHauler;
|
type LanesSupport: XcmBlobHauler;
|
||||||
@@ -86,10 +86,10 @@ pub mod pallet {
|
|||||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||||
/// Returns dedicated/configured lane identifier.
|
/// Returns dedicated/configured lane identifier.
|
||||||
pub(crate) fn lane_for(
|
pub(crate) fn lane_for(
|
||||||
source: &InteriorMultiLocation,
|
source: &InteriorLocation,
|
||||||
dest: (&NetworkId, &InteriorMultiLocation),
|
dest: (&NetworkId, &InteriorLocation),
|
||||||
) -> Option<SenderAndLane> {
|
) -> Option<SenderAndLane> {
|
||||||
let source = source.relative_to(&T::UniversalLocation::get());
|
let source = source.clone().relative_to(&T::UniversalLocation::get());
|
||||||
|
|
||||||
// Check that we have configured a point-to-point lane for 'source' and `dest`.
|
// Check that we have configured a point-to-point lane for 'source' and `dest`.
|
||||||
T::Lanes::get()
|
T::Lanes::get()
|
||||||
|
|||||||
@@ -170,16 +170,13 @@ impl pallet_bridge_messages::WeightInfoExt for TestMessagesWeights {
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
|
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
|
||||||
pub const BridgedRelayNetwork: NetworkId = NetworkId::Polkadot;
|
pub const BridgedRelayNetwork: NetworkId = NetworkId::Polkadot;
|
||||||
pub const BridgedRelayNetworkLocation: MultiLocation = MultiLocation {
|
pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into();
|
||||||
parents: 1,
|
|
||||||
interior: X1(GlobalConsensus(BridgedRelayNetwork::get()))
|
|
||||||
};
|
|
||||||
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
|
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
|
||||||
pub const BridgeReserve: Balance = 100_000;
|
pub const BridgeReserve: Balance = 100_000;
|
||||||
pub UniversalLocation: InteriorMultiLocation = X2(
|
pub UniversalLocation: InteriorLocation = [
|
||||||
GlobalConsensus(RelayNetwork::get()),
|
GlobalConsensus(RelayNetwork::get()),
|
||||||
Parachain(THIS_BRIDGE_HUB_ID),
|
Parachain(THIS_BRIDGE_HUB_ID),
|
||||||
);
|
].into();
|
||||||
pub const Penalty: Balance = 1_000;
|
pub const Penalty: Balance = 1_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,13 +194,13 @@ impl pallet_xcm_bridge_hub::Config for TestRuntime {
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub TestSenderAndLane: SenderAndLane = SenderAndLane {
|
pub TestSenderAndLane: SenderAndLane = SenderAndLane {
|
||||||
location: MultiLocation::new(1, X1(Parachain(SIBLING_ASSET_HUB_ID))),
|
location: Location::new(1, [Parachain(SIBLING_ASSET_HUB_ID)]),
|
||||||
lane: TEST_LANE_ID,
|
lane: TEST_LANE_ID,
|
||||||
};
|
};
|
||||||
pub const BridgedDestination: InteriorMultiLocation = X1(
|
pub BridgedDestination: InteriorLocation = [
|
||||||
Parachain(BRIDGED_ASSET_HUB_ID)
|
Parachain(BRIDGED_ASSET_HUB_ID)
|
||||||
);
|
].into();
|
||||||
pub TestLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
pub TestLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||||
(TestSenderAndLane::get(), (BridgedRelayNetwork::get(), BridgedDestination::get()))
|
(TestSenderAndLane::get(), (BridgedRelayNetwork::get(), BridgedDestination::get()))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ use scale_info::TypeInfo;
|
|||||||
use sp_core::{H160, H256};
|
use sp_core::{H160, H256};
|
||||||
use sp_std::{convert::TryFrom, vec};
|
use sp_std::{convert::TryFrom, vec};
|
||||||
use xcm::prelude::{
|
use xcm::prelude::{
|
||||||
send_xcm, Instruction::SetTopic, Junction::*, Junctions::*, MultiLocation,
|
send_xcm, Instruction::SetTopic, Junction::*, Location, SendError as XcmpSendError, SendXcm,
|
||||||
SendError as XcmpSendError, SendXcm, Xcm, XcmContext, XcmHash,
|
Xcm, XcmContext, XcmHash,
|
||||||
};
|
};
|
||||||
use xcm_executor::traits::TransactAsset;
|
use xcm_executor::traits::TransactAsset;
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result<XcmHash, Error<T>> {
|
pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result<XcmHash, Error<T>> {
|
||||||
let dest = MultiLocation { parents: 1, interior: X1(Parachain(dest.into())) };
|
let dest = Location::new(1, [Parachain(dest.into())]);
|
||||||
let (xcm_hash, _) = send_xcm::<T::XcmSender>(dest, xcm).map_err(Error::<T>::from)?;
|
let (xcm_hash, _) = send_xcm::<T::XcmSender>(dest, xcm).map_err(Error::<T>::from)?;
|
||||||
Ok(xcm_hash)
|
Ok(xcm_hash)
|
||||||
}
|
}
|
||||||
@@ -341,8 +341,8 @@ pub mod pallet {
|
|||||||
pub fn burn_fees(para_id: ParaId, fee: BalanceOf<T>) -> DispatchResult {
|
pub fn burn_fees(para_id: ParaId, fee: BalanceOf<T>) -> DispatchResult {
|
||||||
let dummy_context =
|
let dummy_context =
|
||||||
XcmContext { origin: None, message_id: Default::default(), topic: None };
|
XcmContext { origin: None, message_id: Default::default(), topic: None };
|
||||||
let dest = MultiLocation { parents: 1, interior: X1(Parachain(para_id.into())) };
|
let dest = Location::new(1, [Parachain(para_id.into())]);
|
||||||
let fees = (MultiLocation::parent(), fee.saturated_into::<u128>()).into();
|
let fees = (Location::parent(), fee.saturated_into::<u128>()).into();
|
||||||
T::AssetTransactor::can_check_out(&dest, &fees, &dummy_context).map_err(|error| {
|
T::AssetTransactor::can_check_out(&dest, &fees, &dummy_context).map_err(|error| {
|
||||||
log::error!(
|
log::error!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ use sp_runtime::{
|
|||||||
BuildStorage, FixedU128, MultiSignature,
|
BuildStorage, FixedU128, MultiSignature,
|
||||||
};
|
};
|
||||||
use sp_std::convert::From;
|
use sp_std::convert::From;
|
||||||
use xcm::v3::{prelude::*, MultiAssets, SendXcm};
|
use xcm::v4::{prelude::*, SendXcm};
|
||||||
use xcm_executor::Assets;
|
use xcm_executor::AssetsInHolding;
|
||||||
|
|
||||||
use crate::{self as inbound_queue};
|
use crate::{self as inbound_queue};
|
||||||
|
|
||||||
@@ -155,17 +155,16 @@ impl SendXcm for MockXcmSender {
|
|||||||
type Ticket = Xcm<()>;
|
type Ticket = Xcm<()>;
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
dest: &mut Option<MultiLocation>,
|
dest: &mut Option<Location>,
|
||||||
xcm: &mut Option<xcm::v3::Xcm<()>>,
|
xcm: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
match dest {
|
if let Some(location) = dest {
|
||||||
Some(MultiLocation { interior, .. }) => {
|
match location.unpack() {
|
||||||
if let X1(Parachain(1001)) = interior {
|
(_, [Parachain(1001)]) => return Err(XcmpSendError::NotApplicable),
|
||||||
return Err(XcmpSendError::NotApplicable)
|
_ => Ok((xcm.clone().unwrap(), Assets::default())),
|
||||||
}
|
}
|
||||||
Ok((xcm.clone().unwrap(), MultiAssets::default()))
|
} else {
|
||||||
},
|
Ok((xcm.clone().unwrap(), Assets::default()))
|
||||||
_ => Ok((xcm.clone().unwrap(), MultiAssets::default())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,45 +202,33 @@ impl StaticLookup for MockChannelLookup {
|
|||||||
|
|
||||||
pub struct SuccessfulTransactor;
|
pub struct SuccessfulTransactor;
|
||||||
impl TransactAsset for SuccessfulTransactor {
|
impl TransactAsset for SuccessfulTransactor {
|
||||||
fn can_check_in(
|
fn can_check_in(_origin: &Location, _what: &Asset, _context: &XcmContext) -> XcmResult {
|
||||||
_origin: &MultiLocation,
|
|
||||||
_what: &MultiAsset,
|
|
||||||
_context: &XcmContext,
|
|
||||||
) -> XcmResult {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_check_out(
|
fn can_check_out(_dest: &Location, _what: &Asset, _context: &XcmContext) -> XcmResult {
|
||||||
_dest: &MultiLocation,
|
|
||||||
_what: &MultiAsset,
|
|
||||||
_context: &XcmContext,
|
|
||||||
) -> XcmResult {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deposit_asset(
|
fn deposit_asset(_what: &Asset, _who: &Location, _context: Option<&XcmContext>) -> XcmResult {
|
||||||
_what: &MultiAsset,
|
|
||||||
_who: &MultiLocation,
|
|
||||||
_context: Option<&XcmContext>,
|
|
||||||
) -> XcmResult {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn withdraw_asset(
|
fn withdraw_asset(
|
||||||
_what: &MultiAsset,
|
_what: &Asset,
|
||||||
_who: &MultiLocation,
|
_who: &Location,
|
||||||
_context: Option<&XcmContext>,
|
_context: Option<&XcmContext>,
|
||||||
) -> Result<Assets, XcmError> {
|
) -> Result<AssetsInHolding, XcmError> {
|
||||||
Ok(Assets::default())
|
Ok(AssetsInHolding::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn internal_transfer_asset(
|
fn internal_transfer_asset(
|
||||||
_what: &MultiAsset,
|
_what: &Asset,
|
||||||
_from: &MultiLocation,
|
_from: &Location,
|
||||||
_to: &MultiLocation,
|
_to: &Location,
|
||||||
_context: &XcmContext,
|
_context: &XcmContext,
|
||||||
) -> Result<Assets, XcmError> {
|
) -> Result<AssetsInHolding, XcmError> {
|
||||||
Ok(Assets::default())
|
Ok(AssetsInHolding::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ fn test_submit_happy_path() {
|
|||||||
.into(),
|
.into(),
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
message_id: [
|
message_id: [
|
||||||
27, 217, 88, 127, 46, 143, 199, 70, 236, 66, 212, 244, 85, 221, 153, 104, 175, 37,
|
57, 61, 232, 3, 66, 61, 25, 190, 234, 188, 193, 174, 13, 186, 1, 64, 237, 94, 73,
|
||||||
224, 20, 140, 95, 140, 7, 27, 74, 182, 199, 77, 12, 194, 236,
|
83, 14, 18, 209, 213, 78, 121, 43, 108, 251, 245, 107, 67,
|
||||||
],
|
],
|
||||||
fee_burned: 110000000000,
|
fee_burned: 110000000000,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
use snowbridge_core::AgentId;
|
use snowbridge_core::AgentId;
|
||||||
use xcm::VersionedMultiLocation;
|
use xcm::VersionedLocation;
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
pub trait ControlApi
|
pub trait ControlApi
|
||||||
{
|
{
|
||||||
fn agent_id(location: VersionedMultiLocation) -> Option<AgentId>;
|
fn agent_id(location: VersionedLocation) -> Option<AgentId>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
//! Helpers for implementing runtime api
|
//! Helpers for implementing runtime api
|
||||||
|
|
||||||
use snowbridge_core::AgentId;
|
use snowbridge_core::AgentId;
|
||||||
use xcm::{prelude::*, VersionedMultiLocation};
|
use xcm::{prelude::*, VersionedLocation};
|
||||||
|
|
||||||
use crate::{agent_id_of, Config};
|
use crate::{agent_id_of, Config};
|
||||||
|
|
||||||
pub fn agent_id<Runtime>(location: VersionedMultiLocation) -> Option<AgentId>
|
pub fn agent_id<Runtime>(location: VersionedLocation) -> Option<AgentId>
|
||||||
where
|
where
|
||||||
Runtime: Config,
|
Runtime: Config,
|
||||||
{
|
{
|
||||||
let location: MultiLocation = location.try_into().ok()?;
|
let location: Location = location.try_into().ok()?;
|
||||||
agent_id_of::<Runtime>(&location).ok()
|
agent_id_of::<Runtime>(&location).ok()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn create_agent() -> Result<(), BenchmarkError> {
|
fn create_agent() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location);
|
||||||
fund_sovereign_account::<T>(origin_para_id.into())?;
|
fund_sovereign_account::<T>(origin_para_id.into())?;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn create_channel() -> Result<(), BenchmarkError> {
|
fn create_channel() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location);
|
||||||
fund_sovereign_account::<T>(origin_para_id.into())?;
|
fund_sovereign_account::<T>(origin_para_id.into())?;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn update_channel() -> Result<(), BenchmarkError> {
|
fn update_channel() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location);
|
||||||
fund_sovereign_account::<T>(origin_para_id.into())?;
|
fund_sovereign_account::<T>(origin_para_id.into())?;
|
||||||
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
||||||
@@ -106,7 +106,7 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn force_update_channel() -> Result<(), BenchmarkError> {
|
fn force_update_channel() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location);
|
||||||
let channel_id: ChannelId = ParaId::from(origin_para_id).into();
|
let channel_id: ChannelId = ParaId::from(origin_para_id).into();
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn transfer_native_from_agent() -> Result<(), BenchmarkError> {
|
fn transfer_native_from_agent() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location);
|
||||||
fund_sovereign_account::<T>(origin_para_id.into())?;
|
fund_sovereign_account::<T>(origin_para_id.into())?;
|
||||||
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
||||||
@@ -138,12 +138,12 @@ mod benchmarks {
|
|||||||
#[benchmark]
|
#[benchmark]
|
||||||
fn force_transfer_native_from_agent() -> Result<(), BenchmarkError> {
|
fn force_transfer_native_from_agent() -> Result<(), BenchmarkError> {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let origin = T::Helper::make_xcm_origin(origin_location);
|
let origin = T::Helper::make_xcm_origin(origin_location.clone());
|
||||||
fund_sovereign_account::<T>(origin_para_id.into())?;
|
fund_sovereign_account::<T>(origin_para_id.into())?;
|
||||||
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
SnowbridgeControl::<T>::create_agent(origin.clone())?;
|
||||||
|
|
||||||
let versioned_location: VersionedMultiLocation = origin_location.into();
|
let versioned_location: VersionedLocation = origin_location.into();
|
||||||
|
|
||||||
#[extrinsic_call]
|
#[extrinsic_call]
|
||||||
_(RawOrigin::Root, Box::new(versioned_location), H160::default(), 1);
|
_(RawOrigin::Root, Box::new(versioned_location), H160::default(), 1);
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
|
|||||||
pub type PricingParametersOf<T> = PricingParametersRecord<BalanceOf<T>>;
|
pub type PricingParametersOf<T> = PricingParametersRecord<BalanceOf<T>>;
|
||||||
|
|
||||||
/// Ensure origin location is a sibling
|
/// Ensure origin location is a sibling
|
||||||
fn ensure_sibling<T>(location: &MultiLocation) -> Result<(ParaId, H256), DispatchError>
|
fn ensure_sibling<T>(location: &Location) -> Result<(ParaId, H256), DispatchError>
|
||||||
where
|
where
|
||||||
T: Config,
|
T: Config,
|
||||||
{
|
{
|
||||||
match location {
|
match location.unpack() {
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } => {
|
(1, [Parachain(para_id)]) => {
|
||||||
let agent_id = agent_id_of::<T>(location)?;
|
let agent_id = agent_id_of::<T>(location)?;
|
||||||
Ok(((*para_id).into(), agent_id))
|
Ok(((*para_id).into(), agent_id))
|
||||||
},
|
},
|
||||||
@@ -101,7 +101,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Hash the location to produce an agent id
|
/// Hash the location to produce an agent id
|
||||||
fn agent_id_of<T: Config>(location: &MultiLocation) -> Result<H256, DispatchError> {
|
fn agent_id_of<T: Config>(location: &Location) -> Result<H256, DispatchError> {
|
||||||
T::AgentIdOf::convert_location(location).ok_or(Error::<T>::LocationConversionFailed.into())
|
T::AgentIdOf::convert_location(location).ok_or(Error::<T>::LocationConversionFailed.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ pub trait BenchmarkHelper<O>
|
|||||||
where
|
where
|
||||||
O: OriginTrait,
|
O: OriginTrait,
|
||||||
{
|
{
|
||||||
fn make_xcm_origin(location: MultiLocation) -> O;
|
fn make_xcm_origin(location: Location) -> O;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether a fee should be withdrawn to an account for sending an outbound message
|
/// Whether a fee should be withdrawn to an account for sending an outbound message
|
||||||
@@ -145,9 +145,9 @@ pub mod pallet {
|
|||||||
type OutboundQueue: SendMessage<Balance = BalanceOf<Self>>;
|
type OutboundQueue: SendMessage<Balance = BalanceOf<Self>>;
|
||||||
|
|
||||||
/// Origin check for XCM locations that can create agents
|
/// Origin check for XCM locations that can create agents
|
||||||
type SiblingOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = MultiLocation>;
|
type SiblingOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Location>;
|
||||||
|
|
||||||
/// Converts MultiLocation to AgentId
|
/// Converts Location to AgentId
|
||||||
type AgentIdOf: ConvertLocation<AgentId>;
|
type AgentIdOf: ConvertLocation<AgentId>;
|
||||||
|
|
||||||
/// Token reserved for control operations
|
/// Token reserved for control operations
|
||||||
@@ -180,7 +180,7 @@ pub mod pallet {
|
|||||||
},
|
},
|
||||||
/// An CreateAgent message was sent to the Gateway
|
/// An CreateAgent message was sent to the Gateway
|
||||||
CreateAgent {
|
CreateAgent {
|
||||||
location: Box<MultiLocation>,
|
location: Box<Location>,
|
||||||
agent_id: AgentId,
|
agent_id: AgentId,
|
||||||
},
|
},
|
||||||
/// An CreateChannel message was sent to the Gateway
|
/// An CreateChannel message was sent to the Gateway
|
||||||
@@ -299,7 +299,7 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Fee required: No
|
/// Fee required: No
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be `MultiLocation`
|
/// - `origin`: Must be `Location`
|
||||||
#[pallet::call_index(1)]
|
#[pallet::call_index(1)]
|
||||||
#[pallet::weight((T::WeightInfo::set_operating_mode(), DispatchClass::Operational))]
|
#[pallet::weight((T::WeightInfo::set_operating_mode(), DispatchClass::Operational))]
|
||||||
pub fn set_operating_mode(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
pub fn set_operating_mode(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
||||||
@@ -342,11 +342,11 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// Fee required: Yes
|
/// Fee required: Yes
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be `MultiLocation` of a sibling parachain
|
/// - `origin`: Must be `Location` of a sibling parachain
|
||||||
#[pallet::call_index(3)]
|
#[pallet::call_index(3)]
|
||||||
#[pallet::weight(T::WeightInfo::create_agent())]
|
#[pallet::weight(T::WeightInfo::create_agent())]
|
||||||
pub fn create_agent(origin: OriginFor<T>) -> DispatchResult {
|
pub fn create_agent(origin: OriginFor<T>) -> DispatchResult {
|
||||||
let origin_location: MultiLocation = T::SiblingOrigin::ensure_origin(origin)?;
|
let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Ensure that origin location is some consensus system on a sibling parachain
|
// Ensure that origin location is some consensus system on a sibling parachain
|
||||||
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
||||||
@@ -375,12 +375,12 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// The message is sent over the bridge on BridgeHub's own channel to the Gateway.
|
/// The message is sent over the bridge on BridgeHub's own channel to the Gateway.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be `MultiLocation`
|
/// - `origin`: Must be `Location`
|
||||||
/// - `mode`: Initial operating mode of the channel
|
/// - `mode`: Initial operating mode of the channel
|
||||||
#[pallet::call_index(4)]
|
#[pallet::call_index(4)]
|
||||||
#[pallet::weight(T::WeightInfo::create_channel())]
|
#[pallet::weight(T::WeightInfo::create_channel())]
|
||||||
pub fn create_channel(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
pub fn create_channel(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
||||||
let origin_location: MultiLocation = T::SiblingOrigin::ensure_origin(origin)?;
|
let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Ensure that origin location is a sibling parachain
|
// Ensure that origin location is a sibling parachain
|
||||||
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
||||||
@@ -407,12 +407,12 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// A partial fee will be charged for local processing only.
|
/// A partial fee will be charged for local processing only.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be `MultiLocation`
|
/// - `origin`: Must be `Location`
|
||||||
/// - `mode`: Initial operating mode of the channel
|
/// - `mode`: Initial operating mode of the channel
|
||||||
#[pallet::call_index(5)]
|
#[pallet::call_index(5)]
|
||||||
#[pallet::weight(T::WeightInfo::update_channel())]
|
#[pallet::weight(T::WeightInfo::update_channel())]
|
||||||
pub fn update_channel(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
pub fn update_channel(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
|
||||||
let origin_location: MultiLocation = T::SiblingOrigin::ensure_origin(origin)?;
|
let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Ensure that origin location is a sibling parachain
|
// Ensure that origin location is a sibling parachain
|
||||||
let (para_id, _) = ensure_sibling::<T>(&origin_location)?;
|
let (para_id, _) = ensure_sibling::<T>(&origin_location)?;
|
||||||
@@ -461,7 +461,7 @@ pub mod pallet {
|
|||||||
///
|
///
|
||||||
/// A partial fee will be charged for local processing only.
|
/// A partial fee will be charged for local processing only.
|
||||||
///
|
///
|
||||||
/// - `origin`: Must be `MultiLocation`
|
/// - `origin`: Must be `Location`
|
||||||
#[pallet::call_index(7)]
|
#[pallet::call_index(7)]
|
||||||
#[pallet::weight(T::WeightInfo::transfer_native_from_agent())]
|
#[pallet::weight(T::WeightInfo::transfer_native_from_agent())]
|
||||||
pub fn transfer_native_from_agent(
|
pub fn transfer_native_from_agent(
|
||||||
@@ -469,7 +469,7 @@ pub mod pallet {
|
|||||||
recipient: H160,
|
recipient: H160,
|
||||||
amount: u128,
|
amount: u128,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let origin_location: MultiLocation = T::SiblingOrigin::ensure_origin(origin)?;
|
let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?;
|
||||||
|
|
||||||
// Ensure that origin location is some consensus system on a sibling parachain
|
// Ensure that origin location is some consensus system on a sibling parachain
|
||||||
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
let (para_id, agent_id) = ensure_sibling::<T>(&origin_location)?;
|
||||||
@@ -501,14 +501,14 @@ pub mod pallet {
|
|||||||
#[pallet::weight(T::WeightInfo::force_transfer_native_from_agent())]
|
#[pallet::weight(T::WeightInfo::force_transfer_native_from_agent())]
|
||||||
pub fn force_transfer_native_from_agent(
|
pub fn force_transfer_native_from_agent(
|
||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
location: Box<VersionedMultiLocation>,
|
location: Box<VersionedLocation>,
|
||||||
recipient: H160,
|
recipient: H160,
|
||||||
amount: u128,
|
amount: u128,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
ensure_root(origin)?;
|
ensure_root(origin)?;
|
||||||
|
|
||||||
// Ensure that location is some consensus system on a sibling parachain
|
// Ensure that location is some consensus system on a sibling parachain
|
||||||
let location: MultiLocation =
|
let location: Location =
|
||||||
(*location).try_into().map_err(|_| Error::<T>::UnsupportedLocationVersion)?;
|
(*location).try_into().map_err(|_| Error::<T>::UnsupportedLocationVersion)?;
|
||||||
let (_, agent_id) =
|
let (_, agent_id) =
|
||||||
ensure_sibling::<T>(&location).map_err(|_| Error::<T>::InvalidLocation)?;
|
ensure_sibling::<T>(&location).map_err(|_| Error::<T>::InvalidLocation)?;
|
||||||
@@ -621,8 +621,8 @@ pub mod pallet {
|
|||||||
/// Initializes agents and channels.
|
/// Initializes agents and channels.
|
||||||
pub fn initialize(para_id: ParaId, asset_hub_para_id: ParaId) -> Result<(), DispatchError> {
|
pub fn initialize(para_id: ParaId, asset_hub_para_id: ParaId) -> Result<(), DispatchError> {
|
||||||
// Asset Hub
|
// Asset Hub
|
||||||
let asset_hub_location: MultiLocation =
|
let asset_hub_location: Location =
|
||||||
ParentThen(X1(Parachain(asset_hub_para_id.into()))).into();
|
ParentThen(Parachain(asset_hub_para_id.into()).into()).into();
|
||||||
let asset_hub_agent_id = agent_id_of::<T>(&asset_hub_location)?;
|
let asset_hub_agent_id = agent_id_of::<T>(&asset_hub_location)?;
|
||||||
let asset_hub_channel_id: ChannelId = asset_hub_para_id.into();
|
let asset_hub_channel_id: ChannelId = asset_hub_para_id.into();
|
||||||
Agents::<T>::insert(asset_hub_agent_id, ());
|
Agents::<T>::insert(asset_hub_agent_id, ());
|
||||||
@@ -632,7 +632,7 @@ pub mod pallet {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Governance channels
|
// Governance channels
|
||||||
let bridge_hub_agent_id = agent_id_of::<T>(&MultiLocation::here())?;
|
let bridge_hub_agent_id = agent_id_of::<T>(&Location::here())?;
|
||||||
// Agent for BridgeHub
|
// Agent for BridgeHub
|
||||||
Agents::<T>::insert(bridge_hub_agent_id, ());
|
Agents::<T>::insert(bridge_hub_agent_id, ());
|
||||||
|
|
||||||
|
|||||||
@@ -49,22 +49,22 @@ mod pallet_xcm_origin {
|
|||||||
// Insert this custom Origin into the aggregate RuntimeOrigin
|
// Insert this custom Origin into the aggregate RuntimeOrigin
|
||||||
#[pallet::origin]
|
#[pallet::origin]
|
||||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||||
pub struct Origin(pub MultiLocation);
|
pub struct Origin(pub Location);
|
||||||
|
|
||||||
impl From<MultiLocation> for Origin {
|
impl From<Location> for Origin {
|
||||||
fn from(location: MultiLocation) -> Origin {
|
fn from(location: Location) -> Origin {
|
||||||
Origin(location)
|
Origin(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `EnsureOrigin` implementation succeeding with a `MultiLocation` value to recognize and
|
/// `EnsureOrigin` implementation succeeding with a `Location` value to recognize and
|
||||||
/// filter the contained location
|
/// filter the contained location
|
||||||
pub struct EnsureXcm<F>(PhantomData<F>);
|
pub struct EnsureXcm<F>(PhantomData<F>);
|
||||||
impl<O: OriginTrait + From<Origin>, F: Contains<MultiLocation>> EnsureOrigin<O> for EnsureXcm<F>
|
impl<O: OriginTrait + From<Origin>, F: Contains<Location>> EnsureOrigin<O> for EnsureXcm<F>
|
||||||
where
|
where
|
||||||
O::PalletsOrigin: From<Origin> + TryInto<Origin, Error = O::PalletsOrigin>,
|
O::PalletsOrigin: From<Origin> + TryInto<Origin, Error = O::PalletsOrigin>,
|
||||||
{
|
{
|
||||||
type Success = MultiLocation;
|
type Success = Location;
|
||||||
|
|
||||||
fn try_origin(outer: O) -> Result<Self::Success, O> {
|
fn try_origin(outer: O) -> Result<Self::Success, O> {
|
||||||
outer.try_with_caller(|caller| {
|
outer.try_with_caller(|caller| {
|
||||||
@@ -77,7 +77,7 @@ mod pallet_xcm_origin {
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
fn try_successful_origin() -> Result<O, ()> {
|
fn try_successful_origin() -> Result<O, ()> {
|
||||||
Ok(O::from(Origin(MultiLocation { parents: 1, interior: X1(Parachain(2000)) })))
|
Ok(O::from(Origin(Location::new(1, [Parachain(2000)]))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,9 +186,9 @@ parameter_types! {
|
|||||||
pub const SS58Prefix: u8 = 42;
|
pub const SS58Prefix: u8 = 42;
|
||||||
pub const AnyNetwork: Option<NetworkId> = None;
|
pub const AnyNetwork: Option<NetworkId> = None;
|
||||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
|
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
|
||||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
pub const RelayLocation: Location = Location::parent();
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(1013));
|
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(1013)].into();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DOT: u128 = 10_000_000_000;
|
pub const DOT: u128 = 10_000_000_000;
|
||||||
@@ -211,7 +211,7 @@ parameter_types! {
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
impl BenchmarkHelper<RuntimeOrigin> for () {
|
impl BenchmarkHelper<RuntimeOrigin> for () {
|
||||||
fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
|
fn make_xcm_origin(location: Location) -> RuntimeOrigin {
|
||||||
RuntimeOrigin::from(pallet_xcm_origin::Origin(location))
|
RuntimeOrigin::from(pallet_xcm_origin::Origin(location))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,11 +260,11 @@ pub fn new_test_ext(genesis_build: bool) -> sp_io::TestExternalities {
|
|||||||
|
|
||||||
// Test helpers
|
// Test helpers
|
||||||
|
|
||||||
pub fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
|
pub fn make_xcm_origin(location: Location) -> RuntimeOrigin {
|
||||||
pallet_xcm_origin::Origin(location).into()
|
pallet_xcm_origin::Origin(location).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_agent_id(location: MultiLocation) -> AgentId {
|
pub fn make_agent_id(location: Location) -> AgentId {
|
||||||
<Test as snowbridge_system::Config>::AgentIdOf::convert_location(&location)
|
<Test as snowbridge_system::Config>::AgentIdOf::convert_location(&location)
|
||||||
.expect("convert location")
|
.expect("convert location")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ use sp_runtime::{AccountId32, DispatchError::BadOrigin, TokenError};
|
|||||||
fn create_agent() {
|
fn create_agent() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let agent_id = make_agent_id(origin_location);
|
let agent_id = make_agent_id(origin_location.clone());
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
||||||
|
|
||||||
// fund sovereign account of origin
|
// fund sovereign account of origin
|
||||||
@@ -30,7 +30,7 @@ fn create_agent() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_agent_for_here() {
|
fn test_agent_for_here() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_location = MultiLocation::here();
|
let origin_location = Location::here();
|
||||||
let agent_id = make_agent_id(origin_location);
|
let agent_id = make_agent_id(origin_location);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
agent_id,
|
agent_id,
|
||||||
@@ -42,7 +42,7 @@ fn test_agent_for_here() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn create_agent_fails_on_funds_unavailable() {
|
fn create_agent_fails_on_funds_unavailable() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
|
let origin_location = Location::new(1, [Parachain(2000)]);
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
// Reset balance of sovereign_account to zero so to trigger the FundsUnavailable error
|
// Reset balance of sovereign_account to zero so to trigger the FundsUnavailable error
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(2000.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(2000.into());
|
||||||
@@ -56,19 +56,16 @@ fn create_agent_bad_origin() {
|
|||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
// relay chain location not allowed
|
// relay chain location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::create_agent(make_xcm_origin(MultiLocation {
|
EthereumSystem::create_agent(make_xcm_origin(Location::new(1, [],))),
|
||||||
parents: 1,
|
|
||||||
interior: Here,
|
|
||||||
})),
|
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
);
|
);
|
||||||
|
|
||||||
// local account location not allowed
|
// local account location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::create_agent(make_xcm_origin(MultiLocation {
|
EthereumSystem::create_agent(make_xcm_origin(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
|
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
})),
|
))),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -243,7 +240,7 @@ fn set_token_transfer_fees_invalid() {
|
|||||||
fn create_channel() {
|
fn create_channel() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
|
|
||||||
@@ -259,7 +256,7 @@ fn create_channel() {
|
|||||||
fn create_channel_fail_already_exists() {
|
fn create_channel_fail_already_exists() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
|
|
||||||
@@ -282,7 +279,7 @@ fn create_channel_bad_origin() {
|
|||||||
// relay chain location not allowed
|
// relay chain location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::create_channel(
|
EthereumSystem::create_channel(
|
||||||
make_xcm_origin(MultiLocation { parents: 1, interior: Here }),
|
make_xcm_origin(Location::new(1, [])),
|
||||||
OperatingMode::Normal,
|
OperatingMode::Normal,
|
||||||
),
|
),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
@@ -291,13 +288,10 @@ fn create_channel_bad_origin() {
|
|||||||
// child of sibling location not allowed
|
// child of sibling location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::create_channel(
|
EthereumSystem::create_channel(
|
||||||
make_xcm_origin(MultiLocation {
|
make_xcm_origin(Location::new(
|
||||||
parents: 1,
|
1,
|
||||||
interior: X2(
|
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
Parachain(2000),
|
)),
|
||||||
Junction::AccountId32 { network: None, id: [67u8; 32] }
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
OperatingMode::Normal,
|
OperatingMode::Normal,
|
||||||
),
|
),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
@@ -306,10 +300,10 @@ fn create_channel_bad_origin() {
|
|||||||
// local account location not allowed
|
// local account location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::create_channel(
|
EthereumSystem::create_channel(
|
||||||
make_xcm_origin(MultiLocation {
|
make_xcm_origin(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
|
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
}),
|
)),
|
||||||
OperatingMode::Normal,
|
OperatingMode::Normal,
|
||||||
),
|
),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
@@ -333,7 +327,7 @@ fn create_channel_bad_origin() {
|
|||||||
fn update_channel() {
|
fn update_channel() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
|
|
||||||
@@ -359,23 +353,17 @@ fn update_channel_bad_origin() {
|
|||||||
|
|
||||||
// relay chain location not allowed
|
// relay chain location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::update_channel(
|
EthereumSystem::update_channel(make_xcm_origin(Location::new(1, [])), mode,),
|
||||||
make_xcm_origin(MultiLocation { parents: 1, interior: Here }),
|
|
||||||
mode,
|
|
||||||
),
|
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
);
|
);
|
||||||
|
|
||||||
// child of sibling location not allowed
|
// child of sibling location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::update_channel(
|
EthereumSystem::update_channel(
|
||||||
make_xcm_origin(MultiLocation {
|
make_xcm_origin(Location::new(
|
||||||
parents: 1,
|
1,
|
||||||
interior: X2(
|
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
Parachain(2000),
|
)),
|
||||||
Junction::AccountId32 { network: None, id: [67u8; 32] }
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
mode,
|
mode,
|
||||||
),
|
),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
@@ -384,10 +372,10 @@ fn update_channel_bad_origin() {
|
|||||||
// local account location not allowed
|
// local account location not allowed
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
EthereumSystem::update_channel(
|
EthereumSystem::update_channel(
|
||||||
make_xcm_origin(MultiLocation {
|
make_xcm_origin(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
|
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
}),
|
)),
|
||||||
mode,
|
mode,
|
||||||
),
|
),
|
||||||
BadOrigin,
|
BadOrigin,
|
||||||
@@ -407,7 +395,7 @@ fn update_channel_bad_origin() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn update_channel_fails_not_exist() {
|
fn update_channel_fails_not_exist() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
|
let origin_location = Location::new(1, [Parachain(2000)]);
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
|
|
||||||
// Now try to update it
|
// Now try to update it
|
||||||
@@ -422,7 +410,7 @@ fn update_channel_fails_not_exist() {
|
|||||||
fn force_update_channel() {
|
fn force_update_channel() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_para_id = 2000;
|
let origin_para_id = 2000;
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
|
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location);
|
||||||
|
|
||||||
@@ -468,8 +456,8 @@ fn force_update_channel_bad_origin() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn transfer_native_from_agent() {
|
fn transfer_native_from_agent() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
|
let origin_location = Location::new(1, [Parachain(2000)]);
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location.clone());
|
||||||
let recipient: H160 = [27u8; 20].into();
|
let recipient: H160 = [27u8; 20].into();
|
||||||
let amount = 103435;
|
let amount = 103435;
|
||||||
|
|
||||||
@@ -477,7 +465,7 @@ fn transfer_native_from_agent() {
|
|||||||
assert_ok!(EthereumSystem::create_agent(origin.clone()));
|
assert_ok!(EthereumSystem::create_agent(origin.clone()));
|
||||||
assert_ok!(EthereumSystem::create_channel(origin, OperatingMode::Normal));
|
assert_ok!(EthereumSystem::create_channel(origin, OperatingMode::Normal));
|
||||||
|
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location.clone());
|
||||||
assert_ok!(EthereumSystem::transfer_native_from_agent(origin, recipient, amount),);
|
assert_ok!(EthereumSystem::transfer_native_from_agent(origin, recipient, amount),);
|
||||||
|
|
||||||
System::assert_last_event(RuntimeEvent::EthereumSystem(
|
System::assert_last_event(RuntimeEvent::EthereumSystem(
|
||||||
@@ -494,13 +482,13 @@ fn transfer_native_from_agent() {
|
|||||||
fn force_transfer_native_from_agent() {
|
fn force_transfer_native_from_agent() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let origin = RuntimeOrigin::root();
|
let origin = RuntimeOrigin::root();
|
||||||
let location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
|
let location = Location::new(1, [Parachain(2000)]);
|
||||||
let versioned_location: Box<VersionedMultiLocation> = Box::new(location.into());
|
let versioned_location: Box<VersionedLocation> = Box::new(location.clone().into());
|
||||||
let recipient: H160 = [27u8; 20].into();
|
let recipient: H160 = [27u8; 20].into();
|
||||||
let amount = 103435;
|
let amount = 103435;
|
||||||
|
|
||||||
// First create the agent
|
// First create the agent
|
||||||
Agents::<Test>::insert(make_agent_id(location), ());
|
Agents::<Test>::insert(make_agent_id(location.clone()), ());
|
||||||
|
|
||||||
assert_ok!(EthereumSystem::force_transfer_native_from_agent(
|
assert_ok!(EthereumSystem::force_transfer_native_from_agent(
|
||||||
origin,
|
origin,
|
||||||
@@ -530,13 +518,10 @@ fn force_transfer_native_from_agent_bad_origin() {
|
|||||||
EthereumSystem::force_transfer_native_from_agent(
|
EthereumSystem::force_transfer_native_from_agent(
|
||||||
RuntimeOrigin::signed([14; 32].into()),
|
RuntimeOrigin::signed([14; 32].into()),
|
||||||
Box::new(
|
Box::new(
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 1,
|
1,
|
||||||
interior: X2(
|
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
|
||||||
Parachain(2000),
|
)
|
||||||
Junction::AccountId32 { network: None, id: [67u8; 32] }
|
|
||||||
),
|
|
||||||
}
|
|
||||||
.into()
|
.into()
|
||||||
),
|
),
|
||||||
recipient,
|
recipient,
|
||||||
@@ -571,8 +556,8 @@ fn check_sibling_sovereign_account() {
|
|||||||
fn charge_fee_for_create_agent() {
|
fn charge_fee_for_create_agent() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let para_id: u32 = TestParaId::get();
|
let para_id: u32 = TestParaId::get();
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(para_id)) };
|
let origin_location = Location::new(1, [Parachain(para_id)]);
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location.clone());
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(para_id.into());
|
||||||
let (_, agent_id) = ensure_sibling::<Test>(&origin_location).unwrap();
|
let (_, agent_id) = ensure_sibling::<Test>(&origin_location).unwrap();
|
||||||
|
|
||||||
@@ -605,10 +590,10 @@ fn charge_fee_for_create_agent() {
|
|||||||
fn charge_fee_for_transfer_native_from_agent() {
|
fn charge_fee_for_transfer_native_from_agent() {
|
||||||
new_test_ext(true).execute_with(|| {
|
new_test_ext(true).execute_with(|| {
|
||||||
let para_id: u32 = TestParaId::get();
|
let para_id: u32 = TestParaId::get();
|
||||||
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(para_id)) };
|
let origin_location = Location::new(1, [Parachain(para_id)]);
|
||||||
let recipient: H160 = [27u8; 20].into();
|
let recipient: H160 = [27u8; 20].into();
|
||||||
let amount = 103435;
|
let amount = 103435;
|
||||||
let origin = make_xcm_origin(origin_location);
|
let origin = make_xcm_origin(origin_location.clone());
|
||||||
let (_, agent_id) = ensure_sibling::<Test>(&origin_location).unwrap();
|
let (_, agent_id) = ensure_sibling::<Test>(&origin_location).unwrap();
|
||||||
|
|
||||||
let sovereign_account = sibling_sovereign_account::<Test>(para_id.into());
|
let sovereign_account = sibling_sovereign_account::<Test>(para_id.into());
|
||||||
|
|||||||
@@ -28,11 +28,7 @@ use sp_core::H256;
|
|||||||
use sp_io::hashing::keccak_256;
|
use sp_io::hashing::keccak_256;
|
||||||
use sp_runtime::{traits::AccountIdConversion, RuntimeDebug};
|
use sp_runtime::{traits::AccountIdConversion, RuntimeDebug};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::prelude::{
|
use xcm::prelude::{Junction::Parachain, Location};
|
||||||
Junction::Parachain,
|
|
||||||
Junctions::{Here, X1},
|
|
||||||
MultiLocation,
|
|
||||||
};
|
|
||||||
use xcm_builder::{DescribeAllTerminal, DescribeFamily, DescribeLocation, HashedDescription};
|
use xcm_builder::{DescribeAllTerminal, DescribeFamily, DescribeLocation, HashedDescription};
|
||||||
|
|
||||||
/// The ID of an agent contract
|
/// The ID of an agent contract
|
||||||
@@ -53,9 +49,9 @@ pub fn sibling_sovereign_account_raw(para_id: ParaId) -> [u8; 32] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct AllowSiblingsOnly;
|
pub struct AllowSiblingsOnly;
|
||||||
impl Contains<MultiLocation> for AllowSiblingsOnly {
|
impl Contains<Location> for AllowSiblingsOnly {
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &Location) -> bool {
|
||||||
matches!(location, MultiLocation { parents: 1, interior: X1(Parachain(_)) })
|
matches!(location.unpack(), (1, [Parachain(_)]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +157,14 @@ pub const SECONDARY_GOVERNANCE_CHANNEL: ChannelId =
|
|||||||
|
|
||||||
pub struct DescribeHere;
|
pub struct DescribeHere;
|
||||||
impl DescribeLocation for DescribeHere {
|
impl DescribeLocation for DescribeHere {
|
||||||
fn describe_location(l: &MultiLocation) -> Option<Vec<u8>> {
|
fn describe_location(l: &Location) -> Option<Vec<u8>> {
|
||||||
match (l.parents, l.interior) {
|
match l.unpack() {
|
||||||
(0, Here) => Some(Vec::<u8>::new().encode()),
|
(0, []) => Some(Vec::<u8>::new().encode()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an AgentId from a MultiLocation. An AgentId is a unique mapping to a Agent contract on
|
/// Creates an AgentId from a Location. An AgentId is a unique mapping to a Agent contract on
|
||||||
/// Ethereum which acts as the sovereign account for the MultiLocation.
|
/// Ethereum which acts as the sovereign account for the Location.
|
||||||
pub type AgentIdOf = HashedDescription<H256, (DescribeHere, DescribeFamily<DescribeAllTerminal>)>;
|
pub type AgentIdOf = HashedDescription<H256, (DescribeHere, DescribeFamily<DescribeAllTerminal>)>;
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
mod tests {
|
mod tests {
|
||||||
use frame_support::traits::Contains;
|
use frame_support::traits::Contains;
|
||||||
use snowbridge_core::AllowSiblingsOnly;
|
use snowbridge_core::AllowSiblingsOnly;
|
||||||
use xcm::prelude::{Junction::Parachain, Junctions::X1, MultiLocation};
|
use xcm::prelude::{Junction::Parachain, Location};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn allow_siblings_predicate_only_allows_siblings() {
|
fn allow_siblings_predicate_only_allows_siblings() {
|
||||||
let sibling = MultiLocation::new(1, X1(Parachain(1000)));
|
let sibling = Location::new(1, [Parachain(1000)]);
|
||||||
let child = MultiLocation::new(0, X1(Parachain(1000)));
|
let child = Location::new(0, [Parachain(1000)]);
|
||||||
assert!(AllowSiblingsOnly::contains(&sibling), "Sibling returns true.");
|
assert!(AllowSiblingsOnly::contains(&sibling), "Sibling returns true.");
|
||||||
assert!(!AllowSiblingsOnly::contains(&child), "Child returns false.");
|
assert!(!AllowSiblingsOnly::contains(&child), "Child returns false.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ where
|
|||||||
{
|
{
|
||||||
fn convert_register_token(chain_id: u64, token: H160, fee: u128) -> (Xcm<()>, Balance) {
|
fn convert_register_token(chain_id: u64, token: H160, fee: u128) -> (Xcm<()>, Balance) {
|
||||||
let network = Ethereum { chain_id };
|
let network = Ethereum { chain_id };
|
||||||
let xcm_fee: MultiAsset = (MultiLocation::parent(), fee).into();
|
let xcm_fee: Asset = (Location::parent(), fee).into();
|
||||||
let deposit: MultiAsset = (MultiLocation::parent(), CreateAssetDeposit::get()).into();
|
let deposit: Asset = (Location::parent(), CreateAssetDeposit::get()).into();
|
||||||
|
|
||||||
let total_amount = fee + CreateAssetDeposit::get();
|
let total_amount = fee + CreateAssetDeposit::get();
|
||||||
let total: MultiAsset = (MultiLocation::parent(), total_amount).into();
|
let total: Asset = (Location::parent(), total_amount).into();
|
||||||
|
|
||||||
let bridge_location: MultiLocation = (Parent, Parent, GlobalConsensus(network)).into();
|
let bridge_location: Location = (Parent, Parent, GlobalConsensus(network)).into();
|
||||||
|
|
||||||
let owner = GlobalConsensusEthereumConvertsFor::<[u8; 32]>::from_chain_id(&chain_id);
|
let owner = GlobalConsensusEthereumConvertsFor::<[u8; 32]>::from_chain_id(&chain_id);
|
||||||
let asset_id = Self::convert_token_address(network, token);
|
let asset_id = Self::convert_token_address(network, token);
|
||||||
@@ -182,7 +182,7 @@ where
|
|||||||
// Fund the snowbridge sovereign with the required deposit for creation.
|
// Fund the snowbridge sovereign with the required deposit for creation.
|
||||||
DepositAsset { assets: Definite(deposit.into()), beneficiary: bridge_location },
|
DepositAsset { assets: Definite(deposit.into()), beneficiary: bridge_location },
|
||||||
// Only our inbound-queue pallet is allowed to invoke `UniversalOrigin`
|
// Only our inbound-queue pallet is allowed to invoke `UniversalOrigin`
|
||||||
DescendOrigin(X1(PalletInstance(inbound_queue_pallet_index))),
|
DescendOrigin(PalletInstance(inbound_queue_pallet_index).into()),
|
||||||
// Change origin to the bridge.
|
// Change origin to the bridge.
|
||||||
UniversalOrigin(GlobalConsensus(network)),
|
UniversalOrigin(GlobalConsensus(network)),
|
||||||
// Call create_asset on foreign assets pallet.
|
// Call create_asset on foreign assets pallet.
|
||||||
@@ -216,40 +216,37 @@ where
|
|||||||
asset_hub_fee: u128,
|
asset_hub_fee: u128,
|
||||||
) -> (Xcm<()>, Balance) {
|
) -> (Xcm<()>, Balance) {
|
||||||
let network = Ethereum { chain_id };
|
let network = Ethereum { chain_id };
|
||||||
let asset_hub_fee_asset: MultiAsset = (MultiLocation::parent(), asset_hub_fee).into();
|
let asset_hub_fee_asset: Asset = (Location::parent(), asset_hub_fee).into();
|
||||||
let asset: MultiAsset = (Self::convert_token_address(network, token), amount).into();
|
let asset: Asset = (Self::convert_token_address(network, token), amount).into();
|
||||||
|
|
||||||
let (dest_para_id, beneficiary, dest_para_fee) = match destination {
|
let (dest_para_id, beneficiary, dest_para_fee) = match destination {
|
||||||
// Final destination is a 32-byte account on AssetHub
|
// Final destination is a 32-byte account on AssetHub
|
||||||
Destination::AccountId32 { id } => (
|
Destination::AccountId32 { id } =>
|
||||||
None,
|
(None, Location::new(0, [AccountId32 { network: None, id }]), 0),
|
||||||
MultiLocation { parents: 0, interior: X1(AccountId32 { network: None, id }) },
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
// Final destination is a 32-byte account on a sibling of AssetHub
|
// Final destination is a 32-byte account on a sibling of AssetHub
|
||||||
Destination::ForeignAccountId32 { para_id, id, fee } => (
|
Destination::ForeignAccountId32 { para_id, id, fee } => (
|
||||||
Some(para_id),
|
Some(para_id),
|
||||||
MultiLocation { parents: 0, interior: X1(AccountId32 { network: None, id }) },
|
Location::new(0, [AccountId32 { network: None, id }]),
|
||||||
// Total fee needs to cover execution on AssetHub and Sibling
|
// Total fee needs to cover execution on AssetHub and Sibling
|
||||||
fee,
|
fee,
|
||||||
),
|
),
|
||||||
// Final destination is a 20-byte account on a sibling of AssetHub
|
// Final destination is a 20-byte account on a sibling of AssetHub
|
||||||
Destination::ForeignAccountId20 { para_id, id, fee } => (
|
Destination::ForeignAccountId20 { para_id, id, fee } => (
|
||||||
Some(para_id),
|
Some(para_id),
|
||||||
MultiLocation { parents: 0, interior: X1(AccountKey20 { network: None, key: id }) },
|
Location::new(0, [AccountKey20 { network: None, key: id }]),
|
||||||
// Total fee needs to cover execution on AssetHub and Sibling
|
// Total fee needs to cover execution on AssetHub and Sibling
|
||||||
fee,
|
fee,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let total_fees = asset_hub_fee.saturating_add(dest_para_fee);
|
let total_fees = asset_hub_fee.saturating_add(dest_para_fee);
|
||||||
let total_fee_asset: MultiAsset = (MultiLocation::parent(), total_fees).into();
|
let total_fee_asset: Asset = (Location::parent(), total_fees).into();
|
||||||
let inbound_queue_pallet_index = InboundQueuePalletInstance::get();
|
let inbound_queue_pallet_index = InboundQueuePalletInstance::get();
|
||||||
|
|
||||||
let mut instructions = vec![
|
let mut instructions = vec![
|
||||||
ReceiveTeleportedAsset(total_fee_asset.into()),
|
ReceiveTeleportedAsset(total_fee_asset.into()),
|
||||||
BuyExecution { fees: asset_hub_fee_asset, weight_limit: Unlimited },
|
BuyExecution { fees: asset_hub_fee_asset, weight_limit: Unlimited },
|
||||||
DescendOrigin(X1(PalletInstance(inbound_queue_pallet_index))),
|
DescendOrigin(PalletInstance(inbound_queue_pallet_index).into()),
|
||||||
UniversalOrigin(GlobalConsensus(network)),
|
UniversalOrigin(GlobalConsensus(network)),
|
||||||
ReserveAssetDeposited(asset.clone().into()),
|
ReserveAssetDeposited(asset.clone().into()),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
@@ -257,14 +254,13 @@ where
|
|||||||
|
|
||||||
match dest_para_id {
|
match dest_para_id {
|
||||||
Some(dest_para_id) => {
|
Some(dest_para_id) => {
|
||||||
let dest_para_fee_asset: MultiAsset =
|
let dest_para_fee_asset: Asset = (Location::parent(), dest_para_fee).into();
|
||||||
(MultiLocation::parent(), dest_para_fee).into();
|
|
||||||
|
|
||||||
instructions.extend(vec![
|
instructions.extend(vec![
|
||||||
// Perform a deposit reserve to send to destination chain.
|
// Perform a deposit reserve to send to destination chain.
|
||||||
DepositReserveAsset {
|
DepositReserveAsset {
|
||||||
assets: Definite(vec![dest_para_fee_asset.clone(), asset.clone()].into()),
|
assets: Definite(vec![dest_para_fee_asset.clone(), asset.clone()].into()),
|
||||||
dest: MultiLocation { parents: 1, interior: X1(Parachain(dest_para_id)) },
|
dest: Location::new(1, [Parachain(dest_para_id)]),
|
||||||
xcm: vec![
|
xcm: vec![
|
||||||
// Buy execution on target.
|
// Buy execution on target.
|
||||||
BuyExecution { fees: dest_para_fee_asset, weight_limit: Unlimited },
|
BuyExecution { fees: dest_para_fee_asset, weight_limit: Unlimited },
|
||||||
@@ -286,15 +282,12 @@ where
|
|||||||
(instructions.into(), total_fees.into())
|
(instructions.into(), total_fees.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert ERC20 token address to a Multilocation that can be understood by Assets Hub.
|
// Convert ERC20 token address to a location that can be understood by Assets Hub.
|
||||||
fn convert_token_address(network: NetworkId, token: H160) -> MultiLocation {
|
fn convert_token_address(network: NetworkId, token: H160) -> Location {
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }],
|
||||||
GlobalConsensus(network),
|
)
|
||||||
AccountKey20 { network: None, key: token.into() },
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,12 +296,11 @@ impl<AccountId> ConvertLocation<AccountId> for GlobalConsensusEthereumConvertsFo
|
|||||||
where
|
where
|
||||||
AccountId: From<[u8; 32]> + Clone,
|
AccountId: From<[u8; 32]> + Clone,
|
||||||
{
|
{
|
||||||
fn convert_location(location: &MultiLocation) -> Option<AccountId> {
|
fn convert_location(location: &Location) -> Option<AccountId> {
|
||||||
if let MultiLocation { interior: X1(GlobalConsensus(Ethereum { chain_id })), .. } = location
|
match location.unpack() {
|
||||||
{
|
(_, [GlobalConsensus(Ethereum { chain_id })]) =>
|
||||||
Some(Self::from_chain_id(chain_id).into())
|
Some(Self::from_chain_id(chain_id).into()),
|
||||||
} else {
|
_ => None,
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use super::GlobalConsensusEthereumConvertsFor;
|
|||||||
use crate::inbound::CallIndex;
|
use crate::inbound::CallIndex;
|
||||||
use frame_support::parameter_types;
|
use frame_support::parameter_types;
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use xcm::v3::prelude::*;
|
use xcm::v4::prelude::*;
|
||||||
use xcm_executor::traits::ConvertLocation;
|
use xcm_executor::traits::ConvertLocation;
|
||||||
|
|
||||||
const NETWORK: NetworkId = Ethereum { chain_id: 11155111 };
|
const NETWORK: NetworkId = Ethereum { chain_id: 11155111 };
|
||||||
@@ -20,7 +20,7 @@ parameter_types! {
|
|||||||
fn test_contract_location_with_network_converts_successfully() {
|
fn test_contract_location_with_network_converts_successfully() {
|
||||||
let expected_account: [u8; 32] =
|
let expected_account: [u8; 32] =
|
||||||
hex!("ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d");
|
hex!("ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d");
|
||||||
let contract_location = MultiLocation { parents: 2, interior: X1(GlobalConsensus(NETWORK)) };
|
let contract_location = Location::new(2, [GlobalConsensus(NETWORK)]);
|
||||||
|
|
||||||
let account =
|
let account =
|
||||||
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location)
|
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location)
|
||||||
@@ -31,8 +31,7 @@ fn test_contract_location_with_network_converts_successfully() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_contract_location_with_incorrect_location_fails_convert() {
|
fn test_contract_location_with_incorrect_location_fails_convert() {
|
||||||
let contract_location =
|
let contract_location = Location::new(2, [GlobalConsensus(Polkadot), Parachain(1000)]);
|
||||||
MultiLocation { parents: 2, interior: X2(GlobalConsensus(Polkadot), Parachain(1000)) };
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location),
|
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use snowbridge_core::{
|
|||||||
};
|
};
|
||||||
use sp_core::{H160, H256};
|
use sp_core::{H160, H256};
|
||||||
use sp_std::{iter::Peekable, marker::PhantomData, prelude::*};
|
use sp_std::{iter::Peekable, marker::PhantomData, prelude::*};
|
||||||
use xcm::v3::prelude::*;
|
use xcm::v4::prelude::*;
|
||||||
use xcm_executor::traits::{ConvertLocation, ExportXcm};
|
use xcm_executor::traits::{ConvertLocation, ExportXcm};
|
||||||
|
|
||||||
pub struct EthereumBlobExporter<
|
pub struct EthereumBlobExporter<
|
||||||
@@ -29,7 +29,7 @@ pub struct EthereumBlobExporter<
|
|||||||
impl<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription> ExportXcm
|
impl<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription> ExportXcm
|
||||||
for EthereumBlobExporter<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription>
|
for EthereumBlobExporter<UniversalLocation, EthereumNetwork, OutboundQueue, AgentHashedDescription>
|
||||||
where
|
where
|
||||||
UniversalLocation: Get<InteriorMultiLocation>,
|
UniversalLocation: Get<InteriorLocation>,
|
||||||
EthereumNetwork: Get<NetworkId>,
|
EthereumNetwork: Get<NetworkId>,
|
||||||
OutboundQueue: SendMessage<Balance = u128>,
|
OutboundQueue: SendMessage<Balance = u128>,
|
||||||
AgentHashedDescription: ConvertLocation<H256>,
|
AgentHashedDescription: ConvertLocation<H256>,
|
||||||
@@ -39,8 +39,8 @@ where
|
|||||||
fn validate(
|
fn validate(
|
||||||
network: NetworkId,
|
network: NetworkId,
|
||||||
_channel: u32,
|
_channel: u32,
|
||||||
universal_source: &mut Option<InteriorMultiLocation>,
|
universal_source: &mut Option<InteriorLocation>,
|
||||||
destination: &mut Option<InteriorMultiLocation>,
|
destination: &mut Option<InteriorLocation>,
|
||||||
message: &mut Option<Xcm<()>>,
|
message: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
let expected_network = EthereumNetwork::get();
|
let expected_network = EthereumNetwork::get();
|
||||||
@@ -74,8 +74,8 @@ where
|
|||||||
return Err(SendError::NotApplicable)
|
return Err(SendError::NotApplicable)
|
||||||
}
|
}
|
||||||
|
|
||||||
let para_id = match local_sub {
|
let para_id = match local_sub.as_slice() {
|
||||||
X1(Parachain(para_id)) => para_id,
|
[Parachain(para_id)] => *para_id,
|
||||||
_ => {
|
_ => {
|
||||||
log::error!(target: "xcm::ethereum_blob_exporter", "could not get parachain id from universal source '{local_sub:?}'.");
|
log::error!(target: "xcm::ethereum_blob_exporter", "could not get parachain id from universal source '{local_sub:?}'.");
|
||||||
return Err(SendError::MissingArgument)
|
return Err(SendError::MissingArgument)
|
||||||
@@ -93,7 +93,7 @@ where
|
|||||||
SendError::Unroutable
|
SendError::Unroutable
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let source_location: MultiLocation = MultiLocation { parents: 1, interior: local_sub };
|
let source_location = Location::new(1, local_sub.clone());
|
||||||
let agent_id = match AgentHashedDescription::convert_location(&source_location) {
|
let agent_id = match AgentHashedDescription::convert_location(&source_location) {
|
||||||
Some(id) => id,
|
Some(id) => id,
|
||||||
None => {
|
None => {
|
||||||
@@ -116,8 +116,8 @@ where
|
|||||||
SendError::Unroutable
|
SendError::Unroutable
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// convert fee to MultiAsset
|
// convert fee to Asset
|
||||||
let fee = MultiAsset::from((MultiLocation::parent(), fee.total())).into();
|
let fee = Asset::from((Location::parent(), fee.total())).into();
|
||||||
|
|
||||||
Ok(((ticket.encode(), message_id), fee))
|
Ok(((ticket.encode(), message_id), fee))
|
||||||
}
|
}
|
||||||
@@ -216,8 +216,8 @@ impl<'a, Call> XcmConverter<'a, Call> {
|
|||||||
|
|
||||||
// assert that the beneficiary is AccountKey20.
|
// assert that the beneficiary is AccountKey20.
|
||||||
let recipient = match_expression!(
|
let recipient = match_expression!(
|
||||||
beneficiary,
|
beneficiary.unpack(),
|
||||||
MultiLocation { parents: 0, interior: X1(AccountKey20 { network, key }) }
|
(0, [AccountKey20 { network, key }])
|
||||||
if self.network_matches(network),
|
if self.network_matches(network),
|
||||||
H160(*key)
|
H160(*key)
|
||||||
)
|
)
|
||||||
@@ -245,14 +245,15 @@ impl<'a, Call> XcmConverter<'a, Call> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (token, amount) = match_expression!(
|
let (token, amount) = match reserve_asset {
|
||||||
reserve_asset,
|
Asset { id: AssetId(inner_location), fun: Fungible(amount) } =>
|
||||||
MultiAsset {
|
match inner_location.unpack() {
|
||||||
id: Concrete(MultiLocation { parents: 0, interior: X1(AccountKey20 { network , key })}),
|
(0, [AccountKey20 { network, key }]) if self.network_matches(network) =>
|
||||||
fun: Fungible(amount)
|
Some((H160(*key), *amount)),
|
||||||
} if self.network_matches(network),
|
_ => None,
|
||||||
(H160(*key), *amount)
|
},
|
||||||
)
|
_ => None,
|
||||||
|
}
|
||||||
.ok_or(AssetResolutionFailed)?;
|
.ok_or(AssetResolutionFailed)?;
|
||||||
|
|
||||||
// transfer amount must be greater than 0.
|
// transfer amount must be greater than 0.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use super::*;
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
const MaxMessageSize: u32 = u32::MAX;
|
const MaxMessageSize: u32 = u32::MAX;
|
||||||
const RelayNetwork: NetworkId = Polkadot;
|
const RelayNetwork: NetworkId = Polkadot;
|
||||||
const UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetwork::get()), Parachain(1013));
|
UniversalLocation: InteriorLocation = [GlobalConsensus(RelayNetwork::get()), Parachain(1013)].into();
|
||||||
const BridgedNetwork: NetworkId = Ethereum{ chain_id: 1 };
|
const BridgedNetwork: NetworkId = Ethereum{ chain_id: 1 };
|
||||||
const NonBridgedNetwork: NetworkId = Ethereum{ chain_id: 2 };
|
const NonBridgedNetwork: NetworkId = Ethereum{ chain_id: 2 };
|
||||||
}
|
}
|
||||||
@@ -61,8 +61,8 @@ impl SendMessageFeeProvider for MockErrOutboundQueue {
|
|||||||
fn exporter_validate_with_unknown_network_yields_not_applicable() {
|
fn exporter_validate_with_unknown_network_yields_not_applicable() {
|
||||||
let network = Ethereum { chain_id: 1337 };
|
let network = Ethereum { chain_id: 1337 };
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = None;
|
let mut universal_source: Option<InteriorLocation> = None;
|
||||||
let mut destination: Option<InteriorMultiLocation> = None;
|
let mut destination: Option<InteriorLocation> = None;
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -80,8 +80,8 @@ fn exporter_validate_with_unknown_network_yields_not_applicable() {
|
|||||||
fn exporter_validate_with_invalid_destination_yields_missing_argument() {
|
fn exporter_validate_with_invalid_destination_yields_missing_argument() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = None;
|
let mut universal_source: Option<InteriorLocation> = None;
|
||||||
let mut destination: Option<InteriorMultiLocation> = None;
|
let mut destination: Option<InteriorLocation> = None;
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -99,10 +99,11 @@ fn exporter_validate_with_invalid_destination_yields_missing_argument() {
|
|||||||
fn exporter_validate_with_x8_destination_yields_not_applicable() {
|
fn exporter_validate_with_x8_destination_yields_not_applicable() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = None;
|
let mut universal_source: Option<InteriorLocation> = None;
|
||||||
let mut destination: Option<InteriorMultiLocation> = Some(X8(
|
let mut destination: Option<InteriorLocation> = Some(
|
||||||
OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild,
|
[OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild, OnlyChild]
|
||||||
));
|
.into(),
|
||||||
|
);
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -120,8 +121,8 @@ fn exporter_validate_with_x8_destination_yields_not_applicable() {
|
|||||||
fn exporter_validate_without_universal_source_yields_missing_argument() {
|
fn exporter_validate_without_universal_source_yields_missing_argument() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = None;
|
let mut universal_source: Option<InteriorLocation> = None;
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -139,8 +140,8 @@ fn exporter_validate_without_universal_source_yields_missing_argument() {
|
|||||||
fn exporter_validate_without_global_universal_location_yields_unroutable() {
|
fn exporter_validate_without_global_universal_location_yields_unroutable() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = Here.into();
|
let mut universal_source: Option<InteriorLocation> = Here.into();
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -158,8 +159,8 @@ fn exporter_validate_without_global_universal_location_yields_unroutable() {
|
|||||||
fn exporter_validate_without_global_bridge_location_yields_not_applicable() {
|
fn exporter_validate_without_global_bridge_location_yields_not_applicable() {
|
||||||
let network = NonBridgedNetwork::get();
|
let network = NonBridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = Here.into();
|
let mut universal_source: Option<InteriorLocation> = Here.into();
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -177,9 +178,9 @@ fn exporter_validate_without_global_bridge_location_yields_not_applicable() {
|
|||||||
fn exporter_validate_with_remote_universal_source_yields_not_applicable() {
|
fn exporter_validate_with_remote_universal_source_yields_not_applicable() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X2(GlobalConsensus(Kusama), Parachain(1000)));
|
Some([GlobalConsensus(Kusama), Parachain(1000)].into());
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -197,8 +198,8 @@ fn exporter_validate_with_remote_universal_source_yields_not_applicable() {
|
|||||||
fn exporter_validate_without_para_id_in_source_yields_missing_argument() {
|
fn exporter_validate_without_para_id_in_source_yields_missing_argument() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> = Some(X1(GlobalConsensus(Polkadot)));
|
let mut universal_source: Option<InteriorLocation> = Some(GlobalConsensus(Polkadot).into());
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -216,9 +217,9 @@ fn exporter_validate_without_para_id_in_source_yields_missing_argument() {
|
|||||||
fn exporter_validate_complex_para_id_in_source_yields_missing_argument() {
|
fn exporter_validate_complex_para_id_in_source_yields_missing_argument() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X3(GlobalConsensus(Polkadot), Parachain(1000), PalletInstance(12)));
|
Some([GlobalConsensus(Polkadot), Parachain(1000), PalletInstance(12)].into());
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -236,9 +237,9 @@ fn exporter_validate_complex_para_id_in_source_yields_missing_argument() {
|
|||||||
fn exporter_validate_without_xcm_message_yields_missing_argument() {
|
fn exporter_validate_without_xcm_message_yields_missing_argument() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X2(GlobalConsensus(Polkadot), Parachain(1000)));
|
Some([GlobalConsensus(Polkadot), Parachain(1000)].into());
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
let mut message: Option<Xcm<()>> = None;
|
let mut message: Option<Xcm<()>> = None;
|
||||||
|
|
||||||
let result = EthereumBlobExporter::<
|
let result = EthereumBlobExporter::<
|
||||||
@@ -255,23 +256,23 @@ fn exporter_validate_without_xcm_message_yields_missing_argument() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn exporter_validate_with_max_target_fee_yields_unroutable() {
|
fn exporter_validate_with_max_target_fee_yields_unroutable() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
|
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X2(GlobalConsensus(Polkadot), Parachain(1000)));
|
Some([GlobalConsensus(Polkadot), Parachain(1000)].into());
|
||||||
|
|
||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let fee = MultiAsset { id: Concrete(Here.into()), fun: Fungible(1000) };
|
let fee = Asset { id: AssetId(Here.into()), fun: Fungible(1000) };
|
||||||
let fees: MultiAssets = vec![fee.clone()].into();
|
let fees: Assets = vec![fee.clone()].into();
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let mut message: Option<Xcm<()>> = Some(
|
let mut message: Option<Xcm<()>> = Some(
|
||||||
vec![
|
vec![
|
||||||
@@ -280,7 +281,7 @@ fn exporter_validate_with_max_target_fee_yields_unroutable() {
|
|||||||
WithdrawAsset(assets),
|
WithdrawAsset(assets),
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: Some(network), key: beneficiary_address })
|
beneficiary: AccountKey20 { network: Some(network), key: beneficiary_address }
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
@@ -303,14 +304,14 @@ fn exporter_validate_with_max_target_fee_yields_unroutable() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn exporter_validate_with_unparsable_xcm_yields_unroutable() {
|
fn exporter_validate_with_unparsable_xcm_yields_unroutable() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
|
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X2(GlobalConsensus(Polkadot), Parachain(1000)));
|
Some([GlobalConsensus(Polkadot), Parachain(1000)].into());
|
||||||
|
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let fee = MultiAsset { id: Concrete(Here.into()), fun: Fungible(1000) };
|
let fee = Asset { id: AssetId(Here.into()), fun: Fungible(1000) };
|
||||||
let fees: MultiAssets = vec![fee.clone()].into();
|
let fees: Assets = vec![fee.clone()].into();
|
||||||
|
|
||||||
let mut message: Option<Xcm<()>> =
|
let mut message: Option<Xcm<()>> =
|
||||||
Some(vec![WithdrawAsset(fees), BuyExecution { fees: fee, weight_limit: Unlimited }].into());
|
Some(vec![WithdrawAsset(fees), BuyExecution { fees: fee, weight_limit: Unlimited }].into());
|
||||||
@@ -330,22 +331,22 @@ fn exporter_validate_with_unparsable_xcm_yields_unroutable() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn exporter_validate_xcm_success_case_1() {
|
fn exporter_validate_xcm_success_case_1() {
|
||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
let mut destination: Option<InteriorMultiLocation> = Here.into();
|
let mut destination: Option<InteriorLocation> = Here.into();
|
||||||
|
|
||||||
let mut universal_source: Option<InteriorMultiLocation> =
|
let mut universal_source: Option<InteriorLocation> =
|
||||||
Some(X2(GlobalConsensus(Polkadot), Parachain(1000)));
|
Some([GlobalConsensus(Polkadot), Parachain(1000)].into());
|
||||||
|
|
||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let channel: u32 = 0;
|
let channel: u32 = 0;
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let fee = assets.clone().get(0).unwrap().clone();
|
let fee = assets.clone().get(0).unwrap().clone();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let mut message: Option<Xcm<()>> = Some(
|
let mut message: Option<Xcm<()>> = Some(
|
||||||
vec![
|
vec![
|
||||||
@@ -354,7 +355,7 @@ fn exporter_validate_xcm_success_case_1() {
|
|||||||
BuyExecution { fees: fee, weight_limit: Unlimited },
|
BuyExecution { fees: fee, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -391,12 +392,12 @@ fn xcm_converter_convert_success() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -404,7 +405,7 @@ fn xcm_converter_convert_success() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -426,18 +427,18 @@ fn xcm_converter_convert_without_buy_execution_yields_success() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -459,12 +460,12 @@ fn xcm_converter_convert_with_wildcard_all_asset_filter_succeeds() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(All);
|
let filter: AssetFilter = Wild(All);
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -472,7 +473,7 @@ fn xcm_converter_convert_with_wildcard_all_asset_filter_succeeds() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -494,13 +495,12 @@ fn xcm_converter_convert_with_fees_less_than_reserve_yields_success() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let asset_location = X1(AccountKey20 { network: None, key: token_address }).into();
|
let asset_location: Location = [AccountKey20 { network: None, key: token_address }].into();
|
||||||
let fee_asset = MultiAsset { id: Concrete(asset_location), fun: Fungible(500) };
|
let fee_asset = Asset { id: AssetId(asset_location.clone()), fun: Fungible(500) };
|
||||||
|
|
||||||
let assets: MultiAssets =
|
let assets: Assets = vec![Asset { id: AssetId(asset_location), fun: Fungible(1000) }].into();
|
||||||
vec![MultiAsset { id: Concrete(asset_location), fun: Fungible(1000) }].into();
|
|
||||||
|
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -508,7 +508,7 @@ fn xcm_converter_convert_with_fees_less_than_reserve_yields_success() {
|
|||||||
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -530,19 +530,19 @@ fn xcm_converter_convert_without_set_topic_yields_set_topic_expected() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
ClearTopic,
|
ClearTopic,
|
||||||
]
|
]
|
||||||
@@ -557,8 +557,8 @@ fn xcm_converter_convert_with_partial_message_yields_unexpected_end_of_xcm() {
|
|||||||
let network = BridgedNetwork::get();
|
let network = BridgedNetwork::get();
|
||||||
|
|
||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
@@ -576,16 +576,13 @@ fn xcm_converter_with_different_fee_asset_fails() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let asset_location = X1(AccountKey20 { network: None, key: token_address }).into();
|
let asset_location = [AccountKey20 { network: None, key: token_address }].into();
|
||||||
let fee_asset = MultiAsset {
|
let fee_asset =
|
||||||
id: Concrete(MultiLocation { parents: 0, interior: Here }),
|
Asset { id: AssetId(Location { parents: 0, interior: Here }), fun: Fungible(1000) };
|
||||||
fun: Fungible(1000),
|
|
||||||
};
|
|
||||||
|
|
||||||
let assets: MultiAssets =
|
let assets: Assets = vec![Asset { id: AssetId(asset_location), fun: Fungible(1000) }].into();
|
||||||
vec![MultiAsset { id: Concrete(asset_location), fun: Fungible(1000) }].into();
|
|
||||||
|
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -593,7 +590,7 @@ fn xcm_converter_with_different_fee_asset_fails() {
|
|||||||
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -610,13 +607,12 @@ fn xcm_converter_with_fees_greater_than_reserve_fails() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let asset_location = X1(AccountKey20 { network: None, key: token_address }).into();
|
let asset_location: Location = [AccountKey20 { network: None, key: token_address }].into();
|
||||||
let fee_asset = MultiAsset { id: Concrete(asset_location), fun: Fungible(1001) };
|
let fee_asset = Asset { id: AssetId(asset_location.clone()), fun: Fungible(1001) };
|
||||||
|
|
||||||
let assets: MultiAssets =
|
let assets: Assets = vec![Asset { id: AssetId(asset_location), fun: Fungible(1000) }].into();
|
||||||
vec![MultiAsset { id: Concrete(asset_location), fun: Fungible(1000) }].into();
|
|
||||||
|
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -624,7 +620,7 @@ fn xcm_converter_with_fees_greater_than_reserve_fails() {
|
|||||||
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -653,12 +649,12 @@ fn xcm_converter_convert_with_extra_instructions_yields_end_of_xcm_message_expec
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -666,7 +662,7 @@ fn xcm_converter_convert_with_extra_instructions_yields_end_of_xcm_message_expec
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
ClearError,
|
ClearError,
|
||||||
@@ -685,19 +681,19 @@ fn xcm_converter_convert_without_withdraw_asset_yields_withdraw_expected() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId([AccountKey20 { network: None, key: token_address }].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -714,8 +710,8 @@ fn xcm_converter_convert_without_withdraw_asset_yields_deposit_expected() {
|
|||||||
|
|
||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
@@ -741,11 +737,11 @@ fn xcm_converter_convert_without_assets_yields_no_reserve_assets() {
|
|||||||
|
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![].into();
|
let assets: Assets = vec![].into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let fee = MultiAsset {
|
let fee = Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -755,7 +751,7 @@ fn xcm_converter_convert_without_assets_yields_no_reserve_assets() {
|
|||||||
BuyExecution { fees: fee, weight_limit: Unlimited },
|
BuyExecution { fees: fee, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -774,18 +770,18 @@ fn xcm_converter_convert_with_two_assets_yields_too_many_assets() {
|
|||||||
let token_address_2: [u8; 20] = hex!("1100000000000000000000000000000000000000");
|
let token_address_2: [u8; 20] = hex!("1100000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![
|
let assets: Assets = vec![
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address_1 }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address_1 }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
},
|
},
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address_2 }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address_2 }.into()),
|
||||||
fun: Fungible(500),
|
fun: Fungible(500),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = assets.clone().into();
|
let filter: AssetFilter = assets.clone().into();
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -793,7 +789,7 @@ fn xcm_converter_convert_with_two_assets_yields_too_many_assets() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -811,12 +807,12 @@ fn xcm_converter_convert_without_consuming_filter_yields_filter_does_not_consume
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(0));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(0));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -824,7 +820,7 @@ fn xcm_converter_convert_without_consuming_filter_yields_filter_does_not_consume
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -842,12 +838,12 @@ fn xcm_converter_convert_with_zero_amount_asset_yields_zero_asset_transfer() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(0),
|
fun: Fungible(0),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -855,7 +851,7 @@ fn xcm_converter_convert_with_zero_amount_asset_yields_zero_asset_transfer() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -872,12 +868,12 @@ fn xcm_converter_convert_non_ethereum_asset_yields_asset_resolution_failed() {
|
|||||||
|
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X3(GlobalConsensus(Polkadot), Parachain(1000), GeneralIndex(0)).into()),
|
id: AssetId([GlobalConsensus(Polkadot), Parachain(1000), GeneralIndex(0)].into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -885,7 +881,7 @@ fn xcm_converter_convert_non_ethereum_asset_yields_asset_resolution_failed() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -903,14 +899,14 @@ fn xcm_converter_convert_non_ethereum_chain_asset_yields_asset_resolution_failed
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(
|
id: AssetId(
|
||||||
X1(AccountKey20 { network: Some(Ethereum { chain_id: 2 }), key: token_address }).into(),
|
AccountKey20 { network: Some(Ethereum { chain_id: 2 }), key: token_address }.into(),
|
||||||
),
|
),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -918,7 +914,7 @@ fn xcm_converter_convert_non_ethereum_chain_asset_yields_asset_resolution_failed
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -936,14 +932,14 @@ fn xcm_converter_convert_non_ethereum_chain_yields_asset_resolution_failed() {
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(
|
id: AssetId(
|
||||||
X1(AccountKey20 { network: Some(NonBridgedNetwork::get()), key: token_address }).into(),
|
[AccountKey20 { network: Some(NonBridgedNetwork::get()), key: token_address }].into(),
|
||||||
),
|
),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -951,7 +947,7 @@ fn xcm_converter_convert_non_ethereum_chain_yields_asset_resolution_failed() {
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 { network: None, key: beneficiary_address }).into(),
|
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]
|
]
|
||||||
@@ -971,23 +967,23 @@ fn xcm_converter_convert_with_non_ethereum_beneficiary_yields_beneficiary_resolu
|
|||||||
let beneficiary_address: [u8; 32] =
|
let beneficiary_address: [u8; 32] =
|
||||||
hex!("2000000000000000000000000000000000000000000000000000000000000000");
|
hex!("2000000000000000000000000000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X3(
|
beneficiary: [
|
||||||
GlobalConsensus(Polkadot),
|
GlobalConsensus(Polkadot),
|
||||||
Parachain(1000),
|
Parachain(1000),
|
||||||
AccountId32 { network: Some(Polkadot), id: beneficiary_address },
|
AccountId32 { network: Some(Polkadot), id: beneficiary_address },
|
||||||
)
|
]
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
@@ -1007,12 +1003,12 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_
|
|||||||
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
|
||||||
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");
|
||||||
|
|
||||||
let assets: MultiAssets = vec![MultiAsset {
|
let assets: Assets = vec![Asset {
|
||||||
id: Concrete(X1(AccountKey20 { network: None, key: token_address }).into()),
|
id: AssetId(AccountKey20 { network: None, key: token_address }.into()),
|
||||||
fun: Fungible(1000),
|
fun: Fungible(1000),
|
||||||
}]
|
}]
|
||||||
.into();
|
.into();
|
||||||
let filter: MultiAssetFilter = Wild(WildMultiAsset::AllCounted(1));
|
let filter: AssetFilter = Wild(WildAsset::AllCounted(1));
|
||||||
|
|
||||||
let message: Xcm<()> = vec![
|
let message: Xcm<()> = vec![
|
||||||
WithdrawAsset(assets.clone()),
|
WithdrawAsset(assets.clone()),
|
||||||
@@ -1020,10 +1016,10 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_
|
|||||||
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: filter,
|
assets: filter,
|
||||||
beneficiary: X1(AccountKey20 {
|
beneficiary: AccountKey20 {
|
||||||
network: Some(Ethereum { chain_id: 2 }),
|
network: Some(Ethereum { chain_id: 2 }),
|
||||||
key: beneficiary_address,
|
key: beneficiary_address,
|
||||||
})
|
}
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
@@ -1037,14 +1033,13 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_describe_asset_hub() {
|
fn test_describe_asset_hub() {
|
||||||
let legacy_location: MultiLocation =
|
let legacy_location: Location = Location::new(0, [Parachain(1000)]);
|
||||||
MultiLocation { parents: 0, interior: X1(Parachain(1000)) };
|
|
||||||
let legacy_agent_id = AgentIdOf::convert_location(&legacy_location).unwrap();
|
let legacy_agent_id = AgentIdOf::convert_location(&legacy_location).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
legacy_agent_id,
|
legacy_agent_id,
|
||||||
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4").into()
|
hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4").into()
|
||||||
);
|
);
|
||||||
let location: MultiLocation = MultiLocation { parents: 1, interior: X1(Parachain(1000)) };
|
let location: Location = Location::new(1, [Parachain(1000)]);
|
||||||
let agent_id = AgentIdOf::convert_location(&location).unwrap();
|
let agent_id = AgentIdOf::convert_location(&location).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
agent_id,
|
agent_id,
|
||||||
@@ -1054,7 +1049,7 @@ fn test_describe_asset_hub() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_describe_here() {
|
fn test_describe_here() {
|
||||||
let location: MultiLocation = MultiLocation { parents: 0, interior: Here };
|
let location: Location = Location::new(0, []);
|
||||||
let agent_id = AgentIdOf::convert_location(&location).unwrap();
|
let agent_id = AgentIdOf::convert_location(&location).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
agent_id,
|
agent_id,
|
||||||
|
|||||||
@@ -46,43 +46,38 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
|
|||||||
> where
|
> where
|
||||||
Balance: BaseArithmetic + Unsigned + Copy + From<u128> + Into<u128>,
|
Balance: BaseArithmetic + Unsigned + Copy + From<u128> + Into<u128>,
|
||||||
AccountId: Clone + Into<[u8; 32]> + From<[u8; 32]>,
|
AccountId: Clone + Into<[u8; 32]> + From<[u8; 32]>,
|
||||||
FeeAssetLocation: Get<MultiLocation>,
|
FeeAssetLocation: Get<Location>,
|
||||||
EthereumNetwork: Get<NetworkId>,
|
EthereumNetwork: Get<NetworkId>,
|
||||||
AssetTransactor: TransactAsset,
|
AssetTransactor: TransactAsset,
|
||||||
FeeProvider: SendMessageFeeProvider<Balance = Balance>,
|
FeeProvider: SendMessageFeeProvider<Balance = Balance>,
|
||||||
{
|
{
|
||||||
fn handle_fee(
|
fn handle_fee(fees: Assets, context: Option<&XcmContext>, reason: FeeReason) -> Assets {
|
||||||
fees: MultiAssets,
|
|
||||||
context: Option<&XcmContext>,
|
|
||||||
reason: FeeReason,
|
|
||||||
) -> MultiAssets {
|
|
||||||
let token_location = FeeAssetLocation::get();
|
let token_location = FeeAssetLocation::get();
|
||||||
|
|
||||||
// Check the reason to see if this export is for snowbridge.
|
// Check the reason to see if this export is for snowbridge.
|
||||||
if !matches!(
|
if !matches!(
|
||||||
reason,
|
reason,
|
||||||
FeeReason::Export { network: bridged_network, destination }
|
FeeReason::Export { network: bridged_network, ref destination }
|
||||||
if bridged_network == EthereumNetwork::get() && destination == Here
|
if bridged_network == EthereumNetwork::get() && destination == &Here
|
||||||
) {
|
) {
|
||||||
return fees
|
return fees
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the parachain sovereign from the `context`.
|
// Get the parachain sovereign from the `context`.
|
||||||
let para_sovereign = if let Some(XcmContext {
|
let para_sovereign =
|
||||||
origin: Some(MultiLocation { parents: 1, interior }),
|
if let Some(XcmContext { origin: Some(Location { parents: 1, interior }), .. }) =
|
||||||
..
|
context
|
||||||
}) = context
|
{
|
||||||
{
|
if let Some(Parachain(sibling_para_id)) = interior.first() {
|
||||||
if let Some(Parachain(sibling_para_id)) = interior.first() {
|
let account: AccountId =
|
||||||
let account: AccountId =
|
sibling_sovereign_account_raw((*sibling_para_id).into()).into();
|
||||||
sibling_sovereign_account_raw((*sibling_para_id).into()).into();
|
account
|
||||||
account
|
} else {
|
||||||
|
return fees
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fees
|
return fees
|
||||||
}
|
};
|
||||||
} else {
|
|
||||||
return fees
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get the total fee offered by export message.
|
// Get the total fee offered by export message.
|
||||||
let maybe_total_supplied_fee: Option<(usize, Balance)> = fees
|
let maybe_total_supplied_fee: Option<(usize, Balance)> = fees
|
||||||
@@ -90,8 +85,8 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
|
|||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(index, asset)| {
|
.filter_map(|(index, asset)| {
|
||||||
if let MultiAsset { id: Concrete(location), fun: Fungible(amount) } = asset {
|
if let Asset { id: location, fun: Fungible(amount) } = asset {
|
||||||
if *location == token_location {
|
if location.0 == token_location {
|
||||||
return Some((index, (*amount).into()))
|
return Some((index, (*amount).into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +99,7 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
|
|||||||
if remote_fee > (0u128).into() {
|
if remote_fee > (0u128).into() {
|
||||||
// Refund remote component of fee to physical origin
|
// Refund remote component of fee to physical origin
|
||||||
deposit_or_burn_fee::<AssetTransactor, _>(
|
deposit_or_burn_fee::<AssetTransactor, _>(
|
||||||
MultiAsset { id: Concrete(token_location), fun: Fungible(remote_fee.into()) }
|
Asset { id: AssetId(token_location.clone()), fun: Fungible(remote_fee.into()) }
|
||||||
.into(),
|
.into(),
|
||||||
context,
|
context,
|
||||||
para_sovereign,
|
para_sovereign,
|
||||||
@@ -112,8 +107,8 @@ impl<Balance, AccountId, FeeAssetLocation, EthereumNetwork, AssetTransactor, Fee
|
|||||||
// Return remaining fee to the next fee handler in the chain.
|
// Return remaining fee to the next fee handler in the chain.
|
||||||
let mut modified_fees = fees.inner().clone();
|
let mut modified_fees = fees.inner().clone();
|
||||||
modified_fees.remove(fee_index);
|
modified_fees.remove(fee_index);
|
||||||
modified_fees.push(MultiAsset {
|
modified_fees.push(Asset {
|
||||||
id: Concrete(token_location),
|
id: AssetId(token_location),
|
||||||
fun: Fungible((total_fee - remote_fee).into()),
|
fun: Fungible((total_fee - remote_fee).into()),
|
||||||
});
|
});
|
||||||
return modified_fees.into()
|
return modified_fees.into()
|
||||||
|
|||||||
@@ -49,38 +49,36 @@ where
|
|||||||
+ snowbridge_pallet_outbound_queue::Config,
|
+ snowbridge_pallet_outbound_queue::Config,
|
||||||
XcmConfig: xcm_executor::Config,
|
XcmConfig: xcm_executor::Config,
|
||||||
{
|
{
|
||||||
let assethub_parachain_location = MultiLocation::new(1, Parachain(assethub_parachain_id));
|
let assethub_parachain_location = Location::new(1, Parachain(assethub_parachain_id));
|
||||||
let asset = MultiAsset {
|
let asset = Asset {
|
||||||
id: Concrete(MultiLocation {
|
id: AssetId(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountKey20 { network: None, key: weth_contract_address.into() }),
|
[AccountKey20 { network: None, key: weth_contract_address.into() }],
|
||||||
}),
|
)),
|
||||||
fun: Fungible(1000000000),
|
fun: Fungible(1000000000),
|
||||||
};
|
};
|
||||||
let assets = vec![asset.clone()];
|
let assets = vec![asset.clone()];
|
||||||
|
|
||||||
let inner_xcm = Xcm(vec![
|
let inner_xcm = Xcm(vec![
|
||||||
WithdrawAsset(MultiAssets::from(assets.clone())),
|
WithdrawAsset(Assets::from(assets.clone())),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution { fees: asset, weight_limit: Unlimited },
|
BuyExecution { fees: asset, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: Wild(All),
|
assets: Wild(All),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountKey20 { network: None, key: destination_address.into() }),
|
[AccountKey20 { network: None, key: destination_address.into() }],
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let fee = MultiAsset {
|
let fee =
|
||||||
id: Concrete(MultiLocation { parents: 1, interior: Here }),
|
Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(fee_amount) };
|
||||||
fun: Fungible(fee_amount),
|
|
||||||
};
|
|
||||||
|
|
||||||
// prepare transfer token message
|
// prepare transfer token message
|
||||||
let xcm = Xcm(vec![
|
let xcm = Xcm(vec![
|
||||||
WithdrawAsset(MultiAssets::from(vec![fee.clone()])),
|
WithdrawAsset(Assets::from(vec![fee.clone()])),
|
||||||
BuyExecution { fees: fee, weight_limit: Unlimited },
|
BuyExecution { fees: fee, weight_limit: Unlimited },
|
||||||
ExportMessage {
|
ExportMessage {
|
||||||
network: Ethereum { chain_id: 11155111 },
|
network: Ethereum { chain_id: 11155111 },
|
||||||
@@ -90,12 +88,13 @@ where
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// execute XCM
|
// execute XCM
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
XcmExecutor::<XcmConfig>::execute_xcm(
|
XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
assethub_parachain_location,
|
assethub_parachain_location,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +175,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
|||||||
XcmConfig: xcm_executor::Config,
|
XcmConfig: xcm_executor::Config,
|
||||||
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
ValidatorIdOf<Runtime>: From<AccountIdOf<Runtime>>,
|
||||||
{
|
{
|
||||||
let assethub_parachain_location = MultiLocation::new(1, Parachain(assethub_parachain_id));
|
let assethub_parachain_location = Location::new(1, Parachain(assethub_parachain_id));
|
||||||
|
|
||||||
ExtBuilder::<Runtime>::default()
|
ExtBuilder::<Runtime>::default()
|
||||||
.with_collators(collator_session_key.collators())
|
.with_collators(collator_session_key.collators())
|
||||||
@@ -194,28 +193,25 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let asset = MultiAsset {
|
let asset = Asset {
|
||||||
id: Concrete(MultiLocation {
|
id: AssetId(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountKey20 { network: None, key: weth_contract_address.into() }),
|
[AccountKey20 { network: None, key: weth_contract_address.into() }],
|
||||||
}),
|
)),
|
||||||
fun: Fungible(1000000000),
|
fun: Fungible(1000000000),
|
||||||
};
|
};
|
||||||
let assets = vec![asset.clone()];
|
let assets = vec![asset.clone()];
|
||||||
|
|
||||||
let inner_xcm = Xcm(vec![
|
let inner_xcm = Xcm(vec![
|
||||||
WithdrawAsset(MultiAssets::from(assets.clone())),
|
WithdrawAsset(Assets::from(assets.clone())),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution { fees: asset, weight_limit: Unlimited },
|
BuyExecution { fees: asset, weight_limit: Unlimited },
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: Wild(AllCounted(1)),
|
assets: Wild(AllCounted(1)),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountKey20 {
|
[AccountKey20 { network: None, key: destination_contract.into() }],
|
||||||
network: None,
|
),
|
||||||
key: destination_contract.into(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
SetTopic([0; 32]),
|
SetTopic([0; 32]),
|
||||||
]);
|
]);
|
||||||
@@ -231,12 +227,13 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// execute XCM
|
// execute XCM
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
assethub_parachain_location,
|
assethub_parachain_location,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
// check error is barrier
|
// check error is barrier
|
||||||
assert_err!(outcome.ensure_complete(), Barrier);
|
assert_err!(outcome.ensure_complete(), Barrier);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ pub mod pallet {
|
|||||||
/// The origin that is allowed to resume or suspend the XCMP queue.
|
/// The origin that is allowed to resume or suspend the XCMP queue.
|
||||||
type ControllerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
type ControllerOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||||
|
|
||||||
/// The conversion function used to attempt to convert an XCM `MultiLocation` origin to a
|
/// The conversion function used to attempt to convert an XCM `Location` origin to a
|
||||||
/// superuser origin.
|
/// superuser origin.
|
||||||
type ControllerOriginConverter: ConvertOrigin<Self::RuntimeOrigin>;
|
type ControllerOriginConverter: ConvertOrigin<Self::RuntimeOrigin>;
|
||||||
|
|
||||||
@@ -903,14 +903,14 @@ impl<T: Config> SendXcm for Pallet<T> {
|
|||||||
type Ticket = (ParaId, VersionedXcm<()>);
|
type Ticket = (ParaId, VersionedXcm<()>);
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
dest: &mut Option<MultiLocation>,
|
dest: &mut Option<Location>,
|
||||||
msg: &mut Option<Xcm<()>>,
|
msg: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<(ParaId, VersionedXcm<()>)> {
|
) -> SendResult<(ParaId, VersionedXcm<()>)> {
|
||||||
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
||||||
|
|
||||||
match &d {
|
match d.unpack() {
|
||||||
// An HRMP message for a sibling parachain.
|
// An HRMP message for a sibling parachain.
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
(1, [Parachain(id)]) => {
|
||||||
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
||||||
let id = ParaId::from(*id);
|
let id = ParaId::from(*id);
|
||||||
let price = T::PriceForSiblingDelivery::price_for_delivery(id, &xcm);
|
let price = T::PriceForSiblingDelivery::price_for_delivery(id, &xcm);
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ impl cumulus_pallet_parachain_system::Config for Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
pub const RelayChain: Location = Location::parent();
|
||||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32));
|
pub UniversalLocation: InteriorLocation = [Parachain(1u32)].into();
|
||||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024);
|
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024);
|
||||||
pub const MaxInstructions: u32 = 100;
|
pub const MaxInstructions: u32 = 100;
|
||||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||||
@@ -138,7 +138,7 @@ pub type LocalAssetTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<RelayChain>,
|
IsConcrete<RelayChain>,
|
||||||
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
|
// Do a simple punn to convert an AccountId32 Location into a native chain account ID:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -187,17 +187,14 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
|
|||||||
for SystemParachainAsSuperuser<RuntimeOrigin>
|
for SystemParachainAsSuperuser<RuntimeOrigin>
|
||||||
{
|
{
|
||||||
fn convert_origin(
|
fn convert_origin(
|
||||||
origin: impl Into<MultiLocation>,
|
origin: impl Into<Location>,
|
||||||
kind: OriginKind,
|
kind: OriginKind,
|
||||||
) -> Result<RuntimeOrigin, MultiLocation> {
|
) -> Result<RuntimeOrigin, Location> {
|
||||||
let origin = origin.into();
|
let origin = origin.into();
|
||||||
if kind == OriginKind::Superuser &&
|
if kind == OriginKind::Superuser &&
|
||||||
matches!(
|
matches!(
|
||||||
origin,
|
origin.unpack(),
|
||||||
MultiLocation {
|
(1, [Parachain(id)]) if ParaId::from(*id).is_system(),
|
||||||
parents: 1,
|
|
||||||
interior: X1(Parachain(id)),
|
|
||||||
} if ParaId::from(id).is_system(),
|
|
||||||
) {
|
) {
|
||||||
Ok(RuntimeOrigin::root())
|
Ok(RuntimeOrigin::root())
|
||||||
} else {
|
} else {
|
||||||
@@ -256,7 +253,7 @@ impl<T: OnQueueChanged<ParaId>> EnqueueMessage<ParaId> for EnqueueToLocalStorage
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(RelayChain::get());
|
pub FeeAssetId: AssetId = AssetId(RelayChain::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: Balance = 300_000_000;
|
pub const BaseDeliveryFee: Balance = 300_000_000;
|
||||||
/// The fee per byte
|
/// The fee per byte
|
||||||
|
|||||||
@@ -333,11 +333,11 @@ struct OkFixedXcmHashWithAssertingRequiredInputsSender;
|
|||||||
impl OkFixedXcmHashWithAssertingRequiredInputsSender {
|
impl OkFixedXcmHashWithAssertingRequiredInputsSender {
|
||||||
const FIXED_XCM_HASH: [u8; 32] = [9; 32];
|
const FIXED_XCM_HASH: [u8; 32] = [9; 32];
|
||||||
|
|
||||||
fn fixed_delivery_asset() -> MultiAssets {
|
fn fixed_delivery_asset() -> Assets {
|
||||||
MultiAssets::new()
|
Assets::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expected_delivery_result() -> Result<(XcmHash, MultiAssets), SendError> {
|
fn expected_delivery_result() -> Result<(XcmHash, Assets), SendError> {
|
||||||
Ok((Self::FIXED_XCM_HASH, Self::fixed_delivery_asset()))
|
Ok((Self::FIXED_XCM_HASH, Self::fixed_delivery_asset()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ impl SendXcm for OkFixedXcmHashWithAssertingRequiredInputsSender {
|
|||||||
type Ticket = ();
|
type Ticket = ();
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
destination: &mut Option<MultiLocation>,
|
destination: &mut Option<Location>,
|
||||||
message: &mut Option<Xcm<()>>,
|
message: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
assert!(destination.is_some());
|
assert!(destination.is_some());
|
||||||
@@ -392,8 +392,8 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
|
|||||||
let message = Xcm(vec![Trap(5)]);
|
let message = Xcm(vec![Trap(5)]);
|
||||||
|
|
||||||
// XcmpQueue - check dest/msg is valid
|
// XcmpQueue - check dest/msg is valid
|
||||||
let dest = (Parent, X1(Parachain(5555)));
|
let dest: Location = (Parent, Parachain(5555)).into();
|
||||||
let mut dest_wrapper = Some(dest.into());
|
let mut dest_wrapper = Some(dest.clone());
|
||||||
let mut msg_wrapper = Some(message.clone());
|
let mut msg_wrapper = Some(message.clone());
|
||||||
|
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
@@ -416,7 +416,7 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn xcmp_queue_validate_nested_xcm_works() {
|
fn xcmp_queue_validate_nested_xcm_works() {
|
||||||
let dest = (Parent, X1(Parachain(5555)));
|
let dest = (Parent, Parachain(5555));
|
||||||
// Message that is not too deeply nested:
|
// Message that is not too deeply nested:
|
||||||
let mut good = Xcm(vec![ClearOrigin]);
|
let mut good = Xcm(vec![ClearOrigin]);
|
||||||
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
||||||
@@ -441,7 +441,7 @@ fn xcmp_queue_validate_nested_xcm_works() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn send_xcm_nested_works() {
|
fn send_xcm_nested_works() {
|
||||||
let dest = (Parent, X1(Parachain(HRMP_PARA_ID)));
|
let dest = (Parent, Parachain(HRMP_PARA_ID));
|
||||||
// Message that is not too deeply nested:
|
// Message that is not too deeply nested:
|
||||||
let mut good = Xcm(vec![ClearOrigin]);
|
let mut good = Xcm(vec![ClearOrigin]);
|
||||||
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
||||||
@@ -455,7 +455,7 @@ fn send_xcm_nested_works() {
|
|||||||
XcmpQueue::take_outbound_messages(usize::MAX),
|
XcmpQueue::take_outbound_messages(usize::MAX),
|
||||||
vec![(
|
vec![(
|
||||||
HRMP_PARA_ID.into(),
|
HRMP_PARA_ID.into(),
|
||||||
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::V3(good.clone()))
|
(XcmpMessageFormat::ConcatenatedVersionedXcm, VersionedXcm::V4(good.clone()))
|
||||||
.encode(),
|
.encode(),
|
||||||
)]
|
)]
|
||||||
);
|
);
|
||||||
@@ -474,7 +474,7 @@ fn hrmp_signals_are_prioritized() {
|
|||||||
let message = Xcm(vec![Trap(5)]);
|
let message = Xcm(vec![Trap(5)]);
|
||||||
|
|
||||||
let sibling_para_id = ParaId::from(12345);
|
let sibling_para_id = ParaId::from(12345);
|
||||||
let dest = (Parent, X1(Parachain(sibling_para_id.into())));
|
let dest = (Parent, Parachain(sibling_para_id.into()));
|
||||||
let mut dest_wrapper = Some(dest.into());
|
let mut dest_wrapper = Some(dest.into());
|
||||||
let mut msg_wrapper = Some(message.clone());
|
let mut msg_wrapper = Some(message.clone());
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ fn hrmp_signals_are_prioritized() {
|
|||||||
// Without a signal we get the messages in order:
|
// Without a signal we get the messages in order:
|
||||||
let mut expected_msg = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
let mut expected_msg = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
||||||
for _ in 0..31 {
|
for _ in 0..31 {
|
||||||
expected_msg.extend(VersionedXcm::V3(message.clone()).encode());
|
expected_msg.extend(VersionedXcm::V4(message.clone()).encode());
|
||||||
}
|
}
|
||||||
|
|
||||||
hypothetically!({
|
hypothetically!({
|
||||||
@@ -590,7 +590,7 @@ fn take_first_concatenated_xcm_good_recursion_depth_works() {
|
|||||||
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
|
||||||
good = Xcm(vec![SetAppendix(good)]);
|
good = Xcm(vec![SetAppendix(good)]);
|
||||||
}
|
}
|
||||||
let good = VersionedXcm::V3(good);
|
let good = VersionedXcm::V4(good);
|
||||||
|
|
||||||
let page = good.encode();
|
let page = good.encode();
|
||||||
assert_ok!(XcmpQueue::take_first_concatenated_xcm(&mut &page[..], &mut WeightMeter::new()));
|
assert_ok!(XcmpQueue::take_first_concatenated_xcm(&mut &page[..], &mut WeightMeter::new()));
|
||||||
@@ -603,7 +603,7 @@ fn take_first_concatenated_xcm_good_bad_depth_errors() {
|
|||||||
for _ in 0..MAX_XCM_DECODE_DEPTH {
|
for _ in 0..MAX_XCM_DECODE_DEPTH {
|
||||||
bad = Xcm(vec![SetAppendix(bad)]);
|
bad = Xcm(vec![SetAppendix(bad)]);
|
||||||
}
|
}
|
||||||
let bad = VersionedXcm::V3(bad);
|
let bad = VersionedXcm::V4(bad);
|
||||||
|
|
||||||
let page = bad.encode();
|
let page = bad.encode();
|
||||||
assert_err!(
|
assert_err!(
|
||||||
@@ -699,12 +699,12 @@ fn lazy_migration_noop_when_out_of_weight() {
|
|||||||
fn xcmp_queue_send_xcm_works() {
|
fn xcmp_queue_send_xcm_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
let sibling_para_id = ParaId::from(12345);
|
let sibling_para_id = ParaId::from(12345);
|
||||||
let dest = (Parent, X1(Parachain(sibling_para_id.into()))).into();
|
let dest: Location = (Parent, Parachain(sibling_para_id.into())).into();
|
||||||
let msg = Xcm(vec![ClearOrigin]);
|
let msg = Xcm(vec![ClearOrigin]);
|
||||||
|
|
||||||
// try to send without opened HRMP channel to the sibling_para_id
|
// try to send without opened HRMP channel to the sibling_para_id
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
send_xcm::<XcmpQueue>(dest, msg.clone()),
|
send_xcm::<XcmpQueue>(dest.clone(), msg.clone()),
|
||||||
Err(SendError::Transport("NoChannel")),
|
Err(SendError::Transport("NoChannel")),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -728,7 +728,7 @@ fn xcmp_queue_send_xcm_works() {
|
|||||||
fn xcmp_queue_send_too_big_xcm_fails() {
|
fn xcmp_queue_send_too_big_xcm_fails() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
let sibling_para_id = ParaId::from(12345);
|
let sibling_para_id = ParaId::from(12345);
|
||||||
let dest = (Parent, X1(Parachain(sibling_para_id.into()))).into();
|
let dest = (Parent, Parachain(sibling_para_id.into())).into();
|
||||||
|
|
||||||
let max_message_size = 100_u32;
|
let max_message_size = 100_u32;
|
||||||
|
|
||||||
@@ -774,7 +774,7 @@ fn verify_fee_factor_increase_and_decrease() {
|
|||||||
use sp_runtime::FixedU128;
|
use sp_runtime::FixedU128;
|
||||||
|
|
||||||
let sibling_para_id = ParaId::from(12345);
|
let sibling_para_id = ParaId::from(12345);
|
||||||
let destination = (Parent, Parachain(sibling_para_id.into())).into();
|
let destination: Location = (Parent, Parachain(sibling_para_id.into())).into();
|
||||||
let xcm = Xcm(vec![ClearOrigin; 100]);
|
let xcm = Xcm(vec![ClearOrigin; 100]);
|
||||||
let versioned_xcm = VersionedXcm::from(xcm.clone());
|
let versioned_xcm = VersionedXcm::from(xcm.clone());
|
||||||
let mut xcmp_message = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
let mut xcmp_message = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
||||||
@@ -799,15 +799,15 @@ fn verify_fee_factor_increase_and_decrease() {
|
|||||||
|
|
||||||
// Fee factor is only increased in `send_fragment`, which is called by `send_xcm`.
|
// Fee factor is only increased in `send_fragment`, which is called by `send_xcm`.
|
||||||
// When queue is not congested, fee factor doesn't change.
|
// When queue is not congested, fee factor doesn't change.
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, xcm.clone())); // Size 104
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), xcm.clone())); // Size 104
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, xcm.clone())); // Size 208
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), xcm.clone())); // Size 208
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, xcm.clone())); // Size 312
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), xcm.clone())); // Size 312
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, xcm.clone())); // Size 416
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), xcm.clone())); // Size 416
|
||||||
assert_eq!(DeliveryFeeFactor::<Test>::get(sibling_para_id), initial);
|
assert_eq!(DeliveryFeeFactor::<Test>::get(sibling_para_id), initial);
|
||||||
|
|
||||||
// Sending the message right now is cheap
|
// Sending the message right now is cheap
|
||||||
let (_, delivery_fees) =
|
let (_, delivery_fees) = validate_send::<XcmpQueue>(destination.clone(), xcm.clone())
|
||||||
validate_send::<XcmpQueue>(destination, xcm.clone()).expect("message can be sent; qed");
|
.expect("message can be sent; qed");
|
||||||
let Fungible(delivery_fee_amount) = delivery_fees.inner()[0].fun else {
|
let Fungible(delivery_fee_amount) = delivery_fees.inner()[0].fun else {
|
||||||
unreachable!("asset is fungible; qed");
|
unreachable!("asset is fungible; qed");
|
||||||
};
|
};
|
||||||
@@ -817,18 +817,18 @@ fn verify_fee_factor_increase_and_decrease() {
|
|||||||
|
|
||||||
// When we get to half of `max_total_size`, because `THRESHOLD_FACTOR` is 2,
|
// When we get to half of `max_total_size`, because `THRESHOLD_FACTOR` is 2,
|
||||||
// then the fee factor starts to increase.
|
// then the fee factor starts to increase.
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, xcm.clone())); // Size 520
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), xcm.clone())); // Size 520
|
||||||
assert_eq!(DeliveryFeeFactor::<Test>::get(sibling_para_id), FixedU128::from_float(1.05));
|
assert_eq!(DeliveryFeeFactor::<Test>::get(sibling_para_id), FixedU128::from_float(1.05));
|
||||||
|
|
||||||
for _ in 0..12 {
|
for _ in 0..12 {
|
||||||
// We finish at size 929
|
// We finish at size 929
|
||||||
assert_ok!(send_xcm::<XcmpQueue>(destination, smaller_xcm.clone()));
|
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), smaller_xcm.clone()));
|
||||||
}
|
}
|
||||||
assert!(DeliveryFeeFactor::<Test>::get(sibling_para_id) > FixedU128::from_float(1.88));
|
assert!(DeliveryFeeFactor::<Test>::get(sibling_para_id) > FixedU128::from_float(1.88));
|
||||||
|
|
||||||
// Sending the message right now is expensive
|
// Sending the message right now is expensive
|
||||||
let (_, delivery_fees) =
|
let (_, delivery_fees) = validate_send::<XcmpQueue>(destination.clone(), xcm.clone())
|
||||||
validate_send::<XcmpQueue>(destination, xcm.clone()).expect("message can be sent; qed");
|
.expect("message can be sent; qed");
|
||||||
let Fungible(delivery_fee_amount) = delivery_fees.inner()[0].fun else {
|
let Fungible(delivery_fee_amount) = delivery_fees.inner()[0].fun else {
|
||||||
unreachable!("asset is fungible; qed");
|
unreachable!("asset is fungible; qed");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ use super::{
|
|||||||
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{ConstU32, Everything, Nothing},
|
traits::{ConstU32, Contains, Everything, Nothing},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -25,13 +25,13 @@ use xcm_builder::{
|
|||||||
use xcm_executor::XcmExecutor;
|
use xcm_executor::XcmExecutor;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
pub const RelayLocation: Location = Location::parent();
|
||||||
pub const RelayNetwork: Option<NetworkId> = None;
|
pub const RelayNetwork: Option<NetworkId> = None;
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -50,7 +50,7 @@ pub type LocalAssetTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<RelayLocation>,
|
IsConcrete<RelayLocation>,
|
||||||
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
|
// Do a simple punn to convert an AccountId32 Location into a native chain account ID:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -86,11 +86,11 @@ parameter_types! {
|
|||||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsExecutivePlurality;
|
||||||
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsExecutivePlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { id: BodyId::Executive, .. }]))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Barrier = TrailingSetTopicAsId<
|
pub type Barrier = TrailingSetTopicAsId<
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ use pallet_asset_tx_payment::HandleCredit;
|
|||||||
use sp_runtime::traits::Zero;
|
use sp_runtime::traits::Zero;
|
||||||
use sp_std::{marker::PhantomData, prelude::*};
|
use sp_std::{marker::PhantomData, prelude::*};
|
||||||
use xcm::latest::{
|
use xcm::latest::{
|
||||||
AssetId, Fungibility, Fungibility::Fungible, Junction, Junctions::Here, MultiAsset,
|
Asset, AssetId, Fungibility, Fungibility::Fungible, Junction, Junctions::Here, Location,
|
||||||
MultiLocation, Parent, WeightLimit,
|
Parent, WeightLimit,
|
||||||
};
|
};
|
||||||
use xcm_executor::traits::ConvertLocation;
|
use xcm_executor::traits::ConvertLocation;
|
||||||
|
|
||||||
@@ -113,11 +113,11 @@ where
|
|||||||
|
|
||||||
/// Asset filter that allows all assets from a certain location.
|
/// Asset filter that allows all assets from a certain location.
|
||||||
pub struct AssetsFrom<T>(PhantomData<T>);
|
pub struct AssetsFrom<T>(PhantomData<T>);
|
||||||
impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for AssetsFrom<T> {
|
impl<T: Get<Location>> ContainsPair<Asset, Location> for AssetsFrom<T> {
|
||||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||||
let loc = T::get();
|
let loc = T::get();
|
||||||
&loc == origin &&
|
&loc == origin &&
|
||||||
matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) }
|
matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) }
|
||||||
if asset_loc.match_and_split(&loc).is_some())
|
if asset_loc.match_and_split(&loc).is_some())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ where
|
|||||||
Err(amount) => amount,
|
Err(amount) => amount,
|
||||||
};
|
};
|
||||||
let imbalance = amount.peek();
|
let imbalance = amount.peek();
|
||||||
let root_location: MultiLocation = Here.into();
|
let root_location: Location = Here.into();
|
||||||
let root_account: AccountIdOf<T> =
|
let root_account: AccountIdOf<T> =
|
||||||
match AccountIdConverter::convert_location(&root_location) {
|
match AccountIdConverter::convert_location(&root_location) {
|
||||||
Some(a) => a,
|
Some(a) => a,
|
||||||
@@ -329,13 +329,13 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn assets_from_filters_correctly() {
|
fn assets_from_filters_correctly() {
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub SomeSiblingParachain: MultiLocation = MultiLocation::new(1, X1(Parachain(1234)));
|
pub SomeSiblingParachain: Location = (Parent, Parachain(1234)).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
let asset_location = SomeSiblingParachain::get()
|
let asset_location = SomeSiblingParachain::get()
|
||||||
.pushed_with_interior(GeneralIndex(42))
|
.pushed_with_interior(GeneralIndex(42))
|
||||||
.expect("multilocation will only have 2 junctions; qed");
|
.expect("location will only have 2 junctions; qed");
|
||||||
let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000u128.into() };
|
let asset = Asset { id: AssetId(asset_location), fun: 1_000_000u128.into() };
|
||||||
assert!(
|
assert!(
|
||||||
AssetsFrom::<SomeSiblingParachain>::contains(&asset, &SomeSiblingParachain::get()),
|
AssetsFrom::<SomeSiblingParachain>::contains(&asset, &SomeSiblingParachain::get()),
|
||||||
"AssetsFrom should allow assets from any of its interior locations"
|
"AssetsFrom should allow assets from any of its interior locations"
|
||||||
|
|||||||
@@ -66,37 +66,36 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accepts an asset if it is a native asset from a particular `MultiLocation`.
|
/// Accepts an asset if it is a native asset from a particular `Location`.
|
||||||
pub struct ConcreteNativeAssetFrom<Location>(PhantomData<Location>);
|
pub struct ConcreteNativeAssetFrom<LocationValue>(PhantomData<LocationValue>);
|
||||||
impl<Location: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
impl<LocationValue: Get<Location>> ContainsPair<Asset, Location>
|
||||||
for ConcreteNativeAssetFrom<Location>
|
for ConcreteNativeAssetFrom<LocationValue>
|
||||||
{
|
{
|
||||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||||
log::trace!(target: "xcm::filter_asset_location",
|
log::trace!(target: "xcm::filter_asset_location",
|
||||||
"ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}",
|
"ConcreteNativeAsset asset: {:?}, origin: {:?}, location: {:?}",
|
||||||
asset, origin, Location::get());
|
asset, origin, LocationValue::get());
|
||||||
matches!(asset.id, Concrete(ref id) if id == origin && origin == &Location::get())
|
asset.id.0 == *origin && origin == &LocationValue::get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RelayOrOtherSystemParachains<
|
pub struct RelayOrOtherSystemParachains<
|
||||||
SystemParachainMatcher: Contains<MultiLocation>,
|
SystemParachainMatcher: Contains<Location>,
|
||||||
Runtime: parachain_info::Config,
|
Runtime: parachain_info::Config,
|
||||||
> {
|
> {
|
||||||
_runtime: PhantomData<(SystemParachainMatcher, Runtime)>,
|
_runtime: PhantomData<(SystemParachainMatcher, Runtime)>,
|
||||||
}
|
}
|
||||||
impl<SystemParachainMatcher: Contains<MultiLocation>, Runtime: parachain_info::Config>
|
impl<SystemParachainMatcher: Contains<Location>, Runtime: parachain_info::Config> Contains<Location>
|
||||||
Contains<MultiLocation> for RelayOrOtherSystemParachains<SystemParachainMatcher, Runtime>
|
for RelayOrOtherSystemParachains<SystemParachainMatcher, Runtime>
|
||||||
{
|
{
|
||||||
fn contains(l: &MultiLocation) -> bool {
|
fn contains(l: &Location) -> bool {
|
||||||
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
|
let self_para_id: u32 = parachain_info::Pallet::<Runtime>::get().into();
|
||||||
if let MultiLocation { parents: 0, interior: X1(Parachain(para_id)) } = l {
|
if let (0, [Parachain(para_id)]) = l.unpack() {
|
||||||
if *para_id == self_para_id {
|
if *para_id == self_para_id {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matches!(l, MultiLocation { parents: 1, interior: Here }) ||
|
matches!(l.unpack(), (1, [])) || SystemParachainMatcher::contains(l)
|
||||||
SystemParachainMatcher::contains(l)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,14 +104,12 @@ impl<SystemParachainMatcher: Contains<MultiLocation>, Runtime: parachain_info::C
|
|||||||
/// This structure can only be used at a parachain level. In the Relay Chain, please use
|
/// This structure can only be used at a parachain level. In the Relay Chain, please use
|
||||||
/// the `xcm_builder::IsChildSystemParachain` matcher.
|
/// the `xcm_builder::IsChildSystemParachain` matcher.
|
||||||
pub struct AllSiblingSystemParachains;
|
pub struct AllSiblingSystemParachains;
|
||||||
|
impl Contains<Location> for AllSiblingSystemParachains {
|
||||||
impl Contains<MultiLocation> for AllSiblingSystemParachains {
|
fn contains(l: &Location) -> bool {
|
||||||
fn contains(l: &MultiLocation) -> bool {
|
|
||||||
log::trace!(target: "xcm::contains", "AllSiblingSystemParachains location: {:?}", l);
|
log::trace!(target: "xcm::contains", "AllSiblingSystemParachains location: {:?}", l);
|
||||||
match *l {
|
match l.unpack() {
|
||||||
// System parachain
|
// System parachain
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } =>
|
(1, [Parachain(id)]) => ParaId::from(*id).is_system(),
|
||||||
ParaId::from(id).is_system(),
|
|
||||||
// Everything else
|
// Everything else
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@@ -121,21 +118,20 @@ impl Contains<MultiLocation> for AllSiblingSystemParachains {
|
|||||||
|
|
||||||
/// Accepts an asset if it is a concrete asset from the system (Relay Chain or system parachain).
|
/// Accepts an asset if it is a concrete asset from the system (Relay Chain or system parachain).
|
||||||
pub struct ConcreteAssetFromSystem<AssetLocation>(PhantomData<AssetLocation>);
|
pub struct ConcreteAssetFromSystem<AssetLocation>(PhantomData<AssetLocation>);
|
||||||
impl<AssetLocation: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
impl<AssetLocation: Get<Location>> ContainsPair<Asset, Location>
|
||||||
for ConcreteAssetFromSystem<AssetLocation>
|
for ConcreteAssetFromSystem<AssetLocation>
|
||||||
{
|
{
|
||||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||||
log::trace!(target: "xcm::contains", "ConcreteAssetFromSystem asset: {:?}, origin: {:?}", asset, origin);
|
log::trace!(target: "xcm::contains", "ConcreteAssetFromSystem asset: {:?}, origin: {:?}", asset, origin);
|
||||||
let is_system = match origin {
|
let is_system = match origin.unpack() {
|
||||||
// The Relay Chain
|
// The Relay Chain
|
||||||
MultiLocation { parents: 1, interior: Here } => true,
|
(1, []) => true,
|
||||||
// System parachain
|
// System parachain
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } =>
|
(1, [Parachain(id)]) => ParaId::from(*id).is_system(),
|
||||||
ParaId::from(*id).is_system(),
|
|
||||||
// Others
|
// Others
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
matches!(asset.id, Concrete(id) if id == AssetLocation::get()) && is_system
|
asset.id.0 == AssetLocation::get() && is_system
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,13 +140,9 @@ impl<AssetLocation: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
|||||||
/// This type should only be used within the context of a parachain, since it does not verify that
|
/// This type should only be used within the context of a parachain, since it does not verify that
|
||||||
/// the parent is indeed a Relay Chain.
|
/// the parent is indeed a Relay Chain.
|
||||||
pub struct ParentRelayOrSiblingParachains;
|
pub struct ParentRelayOrSiblingParachains;
|
||||||
impl Contains<MultiLocation> for ParentRelayOrSiblingParachains {
|
impl Contains<Location> for ParentRelayOrSiblingParachains {
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &Location) -> bool {
|
||||||
matches!(
|
matches!(location.unpack(), (1, []) | (1, [Parachain(_)]))
|
||||||
location,
|
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(_)) }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,20 +151,20 @@ mod tests {
|
|||||||
use frame_support::{parameter_types, traits::Contains};
|
use frame_support::{parameter_types, traits::Contains};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
AllSiblingSystemParachains, ConcreteAssetFromSystem, ContainsPair, GeneralIndex, Here,
|
AllSiblingSystemParachains, Asset, ConcreteAssetFromSystem, ContainsPair, GeneralIndex,
|
||||||
MultiAsset, MultiLocation, PalletInstance, Parachain, Parent,
|
Here, Location, PalletInstance, Parachain, Parent,
|
||||||
};
|
};
|
||||||
use polkadot_primitives::LOWEST_PUBLIC_ID;
|
use polkadot_primitives::LOWEST_PUBLIC_ID;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
pub const RelayLocation: Location = Location::parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn concrete_asset_from_relay_works() {
|
fn concrete_asset_from_relay_works() {
|
||||||
let expected_asset: MultiAsset = (Parent, 1000000).into();
|
let expected_asset: Asset = (Parent, 1000000).into();
|
||||||
let expected_origin: MultiLocation = (Parent, Here).into();
|
let expected_origin: Location = (Parent, Here).into();
|
||||||
|
|
||||||
assert!(<ConcreteAssetFromSystem<RelayLocation>>::contains(
|
assert!(<ConcreteAssetFromSystem<RelayLocation>>::contains(
|
||||||
&expected_asset,
|
&expected_asset,
|
||||||
@@ -182,12 +174,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn concrete_asset_from_sibling_system_para_fails_for_wrong_asset() {
|
fn concrete_asset_from_sibling_system_para_fails_for_wrong_asset() {
|
||||||
let unexpected_assets: Vec<MultiAsset> = vec![
|
let unexpected_assets: Vec<Asset> = vec![
|
||||||
(Here, 1000000).into(),
|
(Here, 1000000).into(),
|
||||||
((PalletInstance(50), GeneralIndex(1)), 1000000).into(),
|
((PalletInstance(50), GeneralIndex(1)), 1000000).into(),
|
||||||
((Parent, Parachain(1000), PalletInstance(50), GeneralIndex(1)), 1000000).into(),
|
((Parent, Parachain(1000), PalletInstance(50), GeneralIndex(1)), 1000000).into(),
|
||||||
];
|
];
|
||||||
let expected_origin: MultiLocation = (Parent, Parachain(1000)).into();
|
let expected_origin: Location = (Parent, Parachain(1000)).into();
|
||||||
|
|
||||||
unexpected_assets.iter().for_each(|asset| {
|
unexpected_assets.iter().for_each(|asset| {
|
||||||
assert!(!<ConcreteAssetFromSystem<RelayLocation>>::contains(asset, &expected_origin));
|
assert!(!<ConcreteAssetFromSystem<RelayLocation>>::contains(asset, &expected_origin));
|
||||||
@@ -206,10 +198,10 @@ mod tests {
|
|||||||
(2001, false), // Not a System Parachain
|
(2001, false), // Not a System Parachain
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected_asset: MultiAsset = (Parent, 1000000).into();
|
let expected_asset: Asset = (Parent, 1000000).into();
|
||||||
|
|
||||||
for (para_id, expected_result) in test_data {
|
for (para_id, expected_result) in test_data {
|
||||||
let origin: MultiLocation = (Parent, Parachain(para_id)).into();
|
let origin: Location = (Parent, Parachain(para_id)).into();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_result,
|
expected_result,
|
||||||
<ConcreteAssetFromSystem<RelayLocation>>::contains(&expected_asset, &origin)
|
<ConcreteAssetFromSystem<RelayLocation>>::contains(&expected_asset, &origin)
|
||||||
@@ -220,15 +212,15 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn all_sibling_system_parachains_works() {
|
fn all_sibling_system_parachains_works() {
|
||||||
// system parachain
|
// system parachain
|
||||||
assert!(AllSiblingSystemParachains::contains(&MultiLocation::new(1, X1(Parachain(1)))));
|
assert!(AllSiblingSystemParachains::contains(&Location::new(1, [Parachain(1)])));
|
||||||
// non-system parachain
|
// non-system parachain
|
||||||
assert!(!AllSiblingSystemParachains::contains(&MultiLocation::new(
|
assert!(!AllSiblingSystemParachains::contains(&Location::new(
|
||||||
1,
|
1,
|
||||||
X1(Parachain(LOWEST_PUBLIC_ID.into()))
|
[Parachain(LOWEST_PUBLIC_ID.into())]
|
||||||
)));
|
)));
|
||||||
// when used at relay chain
|
// when used at relay chain
|
||||||
assert!(!AllSiblingSystemParachains::contains(&MultiLocation::new(0, X1(Parachain(1)))));
|
assert!(!AllSiblingSystemParachains::contains(&Location::new(0, [Parachain(1)])));
|
||||||
// when used with non-parachain
|
// when used with non-parachain
|
||||||
assert!(!AllSiblingSystemParachains::contains(&MultiLocation::new(1, X1(OnlyChild))));
|
assert!(!AllSiblingSystemParachains::contains(&Location::new(1, [OnlyChild])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
mod genesis;
|
mod genesis;
|
||||||
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
|
pub use genesis::{genesis, ED, PARA_ID_A, PARA_ID_B};
|
||||||
pub use penpal_runtime::xcm_config::{LocalTeleportableToAssetHub, XcmConfig};
|
pub use penpal_runtime::xcm_config::{
|
||||||
|
LocalTeleportableToAssetHub, LocalTeleportableToAssetHubV3, XcmConfig,
|
||||||
|
};
|
||||||
|
|
||||||
// Substrate
|
// Substrate
|
||||||
use frame_support::traits::OnInitialize;
|
use frame_support::traits::OnInitialize;
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ pub use polkadot_runtime_parachains::{
|
|||||||
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
inclusion::{AggregateMessageOrigin, UmpQueueId},
|
||||||
};
|
};
|
||||||
pub use xcm::{
|
pub use xcm::{
|
||||||
prelude::{MultiLocation, OriginKind, Outcome, VersionedXcm, XcmVersion},
|
prelude::{Location, OriginKind, Outcome, VersionedXcm, XcmVersion},
|
||||||
v3::Error,
|
v3,
|
||||||
|
v4::Error as XcmError,
|
||||||
DoubleEncoded,
|
DoubleEncoded,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ macro_rules! impl_assert_events_helpers_for_relay_chain {
|
|||||||
Self,
|
Self,
|
||||||
vec![
|
vec![
|
||||||
[<$chain RuntimeEvent>]::<N>::XcmPallet(
|
[<$chain RuntimeEvent>]::<N>::XcmPallet(
|
||||||
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) }
|
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete { used: weight } }
|
||||||
) => {
|
) => {
|
||||||
weight: $crate::impls::weight_within_threshold(
|
weight: $crate::impls::weight_within_threshold(
|
||||||
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
||||||
@@ -224,21 +225,21 @@ macro_rules! impl_assert_events_helpers_for_relay_chain {
|
|||||||
/// Asserts a dispatchable is incompletely executed and XCM sent
|
/// Asserts a dispatchable is incompletely executed and XCM sent
|
||||||
pub fn assert_xcm_pallet_attempted_incomplete(
|
pub fn assert_xcm_pallet_attempted_incomplete(
|
||||||
expected_weight: Option<$crate::impls::Weight>,
|
expected_weight: Option<$crate::impls::Weight>,
|
||||||
expected_error: Option<$crate::impls::Error>,
|
expected_error: Option<$crate::impls::XcmError>,
|
||||||
) {
|
) {
|
||||||
$crate::impls::assert_expected_events!(
|
$crate::impls::assert_expected_events!(
|
||||||
Self,
|
Self,
|
||||||
vec![
|
vec![
|
||||||
// Dispatchable is properly executed and XCM message sent
|
// Dispatchable is properly executed and XCM message sent
|
||||||
[<$chain RuntimeEvent>]::<N>::XcmPallet(
|
[<$chain RuntimeEvent>]::<N>::XcmPallet(
|
||||||
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) }
|
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error } }
|
||||||
) => {
|
) => {
|
||||||
weight: $crate::impls::weight_within_threshold(
|
weight: $crate::impls::weight_within_threshold(
|
||||||
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
||||||
expected_weight.unwrap_or(*weight),
|
expected_weight.unwrap_or(*weight),
|
||||||
*weight
|
*weight
|
||||||
),
|
),
|
||||||
error: *error == expected_error.unwrap_or(*error),
|
error: *error == expected_error.unwrap_or((*error).into()).into(),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -365,7 +366,7 @@ macro_rules! impl_send_transact_helpers_for_relay_chain {
|
|||||||
|
|
||||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||||
let root_origin = <Self as Chain>::RuntimeOrigin::root();
|
let root_origin = <Self as Chain>::RuntimeOrigin::root();
|
||||||
let destination: $crate::impls::MultiLocation = <Self as RelayChain>::child_location_of(recipient);
|
let destination: $crate::impls::Location = <Self as RelayChain>::child_location_of(recipient);
|
||||||
let xcm = $crate::impls::xcm_transact_unpaid_execution(call, $crate::impls::OriginKind::Superuser);
|
let xcm = $crate::impls::xcm_transact_unpaid_execution(call, $crate::impls::OriginKind::Superuser);
|
||||||
|
|
||||||
// Send XCM `Transact`
|
// Send XCM `Transact`
|
||||||
@@ -416,13 +417,13 @@ macro_rules! impl_accounts_helpers_for_parachain {
|
|||||||
network_id: $crate::impls::NetworkId,
|
network_id: $crate::impls::NetworkId,
|
||||||
para_id: $crate::impls::ParaId,
|
para_id: $crate::impls::ParaId,
|
||||||
) -> $crate::impls::AccountId {
|
) -> $crate::impls::AccountId {
|
||||||
let remote_location = $crate::impls::MultiLocation {
|
let remote_location = $crate::impls::Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: $crate::impls::Junctions::X2(
|
[
|
||||||
$crate::impls::Junction::GlobalConsensus(network_id),
|
$crate::impls::Junction::GlobalConsensus(network_id),
|
||||||
$crate::impls::Junction::Parachain(para_id.into()),
|
$crate::impls::Junction::Parachain(para_id.into()),
|
||||||
),
|
],
|
||||||
};
|
);
|
||||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||||
Self::sovereign_account_id_of(remote_location)
|
Self::sovereign_account_id_of(remote_location)
|
||||||
})
|
})
|
||||||
@@ -445,7 +446,7 @@ macro_rules! impl_assert_events_helpers_for_parachain {
|
|||||||
Self,
|
Self,
|
||||||
vec![
|
vec![
|
||||||
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
||||||
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete(weight) }
|
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Complete { used: weight } }
|
||||||
) => {
|
) => {
|
||||||
weight: $crate::impls::weight_within_threshold(
|
weight: $crate::impls::weight_within_threshold(
|
||||||
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
||||||
@@ -460,36 +461,36 @@ macro_rules! impl_assert_events_helpers_for_parachain {
|
|||||||
/// Asserts a dispatchable is incompletely executed and XCM sent
|
/// Asserts a dispatchable is incompletely executed and XCM sent
|
||||||
pub fn assert_xcm_pallet_attempted_incomplete(
|
pub fn assert_xcm_pallet_attempted_incomplete(
|
||||||
expected_weight: Option<$crate::impls::Weight>,
|
expected_weight: Option<$crate::impls::Weight>,
|
||||||
expected_error: Option<$crate::impls::Error>,
|
expected_error: Option<$crate::impls::XcmError>,
|
||||||
) {
|
) {
|
||||||
$crate::impls::assert_expected_events!(
|
$crate::impls::assert_expected_events!(
|
||||||
Self,
|
Self,
|
||||||
vec![
|
vec![
|
||||||
// Dispatchable is properly executed and XCM message sent
|
// Dispatchable is properly executed and XCM message sent
|
||||||
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
||||||
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete(weight, error) }
|
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Incomplete { used: weight, error } }
|
||||||
) => {
|
) => {
|
||||||
weight: $crate::impls::weight_within_threshold(
|
weight: $crate::impls::weight_within_threshold(
|
||||||
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
($crate::impls::REF_TIME_THRESHOLD, $crate::impls::PROOF_SIZE_THRESHOLD),
|
||||||
expected_weight.unwrap_or(*weight),
|
expected_weight.unwrap_or(*weight),
|
||||||
*weight
|
*weight
|
||||||
),
|
),
|
||||||
error: *error == expected_error.unwrap_or(*error),
|
error: *error == expected_error.unwrap_or((*error).into()).into(),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Asserts a dispatchable throws and error when trying to be sent
|
/// Asserts a dispatchable throws and error when trying to be sent
|
||||||
pub fn assert_xcm_pallet_attempted_error(expected_error: Option<$crate::impls::Error>) {
|
pub fn assert_xcm_pallet_attempted_error(expected_error: Option<$crate::impls::XcmError>) {
|
||||||
$crate::impls::assert_expected_events!(
|
$crate::impls::assert_expected_events!(
|
||||||
Self,
|
Self,
|
||||||
vec![
|
vec![
|
||||||
// Execution fails in the origin with `Barrier`
|
// Execution fails in the origin with `Barrier`
|
||||||
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
[<$chain RuntimeEvent>]::<N>::PolkadotXcm(
|
||||||
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error(error) }
|
$crate::impls::pallet_xcm::Event::Attempted { outcome: $crate::impls::Outcome::Error { error } }
|
||||||
) => {
|
) => {
|
||||||
error: *error == expected_error.unwrap_or(*error),
|
error: *error == expected_error.unwrap_or((*error).into()).into(),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -639,7 +640,7 @@ macro_rules! impl_assets_helpers_for_parachain {
|
|||||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||||
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::Assets::mint(
|
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::Assets::mint(
|
||||||
signed_origin,
|
signed_origin,
|
||||||
id.into(),
|
id.clone().into(),
|
||||||
beneficiary.clone().into(),
|
beneficiary.clone().into(),
|
||||||
amount_to_mint
|
amount_to_mint
|
||||||
));
|
));
|
||||||
@@ -717,7 +718,7 @@ macro_rules! impl_assets_helpers_for_parachain {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(id.into()));
|
assert!(<Self as [<$chain ParaPallet>]>::Assets::asset_exists(id.clone().into()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -732,7 +733,7 @@ macro_rules! impl_foreign_assets_helpers_for_parachain {
|
|||||||
impl<N: $crate::impls::Network> $chain<N> {
|
impl<N: $crate::impls::Network> $chain<N> {
|
||||||
/// Create foreign assets using sudo `ForeignAssets::force_create()`
|
/// Create foreign assets using sudo `ForeignAssets::force_create()`
|
||||||
pub fn force_create_foreign_asset(
|
pub fn force_create_foreign_asset(
|
||||||
id: $crate::impls::MultiLocation,
|
id: $crate::impls::v3::Location,
|
||||||
owner: $crate::impls::AccountId,
|
owner: $crate::impls::AccountId,
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
min_balance: u128,
|
min_balance: u128,
|
||||||
@@ -744,13 +745,13 @@ macro_rules! impl_foreign_assets_helpers_for_parachain {
|
|||||||
$crate::impls::assert_ok!(
|
$crate::impls::assert_ok!(
|
||||||
<Self as [<$chain ParaPallet>]>::ForeignAssets::force_create(
|
<Self as [<$chain ParaPallet>]>::ForeignAssets::force_create(
|
||||||
sudo_origin,
|
sudo_origin,
|
||||||
id,
|
id.clone(),
|
||||||
owner.clone().into(),
|
owner.clone().into(),
|
||||||
is_sufficient,
|
is_sufficient,
|
||||||
min_balance,
|
min_balance,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(id));
|
assert!(<Self as [<$chain ParaPallet>]>::ForeignAssets::asset_exists(id.clone()));
|
||||||
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
type RuntimeEvent<N> = <$chain<N> as $crate::impls::Chain>::RuntimeEvent;
|
||||||
$crate::impls::assert_expected_events!(
|
$crate::impls::assert_expected_events!(
|
||||||
Self,
|
Self,
|
||||||
@@ -767,21 +768,21 @@ macro_rules! impl_foreign_assets_helpers_for_parachain {
|
|||||||
for (beneficiary, amount) in prefund_accounts.into_iter() {
|
for (beneficiary, amount) in prefund_accounts.into_iter() {
|
||||||
let signed_origin =
|
let signed_origin =
|
||||||
<$chain<N> as $crate::impls::Chain>::RuntimeOrigin::signed(owner.clone());
|
<$chain<N> as $crate::impls::Chain>::RuntimeOrigin::signed(owner.clone());
|
||||||
Self::mint_foreign_asset(signed_origin, id, beneficiary, amount);
|
Self::mint_foreign_asset(signed_origin, id.clone(), beneficiary, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mint assets making use of the ForeignAssets pallet-assets instance
|
/// Mint assets making use of the ForeignAssets pallet-assets instance
|
||||||
pub fn mint_foreign_asset(
|
pub fn mint_foreign_asset(
|
||||||
signed_origin: <Self as $crate::impls::Chain>::RuntimeOrigin,
|
signed_origin: <Self as $crate::impls::Chain>::RuntimeOrigin,
|
||||||
id: $crate::impls::MultiLocation,
|
id: $crate::impls::v3::Location,
|
||||||
beneficiary: $crate::impls::AccountId,
|
beneficiary: $crate::impls::AccountId,
|
||||||
amount_to_mint: u128,
|
amount_to_mint: u128,
|
||||||
) {
|
) {
|
||||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||||
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::ForeignAssets::mint(
|
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::ForeignAssets::mint(
|
||||||
signed_origin,
|
signed_origin,
|
||||||
id.into(),
|
id.clone().into(),
|
||||||
beneficiary.clone().into(),
|
beneficiary.clone().into(),
|
||||||
amount_to_mint
|
amount_to_mint
|
||||||
));
|
));
|
||||||
@@ -813,7 +814,7 @@ macro_rules! impl_xcm_helpers_for_parachain {
|
|||||||
$crate::impls::paste::paste! {
|
$crate::impls::paste::paste! {
|
||||||
impl<N: $crate::impls::Network> $chain<N> {
|
impl<N: $crate::impls::Network> $chain<N> {
|
||||||
/// Set XCM version for destination.
|
/// Set XCM version for destination.
|
||||||
pub fn force_xcm_version(dest: $crate::impls::MultiLocation, version: $crate::impls::XcmVersion) {
|
pub fn force_xcm_version(dest: $crate::impls::Location, version: $crate::impls::XcmVersion) {
|
||||||
<Self as $crate::impls::TestExt>::execute_with(|| {
|
<Self as $crate::impls::TestExt>::execute_with(|| {
|
||||||
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::PolkadotXcm::force_xcm_version(
|
$crate::impls::assert_ok!(<Self as [<$chain ParaPallet>]>::PolkadotXcm::force_xcm_version(
|
||||||
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
|
<Self as $crate::impls::Chain>::RuntimeOrigin::root(),
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy;
|
|||||||
|
|
||||||
pub const XCM_V2: u32 = 2;
|
pub const XCM_V2: u32 = 2;
|
||||||
pub const XCM_V3: u32 = 3;
|
pub const XCM_V3: u32 = 3;
|
||||||
|
pub const XCM_V4: u32 = 4;
|
||||||
pub const REF_TIME_THRESHOLD: u64 = 33;
|
pub const REF_TIME_THRESHOLD: u64 = 33;
|
||||||
pub const PROOF_SIZE_THRESHOLD: u64 = 33;
|
pub const PROOF_SIZE_THRESHOLD: u64 = 33;
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ macro_rules! test_parachain_is_trusted_teleporter {
|
|||||||
<$receiver_para as $crate::macros::Chain>::account_data_of(receiver.clone()).free;
|
<$receiver_para as $crate::macros::Chain>::account_data_of(receiver.clone()).free;
|
||||||
let para_destination =
|
let para_destination =
|
||||||
<$sender_para>::sibling_location_of(<$receiver_para>::para_id());
|
<$sender_para>::sibling_location_of(<$receiver_para>::para_id());
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
$crate::macros::AccountId32 { network: None, id: receiver.clone().into() }.into();
|
$crate::macros::AccountId32 { network: None, id: receiver.clone().into() }.into();
|
||||||
|
|
||||||
// Send XCM message from Origin Parachain
|
// Send XCM message from Origin Parachain
|
||||||
@@ -57,8 +57,8 @@ macro_rules! test_parachain_is_trusted_teleporter {
|
|||||||
<$sender_para>::execute_with(|| {
|
<$sender_para>::execute_with(|| {
|
||||||
assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets(
|
assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::limited_teleport_assets(
|
||||||
origin.clone(),
|
origin.clone(),
|
||||||
bx!(para_destination.into()),
|
bx!(para_destination.clone().into()),
|
||||||
bx!(beneficiary.into()),
|
bx!(beneficiary.clone().into()),
|
||||||
bx!($assets.clone().into()),
|
bx!($assets.clone().into()),
|
||||||
fee_asset_item,
|
fee_asset_item,
|
||||||
weight_limit.clone(),
|
weight_limit.clone(),
|
||||||
@@ -127,8 +127,8 @@ macro_rules! include_penpal_create_foreign_asset_on_asset_hub {
|
|||||||
$crate::impls::paste::paste! {
|
$crate::impls::paste::paste! {
|
||||||
pub fn penpal_create_foreign_asset_on_asset_hub(
|
pub fn penpal_create_foreign_asset_on_asset_hub(
|
||||||
asset_id_on_penpal: u32,
|
asset_id_on_penpal: u32,
|
||||||
foreign_asset_at_asset_hub: MultiLocation,
|
foreign_asset_at_asset_hub: v3::Location,
|
||||||
ah_as_seen_by_penpal: MultiLocation,
|
ah_as_seen_by_penpal: Location,
|
||||||
is_sufficient: bool,
|
is_sufficient: bool,
|
||||||
asset_owner: AccountId,
|
asset_owner: AccountId,
|
||||||
prefund_amount: u128,
|
prefund_amount: u128,
|
||||||
@@ -144,14 +144,14 @@ macro_rules! include_penpal_create_foreign_asset_on_asset_hub {
|
|||||||
// prefund SA of Penpal on AssetHub with enough native tokens to pay for creating
|
// prefund SA of Penpal on AssetHub with enough native tokens to pay for creating
|
||||||
// new foreign asset, also prefund CheckingAccount with ED, because teleported asset
|
// new foreign asset, also prefund CheckingAccount with ED, because teleported asset
|
||||||
// itself might not be sufficient and CheckingAccount cannot be created otherwise
|
// itself might not be sufficient and CheckingAccount cannot be created otherwise
|
||||||
let sov_penpal_on_ah = $asset_hub::sovereign_account_id_of(penpal_as_seen_by_ah);
|
let sov_penpal_on_ah = $asset_hub::sovereign_account_id_of(penpal_as_seen_by_ah.clone());
|
||||||
$asset_hub::fund_accounts(vec![
|
$asset_hub::fund_accounts(vec![
|
||||||
(sov_penpal_on_ah.clone().into(), $relay_ed * 100_000_000_000),
|
(sov_penpal_on_ah.clone().into(), $relay_ed * 100_000_000_000),
|
||||||
(ah_check_account.clone().into(), $relay_ed * 1000),
|
(ah_check_account.clone().into(), $relay_ed * 1000),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// prefund SA of AssetHub on Penpal with native asset
|
// prefund SA of AssetHub on Penpal with native asset
|
||||||
let sov_ah_on_penpal = $penpal::sovereign_account_id_of(ah_as_seen_by_penpal);
|
let sov_ah_on_penpal = $penpal::sovereign_account_id_of(ah_as_seen_by_penpal.clone());
|
||||||
$penpal::fund_accounts(vec![
|
$penpal::fund_accounts(vec![
|
||||||
(sov_ah_on_penpal.into(), $relay_ed * 1_000_000_000),
|
(sov_ah_on_penpal.into(), $relay_ed * 1_000_000_000),
|
||||||
(penpal_check_account.clone().into(), $relay_ed * 1000),
|
(penpal_check_account.clone().into(), $relay_ed * 1000),
|
||||||
@@ -183,8 +183,8 @@ macro_rules! include_penpal_create_foreign_asset_on_asset_hub {
|
|||||||
let buy_execution_fee_amount = $weight_to_fee::weight_to_fee(
|
let buy_execution_fee_amount = $weight_to_fee::weight_to_fee(
|
||||||
&Weight::from_parts(10_100_000_000_000, 300_000),
|
&Weight::from_parts(10_100_000_000_000, 300_000),
|
||||||
);
|
);
|
||||||
let buy_execution_fee = MultiAsset {
|
let buy_execution_fee = Asset {
|
||||||
id: Concrete(MultiLocation { parents: 1, interior: Here }),
|
id: AssetId(Location { parents: 1, interior: Here }),
|
||||||
fun: Fungible(buy_execution_fee_amount),
|
fun: Fungible(buy_execution_fee_amount),
|
||||||
};
|
};
|
||||||
let xcm = VersionedXcm::from(Xcm(vec![
|
let xcm = VersionedXcm::from(Xcm(vec![
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ use xcm::{prelude::*, DoubleEncoded};
|
|||||||
pub fn xcm_transact_paid_execution(
|
pub fn xcm_transact_paid_execution(
|
||||||
call: DoubleEncoded<()>,
|
call: DoubleEncoded<()>,
|
||||||
origin_kind: OriginKind,
|
origin_kind: OriginKind,
|
||||||
native_asset: MultiAsset,
|
native_asset: Asset,
|
||||||
beneficiary: AccountId,
|
beneficiary: AccountId,
|
||||||
) -> VersionedXcm<()> {
|
) -> VersionedXcm<()> {
|
||||||
let weight_limit = WeightLimit::Unlimited;
|
let weight_limit = WeightLimit::Unlimited;
|
||||||
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
|
let require_weight_at_most = Weight::from_parts(1000000000, 200000);
|
||||||
let native_assets: MultiAssets = native_asset.clone().into();
|
let native_assets: Assets = native_asset.clone().into();
|
||||||
|
|
||||||
VersionedXcm::from(Xcm(vec![
|
VersionedXcm::from(Xcm(vec![
|
||||||
WithdrawAsset(native_assets),
|
WithdrawAsset(native_assets),
|
||||||
@@ -37,9 +37,9 @@ pub fn xcm_transact_paid_execution(
|
|||||||
RefundSurplus,
|
RefundSurplus,
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: All.into(),
|
assets: All.into(),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 { network: None, id: beneficiary.into() }),
|
interior: [AccountId32 { network: None, id: beneficiary.into() }].into(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]))
|
]))
|
||||||
@@ -61,15 +61,11 @@ pub fn xcm_transact_unpaid_execution(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper method to get the non-fee asset used in multiple assets transfer
|
/// Helper method to get the non-fee asset used in multiple assets transfer
|
||||||
pub fn non_fee_asset(assets: &MultiAssets, fee_idx: usize) -> Option<(MultiLocation, u128)> {
|
pub fn non_fee_asset(assets: &Assets, fee_idx: usize) -> Option<(Location, u128)> {
|
||||||
let asset = assets.inner().into_iter().enumerate().find(|a| a.0 != fee_idx)?.1.clone();
|
let asset = assets.inner().into_iter().enumerate().find(|a| a.0 != fee_idx)?.1.clone();
|
||||||
let asset_id = match asset.id {
|
|
||||||
Concrete(id) => id,
|
|
||||||
_ => return None,
|
|
||||||
};
|
|
||||||
let asset_amount = match asset.fun {
|
let asset_amount = match asset.fun {
|
||||||
Fungible(amount) => amount,
|
Fungible(amount) => amount,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some((asset_id, asset_amount))
|
Some((asset.id.0, asset_amount))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ pub use frame_support::{
|
|||||||
// Polkadot
|
// Polkadot
|
||||||
pub use xcm::{
|
pub use xcm::{
|
||||||
prelude::{AccountId32 as AccountId32Junction, *},
|
prelude::{AccountId32 as AccountId32Junction, *},
|
||||||
v3::{Error, NetworkId::Rococo as RococoId},
|
v3::{self, Error, NetworkId::Rococo as RococoId},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cumulus
|
// Cumulus
|
||||||
|
|||||||
+9
-9
@@ -30,7 +30,7 @@ fn relay_to_para_sender_assertions(t: RelayToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == Rococo::sovereign_account_id_of(
|
to: *to == Rococo::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
amount: *amount == t.args.amount,
|
||||||
},
|
},
|
||||||
@@ -53,7 +53,7 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
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,
|
asset_id: *asset_id == ASSET_ID,
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
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() {
|
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
|
||||||
let signed_origin = <Rococo as Chain>::RuntimeOrigin::signed(RococoSender::get().into());
|
let signed_origin = <Rococo as Chain>::RuntimeOrigin::signed(RococoSender::get().into());
|
||||||
let destination = Rococo::child_location_of(AssetHubRococo::para_id());
|
let destination = Rococo::child_location_of(AssetHubRococo::para_id());
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
|
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
|
||||||
let amount_to_send: Balance = ROCOCO_ED * 1000;
|
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;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
// this should fail
|
// 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());
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
|
||||||
let destination = AssetHubRococo::parent_location();
|
let destination = AssetHubRococo::parent_location();
|
||||||
let beneficiary_id = RococoReceiver::get();
|
let beneficiary_id = RococoReceiver::get();
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
||||||
let amount_to_send: Balance = ASSET_HUB_ROCOCO_ED * 1000;
|
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;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
// this should fail
|
// this should fail
|
||||||
@@ -418,9 +418,9 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
|||||||
let beneficiary_id = PenpalAReceiver::get();
|
let beneficiary_id = PenpalAReceiver::get();
|
||||||
let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000;
|
let fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 1000;
|
||||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||||
let assets: MultiAssets = vec![
|
let assets: Assets = vec![
|
||||||
(Parent, fee_amount_to_send).into(),
|
(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(),
|
||||||
]
|
]
|
||||||
.into();
|
.into();
|
||||||
|
|||||||
+3
-4
@@ -19,14 +19,13 @@ use crate::*;
|
|||||||
fn relay_sets_system_para_xcm_supported_version() {
|
fn relay_sets_system_para_xcm_supported_version() {
|
||||||
// Init tests variables
|
// Init tests variables
|
||||||
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
|
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
|
||||||
let system_para_destination: MultiLocation =
|
let system_para_destination: Location = Rococo::child_location_of(AssetHubRococo::para_id());
|
||||||
Rococo::child_location_of(AssetHubRococo::para_id());
|
|
||||||
|
|
||||||
// Relay Chain sets supported version for Asset Parachain
|
// Relay Chain sets supported version for Asset Parachain
|
||||||
Rococo::execute_with(|| {
|
Rococo::execute_with(|| {
|
||||||
assert_ok!(<Rococo as RococoPallet>::XcmPallet::force_xcm_version(
|
assert_ok!(<Rococo as RococoPallet>::XcmPallet::force_xcm_version(
|
||||||
sudo_origin,
|
sudo_origin,
|
||||||
bx!(system_para_destination),
|
bx!(system_para_destination.clone()),
|
||||||
XCM_V3
|
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>::RuntimeCall::PolkadotXcm(pallet_xcm::Call::<
|
||||||
<AssetHubRococo as Chain>::Runtime,
|
<AssetHubRococo as Chain>::Runtime,
|
||||||
>::force_xcm_version {
|
>::force_xcm_version {
|
||||||
location: bx!(parent_location),
|
location: bx!(parent_location.clone()),
|
||||||
version: XCM_V3,
|
version: XCM_V3,
|
||||||
})
|
})
|
||||||
.encode()
|
.encode()
|
||||||
|
|||||||
+38
-30
@@ -15,16 +15,19 @@
|
|||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
|
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;
|
use sp_runtime::ModuleError;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn swap_locally_on_chain_using_local_assets() {
|
fn swap_locally_on_chain_using_local_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 asset_one = MultiLocation {
|
let asset_one = Box::new(v3::Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())),
|
[
|
||||||
};
|
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
|
||||||
|
v3::Junction::GeneralIndex(ASSET_ID.into()),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
|
||||||
AssetHubRococo::execute_with(|| {
|
AssetHubRococo::execute_with(|| {
|
||||||
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
|
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(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(asset_one),
|
asset_one.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_expected_events!(
|
assert_expected_events!(
|
||||||
@@ -59,8 +62,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(asset_one),
|
asset_one.clone(),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
0,
|
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!(
|
assert_ok!(
|
||||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
<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(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::remove_liquidity(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native,
|
||||||
Box::new(asset_one),
|
asset_one,
|
||||||
1414213562273 - EXISTENTIAL_DEPOSIT * 2, // all but the 2 EDs can't be retrieved.
|
1414213562273 - EXISTENTIAL_DEPOSIT * 2, // all but the 2 EDs can't be retrieved.
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -112,16 +115,16 @@ fn swap_locally_on_chain_using_local_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn swap_locally_on_chain_using_foreign_assets() {
|
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 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() {
|
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!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let asset_owner_on_penpal = PenpalASender::get();
|
let asset_owner_on_penpal = PenpalASender::get();
|
||||||
let foreign_asset_at_asset_hub_rococo =
|
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)
|
.appended_with(asset_location_on_penpal)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -167,7 +170,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 4. Create pool:
|
// 4. Create pool:
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(foreign_asset_at_asset_hub_rococo),
|
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 5. Add liquidity:
|
// 5. Add liquidity:
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahr.clone()),
|
<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),
|
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
@@ -200,7 +203,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 6. Swap!
|
// 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!(
|
assert_ok!(
|
||||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||||
@@ -226,7 +229,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 7. Remove liquidity
|
// 7. Remove liquidity
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::remove_liquidity(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::remove_liquidity(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahr.clone()),
|
<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),
|
Box::new(foreign_asset_at_asset_hub_rococo),
|
||||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||||
0,
|
0,
|
||||||
@@ -238,9 +241,11 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cannot_create_pool_from_pool_assets() {
|
fn cannot_create_pool_from_pool_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 mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
let mut asset_one = asset_hub_rococo_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
asset_one
|
||||||
|
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||||
|
.expect("pool assets");
|
||||||
|
|
||||||
AssetHubRococo::execute_with(|| {
|
AssetHubRococo::execute_with(|| {
|
||||||
let pool_owner_account_id = asset_hub_rococo_runtime::AssetConversionOrigin::get();
|
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!(
|
assert_matches::assert_matches!(
|
||||||
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native,
|
||||||
Box::new(asset_one),
|
Box::new(asset_one),
|
||||||
),
|
),
|
||||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||||
@@ -273,10 +278,14 @@ fn cannot_create_pool_from_pool_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||||
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocation::get();
|
let asset_native = asset_hub_rococo_runtime::xcm_config::TokenLocationV3::get();
|
||||||
let asset_one = MultiLocation {
|
let asset_one = xcm::v3::Location {
|
||||||
parents: 0,
|
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(
|
let penpal = AssetHubRococo::sovereign_account_id_of(AssetHubRococo::sibling_location_of(
|
||||||
PenpalA::para_id(),
|
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 penpal_root = <PenpalA as Chain>::RuntimeOrigin::root();
|
||||||
let fee_amount = 4_000_000_000_000u128;
|
let fee_amount = 4_000_000_000_000u128;
|
||||||
let asset_one =
|
let asset_one =
|
||||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount)
|
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
|
||||||
.into();
|
|
||||||
let asset_hub_location = PenpalA::sibling_location_of(AssetHubRococo::para_id()).into();
|
let asset_hub_location = PenpalA::sibling_location_of(AssetHubRococo::para_id()).into();
|
||||||
let xcm = xcm_transact_paid_execution(
|
let xcm = xcm_transact_paid_execution(
|
||||||
call,
|
call,
|
||||||
|
|||||||
+18
-13
@@ -17,7 +17,7 @@ use crate::*;
|
|||||||
use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig;
|
use asset_hub_rococo_runtime::xcm_config::XcmConfig as AssetHubRococoXcmConfig;
|
||||||
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
||||||
use rococo_runtime::xcm_config::XcmConfig as RococoXcmConfig;
|
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) {
|
fn relay_origin_assertions(t: RelayToSystemParaTest) {
|
||||||
type RuntimeEvent = <Rococo as Chain>::RuntimeEvent;
|
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) =
|
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
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!(
|
assert_expected_events!(
|
||||||
AssetHubRococo,
|
AssetHubRococo,
|
||||||
vec![
|
vec![
|
||||||
@@ -157,7 +158,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
|||||||
who: *who == t.receiver.account_id,
|
who: *who == t.receiver.account_id,
|
||||||
},
|
},
|
||||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
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,
|
owner: *owner == t.receiver.account_id,
|
||||||
amount: *amount == expected_foreign_asset_amount,
|
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);
|
AssetHubRococo::assert_xcm_pallet_attempted_complete(None);
|
||||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
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!(
|
assert_expected_events!(
|
||||||
AssetHubRococo,
|
AssetHubRococo,
|
||||||
vec![
|
vec![
|
||||||
@@ -183,13 +185,13 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubRococo::sovereign_account_id_of(
|
to: *to == AssetHubRococo::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
amount: *amount == t.args.amount,
|
||||||
},
|
},
|
||||||
// foreign asset is burned locally as part of teleportation
|
// foreign asset is burned locally as part of teleportation
|
||||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
|
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,
|
owner: *owner == t.sender.account_id,
|
||||||
balance: *balance == expected_foreign_asset_amount,
|
balance: *balance == expected_foreign_asset_amount,
|
||||||
},
|
},
|
||||||
@@ -542,7 +544,7 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn teleport_to_other_system_parachains_works() {
|
fn teleport_to_other_system_parachains_works() {
|
||||||
let amount = ASSET_HUB_ROCOCO_ED * 100;
|
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!(
|
test_parachain_is_trusted_teleporter!(
|
||||||
AssetHubRococo, // Origin
|
AssetHubRococo, // Origin
|
||||||
@@ -557,20 +559,20 @@ fn teleport_to_other_system_parachains_works() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||||
let ah_as_seen_by_penpal = PenpalA::sibling_location_of(AssetHubRococo::para_id());
|
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() {
|
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!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let asset_owner_on_penpal = PenpalASender::get();
|
let asset_owner_on_penpal = PenpalASender::get();
|
||||||
let foreign_asset_at_asset_hub_rococo =
|
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)
|
.appended_with(asset_location_on_penpal)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
super::penpal_create_foreign_asset_on_asset_hub(
|
super::penpal_create_foreign_asset_on_asset_hub(
|
||||||
asset_id_on_penpal,
|
asset_id_on_penpal,
|
||||||
foreign_asset_at_asset_hub_rococo,
|
foreign_asset_at_asset_hub_rococo,
|
||||||
ah_as_seen_by_penpal,
|
ah_as_seen_by_penpal.clone(),
|
||||||
false,
|
false,
|
||||||
asset_owner_on_penpal,
|
asset_owner_on_penpal,
|
||||||
ASSET_MIN_BALANCE * 1_000_000,
|
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 fee_amount_to_send = ASSET_HUB_ROCOCO_ED * 10_000;
|
||||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 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(),
|
(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();
|
.into();
|
||||||
let fee_asset_index = penpal_assets
|
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 ah_to_penpal_beneficiary_id = PenpalAReceiver::get();
|
||||||
let penpal_as_seen_by_ah = AssetHubRococo::sibling_location_of(PenpalA::para_id());
|
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(),
|
(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();
|
.into();
|
||||||
let fee_asset_index = ah_assets
|
let fee_asset_index = ah_assets
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ pub use frame_support::{
|
|||||||
// Polkadot
|
// Polkadot
|
||||||
pub use xcm::{
|
pub use xcm::{
|
||||||
prelude::{AccountId32 as AccountId32Junction, *},
|
prelude::{AccountId32 as AccountId32Junction, *},
|
||||||
v3::{Error, NetworkId::Westend as WestendId},
|
v3::{self, Error, NetworkId::Westend as WestendId},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cumulus
|
// Cumulus
|
||||||
|
|||||||
+6
-8
@@ -24,22 +24,20 @@ fn create_and_claim_treasury_spend() {
|
|||||||
const ASSET_ID: u32 = 1984;
|
const ASSET_ID: u32 = 1984;
|
||||||
const SPEND_AMOUNT: u128 = 1_000_000;
|
const SPEND_AMOUNT: u128 = 1_000_000;
|
||||||
// treasury location from a sibling parachain.
|
// treasury location from a sibling parachain.
|
||||||
let treasury_location: MultiLocation = MultiLocation::new(
|
let treasury_location: Location =
|
||||||
1,
|
Location::new(1, [Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)]);
|
||||||
X2(Parachain(CollectivesWestend::para_id().into()), PalletInstance(65)),
|
|
||||||
);
|
|
||||||
// treasury account on a sibling parachain.
|
// treasury account on a sibling parachain.
|
||||||
let treasury_account =
|
let treasury_account =
|
||||||
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
||||||
&treasury_location,
|
&treasury_location,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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();
|
let root = <CollectivesWestend as Chain>::RuntimeOrigin::root();
|
||||||
// asset kind to be spent from the treasury.
|
// asset kind to be spent from the treasury.
|
||||||
let asset_kind = VersionedLocatableAsset::V3 {
|
let asset_kind = VersionedLocatableAsset::V4 {
|
||||||
location: asset_hub_location,
|
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.
|
// treasury spend beneficiary.
|
||||||
let alice: AccountId = Westend::account_id_of(ALICE);
|
let alice: AccountId = Westend::account_id_of(ALICE);
|
||||||
@@ -75,7 +73,7 @@ fn create_and_claim_treasury_spend() {
|
|||||||
root,
|
root,
|
||||||
Box::new(asset_kind),
|
Box::new(asset_kind),
|
||||||
SPEND_AMOUNT,
|
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,
|
None,
|
||||||
));
|
));
|
||||||
// claim the spend.
|
// claim the spend.
|
||||||
|
|||||||
+9
-9
@@ -32,7 +32,7 @@ fn relay_to_para_sender_assertions(t: RelayToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == Westend::sovereign_account_id_of(
|
to: *to == Westend::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
amount: *amount == t.args.amount,
|
||||||
},
|
},
|
||||||
@@ -57,7 +57,7 @@ fn system_para_to_para_sender_assertions(t: SystemParaToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
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,
|
asset_id: *asset_id == ASSET_ID,
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
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() {
|
fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
|
||||||
let signed_origin = <Westend as Chain>::RuntimeOrigin::signed(WestendSender::get().into());
|
let signed_origin = <Westend as Chain>::RuntimeOrigin::signed(WestendSender::get().into());
|
||||||
let destination = Westend::child_location_of(AssetHubWestend::para_id());
|
let destination = Westend::child_location_of(AssetHubWestend::para_id());
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
|
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
|
||||||
let amount_to_send: Balance = WESTEND_ED * 1000;
|
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;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
// this should fail
|
// 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());
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
|
||||||
let destination = AssetHubWestend::parent_location();
|
let destination = AssetHubWestend::parent_location();
|
||||||
let beneficiary_id = WestendReceiver::get();
|
let beneficiary_id = WestendReceiver::get();
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
AccountId32Junction { network: None, id: beneficiary_id.into() }.into();
|
||||||
let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
|
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;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
// this should fail
|
// this should fail
|
||||||
@@ -428,9 +428,9 @@ fn reserve_transfer_assets_from_system_para_to_para() {
|
|||||||
let beneficiary_id = PenpalBReceiver::get();
|
let beneficiary_id = PenpalBReceiver::get();
|
||||||
let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
|
let fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
|
||||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
let asset_amount_to_send = ASSET_MIN_BALANCE * 1000;
|
||||||
let assets: MultiAssets = vec![
|
let assets: Assets = vec![
|
||||||
(Parent, fee_amount_to_send).into(),
|
(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(),
|
||||||
]
|
]
|
||||||
.into();
|
.into();
|
||||||
|
|||||||
+3
-4
@@ -19,14 +19,13 @@ use crate::*;
|
|||||||
fn relay_sets_system_para_xcm_supported_version() {
|
fn relay_sets_system_para_xcm_supported_version() {
|
||||||
// Init tests variables
|
// Init tests variables
|
||||||
let sudo_origin = <Westend as Chain>::RuntimeOrigin::root();
|
let sudo_origin = <Westend as Chain>::RuntimeOrigin::root();
|
||||||
let system_para_destination: MultiLocation =
|
let system_para_destination: Location = Westend::child_location_of(AssetHubWestend::para_id());
|
||||||
Westend::child_location_of(AssetHubWestend::para_id());
|
|
||||||
|
|
||||||
// Relay Chain sets supported version for Asset Parachain
|
// Relay Chain sets supported version for Asset Parachain
|
||||||
Westend::execute_with(|| {
|
Westend::execute_with(|| {
|
||||||
assert_ok!(<Westend as WestendPallet>::XcmPallet::force_xcm_version(
|
assert_ok!(<Westend as WestendPallet>::XcmPallet::force_xcm_version(
|
||||||
sudo_origin,
|
sudo_origin,
|
||||||
bx!(system_para_destination),
|
bx!(system_para_destination.clone()),
|
||||||
XCM_V3
|
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>::RuntimeCall::PolkadotXcm(pallet_xcm::Call::<
|
||||||
<AssetHubWestend as Chain>::Runtime,
|
<AssetHubWestend as Chain>::Runtime,
|
||||||
>::force_xcm_version {
|
>::force_xcm_version {
|
||||||
location: bx!(parent_location),
|
location: bx!(parent_location.clone()),
|
||||||
version: XCM_V3,
|
version: XCM_V3,
|
||||||
})
|
})
|
||||||
.encode()
|
.encode()
|
||||||
|
|||||||
+38
-29
@@ -14,15 +14,19 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use crate::*;
|
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]
|
#[test]
|
||||||
fn swap_locally_on_chain_using_local_assets() {
|
fn swap_locally_on_chain_using_local_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 asset_one = MultiLocation {
|
let asset_one = Box::new(v3::Location {
|
||||||
parents: 0,
|
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(|| {
|
AssetHubWestend::execute_with(|| {
|
||||||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
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(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(asset_one),
|
asset_one.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_expected_events!(
|
assert_expected_events!(
|
||||||
@@ -57,8 +61,8 @@ fn swap_locally_on_chain_using_local_assets() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(asset_one),
|
asset_one.clone(),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
0,
|
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(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<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(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::remove_liquidity(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(asset_one),
|
asset_one.clone(),
|
||||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -108,16 +112,16 @@ fn swap_locally_on_chain_using_local_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn swap_locally_on_chain_using_foreign_assets() {
|
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 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() {
|
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!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let asset_owner_on_penpal = PenpalBSender::get();
|
let asset_owner_on_penpal = PenpalBSender::get();
|
||||||
let foreign_asset_at_asset_hub_westend =
|
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)
|
.appended_with(asset_location_on_penpal)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -163,7 +167,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 4. Create pool:
|
// 4. Create pool:
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native.clone(),
|
||||||
Box::new(foreign_asset_at_asset_hub_westend),
|
Box::new(foreign_asset_at_asset_hub_westend),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -177,7 +181,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 5. Add liquidity:
|
// 5. Add liquidity:
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahw.clone()),
|
<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),
|
Box::new(foreign_asset_at_asset_hub_westend),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
@@ -196,7 +200,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 6. Swap!
|
// 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(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::swap_exact_tokens_for_tokens(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
@@ -220,7 +224,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
// 7. Remove liquidity
|
// 7. Remove liquidity
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::remove_liquidity(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::remove_liquidity(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahw.clone()),
|
<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),
|
Box::new(foreign_asset_at_asset_hub_westend),
|
||||||
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
1414213562273 - 2_000_000_000, // all but the 2 EDs can't be retrieved.
|
||||||
0,
|
0,
|
||||||
@@ -232,9 +236,11 @@ fn swap_locally_on_chain_using_foreign_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cannot_create_pool_from_pool_assets() {
|
fn cannot_create_pool_from_pool_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 mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocation::get();
|
let mut asset_one = asset_hub_westend_runtime::xcm_config::PoolAssetsPalletLocationV3::get();
|
||||||
asset_one.append_with(GeneralIndex(ASSET_ID.into())).expect("pool assets");
|
asset_one
|
||||||
|
.append_with(v3::Junction::GeneralIndex(ASSET_ID.into()))
|
||||||
|
.expect("pool assets");
|
||||||
|
|
||||||
AssetHubWestend::execute_with(|| {
|
AssetHubWestend::execute_with(|| {
|
||||||
let pool_owner_account_id = asset_hub_westend_runtime::AssetConversionOrigin::get();
|
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!(
|
assert_matches::assert_matches!(
|
||||||
<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(asset_native),
|
asset_native,
|
||||||
Box::new(asset_one),
|
Box::new(asset_one),
|
||||||
),
|
),
|
||||||
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
Err(DispatchError::Module(ModuleError{index: _, error: _, message})) => assert_eq!(message, Some("Unknown"))
|
||||||
@@ -267,10 +273,14 @@ fn cannot_create_pool_from_pool_assets() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
|
||||||
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocation::get();
|
let asset_native = asset_hub_westend_runtime::xcm_config::WestendLocationV3::get();
|
||||||
let asset_one = MultiLocation {
|
let asset_one = xcm::v3::Location {
|
||||||
parents: 0,
|
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(
|
let penpal = AssetHubWestend::sovereign_account_id_of(AssetHubWestend::sibling_location_of(
|
||||||
PenpalB::para_id(),
|
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 penpal_root = <PenpalB as Chain>::RuntimeOrigin::root();
|
||||||
let fee_amount = 4_000_000_000_000u128;
|
let fee_amount = 4_000_000_000_000u128;
|
||||||
let asset_one =
|
let asset_one =
|
||||||
(X2(PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())), fee_amount)
|
([PalletInstance(ASSETS_PALLET_ID), GeneralIndex(ASSET_ID.into())], fee_amount).into();
|
||||||
.into();
|
|
||||||
let asset_hub_location = PenpalB::sibling_location_of(AssetHubWestend::para_id()).into();
|
let asset_hub_location = PenpalB::sibling_location_of(AssetHubWestend::para_id()).into();
|
||||||
let xcm = xcm_transact_paid_execution(
|
let xcm = xcm_transact_paid_execution(
|
||||||
call,
|
call,
|
||||||
|
|||||||
+18
-13
@@ -17,7 +17,7 @@ use crate::*;
|
|||||||
use asset_hub_westend_runtime::xcm_config::XcmConfig as AssetHubWestendXcmConfig;
|
use asset_hub_westend_runtime::xcm_config::XcmConfig as AssetHubWestendXcmConfig;
|
||||||
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
use emulated_integration_tests_common::xcm_helpers::non_fee_asset;
|
||||||
use westend_runtime::xcm_config::XcmConfig as WestendXcmConfig;
|
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) {
|
fn relay_origin_assertions(t: RelayToSystemParaTest) {
|
||||||
type RuntimeEvent = <Westend as Chain>::RuntimeEvent;
|
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) =
|
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
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!(
|
assert_expected_events!(
|
||||||
AssetHubWestend,
|
AssetHubWestend,
|
||||||
vec![
|
vec![
|
||||||
@@ -157,7 +158,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
|
|||||||
who: *who == t.receiver.account_id,
|
who: *who == t.receiver.account_id,
|
||||||
},
|
},
|
||||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
|
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,
|
owner: *owner == t.receiver.account_id,
|
||||||
amount: *amount == expected_foreign_asset_amount,
|
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);
|
AssetHubWestend::assert_xcm_pallet_attempted_complete(None);
|
||||||
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
|
||||||
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
|
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!(
|
assert_expected_events!(
|
||||||
AssetHubWestend,
|
AssetHubWestend,
|
||||||
vec![
|
vec![
|
||||||
@@ -183,13 +185,13 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
|
|||||||
) => {
|
) => {
|
||||||
from: *from == t.sender.account_id,
|
from: *from == t.sender.account_id,
|
||||||
to: *to == AssetHubWestend::sovereign_account_id_of(
|
to: *to == AssetHubWestend::sovereign_account_id_of(
|
||||||
t.args.dest
|
t.args.dest.clone()
|
||||||
),
|
),
|
||||||
amount: *amount == t.args.amount,
|
amount: *amount == t.args.amount,
|
||||||
},
|
},
|
||||||
// foreign asset is burned locally as part of teleportation
|
// foreign asset is burned locally as part of teleportation
|
||||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
|
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,
|
owner: *owner == t.sender.account_id,
|
||||||
balance: *balance == expected_foreign_asset_amount,
|
balance: *balance == expected_foreign_asset_amount,
|
||||||
},
|
},
|
||||||
@@ -542,7 +544,7 @@ fn teleport_native_assets_from_system_para_to_relay_fails() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn teleport_to_other_system_parachains_works() {
|
fn teleport_to_other_system_parachains_works() {
|
||||||
let amount = ASSET_HUB_WESTEND_ED * 100;
|
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!(
|
test_parachain_is_trusted_teleporter!(
|
||||||
AssetHubWestend, // Origin
|
AssetHubWestend, // Origin
|
||||||
@@ -557,20 +559,20 @@ fn teleport_to_other_system_parachains_works() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
fn bidirectional_teleport_foreign_assets_between_para_and_asset_hub() {
|
||||||
let ah_as_seen_by_penpal = PenpalB::sibling_location_of(AssetHubWestend::para_id());
|
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() {
|
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!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let asset_owner_on_penpal = PenpalBSender::get();
|
let asset_owner_on_penpal = PenpalBSender::get();
|
||||||
let foreign_asset_at_asset_hub_westend =
|
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)
|
.appended_with(asset_location_on_penpal)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
super::penpal_create_foreign_asset_on_asset_hub(
|
super::penpal_create_foreign_asset_on_asset_hub(
|
||||||
asset_id_on_penpal,
|
asset_id_on_penpal,
|
||||||
foreign_asset_at_asset_hub_westend,
|
foreign_asset_at_asset_hub_westend,
|
||||||
ah_as_seen_by_penpal,
|
ah_as_seen_by_penpal.clone(),
|
||||||
false,
|
false,
|
||||||
asset_owner_on_penpal,
|
asset_owner_on_penpal,
|
||||||
ASSET_MIN_BALANCE * 1_000_000,
|
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 fee_amount_to_send = ASSET_HUB_WESTEND_ED * 1000;
|
||||||
let asset_amount_to_send = ASSET_MIN_BALANCE * 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(),
|
(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();
|
.into();
|
||||||
let fee_asset_index = penpal_assets
|
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 ah_to_penpal_beneficiary_id = PenpalBReceiver::get();
|
||||||
let penpal_as_seen_by_ah = AssetHubWestend::sibling_location_of(PenpalB::para_id());
|
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(),
|
(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();
|
.into();
|
||||||
let fee_asset_index = ah_assets
|
let fee_asset_index = ah_assets
|
||||||
|
|||||||
+5
-5
@@ -24,19 +24,19 @@ fn create_and_claim_treasury_spend() {
|
|||||||
const ASSET_ID: u32 = 1984;
|
const ASSET_ID: u32 = 1984;
|
||||||
const SPEND_AMOUNT: u128 = 1_000_000;
|
const SPEND_AMOUNT: u128 = 1_000_000;
|
||||||
// treasury location from a sibling parachain.
|
// 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.
|
// treasury account on a sibling parachain.
|
||||||
let treasury_account =
|
let treasury_account =
|
||||||
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
asset_hub_westend_runtime::xcm_config::LocationToAccountId::convert_location(
|
||||||
&treasury_location,
|
&treasury_location,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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();
|
let root = <Westend as Chain>::RuntimeOrigin::root();
|
||||||
// asset kind to be spend from the treasury.
|
// asset kind to be spend from the treasury.
|
||||||
let asset_kind = VersionedLocatableAsset::V3 {
|
let asset_kind = VersionedLocatableAsset::V4 {
|
||||||
location: asset_hub_location,
|
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.
|
// treasury spend beneficiary.
|
||||||
let alice: AccountId = Westend::account_id_of(ALICE);
|
let alice: AccountId = Westend::account_id_of(ALICE);
|
||||||
@@ -71,7 +71,7 @@ fn create_and_claim_treasury_spend() {
|
|||||||
root,
|
root,
|
||||||
Box::new(asset_kind),
|
Box::new(asset_kind),
|
||||||
SPEND_AMOUNT,
|
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,
|
None,
|
||||||
));
|
));
|
||||||
// claim the spend.
|
// claim the spend.
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ pub use xcm::{
|
|||||||
latest::ParentThen,
|
latest::ParentThen,
|
||||||
prelude::{AccountId32 as AccountId32Junction, *},
|
prelude::{AccountId32 as AccountId32Junction, *},
|
||||||
v3::{
|
v3::{
|
||||||
Error,
|
self, Error,
|
||||||
NetworkId::{Rococo as RococoId, Westend as WestendId},
|
NetworkId::{Rococo as RococoId, Westend as WestendId},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+14
-9
@@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
|
|
||||||
fn send_asset_from_asset_hub_rococo_to_asset_hub_westend(id: MultiLocation, amount: u128) {
|
fn send_asset_from_asset_hub_rococo_to_asset_hub_westend(id: Location, amount: u128) {
|
||||||
let destination = asset_hub_westend_location();
|
let destination = asset_hub_westend_location();
|
||||||
|
|
||||||
// fund the AHR's SA on BHR for paying bridge transport fees
|
// fund the AHR's SA on BHR for paying bridge transport fees
|
||||||
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128);
|
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), 10_000_000_000_000u128);
|
||||||
|
|
||||||
// set XCM versions
|
// set XCM versions
|
||||||
AssetHubRococo::force_xcm_version(destination, XCM_VERSION);
|
AssetHubRococo::force_xcm_version(destination.clone(), XCM_VERSION);
|
||||||
BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), XCM_VERSION);
|
BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), XCM_VERSION);
|
||||||
|
|
||||||
// send message over bridge
|
// send message over bridge
|
||||||
@@ -33,9 +33,9 @@ fn send_asset_from_asset_hub_rococo_to_asset_hub_westend(id: MultiLocation, amou
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
||||||
let roc_at_asset_hub_rococo: MultiLocation = Parent.into();
|
let roc_at_asset_hub_rococo: v3::Location = v3::Parent.into();
|
||||||
let roc_at_asset_hub_westend =
|
let roc_at_asset_hub_westend =
|
||||||
MultiLocation { parents: 2, interior: X1(GlobalConsensus(NetworkId::Rococo)) };
|
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||||
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
||||||
AssetHubWestend::force_create_foreign_asset(
|
AssetHubWestend::force_create_foreign_asset(
|
||||||
roc_at_asset_hub_westend,
|
roc_at_asset_hub_westend,
|
||||||
@@ -62,7 +62,7 @@ fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(Parent.into()),
|
Box::new(xcm::v3::Parent.into()),
|
||||||
Box::new(roc_at_asset_hub_westend),
|
Box::new(roc_at_asset_hub_westend),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubWestend as AssetHubWestendPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get()),
|
||||||
Box::new(Parent.into()),
|
Box::new(xcm::v3::Parent.into()),
|
||||||
Box::new(roc_at_asset_hub_westend),
|
Box::new(roc_at_asset_hub_westend),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
@@ -101,8 +101,9 @@ fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
|||||||
<Assets as Inspect<_>>::balance(roc_at_asset_hub_westend, &AssetHubWestendReceiver::get())
|
<Assets as Inspect<_>>::balance(roc_at_asset_hub_westend, &AssetHubWestendReceiver::get())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let roc_at_asset_hub_rococo_latest: Location = roc_at_asset_hub_rococo.try_into().unwrap();
|
||||||
let amount = ASSET_HUB_ROCOCO_ED * 1_000_000;
|
let amount = ASSET_HUB_ROCOCO_ED * 1_000_000;
|
||||||
send_asset_from_asset_hub_rococo_to_asset_hub_westend(roc_at_asset_hub_rococo, amount);
|
send_asset_from_asset_hub_rococo_to_asset_hub_westend(roc_at_asset_hub_rococo_latest, amount);
|
||||||
AssetHubWestend::execute_with(|| {
|
AssetHubWestend::execute_with(|| {
|
||||||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
||||||
assert_expected_events!(
|
assert_expected_events!(
|
||||||
@@ -142,7 +143,7 @@ fn send_rocs_from_asset_hub_rococo_to_asset_hub_westend() {
|
|||||||
fn send_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
|
fn send_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
|
||||||
let prefund_amount = 10_000_000_000_000u128;
|
let prefund_amount = 10_000_000_000_000u128;
|
||||||
let wnd_at_asset_hub_rococo =
|
let wnd_at_asset_hub_rococo =
|
||||||
MultiLocation { parents: 2, interior: X1(GlobalConsensus(NetworkId::Westend)) };
|
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||||
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
||||||
AssetHubRococo::force_create_foreign_asset(
|
AssetHubRococo::force_create_foreign_asset(
|
||||||
wnd_at_asset_hub_rococo,
|
wnd_at_asset_hub_rococo,
|
||||||
@@ -170,8 +171,12 @@ fn send_wnds_from_asset_hub_rococo_to_asset_hub_westend() {
|
|||||||
let receiver_wnds_before =
|
let receiver_wnds_before =
|
||||||
<AssetHubWestend as Chain>::account_data_of(AssetHubWestendReceiver::get()).free;
|
<AssetHubWestend as Chain>::account_data_of(AssetHubWestendReceiver::get()).free;
|
||||||
|
|
||||||
|
let wnd_at_asset_hub_rococo_latest: Location = wnd_at_asset_hub_rococo.try_into().unwrap();
|
||||||
let amount_to_send = ASSET_HUB_WESTEND_ED * 1_000;
|
let amount_to_send = ASSET_HUB_WESTEND_ED * 1_000;
|
||||||
send_asset_from_asset_hub_rococo_to_asset_hub_westend(wnd_at_asset_hub_rococo, amount_to_send);
|
send_asset_from_asset_hub_rococo_to_asset_hub_westend(
|
||||||
|
wnd_at_asset_hub_rococo_latest.clone(),
|
||||||
|
amount_to_send,
|
||||||
|
);
|
||||||
AssetHubWestend::execute_with(|| {
|
AssetHubWestend::execute_with(|| {
|
||||||
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
|
||||||
assert_expected_events!(
|
assert_expected_events!(
|
||||||
|
|||||||
+14
-20
@@ -20,37 +20,31 @@ mod send_xcm;
|
|||||||
mod snowbridge;
|
mod snowbridge;
|
||||||
mod teleport;
|
mod teleport;
|
||||||
|
|
||||||
pub(crate) fn asset_hub_westend_location() -> MultiLocation {
|
pub(crate) fn asset_hub_westend_location() -> Location {
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[GlobalConsensus(NetworkId::Westend), Parachain(AssetHubWestend::para_id().into())],
|
||||||
GlobalConsensus(NetworkId::Westend),
|
)
|
||||||
Parachain(AssetHubWestend::para_id().into()),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn bridge_hub_westend_location() -> MultiLocation {
|
pub(crate) fn bridge_hub_westend_location() -> Location {
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[GlobalConsensus(NetworkId::Westend), Parachain(BridgeHubWestend::para_id().into())],
|
||||||
GlobalConsensus(NetworkId::Westend),
|
)
|
||||||
Parachain(BridgeHubWestend::para_id().into()),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_asset_from_asset_hub_rococo(
|
pub(crate) fn send_asset_from_asset_hub_rococo(
|
||||||
destination: MultiLocation,
|
destination: Location,
|
||||||
(id, amount): (MultiLocation, u128),
|
(id, amount): (Location, u128),
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let signed_origin =
|
let signed_origin =
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get().into());
|
||||||
|
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
|
AccountId32Junction { network: None, id: AssetHubWestendReceiver::get().into() }.into();
|
||||||
|
|
||||||
let assets: MultiAssets = (id, amount).into();
|
let assets: Assets = (id, amount).into();
|
||||||
let fee_asset_item = 0;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
AssetHubRococo::execute_with(|| {
|
AssetHubRococo::execute_with(|| {
|
||||||
|
|||||||
+15
-9
@@ -29,8 +29,8 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
|
|||||||
let xcm = VersionedXcm::from(Xcm(vec![
|
let xcm = VersionedXcm::from(Xcm(vec![
|
||||||
UnpaidExecution { weight_limit, check_origin },
|
UnpaidExecution { weight_limit, check_origin },
|
||||||
ExportMessage {
|
ExportMessage {
|
||||||
network: WestendId,
|
network: WestendId.into(),
|
||||||
destination: X1(Parachain(AssetHubWestend::para_id().into())),
|
destination: [Parachain(AssetHubWestend::para_id().into())].into(),
|
||||||
xcm: remote_xcm,
|
xcm: remote_xcm,
|
||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
@@ -68,7 +68,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
|
|
||||||
// prepare data
|
// prepare data
|
||||||
let destination = asset_hub_westend_location();
|
let destination = asset_hub_westend_location();
|
||||||
let native_token = MultiLocation::parent();
|
let native_token = Location::parent();
|
||||||
let amount = ASSET_HUB_ROCOCO_ED * 1_000;
|
let amount = ASSET_HUB_ROCOCO_ED * 1_000;
|
||||||
|
|
||||||
// fund the AHR's SA on BHR for paying bridge transport fees
|
// fund the AHR's SA on BHR for paying bridge transport fees
|
||||||
@@ -78,7 +78,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
|
|
||||||
// send XCM from AssetHubRococo - fails - destination version not known
|
// send XCM from AssetHubRococo - fails - destination version not known
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
|
send_asset_from_asset_hub_rococo(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -87,7 +87,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// set destination version
|
// set destination version
|
||||||
AssetHubRococo::force_xcm_version(destination, xcm::v3::prelude::XCM_VERSION);
|
AssetHubRococo::force_xcm_version(destination.clone(), xcm::v3::prelude::XCM_VERSION);
|
||||||
|
|
||||||
// TODO: remove this block, when removing `xcm:v2`
|
// TODO: remove this block, when removing `xcm:v2`
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
// version, which does not have the `ExportMessage` instruction. If the default `2` is
|
// version, which does not have the `ExportMessage` instruction. If the default `2` is
|
||||||
// changed to `3`, then this assert can go away"
|
// changed to `3`, then this assert can go away"
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
|
send_asset_from_asset_hub_rococo(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -110,7 +110,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
// send XCM from AssetHubRococo - fails - `ExportMessage` is not in `2`
|
// send XCM from AssetHubRococo - fails - `ExportMessage` is not in `2`
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_rococo(destination, (native_token, amount)),
|
send_asset_from_asset_hub_rococo(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -125,7 +125,10 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
xcm::v3::prelude::XCM_VERSION,
|
xcm::v3::prelude::XCM_VERSION,
|
||||||
);
|
);
|
||||||
// send XCM from AssetHubRococo - ok
|
// send XCM from AssetHubRococo - ok
|
||||||
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
|
assert_ok!(send_asset_from_asset_hub_rococo(
|
||||||
|
destination.clone(),
|
||||||
|
(native_token.clone(), amount)
|
||||||
|
));
|
||||||
|
|
||||||
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
|
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
|
||||||
assert_bridge_hub_rococo_message_accepted(false);
|
assert_bridge_hub_rococo_message_accepted(false);
|
||||||
@@ -142,7 +145,10 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// send XCM from AssetHubRococo - ok
|
// send XCM from AssetHubRococo - ok
|
||||||
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
|
assert_ok!(send_asset_from_asset_hub_rococo(
|
||||||
|
destination.clone(),
|
||||||
|
(native_token.clone(), amount)
|
||||||
|
));
|
||||||
assert_bridge_hub_rococo_message_accepted(true);
|
assert_bridge_hub_rococo_message_accepted(true);
|
||||||
assert_bridge_hub_westend_message_received();
|
assert_bridge_hub_westend_message_received();
|
||||||
// message delivered and processed at destination
|
// message delivered and processed at destination
|
||||||
|
|||||||
+30
-33
@@ -61,7 +61,7 @@ fn create_agent() {
|
|||||||
|
|
||||||
let remote_xcm = VersionedXcm::from(Xcm(vec![
|
let remote_xcm = VersionedXcm::from(Xcm(vec![
|
||||||
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
||||||
DescendOrigin(X1(Parachain(origin_para))),
|
DescendOrigin(Parachain(origin_para).into()),
|
||||||
Transact {
|
Transact {
|
||||||
require_weight_at_most: 3000000000.into(),
|
require_weight_at_most: 3000000000.into(),
|
||||||
origin_kind: OriginKind::Xcm,
|
origin_kind: OriginKind::Xcm,
|
||||||
@@ -109,14 +109,14 @@ fn create_channel() {
|
|||||||
BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND);
|
BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND);
|
||||||
|
|
||||||
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
|
let sudo_origin = <Rococo as Chain>::RuntimeOrigin::root();
|
||||||
let destination: VersionedMultiLocation =
|
let destination: VersionedLocation =
|
||||||
Rococo::child_location_of(BridgeHubRococo::para_id()).into();
|
Rococo::child_location_of(BridgeHubRococo::para_id()).into();
|
||||||
|
|
||||||
let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});
|
let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {});
|
||||||
|
|
||||||
let create_agent_xcm = VersionedXcm::from(Xcm(vec![
|
let create_agent_xcm = VersionedXcm::from(Xcm(vec![
|
||||||
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
||||||
DescendOrigin(X1(Parachain(origin_para))),
|
DescendOrigin(Parachain(origin_para).into()),
|
||||||
Transact {
|
Transact {
|
||||||
require_weight_at_most: 3000000000.into(),
|
require_weight_at_most: 3000000000.into(),
|
||||||
origin_kind: OriginKind::Xcm,
|
origin_kind: OriginKind::Xcm,
|
||||||
@@ -129,7 +129,7 @@ fn create_channel() {
|
|||||||
|
|
||||||
let create_channel_xcm = VersionedXcm::from(Xcm(vec![
|
let create_channel_xcm = VersionedXcm::from(Xcm(vec![
|
||||||
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
||||||
DescendOrigin(X1(Parachain(origin_para))),
|
DescendOrigin(Parachain(origin_para).into()),
|
||||||
Transact {
|
Transact {
|
||||||
require_weight_at_most: 3000000000.into(),
|
require_weight_at_most: 3000000000.into(),
|
||||||
origin_kind: OriginKind::Xcm,
|
origin_kind: OriginKind::Xcm,
|
||||||
@@ -218,10 +218,10 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn send_token_from_ethereum_to_penpal() {
|
fn send_token_from_ethereum_to_penpal() {
|
||||||
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
|
let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(Location::new(
|
||||||
parents: 1,
|
1,
|
||||||
interior: X1(Parachain(AssetHubRococo::para_id().into())),
|
[Parachain(AssetHubRococo::para_id().into())],
|
||||||
});
|
));
|
||||||
BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]);
|
BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]);
|
||||||
|
|
||||||
PenpalA::fund_accounts(vec![
|
PenpalA::fund_accounts(vec![
|
||||||
@@ -229,9 +229,9 @@ fn send_token_from_ethereum_to_penpal() {
|
|||||||
(PenpalASender::get(), INITIAL_FUND),
|
(PenpalASender::get(), INITIAL_FUND),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let weth_asset_location: MultiLocation =
|
let weth_asset_location: Location =
|
||||||
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
|
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into();
|
||||||
let weth_asset_id = weth_asset_location.into();
|
let weth_asset_id: v3::Location = weth_asset_location.try_into().unwrap();
|
||||||
|
|
||||||
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();
|
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();
|
||||||
|
|
||||||
@@ -375,18 +375,15 @@ fn send_token_from_ethereum_to_asset_hub() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn send_weth_asset_from_asset_hub_to_ethereum() {
|
fn send_weth_asset_from_asset_hub_to_ethereum() {
|
||||||
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
|
use asset_hub_rococo_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
|
||||||
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation {
|
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(Location::new(
|
||||||
parents: 1,
|
1,
|
||||||
interior: X1(Parachain(AssetHubRococo::para_id().into())),
|
[Parachain(AssetHubRococo::para_id().into())],
|
||||||
});
|
));
|
||||||
|
|
||||||
AssetHubRococo::force_default_xcm_version(Some(XCM_VERSION));
|
AssetHubRococo::force_default_xcm_version(Some(XCM_VERSION));
|
||||||
BridgeHubRococo::force_default_xcm_version(Some(XCM_VERSION));
|
BridgeHubRococo::force_default_xcm_version(Some(XCM_VERSION));
|
||||||
AssetHubRococo::force_xcm_version(
|
AssetHubRococo::force_xcm_version(
|
||||||
MultiLocation {
|
Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]),
|
||||||
parents: 2,
|
|
||||||
interior: X1(GlobalConsensus(Ethereum { chain_id: CHAIN_ID })),
|
|
||||||
},
|
|
||||||
XCM_VERSION,
|
XCM_VERSION,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -437,27 +434,27 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
|
|||||||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
|
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
let assets = vec![MultiAsset {
|
let assets = vec![Asset {
|
||||||
id: Concrete(MultiLocation {
|
id: AssetId(Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[
|
||||||
GlobalConsensus(Ethereum { chain_id: CHAIN_ID }),
|
GlobalConsensus(Ethereum { chain_id: CHAIN_ID }),
|
||||||
AccountKey20 { network: None, key: WETH },
|
AccountKey20 { network: None, key: WETH },
|
||||||
),
|
],
|
||||||
}),
|
)),
|
||||||
fun: Fungible(WETH_AMOUNT),
|
fun: Fungible(WETH_AMOUNT),
|
||||||
}];
|
}];
|
||||||
let multi_assets = VersionedMultiAssets::V3(MultiAssets::from(assets));
|
let multi_assets = VersionedAssets::V4(Assets::from(assets));
|
||||||
|
|
||||||
let destination = VersionedMultiLocation::V3(MultiLocation {
|
let destination = VersionedLocation::V4(Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X1(GlobalConsensus(Ethereum { chain_id: CHAIN_ID })),
|
[GlobalConsensus(Ethereum { chain_id: CHAIN_ID })],
|
||||||
});
|
));
|
||||||
|
|
||||||
let beneficiary = VersionedMultiLocation::V3(MultiLocation {
|
let beneficiary = VersionedLocation::V4(Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }),
|
[AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS.into() }],
|
||||||
});
|
));
|
||||||
|
|
||||||
let free_balance_before = <AssetHubRococo as AssetHubRococoPallet>::Balances::free_balance(
|
let free_balance_before = <AssetHubRococo as AssetHubRococoPallet>::Balances::free_balance(
|
||||||
AssetHubRococoReceiver::get(),
|
AssetHubRococoReceiver::get(),
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ use bridge_hub_rococo_runtime::xcm_config::XcmConfig;
|
|||||||
#[test]
|
#[test]
|
||||||
fn teleport_to_other_system_parachains_works() {
|
fn teleport_to_other_system_parachains_works() {
|
||||||
let amount = BRIDGE_HUB_ROCOCO_ED * 100;
|
let amount = BRIDGE_HUB_ROCOCO_ED * 100;
|
||||||
let native_asset: MultiAssets = (Parent, amount).into();
|
let native_asset: Assets = (Parent, amount).into();
|
||||||
|
|
||||||
test_parachain_is_trusted_teleporter!(
|
test_parachain_is_trusted_teleporter!(
|
||||||
BridgeHubRococo, // Origin
|
BridgeHubRococo, // Origin
|
||||||
|
|||||||
+2
-1
@@ -21,7 +21,8 @@ pub use sp_runtime::DispatchError;
|
|||||||
pub use xcm::{
|
pub use xcm::{
|
||||||
latest::ParentThen,
|
latest::ParentThen,
|
||||||
prelude::{AccountId32 as AccountId32Junction, *},
|
prelude::{AccountId32 as AccountId32Junction, *},
|
||||||
v3::{
|
v3,
|
||||||
|
v4::{
|
||||||
Error,
|
Error,
|
||||||
NetworkId::{Rococo as RococoId, Westend as WestendId},
|
NetworkId::{Rococo as RococoId, Westend as WestendId},
|
||||||
},
|
},
|
||||||
|
|||||||
+12
-8
@@ -14,14 +14,14 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
use crate::tests::*;
|
use crate::tests::*;
|
||||||
|
|
||||||
fn send_asset_from_asset_hub_westend_to_asset_hub_rococo(id: MultiLocation, amount: u128) {
|
fn send_asset_from_asset_hub_westend_to_asset_hub_rococo(id: Location, amount: u128) {
|
||||||
let destination = asset_hub_rococo_location();
|
let destination = asset_hub_rococo_location();
|
||||||
|
|
||||||
// fund the AHW's SA on BHW for paying bridge transport fees
|
// fund the AHW's SA on BHW for paying bridge transport fees
|
||||||
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128);
|
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), 10_000_000_000_000u128);
|
||||||
|
|
||||||
// set XCM versions
|
// set XCM versions
|
||||||
AssetHubWestend::force_xcm_version(destination, XCM_VERSION);
|
AssetHubWestend::force_xcm_version(destination.clone(), XCM_VERSION);
|
||||||
BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), XCM_VERSION);
|
BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), XCM_VERSION);
|
||||||
|
|
||||||
// send message over bridge
|
// send message over bridge
|
||||||
@@ -32,9 +32,9 @@ fn send_asset_from_asset_hub_westend_to_asset_hub_rococo(id: MultiLocation, amou
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
|
fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
|
||||||
let wnd_at_asset_hub_westend: MultiLocation = Parent.into();
|
let wnd_at_asset_hub_westend: Location = Parent.into();
|
||||||
let wnd_at_asset_hub_rococo =
|
let wnd_at_asset_hub_rococo =
|
||||||
MultiLocation { parents: 2, interior: X1(GlobalConsensus(NetworkId::Westend)) };
|
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Westend)]);
|
||||||
let owner: AccountId = AssetHubRococo::account_id_of(ALICE);
|
let owner: AccountId = AssetHubRococo::account_id_of(ALICE);
|
||||||
AssetHubRococo::force_create_foreign_asset(
|
AssetHubRococo::force_create_foreign_asset(
|
||||||
wnd_at_asset_hub_rococo,
|
wnd_at_asset_hub_rococo,
|
||||||
@@ -61,7 +61,7 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::create_pool(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(Parent.into()),
|
Box::new(xcm::v3::Parent.into()),
|
||||||
Box::new(wnd_at_asset_hub_rococo),
|
Box::new(wnd_at_asset_hub_rococo),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
|
|||||||
|
|
||||||
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
assert_ok!(<AssetHubRococo as AssetHubRococoPallet>::AssetConversion::add_liquidity(
|
||||||
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
<AssetHubRococo as Chain>::RuntimeOrigin::signed(AssetHubRococoSender::get()),
|
||||||
Box::new(Parent.into()),
|
Box::new(xcm::v3::Parent.into()),
|
||||||
Box::new(wnd_at_asset_hub_rococo),
|
Box::new(wnd_at_asset_hub_rococo),
|
||||||
1_000_000_000_000,
|
1_000_000_000_000,
|
||||||
2_000_000_000_000,
|
2_000_000_000_000,
|
||||||
@@ -141,7 +141,7 @@ fn send_wnds_from_asset_hub_westend_to_asset_hub_rococo() {
|
|||||||
fn send_rocs_from_asset_hub_westend_to_asset_hub_rococo() {
|
fn send_rocs_from_asset_hub_westend_to_asset_hub_rococo() {
|
||||||
let prefund_amount = 10_000_000_000_000u128;
|
let prefund_amount = 10_000_000_000_000u128;
|
||||||
let roc_at_asset_hub_westend =
|
let roc_at_asset_hub_westend =
|
||||||
MultiLocation { parents: 2, interior: X1(GlobalConsensus(NetworkId::Rococo)) };
|
v3::Location::new(2, [v3::Junction::GlobalConsensus(v3::NetworkId::Rococo)]);
|
||||||
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
let owner: AccountId = AssetHubWestend::account_id_of(ALICE);
|
||||||
AssetHubWestend::force_create_foreign_asset(
|
AssetHubWestend::force_create_foreign_asset(
|
||||||
roc_at_asset_hub_westend,
|
roc_at_asset_hub_westend,
|
||||||
@@ -169,8 +169,12 @@ fn send_rocs_from_asset_hub_westend_to_asset_hub_rococo() {
|
|||||||
let receiver_rocs_before =
|
let receiver_rocs_before =
|
||||||
<AssetHubRococo as Chain>::account_data_of(AssetHubRococoReceiver::get()).free;
|
<AssetHubRococo as Chain>::account_data_of(AssetHubRococoReceiver::get()).free;
|
||||||
|
|
||||||
|
let roc_at_asset_hub_westend_latest: Location = roc_at_asset_hub_westend.try_into().unwrap();
|
||||||
let amount_to_send = ASSET_HUB_ROCOCO_ED * 1_000;
|
let amount_to_send = ASSET_HUB_ROCOCO_ED * 1_000;
|
||||||
send_asset_from_asset_hub_westend_to_asset_hub_rococo(roc_at_asset_hub_westend, amount_to_send);
|
send_asset_from_asset_hub_westend_to_asset_hub_rococo(
|
||||||
|
roc_at_asset_hub_westend_latest.clone(),
|
||||||
|
amount_to_send,
|
||||||
|
);
|
||||||
AssetHubRococo::execute_with(|| {
|
AssetHubRococo::execute_with(|| {
|
||||||
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
|
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
|
||||||
assert_expected_events!(
|
assert_expected_events!(
|
||||||
|
|||||||
+14
-20
@@ -19,37 +19,31 @@ mod asset_transfers;
|
|||||||
mod send_xcm;
|
mod send_xcm;
|
||||||
mod teleport;
|
mod teleport;
|
||||||
|
|
||||||
pub(crate) fn asset_hub_rococo_location() -> MultiLocation {
|
pub(crate) fn asset_hub_rococo_location() -> Location {
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[GlobalConsensus(NetworkId::Rococo), Parachain(AssetHubRococo::para_id().into())],
|
||||||
GlobalConsensus(NetworkId::Rococo),
|
)
|
||||||
Parachain(AssetHubRococo::para_id().into()),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn bridge_hub_rococo_location() -> MultiLocation {
|
pub(crate) fn bridge_hub_rococo_location() -> Location {
|
||||||
MultiLocation {
|
Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[GlobalConsensus(NetworkId::Rococo), Parachain(BridgeHubRococo::para_id().into())],
|
||||||
GlobalConsensus(NetworkId::Rococo),
|
)
|
||||||
Parachain(BridgeHubRococo::para_id().into()),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn send_asset_from_asset_hub_westend(
|
pub(crate) fn send_asset_from_asset_hub_westend(
|
||||||
destination: MultiLocation,
|
destination: Location,
|
||||||
(id, amount): (MultiLocation, u128),
|
(id, amount): (Location, u128),
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let signed_origin =
|
let signed_origin =
|
||||||
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
|
<AssetHubWestend as Chain>::RuntimeOrigin::signed(AssetHubWestendSender::get().into());
|
||||||
|
|
||||||
let beneficiary: MultiLocation =
|
let beneficiary: Location =
|
||||||
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
|
AccountId32Junction { network: None, id: AssetHubRococoReceiver::get().into() }.into();
|
||||||
|
|
||||||
let assets: MultiAssets = (id, amount).into();
|
let assets: Assets = (id, amount).into();
|
||||||
let fee_asset_item = 0;
|
let fee_asset_item = 0;
|
||||||
|
|
||||||
AssetHubWestend::execute_with(|| {
|
AssetHubWestend::execute_with(|| {
|
||||||
|
|||||||
+14
-8
@@ -30,7 +30,7 @@ fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable
|
|||||||
UnpaidExecution { weight_limit, check_origin },
|
UnpaidExecution { weight_limit, check_origin },
|
||||||
ExportMessage {
|
ExportMessage {
|
||||||
network: RococoId,
|
network: RococoId,
|
||||||
destination: X1(Parachain(AssetHubRococo::para_id().into())),
|
destination: [Parachain(AssetHubRococo::para_id().into())].into(),
|
||||||
xcm: remote_xcm,
|
xcm: remote_xcm,
|
||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
@@ -68,7 +68,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
|
|
||||||
// prepare data
|
// prepare data
|
||||||
let destination = asset_hub_rococo_location();
|
let destination = asset_hub_rococo_location();
|
||||||
let native_token = MultiLocation::parent();
|
let native_token = Location::parent();
|
||||||
let amount = ASSET_HUB_WESTEND_ED * 1_000;
|
let amount = ASSET_HUB_WESTEND_ED * 1_000;
|
||||||
|
|
||||||
// fund the AHR's SA on BHR for paying bridge transport fees
|
// fund the AHR's SA on BHR for paying bridge transport fees
|
||||||
@@ -78,7 +78,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
|
|
||||||
// send XCM from AssetHubWestend - fails - destination version not known
|
// send XCM from AssetHubWestend - fails - destination version not known
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
|
send_asset_from_asset_hub_westend(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -87,7 +87,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// set destination version
|
// set destination version
|
||||||
AssetHubWestend::force_xcm_version(destination, xcm::v3::prelude::XCM_VERSION);
|
AssetHubWestend::force_xcm_version(destination.clone(), xcm::v3::prelude::XCM_VERSION);
|
||||||
|
|
||||||
// TODO: remove this block, when removing `xcm:v2`
|
// TODO: remove this block, when removing `xcm:v2`
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
// version, which does not have the `ExportMessage` instruction. If the default `2` is
|
// version, which does not have the `ExportMessage` instruction. If the default `2` is
|
||||||
// changed to `3`, then this assert can go away"
|
// changed to `3`, then this assert can go away"
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
|
send_asset_from_asset_hub_westend(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -110,7 +110,7 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
// send XCM from AssetHubWestend - fails - `ExportMessage` is not in `2`
|
// send XCM from AssetHubWestend - fails - `ExportMessage` is not in `2`
|
||||||
assert_err!(
|
assert_err!(
|
||||||
send_asset_from_asset_hub_westend(destination, (native_token, amount)),
|
send_asset_from_asset_hub_westend(destination.clone(), (native_token.clone(), amount)),
|
||||||
DispatchError::Module(sp_runtime::ModuleError {
|
DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
error: [1, 0, 0, 0],
|
error: [1, 0, 0, 0],
|
||||||
@@ -125,7 +125,10 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
xcm::v3::prelude::XCM_VERSION,
|
xcm::v3::prelude::XCM_VERSION,
|
||||||
);
|
);
|
||||||
// send XCM from AssetHubWestend - ok
|
// send XCM from AssetHubWestend - ok
|
||||||
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
|
assert_ok!(send_asset_from_asset_hub_westend(
|
||||||
|
destination.clone(),
|
||||||
|
(native_token.clone(), amount)
|
||||||
|
));
|
||||||
|
|
||||||
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
|
// `ExportMessage` on local BridgeHub - fails - remote BridgeHub version not known
|
||||||
assert_bridge_hub_westend_message_accepted(false);
|
assert_bridge_hub_westend_message_accepted(false);
|
||||||
@@ -142,7 +145,10 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// send XCM from AssetHubWestend - ok
|
// send XCM from AssetHubWestend - ok
|
||||||
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
|
assert_ok!(send_asset_from_asset_hub_westend(
|
||||||
|
destination.clone(),
|
||||||
|
(native_token.clone(), amount)
|
||||||
|
));
|
||||||
assert_bridge_hub_westend_message_accepted(true);
|
assert_bridge_hub_westend_message_accepted(true);
|
||||||
assert_bridge_hub_rococo_message_received();
|
assert_bridge_hub_rococo_message_received();
|
||||||
// message delivered and processed at destination
|
// message delivered and processed at destination
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ use bridge_hub_westend_runtime::xcm_config::XcmConfig;
|
|||||||
#[test]
|
#[test]
|
||||||
fn teleport_to_other_system_parachains_works() {
|
fn teleport_to_other_system_parachains_works() {
|
||||||
let amount = BRIDGE_HUB_WESTEND_ED * 100;
|
let amount = BRIDGE_HUB_WESTEND_ED * 100;
|
||||||
let native_asset: MultiAssets = (Parent, amount).into();
|
let native_asset: Assets = (Parent, amount).into();
|
||||||
|
|
||||||
test_parachain_is_trusted_teleporter!(
|
test_parachain_is_trusted_teleporter!(
|
||||||
BridgeHubWestend, // Origin
|
BridgeHubWestend, // Origin
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ pub mod pallet {
|
|||||||
#[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> {
|
||||||
PingSent(ParaId, u32, Vec<u8>, XcmHash, MultiAssets),
|
PingSent(ParaId, u32, Vec<u8>, XcmHash, Assets),
|
||||||
Pinged(ParaId, u32, Vec<u8>),
|
Pinged(ParaId, u32, Vec<u8>),
|
||||||
PongSent(ParaId, u32, Vec<u8>, XcmHash, MultiAssets),
|
PongSent(ParaId, u32, Vec<u8>, XcmHash, Assets),
|
||||||
Ponged(ParaId, u32, Vec<u8>, BlockNumberFor<T>),
|
Ponged(ParaId, u32, Vec<u8>, BlockNumberFor<T>),
|
||||||
ErrorSendingPing(SendError, ParaId, u32, Vec<u8>),
|
ErrorSendingPing(SendError, ParaId, u32, Vec<u8>),
|
||||||
ErrorSendingPong(SendError, ParaId, u32, Vec<u8>),
|
ErrorSendingPong(SendError, ParaId, u32, Vec<u8>),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use assets_common::{
|
|||||||
foreign_creators::ForeignCreators,
|
foreign_creators::ForeignCreators,
|
||||||
local_and_foreign_assets::{LocalFromLeft, TargetFromLeft},
|
local_and_foreign_assets::{LocalFromLeft, TargetFromLeft},
|
||||||
matching::{FromNetwork, FromSiblingParachain},
|
matching::{FromNetwork, FromSiblingParachain},
|
||||||
AssetIdForTrustBackedAssetsConvert, MultiLocationForAssetId,
|
AssetIdForTrustBackedAssetsConvert,
|
||||||
};
|
};
|
||||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||||
use cumulus_primitives_core::AggregateMessageOrigin;
|
use cumulus_primitives_core::AggregateMessageOrigin;
|
||||||
@@ -80,13 +80,11 @@ use parachains_common::{
|
|||||||
Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
|
Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
|
||||||
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
use sp_runtime::{Perbill, RuntimeDebug};
|
use sp_runtime::{Perbill, RuntimeDebug};
|
||||||
use xcm::opaque::v3::MultiLocation;
|
|
||||||
use xcm_config::{
|
use xcm_config::{
|
||||||
ForeignAssetsConvertedConcreteId, ForeignCreatorsSovereignAccountOf, GovernanceLocation,
|
ForeignAssetsConvertedConcreteId, ForeignCreatorsSovereignAccountOf, GovernanceLocation,
|
||||||
PoolAssetsConvertedConcreteId, TokenLocation, TrustBackedAssetsConvertedConcreteId,
|
PoolAssetsConvertedConcreteId, TokenLocation, TokenLocationV3,
|
||||||
TrustBackedAssetsPalletLocation,
|
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocationV3,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
@@ -95,7 +93,13 @@ pub use sp_runtime::BuildStorage;
|
|||||||
// Polkadot imports
|
// Polkadot imports
|
||||||
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
||||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||||
use xcm::latest::prelude::*;
|
// We exclude `Assets` since it's the name of a pallet
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
use xcm::latest::prelude::{
|
||||||
|
Asset, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, NetworkId,
|
||||||
|
NonFungible, Parent, ParentThen, Response, XCM_VERSION,
|
||||||
|
};
|
||||||
|
use xcm::latest::prelude::{AssetId, BodyId};
|
||||||
|
|
||||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||||
|
|
||||||
@@ -317,10 +321,11 @@ pub type LocalAndForeignAssets = fungibles::UnionOf<
|
|||||||
Assets,
|
Assets,
|
||||||
ForeignAssets,
|
ForeignAssets,
|
||||||
LocalFromLeft<
|
LocalFromLeft<
|
||||||
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>,
|
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocationV3>,
|
||||||
AssetIdForTrustBackedAssets,
|
AssetIdForTrustBackedAssets,
|
||||||
|
xcm::v3::Location,
|
||||||
>,
|
>,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
AccountId,
|
AccountId,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -328,8 +333,8 @@ pub type LocalAndForeignAssets = fungibles::UnionOf<
|
|||||||
pub type NativeAndAssets = fungible::UnionOf<
|
pub type NativeAndAssets = fungible::UnionOf<
|
||||||
Balances,
|
Balances,
|
||||||
LocalAndForeignAssets,
|
LocalAndForeignAssets,
|
||||||
TargetFromLeft<TokenLocation>,
|
TargetFromLeft<TokenLocationV3, xcm::v3::Location>,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
AccountId,
|
AccountId,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -337,15 +342,15 @@ impl pallet_asset_conversion::Config for Runtime {
|
|||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type HigherPrecisionBalance = sp_core::U256;
|
type HigherPrecisionBalance = sp_core::U256;
|
||||||
type AssetKind = MultiLocation;
|
type AssetKind = xcm::v3::Location;
|
||||||
type Assets = NativeAndAssets;
|
type Assets = NativeAndAssets;
|
||||||
type PoolId = (Self::AssetKind, Self::AssetKind);
|
type PoolId = (Self::AssetKind, Self::AssetKind);
|
||||||
type PoolLocator =
|
type PoolLocator =
|
||||||
pallet_asset_conversion::WithFirstAsset<TokenLocation, AccountId, Self::AssetKind>;
|
pallet_asset_conversion::WithFirstAsset<TokenLocationV3, AccountId, Self::AssetKind>;
|
||||||
type PoolAssetId = u32;
|
type PoolAssetId = u32;
|
||||||
type PoolAssets = PoolAssets;
|
type PoolAssets = PoolAssets;
|
||||||
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
||||||
type PoolSetupFeeAsset = TokenLocation;
|
type PoolSetupFeeAsset = TokenLocationV3;
|
||||||
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
|
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
|
||||||
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
|
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
|
||||||
type LPFee = ConstU32<3>;
|
type LPFee = ConstU32<3>;
|
||||||
@@ -355,9 +360,10 @@ impl pallet_asset_conversion::Config for Runtime {
|
|||||||
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
|
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
|
||||||
TokenLocation,
|
TokenLocationV3,
|
||||||
parachain_info::Pallet<Runtime>,
|
parachain_info::Pallet<Runtime>,
|
||||||
xcm_config::AssetsPalletIndex,
|
xcm_config::TrustBackedAssetsPalletIndex,
|
||||||
|
xcm::v3::Location,
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,16 +385,17 @@ pub type ForeignAssetsInstance = pallet_assets::Instance2;
|
|||||||
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type AssetId = MultiLocationForAssetId;
|
type AssetId = xcm::v3::MultiLocation;
|
||||||
type AssetIdParameter = MultiLocationForAssetId;
|
type AssetIdParameter = xcm::v3::MultiLocation;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type CreateOrigin = ForeignCreators<
|
type CreateOrigin = ForeignCreators<
|
||||||
(
|
(
|
||||||
FromSiblingParachain<parachain_info::Pallet<Runtime>>,
|
FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v3::Location>,
|
||||||
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork>,
|
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v3::Location>,
|
||||||
),
|
),
|
||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
AccountId,
|
AccountId,
|
||||||
|
xcm::v3::Location,
|
||||||
>;
|
>;
|
||||||
type ForceOrigin = AssetsForceOrigin;
|
type ForceOrigin = AssetsForceOrigin;
|
||||||
type AssetDeposit = ForeignAssetsAssetDeposit;
|
type AssetDeposit = ForeignAssetsAssetDeposit;
|
||||||
@@ -664,7 +671,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(xcm_config::TokenLocation::get());
|
pub FeeAssetId: AssetId = AssetId(xcm_config::TokenLocation::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||||
}
|
}
|
||||||
@@ -753,7 +760,7 @@ impl pallet_asset_conversion_tx_payment::Config for Runtime {
|
|||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Fungibles = LocalAndForeignAssets;
|
type Fungibles = LocalAndForeignAssets;
|
||||||
type OnChargeAssetTransaction =
|
type OnChargeAssetTransaction =
|
||||||
AssetConversionAdapter<Balances, AssetConversion, TokenLocation>;
|
AssetConversionAdapter<Balances, AssetConversion, TokenLocationV3>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -1157,18 +1164,16 @@ impl_runtime_apis! {
|
|||||||
impl pallet_asset_conversion::AssetConversionApi<
|
impl pallet_asset_conversion::AssetConversionApi<
|
||||||
Block,
|
Block,
|
||||||
Balance,
|
Balance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
> for Runtime
|
> for Runtime
|
||||||
{
|
{
|
||||||
fn quote_price_exact_tokens_for_tokens(asset1: MultiLocation, asset2: MultiLocation, amount: Balance, include_fee: bool) -> Option<Balance> {
|
fn quote_price_exact_tokens_for_tokens(asset1: xcm::v3::Location, asset2: xcm::v3::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
|
||||||
AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
|
AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
|
||||||
}
|
}
|
||||||
|
fn quote_price_tokens_for_exact_tokens(asset1: xcm::v3::Location, asset2: xcm::v3::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
|
||||||
fn quote_price_tokens_for_exact_tokens(asset1: MultiLocation, asset2: MultiLocation, amount: Balance, include_fee: bool) -> Option<Balance> {
|
|
||||||
AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
|
AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
|
||||||
}
|
}
|
||||||
|
fn get_reserves(asset1: xcm::v3::Location, asset2: xcm::v3::Location) -> Option<(Balance, Balance)> {
|
||||||
fn get_reserves(asset1: MultiLocation, asset2: MultiLocation) -> Option<(Balance, Balance)> {
|
|
||||||
AssetConversion::get_reserves(asset1, asset2).ok()
|
AssetConversion::get_reserves(asset1, asset2).ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1222,7 +1227,7 @@ impl_runtime_apis! {
|
|||||||
AccountId,
|
AccountId,
|
||||||
> for Runtime
|
> for Runtime
|
||||||
{
|
{
|
||||||
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedMultiAssets, assets_common::runtime_api::FungiblesAccessError> {
|
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedAssets, assets_common::runtime_api::FungiblesAccessError> {
|
||||||
use assets_common::fungible_conversion::{convert, convert_balance};
|
use assets_common::fungible_conversion::{convert, convert_balance};
|
||||||
Ok([
|
Ok([
|
||||||
// collect pallet_balance
|
// collect pallet_balance
|
||||||
@@ -1346,45 +1351,45 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||||
fn reachable_dest() -> Option<MultiLocation> {
|
fn reachable_dest() -> Option<Location> {
|
||||||
Some(Parent.into())
|
Some(Parent.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Relay/native token can be teleported between AH and Relay.
|
// Relay/native token can be teleported between AH and Relay.
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
Parent.into(),
|
Parent.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// AH can reserve transfer native token to some random parachain.
|
// AH can reserve transfer native token to some random parachain.
|
||||||
let random_para_id = 43211234;
|
let random_para_id = 43211234;
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
||||||
random_para_id.into()
|
random_para_id.into()
|
||||||
);
|
);
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
ParentThen(Parachain(random_para_id).into()).into(),
|
ParentThen(Parachain(random_para_id).into()).into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_complex_asset_transfer(
|
fn set_up_complex_asset_transfer(
|
||||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
) -> Option<(xcm::v4::Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||||
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
|
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
|
||||||
// fees using teleported native token.
|
// fees using teleported native token.
|
||||||
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
|
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
|
||||||
let dest = Parent.into();
|
let dest = Parent.into();
|
||||||
|
|
||||||
let fee_amount = EXISTENTIAL_DEPOSIT;
|
let fee_amount = EXISTENTIAL_DEPOSIT;
|
||||||
let fee_asset: MultiAsset = (MultiLocation::parent(), fee_amount).into();
|
let fee_asset: Asset = (Location::parent(), fee_amount).into();
|
||||||
|
|
||||||
let who = frame_benchmarking::whitelisted_caller();
|
let who = frame_benchmarking::whitelisted_caller();
|
||||||
// Give some multiple of the existential deposit
|
// Give some multiple of the existential deposit
|
||||||
@@ -1402,13 +1407,13 @@ impl_runtime_apis! {
|
|||||||
Runtime,
|
Runtime,
|
||||||
pallet_assets::Instance1
|
pallet_assets::Instance1
|
||||||
>(true, initial_asset_amount);
|
>(true, initial_asset_amount);
|
||||||
let asset_location = MultiLocation::new(
|
let asset_location = Location::new(
|
||||||
0,
|
0,
|
||||||
X2(PalletInstance(50), GeneralIndex(u32::from(asset_id).into()))
|
[PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]
|
||||||
);
|
);
|
||||||
let transfer_asset: MultiAsset = (asset_location, asset_amount).into();
|
let transfer_asset: Asset = (asset_location, asset_amount).into();
|
||||||
|
|
||||||
let assets: MultiAssets = vec![fee_asset.clone(), transfer_asset].into();
|
let assets: xcm::v4::Assets = vec![fee_asset.clone(), transfer_asset].into();
|
||||||
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
|
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
|
||||||
|
|
||||||
// verify transferred successfully
|
// verify transferred successfully
|
||||||
@@ -1432,14 +1437,14 @@ impl_runtime_apis! {
|
|||||||
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn ensure_bridged_target_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn ensure_bridged_target_destination() -> Result<Location, BenchmarkError> {
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
||||||
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
||||||
);
|
);
|
||||||
let bridged_asset_hub = xcm_config::bridging::to_westend::AssetHubWestend::get();
|
let bridged_asset_hub = xcm_config::bridging::to_westend::AssetHubWestend::get();
|
||||||
let _ = PolkadotXcm::force_xcm_version(
|
let _ = PolkadotXcm::force_xcm_version(
|
||||||
RuntimeOrigin::root(),
|
RuntimeOrigin::root(),
|
||||||
Box::new(bridged_asset_hub),
|
Box::new(bridged_asset_hub.clone()),
|
||||||
XCM_VERSION,
|
XCM_VERSION,
|
||||||
).map_err(|e| {
|
).map_err(|e| {
|
||||||
log::error!(
|
log::error!(
|
||||||
@@ -1455,12 +1460,11 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use xcm::latest::prelude::*;
|
|
||||||
use xcm_config::{TokenLocation, MaxAssetsIntoHolding};
|
use xcm_config::{TokenLocation, MaxAssetsIntoHolding};
|
||||||
use pallet_xcm_benchmarks::asset_instance_from;
|
use pallet_xcm_benchmarks::asset_instance_from;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||||
TokenLocation::get(),
|
TokenLocation::get(),
|
||||||
ExistentialDeposit::get()
|
ExistentialDeposit::get()
|
||||||
).into());
|
).into());
|
||||||
@@ -1471,33 +1475,33 @@ impl_runtime_apis! {
|
|||||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||||
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
||||||
xcm_config::XcmConfig,
|
xcm_config::XcmConfig,
|
||||||
ExistentialDepositMultiAsset,
|
ExistentialDepositAsset,
|
||||||
xcm_config::PriceForParentDelivery,
|
xcm_config::PriceForParentDelivery,
|
||||||
>;
|
>;
|
||||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||||
Ok(TokenLocation::get())
|
Ok(TokenLocation::get())
|
||||||
}
|
}
|
||||||
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
|
fn worst_case_holding(depositable_count: u32) -> xcm::v4::Assets {
|
||||||
// A mix of fungible, non-fungible, and concrete assets.
|
// A mix of fungible, non-fungible, and concrete assets.
|
||||||
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
||||||
let holding_fungibles = holding_non_fungibles.saturating_sub(1);
|
let holding_fungibles = holding_non_fungibles.saturating_sub(1);
|
||||||
let fungibles_amount: u128 = 100;
|
let fungibles_amount: u128 = 100;
|
||||||
let mut assets = (0..holding_fungibles)
|
let mut assets = (0..holding_fungibles)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(GeneralIndex(i as u128).into()),
|
id: GeneralIndex(i as u128).into(),
|
||||||
fun: Fungible(fungibles_amount * i as u128),
|
fun: Fungible(fungibles_amount * i as u128),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
.chain(core::iter::once(Asset { id: Here.into(), fun: Fungible(u128::MAX) }))
|
||||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
.chain((0..holding_non_fungibles).map(|i| Asset {
|
||||||
id: Concrete(GeneralIndex(i as u128).into()),
|
id: GeneralIndex(i as u128).into(),
|
||||||
fun: NonFungible(asset_instance_from(i)),
|
fun: NonFungible(asset_instance_from(i)),
|
||||||
}))
|
}))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
assets.push(MultiAsset {
|
assets.push(Asset {
|
||||||
id: Concrete(TokenLocation::get()),
|
id: AssetId(TokenLocation::get()),
|
||||||
fun: Fungible(1_000_000 * UNITS),
|
fun: Fungible(1_000_000 * UNITS),
|
||||||
});
|
});
|
||||||
assets.into()
|
assets.into()
|
||||||
@@ -1505,16 +1509,16 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||||
TokenLocation::get(),
|
TokenLocation::get(),
|
||||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(TokenLocation::get()) },
|
Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
|
||||||
));
|
));
|
||||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||||
// AssetHubRococo trusts AssetHubWestend as reserve for WNDs
|
// AssetHubRococo trusts AssetHubWestend as reserve for WNDs
|
||||||
pub TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(
|
pub TrustedReserve: Option<(Location, Asset)> = Some(
|
||||||
(
|
(
|
||||||
xcm_config::bridging::to_westend::AssetHubWestend::get(),
|
xcm_config::bridging::to_westend::AssetHubWestend::get(),
|
||||||
MultiAsset::from((xcm_config::bridging::to_westend::WndLocation::get(), 1000000000000 as u128))
|
Asset::from((xcm_config::bridging::to_westend::WndLocation::get(), 1000000000000 as u128))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1526,9 +1530,9 @@ impl_runtime_apis! {
|
|||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
type TrustedReserve = TrustedReserve;
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_asset() -> Asset {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(TokenLocation::get()),
|
id: AssetId(TokenLocation::get()),
|
||||||
fun: Fungible(UNITS),
|
fun: Fungible(UNITS),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1542,42 +1546,42 @@ impl_runtime_apis! {
|
|||||||
(0u64, Response::Version(Default::default()))
|
(0u64, Response::Version(Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
fn worst_case_asset_exchange() -> Result<(xcm::v4::Assets, xcm::v4::Assets), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||||
match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() {
|
match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() {
|
||||||
Some(alias) => Ok(alias),
|
Some(alias) => Ok(alias),
|
||||||
None => Err(BenchmarkError::Skip)
|
None => Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||||
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||||
Ok(TokenLocation::get())
|
Ok(TokenLocation::get())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
fn claimable_asset() -> Result<(Location, Location, xcm::v4::Assets), BenchmarkError> {
|
||||||
let origin = TokenLocation::get();
|
let origin = TokenLocation::get();
|
||||||
let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into();
|
let assets: xcm::v4::Assets = (TokenLocation::get(), 1_000 * UNITS).into();
|
||||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
let ticket = Location { parents: 0, interior: Here };
|
||||||
Ok((origin, ticket, assets))
|
Ok((origin, ticket, assets))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_message_origin_and_destination(
|
fn export_message_origin_and_destination(
|
||||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||||
|
|
||||||
trait WeighMultiAssets {
|
trait WeighAssets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
fn weigh_assets(&self, weight: Weight) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_ASSETS: u64 = 100;
|
const MAX_ASSETS: u64 = 100;
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssetFilter {
|
impl WeighAssets for AssetFilter {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
match self {
|
match self {
|
||||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||||
Self::Wild(asset) => match asset {
|
Self::Wild(asset) => match asset {
|
||||||
@@ -50,40 +50,36 @@ impl WeighMultiAssets for MultiAssetFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssets {
|
impl WeighAssets for Assets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AssetHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
pub struct AssetHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||||
impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
||||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||||
}
|
}
|
||||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||||
}
|
}
|
||||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||||
}
|
}
|
||||||
fn query_response(
|
fn query_response(
|
||||||
_query_id: &u64,
|
_query_id: &u64,
|
||||||
_response: &Response,
|
_response: &Response,
|
||||||
_max_weight: &Weight,
|
_max_weight: &Weight,
|
||||||
_querier: &Option<MultiLocation>,
|
_querier: &Option<Location>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
XcmGeneric::<Runtime>::query_response()
|
XcmGeneric::<Runtime>::query_response()
|
||||||
}
|
}
|
||||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||||
}
|
}
|
||||||
fn transfer_reserve_asset(
|
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssets,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn transact(
|
fn transact(
|
||||||
_origin_type: &OriginKind,
|
_origin_type: &OriginKind,
|
||||||
@@ -111,43 +107,35 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
|||||||
fn clear_origin() -> Weight {
|
fn clear_origin() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_origin()
|
XcmGeneric::<Runtime>::clear_origin()
|
||||||
}
|
}
|
||||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||||
XcmGeneric::<Runtime>::descend_origin()
|
XcmGeneric::<Runtime>::descend_origin()
|
||||||
}
|
}
|
||||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_error()
|
XcmGeneric::<Runtime>::report_error()
|
||||||
}
|
}
|
||||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||||
}
|
}
|
||||||
fn deposit_reserve_asset(
|
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn initiate_reserve_withdraw(
|
fn initiate_reserve_withdraw(
|
||||||
assets: &MultiAssetFilter,
|
assets: &AssetFilter,
|
||||||
_reserve: &MultiLocation,
|
_reserve: &Location,
|
||||||
_xcm: &Xcm<()>,
|
_xcm: &Xcm<()>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||||
}
|
}
|
||||||
fn initiate_teleport(
|
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
|
||||||
}
|
}
|
||||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_holding()
|
XcmGeneric::<Runtime>::report_holding()
|
||||||
}
|
}
|
||||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||||
XcmGeneric::<Runtime>::buy_execution()
|
XcmGeneric::<Runtime>::buy_execution()
|
||||||
}
|
}
|
||||||
fn refund_surplus() -> Weight {
|
fn refund_surplus() -> Weight {
|
||||||
@@ -162,7 +150,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
|||||||
fn clear_error() -> Weight {
|
fn clear_error() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_error()
|
XcmGeneric::<Runtime>::clear_error()
|
||||||
}
|
}
|
||||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||||
XcmGeneric::<Runtime>::claim_asset()
|
XcmGeneric::<Runtime>::claim_asset()
|
||||||
}
|
}
|
||||||
fn trap(_code: &u64) -> Weight {
|
fn trap(_code: &u64) -> Weight {
|
||||||
@@ -174,13 +162,13 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
|||||||
fn unsubscribe_version() -> Weight {
|
fn unsubscribe_version() -> Weight {
|
||||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||||
}
|
}
|
||||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
fn burn_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||||
}
|
}
|
||||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
fn expect_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||||
}
|
}
|
||||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::expect_origin()
|
XcmGeneric::<Runtime>::expect_origin()
|
||||||
}
|
}
|
||||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||||
@@ -213,16 +201,16 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
|||||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn set_fees_mode(_: &bool) -> Weight {
|
fn set_fees_mode(_: &bool) -> Weight {
|
||||||
@@ -234,11 +222,11 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
|
|||||||
fn clear_topic() -> Weight {
|
fn clear_topic() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_topic()
|
XcmGeneric::<Runtime>::clear_topic()
|
||||||
}
|
}
|
||||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
fn alias_origin(_: &Location) -> Weight {
|
||||||
// XCM Executor does not currently support alias origin operations
|
// XCM Executor does not currently support alias origin operations
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::unpaid_execution()
|
XcmGeneric::<Runtime>::unpaid_execution()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ use super::{
|
|||||||
ToWestendXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
|
ToWestendXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
|
||||||
};
|
};
|
||||||
use assets_common::{
|
use assets_common::{
|
||||||
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
|
local_and_foreign_assets::MatchesLocalAndForeignAssetsLocation,
|
||||||
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset},
|
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset},
|
||||||
TrustBackedAssetsAsMultiLocation,
|
TrustBackedAssetsAsLocation,
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{
|
traits::{
|
||||||
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
|
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
|
||||||
PalletInfoAccess,
|
PalletInfoAccess,
|
||||||
@@ -64,26 +64,32 @@ use xcm_builder::{
|
|||||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TokenLocation: MultiLocation = MultiLocation::parent();
|
pub const TokenLocation: Location = Location::parent();
|
||||||
|
pub const TokenLocationV3: xcm::v3::Location = xcm::v3::Location::parent();
|
||||||
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
|
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
|
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||||
pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap();
|
pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap();
|
||||||
pub AssetsPalletIndex: u32 = <Assets as PalletInfoAccess>::index() as u32;
|
pub TrustBackedAssetsPalletLocation: Location =
|
||||||
pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(AssetsPalletIndex::get() as u8).into();
|
PalletInstance(TrustBackedAssetsPalletIndex::get()).into();
|
||||||
pub ForeignAssetsPalletLocation: MultiLocation =
|
pub TrustBackedAssetsPalletIndex: u8 = <Assets as PalletInfoAccess>::index() as u8;
|
||||||
|
pub TrustBackedAssetsPalletLocationV3: xcm::v3::Location =
|
||||||
|
xcm::v3::Junction::PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||||
|
pub ForeignAssetsPalletLocation: Location =
|
||||||
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
|
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
pub PoolAssetsPalletLocation: MultiLocation =
|
pub PoolAssetsPalletLocation: Location =
|
||||||
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
|
pub PoolAssetsPalletLocationV3: xcm::v3::Location =
|
||||||
|
xcm::v3::Junction::PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||||
|
pub const GovernanceLocation: Location = Location::parent();
|
||||||
pub StakingPot: AccountId = CollatorSelection::account_id();
|
pub StakingPot: AccountId = CollatorSelection::account_id();
|
||||||
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
|
|
||||||
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
||||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -110,7 +116,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<TokenLocation>,
|
IsConcrete<TokenLocation>,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -128,7 +134,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
|||||||
Assets,
|
Assets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
TrustBackedAssetsConvertedConcreteId,
|
TrustBackedAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -145,8 +151,8 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
|
|||||||
// Ignore `TrustBackedAssets` explicitly
|
// Ignore `TrustBackedAssets` explicitly
|
||||||
StartsWith<TrustBackedAssetsPalletLocation>,
|
StartsWith<TrustBackedAssetsPalletLocation>,
|
||||||
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
|
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
|
||||||
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
|
// - foreign assets from our consensus should be: `Location {parents: 1, X*(Parachain(xyz),
|
||||||
// X*(Parachain(xyz), ..)}`
|
// ..)}`
|
||||||
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
|
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
|
||||||
// be accepted here
|
// be accepted here
|
||||||
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
|
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
|
||||||
@@ -160,7 +166,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
|
|||||||
ForeignAssets,
|
ForeignAssets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
ForeignAssetsConvertedConcreteId,
|
ForeignAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -180,7 +186,7 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
|
|||||||
PoolAssets,
|
PoolAssets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
PoolAssetsConvertedConcreteId,
|
PoolAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -195,20 +201,32 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
|
|||||||
pub type AssetTransactors =
|
pub type AssetTransactors =
|
||||||
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
|
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
|
||||||
|
|
||||||
/// Simple `MultiLocation` matcher for Local and Foreign asset `MultiLocation`.
|
/// Simple `Location` matcher for Local and Foreign asset `Location`.
|
||||||
pub struct LocalAndForeignAssetsMultiLocationMatcher;
|
pub struct LocalAndForeignAssetsLocationMatcher;
|
||||||
impl MatchesLocalAndForeignAssetsMultiLocation for LocalAndForeignAssetsMultiLocationMatcher {
|
impl MatchesLocalAndForeignAssetsLocation<xcm::v3::Location>
|
||||||
fn is_local(location: &MultiLocation) -> bool {
|
for LocalAndForeignAssetsLocationMatcher
|
||||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
{
|
||||||
TrustBackedAssetsConvertedConcreteId::contains(location)
|
fn is_local(location: &xcm::v3::Location) -> bool {
|
||||||
|
use assets_common::fungible_conversion::MatchesLocation;
|
||||||
|
let latest_location: Location = if let Ok(location) = (*location).try_into() {
|
||||||
|
location
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
TrustBackedAssetsConvertedConcreteId::contains(&latest_location)
|
||||||
}
|
}
|
||||||
fn is_foreign(location: &MultiLocation) -> bool {
|
fn is_foreign(location: &xcm::v3::Location) -> bool {
|
||||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
use assets_common::fungible_conversion::MatchesLocation;
|
||||||
ForeignAssetsConvertedConcreteId::contains(location)
|
let latest_location: Location = if let Ok(location) = (*location).try_into() {
|
||||||
|
location
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
ForeignAssetsConvertedConcreteId::contains(&latest_location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Contains<MultiLocation> for LocalAndForeignAssetsMultiLocationMatcher {
|
impl Contains<xcm::v3::Location> for LocalAndForeignAssetsLocationMatcher {
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &xcm::v3::Location) -> bool {
|
||||||
Self::is_local(location) || Self::is_foreign(location)
|
Self::is_local(location) || Self::is_foreign(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,11 +261,11 @@ parameter_types! {
|
|||||||
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
||||||
}
|
}
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsPlurality;
|
||||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsPlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||||
@@ -556,12 +574,12 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type Trader = (
|
type Trader = (
|
||||||
UsingComponents<WeightToFee, TokenLocation, AccountId, Balances, ToStakingPot<Runtime>>,
|
UsingComponents<WeightToFee, TokenLocation, AccountId, Balances, ToStakingPot<Runtime>>,
|
||||||
cumulus_primitives_utility::SwapFirstAssetTrader<
|
cumulus_primitives_utility::SwapFirstAssetTrader<
|
||||||
TokenLocation,
|
TokenLocationV3,
|
||||||
crate::AssetConversion,
|
crate::AssetConversion,
|
||||||
WeightToFee,
|
WeightToFee,
|
||||||
crate::NativeAndAssets,
|
crate::NativeAndAssets,
|
||||||
(
|
(
|
||||||
TrustBackedAssetsAsMultiLocation<TrustBackedAssetsPalletLocation, Balance>,
|
TrustBackedAssetsAsLocation<TrustBackedAssetsPalletLocation, Balance>,
|
||||||
ForeignAssetsConvertedConcreteId,
|
ForeignAssetsConvertedConcreteId,
|
||||||
),
|
),
|
||||||
ResolveAssetTo<StakingPot, crate::NativeAndAssets>,
|
ResolveAssetTo<StakingPot, crate::NativeAndAssets>,
|
||||||
@@ -588,7 +606,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type Aliasers = Nothing;
|
type Aliasers = Nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a local signed origin into an XCM multilocation.
|
/// Converts a local signed origin into an XCM location.
|
||||||
/// Forms the basis for local origins sending/executing XCMs.
|
/// Forms the basis for local origins sending/executing XCMs.
|
||||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||||
|
|
||||||
@@ -664,9 +682,9 @@ pub type ForeignCreatorsSovereignAccountOf = (
|
|||||||
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
||||||
pub struct XcmBenchmarkHelper;
|
pub struct XcmBenchmarkHelper;
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
|
impl pallet_assets::BenchmarkHelper<xcm::v3::Location> for XcmBenchmarkHelper {
|
||||||
fn create_asset_id_parameter(id: u32) -> MultiLocation {
|
fn create_asset_id_parameter(id: u32) -> xcm::v3::Location {
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
|
xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(id)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,7 +716,7 @@ pub mod bridging {
|
|||||||
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
|
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
|
||||||
|
|
||||||
pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID;
|
pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID;
|
||||||
pub SiblingBridgeHub: MultiLocation = MultiLocation::new(1, X1(Parachain(SiblingBridgeHubParaId::get())));
|
pub SiblingBridgeHub: Location = Location::new(1, [Parachain(SiblingBridgeHubParaId::get())]);
|
||||||
/// Router expects payment with this `AssetId`.
|
/// Router expects payment with this `AssetId`.
|
||||||
/// (`AssetId` has to be aligned with `BridgeTable`)
|
/// (`AssetId` has to be aligned with `BridgeTable`)
|
||||||
pub XcmBridgeHubRouterFeeAssetId: AssetId = TokenLocation::get().into();
|
pub XcmBridgeHubRouterFeeAssetId: AssetId = TokenLocation::get().into();
|
||||||
@@ -722,25 +740,25 @@ pub mod bridging {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub SiblingBridgeHubWithBridgeHubWestendInstance: MultiLocation = MultiLocation::new(
|
pub SiblingBridgeHubWithBridgeHubWestendInstance: Location = Location::new(
|
||||||
1,
|
1,
|
||||||
X2(
|
[
|
||||||
Parachain(SiblingBridgeHubParaId::get()),
|
Parachain(SiblingBridgeHubParaId::get()),
|
||||||
PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)
|
PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub const WestendNetwork: NetworkId = NetworkId::Westend;
|
pub const WestendNetwork: NetworkId = NetworkId::Westend;
|
||||||
pub AssetHubWestend: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(WestendNetwork::get()), Parachain(bp_asset_hub_westend::ASSET_HUB_WESTEND_PARACHAIN_ID)));
|
pub AssetHubWestend: Location = Location::new(2, [GlobalConsensus(WestendNetwork::get()), Parachain(bp_asset_hub_westend::ASSET_HUB_WESTEND_PARACHAIN_ID)]);
|
||||||
pub WndLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(WestendNetwork::get())));
|
pub WndLocation: Location = Location::new(2, [GlobalConsensus(WestendNetwork::get())]);
|
||||||
|
|
||||||
pub WndFromAssetHubWestend: (MultiAssetFilter, MultiLocation) = (
|
pub WndFromAssetHubWestend: (AssetFilter, Location) = (
|
||||||
Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }),
|
Wild(AllOf { fun: WildFungible, id: AssetId(WndLocation::get()) }),
|
||||||
AssetHubWestend::get()
|
AssetHubWestend::get()
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Set up exporters configuration.
|
/// Set up exporters configuration.
|
||||||
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
|
/// `Option<Asset>` represents static "base fee" which is used for total delivery fee calculation.
|
||||||
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
||||||
NetworkExportTableItem::new(
|
NetworkExportTableItem::new(
|
||||||
WestendNetwork::get(),
|
WestendNetwork::get(),
|
||||||
@@ -757,15 +775,15 @@ pub mod bridging {
|
|||||||
];
|
];
|
||||||
|
|
||||||
/// Universal aliases
|
/// Universal aliases
|
||||||
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
|
pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter(
|
||||||
sp_std::vec![
|
sp_std::vec![
|
||||||
(SiblingBridgeHubWithBridgeHubWestendInstance::get(), GlobalConsensus(WestendNetwork::get()))
|
(SiblingBridgeHubWithBridgeHubWestendInstance::get(), GlobalConsensus(WestendNetwork::get()))
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Contains<(MultiLocation, Junction)> for UniversalAliases {
|
impl Contains<(Location, Junction)> for UniversalAliases {
|
||||||
fn contains(alias: &(MultiLocation, Junction)) -> bool {
|
fn contains(alias: &(Location, Junction)) -> bool {
|
||||||
UniversalAliases::get().contains(alias)
|
UniversalAliases::get().contains(alias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -804,16 +822,16 @@ pub mod bridging {
|
|||||||
/// Polkadot uses 10 decimals, Kusama and Rococo 12 decimals.
|
/// Polkadot uses 10 decimals, Kusama and Rococo 12 decimals.
|
||||||
pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000;
|
pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000;
|
||||||
pub storage BridgeHubEthereumBaseFee: Balance = DefaultBridgeHubEthereumBaseFee::get();
|
pub storage BridgeHubEthereumBaseFee: Balance = DefaultBridgeHubEthereumBaseFee::get();
|
||||||
pub SiblingBridgeHubWithEthereumInboundQueueInstance: MultiLocation = MultiLocation::new(
|
pub SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new(
|
||||||
1,
|
1,
|
||||||
X2(
|
[
|
||||||
Parachain(SiblingBridgeHubParaId::get()),
|
Parachain(SiblingBridgeHubParaId::get()),
|
||||||
PalletInstance(parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX)
|
PalletInstance(parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX)
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Set up exporters configuration.
|
/// Set up exporters configuration.
|
||||||
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
|
/// `Option<Asset>` represents static "base fee" which is used for total delivery fee calculation.
|
||||||
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
||||||
NetworkExportTableItem::new(
|
NetworkExportTableItem::new(
|
||||||
EthereumNetwork::get(),
|
EthereumNetwork::get(),
|
||||||
@@ -827,7 +845,7 @@ pub mod bridging {
|
|||||||
];
|
];
|
||||||
|
|
||||||
/// Universal aliases
|
/// Universal aliases
|
||||||
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
|
pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter(
|
||||||
sp_std::vec![
|
sp_std::vec![
|
||||||
(SiblingBridgeHubWithEthereumInboundQueueInstance::get(), GlobalConsensus(EthereumNetwork::get())),
|
(SiblingBridgeHubWithEthereumInboundQueueInstance::get(), GlobalConsensus(EthereumNetwork::get())),
|
||||||
]
|
]
|
||||||
@@ -837,8 +855,8 @@ pub mod bridging {
|
|||||||
pub type IsTrustedBridgedReserveLocationForForeignAsset =
|
pub type IsTrustedBridgedReserveLocationForForeignAsset =
|
||||||
matching::IsForeignConcreteAsset<FromNetwork<UniversalLocation, EthereumNetwork>>;
|
matching::IsForeignConcreteAsset<FromNetwork<UniversalLocation, EthereumNetwork>>;
|
||||||
|
|
||||||
impl Contains<(MultiLocation, Junction)> for UniversalAliases {
|
impl Contains<(Location, Junction)> for UniversalAliases {
|
||||||
fn contains(alias: &(MultiLocation, Junction)) -> bool {
|
fn contains(alias: &(Location, Junction)) -> bool {
|
||||||
UniversalAliases::get().contains(alias)
|
UniversalAliases::get().contains(alias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -850,7 +868,7 @@ pub mod bridging {
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
impl BridgingBenchmarksHelper {
|
impl BridgingBenchmarksHelper {
|
||||||
pub fn prepare_universal_alias() -> Option<(MultiLocation, Junction)> {
|
pub fn prepare_universal_alias() -> Option<(Location, Junction)> {
|
||||||
let alias =
|
let alias =
|
||||||
to_westend::UniversalAliases::get()
|
to_westend::UniversalAliases::get()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
@@ -19,12 +19,18 @@
|
|||||||
|
|
||||||
use asset_hub_rococo_runtime::{
|
use asset_hub_rococo_runtime::{
|
||||||
xcm_config,
|
xcm_config,
|
||||||
xcm_config::{bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, TokenLocation},
|
xcm_config::{
|
||||||
|
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, TokenLocation,
|
||||||
|
TokenLocationV3,
|
||||||
|
},
|
||||||
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, RuntimeCall,
|
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, RuntimeCall,
|
||||||
RuntimeEvent, ToWestendXcmRouterInstance, XcmpQueue,
|
RuntimeEvent, ToWestendXcmRouterInstance, XcmpQueue,
|
||||||
};
|
};
|
||||||
pub use asset_hub_rococo_runtime::{
|
pub use asset_hub_rococo_runtime::{
|
||||||
xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, XcmConfig},
|
xcm_config::{
|
||||||
|
CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3,
|
||||||
|
XcmConfig,
|
||||||
|
},
|
||||||
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
|
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
|
||||||
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
|
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
|
||||||
TrustBackedAssetsInstance,
|
TrustBackedAssetsInstance,
|
||||||
@@ -49,14 +55,18 @@ use parachains_common::{
|
|||||||
};
|
};
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||||
use xcm_executor::traits::{Identity, JustTry, WeightTrader};
|
use xcm_builder::V4V3LocationConverter;
|
||||||
|
use xcm_executor::traits::{JustTry, WeightTrader};
|
||||||
|
|
||||||
const ALICE: [u8; 32] = [1u8; 32];
|
const ALICE: [u8; 32] = [1u8; 32];
|
||||||
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
|
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
|
||||||
|
|
||||||
type AssetIdForTrustBackedAssetsConvert =
|
type AssetIdForTrustBackedAssetsConvert =
|
||||||
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>;
|
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocationV3>;
|
||||||
|
|
||||||
|
type AssetIdForTrustBackedAssetsConvertLatest =
|
||||||
|
assets_common::AssetIdForTrustBackedAssetsConvertLatest<TrustBackedAssetsPalletLocation>;
|
||||||
|
|
||||||
type RuntimeHelper = asset_test_utils::RuntimeHelper<Runtime, AllPalletsWithoutSystem>;
|
type RuntimeHelper = asset_test_utils::RuntimeHelper<Runtime, AllPalletsWithoutSystem>;
|
||||||
|
|
||||||
@@ -99,7 +109,7 @@ fn test_buy_and_refund_weight_in_native() {
|
|||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (native_location, fee + extra_amount).into();
|
let payment: Asset = (native_location.clone(), fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -108,7 +118,7 @@ fn test_buy_and_refund_weight_in_native() {
|
|||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount =
|
||||||
unused_asset.fungible.get(&native_location.into()).map_or(0, |a| *a);
|
unused_asset.fungible.get(&native_location.clone().into()).map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(Balances::total_issuance(), total_issuance);
|
assert_eq!(Balances::total_issuance(), total_issuance);
|
||||||
|
|
||||||
@@ -144,7 +154,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
||||||
let staking_pot = CollatorSelection::account_id();
|
let staking_pot = CollatorSelection::account_id();
|
||||||
let asset_1: u32 = 1;
|
let asset_1: u32 = 1;
|
||||||
let native_location = TokenLocation::get();
|
let native_location = TokenLocationV3::get();
|
||||||
let asset_1_location =
|
let asset_1_location =
|
||||||
AssetIdForTrustBackedAssetsConvert::convert_back(&asset_1).unwrap();
|
AssetIdForTrustBackedAssetsConvert::convert_back(&asset_1).unwrap();
|
||||||
// bob's initial balance for native and `asset1` assets.
|
// bob's initial balance for native and `asset1` assets.
|
||||||
@@ -180,6 +190,8 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
let asset_total_issuance = Assets::total_issuance(asset_1);
|
let asset_total_issuance = Assets::total_issuance(asset_1);
|
||||||
let native_total_issuance = Balances::total_issuance();
|
let native_total_issuance = Balances::total_issuance();
|
||||||
|
|
||||||
|
let asset_1_location_latest: Location = asset_1_location.try_into().unwrap();
|
||||||
|
|
||||||
// prepare input to buy weight.
|
// prepare input to buy weight.
|
||||||
let weight = Weight::from_parts(4_000_000_000, 0);
|
let weight = Weight::from_parts(4_000_000_000, 0);
|
||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
@@ -187,7 +199,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (asset_1_location, asset_fee + extra_amount).into();
|
let payment: Asset = (asset_1_location_latest.clone(), asset_fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -195,8 +207,10 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount = unused_asset
|
||||||
unused_asset.fungible.get(&asset_1_location.into()).map_or(0, |a| *a);
|
.fungible
|
||||||
|
.get(&asset_1_location_latest.clone().into())
|
||||||
|
.map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);
|
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);
|
||||||
|
|
||||||
@@ -210,7 +224,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
|
|
||||||
// refund.
|
// refund.
|
||||||
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
||||||
assert_eq!(actual_refund, (asset_1_location, asset_refund).into());
|
assert_eq!(actual_refund, (asset_1_location_latest, asset_refund).into());
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
||||||
@@ -239,9 +253,15 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
.execute_with(|| {
|
.execute_with(|| {
|
||||||
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
||||||
let staking_pot = CollatorSelection::account_id();
|
let staking_pot = CollatorSelection::account_id();
|
||||||
let native_location = TokenLocation::get();
|
let native_location = TokenLocationV3::get();
|
||||||
let foreign_location =
|
let foreign_location = xcm::v3::Location {
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1234), GeneralIndex(12345)) };
|
parents: 1,
|
||||||
|
interior: (
|
||||||
|
xcm::v3::Junction::Parachain(1234),
|
||||||
|
xcm::v3::Junction::GeneralIndex(12345),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
};
|
||||||
// bob's initial balance for native and `asset1` assets.
|
// bob's initial balance for native and `asset1` assets.
|
||||||
let initial_balance = 200 * UNITS;
|
let initial_balance = 200 * UNITS;
|
||||||
// liquidity for both arms of (native, asset1) pool.
|
// liquidity for both arms of (native, asset1) pool.
|
||||||
@@ -280,6 +300,8 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
let asset_total_issuance = ForeignAssets::total_issuance(foreign_location);
|
let asset_total_issuance = ForeignAssets::total_issuance(foreign_location);
|
||||||
let native_total_issuance = Balances::total_issuance();
|
let native_total_issuance = Balances::total_issuance();
|
||||||
|
|
||||||
|
let foreign_location_latest: Location = foreign_location.try_into().unwrap();
|
||||||
|
|
||||||
// prepare input to buy weight.
|
// prepare input to buy weight.
|
||||||
let weight = Weight::from_parts(4_000_000_000, 0);
|
let weight = Weight::from_parts(4_000_000_000, 0);
|
||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
@@ -287,7 +309,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (foreign_location, asset_fee + extra_amount).into();
|
let payment: Asset = (foreign_location_latest.clone(), asset_fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -295,8 +317,10 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount = unused_asset
|
||||||
unused_asset.fungible.get(&foreign_location.into()).map_or(0, |a| *a);
|
.fungible
|
||||||
|
.get(&foreign_location_latest.clone().into())
|
||||||
|
.map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::total_issuance(foreign_location),
|
ForeignAssets::total_issuance(foreign_location),
|
||||||
@@ -313,7 +337,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
|
|
||||||
// refund.
|
// refund.
|
||||||
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
||||||
assert_eq!(actual_refund, (foreign_location, asset_refund).into());
|
assert_eq!(actual_refund, (foreign_location_latest, asset_refund).into());
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
||||||
@@ -343,19 +367,21 @@ fn test_assets_balances_api_works() {
|
|||||||
.build()
|
.build()
|
||||||
.execute_with(|| {
|
.execute_with(|| {
|
||||||
let local_asset_id = 1;
|
let local_asset_id = 1;
|
||||||
let foreign_asset_id_multilocation =
|
let foreign_asset_id_location = xcm::v3::Location::new(
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1234), GeneralIndex(12345)) };
|
1,
|
||||||
|
[xcm::v3::Junction::Parachain(1234), xcm::v3::Junction::GeneralIndex(12345)],
|
||||||
|
);
|
||||||
|
|
||||||
// check before
|
// check before
|
||||||
assert_eq!(Assets::balance(local_asset_id, AccountId::from(ALICE)), 0);
|
assert_eq!(Assets::balance(local_asset_id, AccountId::from(ALICE)), 0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)),
|
ForeignAssets::balance(foreign_asset_id_location, AccountId::from(ALICE)),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0);
|
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0);
|
||||||
assert!(Runtime::query_account_balances(AccountId::from(ALICE))
|
assert!(Runtime::query_account_balances(AccountId::from(ALICE))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_as::<MultiAssets>()
|
.try_as::<XcmAssets>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_none());
|
.is_none());
|
||||||
|
|
||||||
@@ -386,7 +412,7 @@ fn test_assets_balances_api_works() {
|
|||||||
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
||||||
assert_ok!(ForeignAssets::force_create(
|
assert_ok!(ForeignAssets::force_create(
|
||||||
RuntimeHelper::root_origin(),
|
RuntimeHelper::root_origin(),
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
AccountId::from(SOME_ASSET_ADMIN).into(),
|
AccountId::from(SOME_ASSET_ADMIN).into(),
|
||||||
false,
|
false,
|
||||||
foreign_asset_minimum_asset_balance
|
foreign_asset_minimum_asset_balance
|
||||||
@@ -395,7 +421,7 @@ fn test_assets_balances_api_works() {
|
|||||||
// We first mint enough asset for the account to exist for assets
|
// We first mint enough asset for the account to exist for assets
|
||||||
assert_ok!(ForeignAssets::mint(
|
assert_ok!(ForeignAssets::mint(
|
||||||
RuntimeHelper::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
RuntimeHelper::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
AccountId::from(ALICE).into(),
|
AccountId::from(ALICE).into(),
|
||||||
6 * foreign_asset_minimum_asset_balance
|
6 * foreign_asset_minimum_asset_balance
|
||||||
));
|
));
|
||||||
@@ -406,12 +432,12 @@ fn test_assets_balances_api_works() {
|
|||||||
minimum_asset_balance
|
minimum_asset_balance
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)),
|
ForeignAssets::balance(foreign_asset_id_location, AccountId::from(ALICE)),
|
||||||
6 * minimum_asset_balance
|
6 * minimum_asset_balance
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency);
|
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency);
|
||||||
|
|
||||||
let result: MultiAssets = Runtime::query_account_balances(AccountId::from(ALICE))
|
let result: XcmAssets = Runtime::query_account_balances(AccountId::from(ALICE))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -426,13 +452,13 @@ fn test_assets_balances_api_works() {
|
|||||||
)));
|
)));
|
||||||
// check trusted asset
|
// check trusted asset
|
||||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||||
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap(),
|
AssetIdForTrustBackedAssetsConvertLatest::convert_back(&local_asset_id).unwrap(),
|
||||||
minimum_asset_balance
|
minimum_asset_balance
|
||||||
)
|
)
|
||||||
.into())));
|
.into())));
|
||||||
// check foreign asset
|
// check foreign asset
|
||||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||||
Identity::convert_back(&foreign_asset_id_multilocation).unwrap(),
|
V4V3LocationConverter::convert_back(&foreign_asset_id_location).unwrap(),
|
||||||
6 * foreign_asset_minimum_asset_balance
|
6 * foreign_asset_minimum_asset_balance
|
||||||
)
|
)
|
||||||
.into())));
|
.into())));
|
||||||
@@ -503,7 +529,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_
|
|||||||
XcmConfig,
|
XcmConfig,
|
||||||
TrustBackedAssetsInstance,
|
TrustBackedAssetsInstance,
|
||||||
AssetIdForTrustBackedAssets,
|
AssetIdForTrustBackedAssets,
|
||||||
AssetIdForTrustBackedAssetsConvert,
|
AssetIdForTrustBackedAssetsConvertLatest,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
12345,
|
12345,
|
||||||
@@ -520,11 +546,14 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_
|
|||||||
Runtime,
|
Runtime,
|
||||||
XcmConfig,
|
XcmConfig,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
JustTry,
|
JustTry,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1313), GeneralIndex(12345)) },
|
xcm::v3::Location::new(
|
||||||
|
1,
|
||||||
|
[xcm::v3::Junction::Parachain(1313), xcm::v3::Junction::GeneralIndex(12345)]
|
||||||
|
),
|
||||||
Box::new(|| {
|
Box::new(|| {
|
||||||
assert!(Assets::asset_ids().collect::<Vec<_>>().is_empty());
|
assert!(Assets::asset_ids().collect::<Vec<_>>().is_empty());
|
||||||
}),
|
}),
|
||||||
@@ -539,8 +568,8 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
JustTry,
|
V4V3LocationConverter,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AssetDeposit::get(),
|
AssetDeposit::get(),
|
||||||
@@ -637,12 +666,12 @@ mod asset_hub_rococo_tests {
|
|||||||
AccountId::from([73; 32]),
|
AccountId::from([73; 32]),
|
||||||
AccountId::from(BLOCK_AUTHOR_ACCOUNT),
|
AccountId::from(BLOCK_AUTHOR_ACCOUNT),
|
||||||
// receiving WNDs
|
// receiving WNDs
|
||||||
(MultiLocation { parents: 2, interior: X1(GlobalConsensus(Westend)) }, 1000000000000, 1_000_000_000),
|
(xcm::v3::Location::new(2, [xcm::v3::Junction::GlobalConsensus(xcm::v3::NetworkId::Westend)]), 1000000000000, 1_000_000_000),
|
||||||
bridging_to_asset_hub_westend,
|
bridging_to_asset_hub_westend,
|
||||||
(
|
(
|
||||||
X1(PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)),
|
[PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX)].into(),
|
||||||
GlobalConsensus(Westend),
|
GlobalConsensus(Westend),
|
||||||
X1(Parachain(1000))
|
[Parachain(1000)].into()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,21 +76,25 @@ use sp_std::prelude::*;
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use sp_version::NativeVersion;
|
use sp_version::NativeVersion;
|
||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
use xcm::opaque::v3::MultiLocation;
|
|
||||||
use xcm_config::{
|
use xcm_config::{
|
||||||
ForeignAssetsConvertedConcreteId, PoolAssetsConvertedConcreteId,
|
ForeignAssetsConvertedConcreteId, PoolAssetsConvertedConcreteId,
|
||||||
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocation, WestendLocation,
|
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocationV3, WestendLocation,
|
||||||
XcmOriginToTransactDispatchOrigin,
|
WestendLocationV3, XcmOriginToTransactDispatchOrigin,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use sp_runtime::BuildStorage;
|
pub use sp_runtime::BuildStorage;
|
||||||
|
|
||||||
use assets_common::{
|
use assets_common::{foreign_creators::ForeignCreators, matching::FromSiblingParachain};
|
||||||
foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId,
|
|
||||||
};
|
|
||||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||||
use xcm::latest::prelude::*;
|
// We exclude `Assets` since it's the name of a pallet
|
||||||
|
use xcm::latest::prelude::AssetId;
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
use xcm::latest::prelude::{
|
||||||
|
Asset, Fungible, Here, InteriorLocation, Junction, Junction::*, Location, NetworkId,
|
||||||
|
NonFungible, Parent, ParentThen, Response, XCM_VERSION,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::xcm_config::ForeignCreatorsSovereignAccountOf;
|
use crate::xcm_config::ForeignCreatorsSovereignAccountOf;
|
||||||
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
|
||||||
@@ -300,10 +304,11 @@ pub type LocalAndForeignAssets = fungibles::UnionOf<
|
|||||||
Assets,
|
Assets,
|
||||||
ForeignAssets,
|
ForeignAssets,
|
||||||
LocalFromLeft<
|
LocalFromLeft<
|
||||||
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>,
|
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocationV3>,
|
||||||
AssetIdForTrustBackedAssets,
|
AssetIdForTrustBackedAssets,
|
||||||
|
xcm::v3::Location,
|
||||||
>,
|
>,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
AccountId,
|
AccountId,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -311,8 +316,8 @@ pub type LocalAndForeignAssets = fungibles::UnionOf<
|
|||||||
pub type NativeAndAssets = fungible::UnionOf<
|
pub type NativeAndAssets = fungible::UnionOf<
|
||||||
Balances,
|
Balances,
|
||||||
LocalAndForeignAssets,
|
LocalAndForeignAssets,
|
||||||
TargetFromLeft<WestendLocation>,
|
TargetFromLeft<WestendLocationV3, xcm::v3::Location>,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
AccountId,
|
AccountId,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@@ -320,15 +325,15 @@ impl pallet_asset_conversion::Config for Runtime {
|
|||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type HigherPrecisionBalance = sp_core::U256;
|
type HigherPrecisionBalance = sp_core::U256;
|
||||||
type AssetKind = MultiLocation;
|
type AssetKind = xcm::v3::Location;
|
||||||
type Assets = NativeAndAssets;
|
type Assets = NativeAndAssets;
|
||||||
type PoolId = (Self::AssetKind, Self::AssetKind);
|
type PoolId = (Self::AssetKind, Self::AssetKind);
|
||||||
type PoolLocator =
|
type PoolLocator =
|
||||||
pallet_asset_conversion::WithFirstAsset<WestendLocation, AccountId, Self::AssetKind>;
|
pallet_asset_conversion::WithFirstAsset<WestendLocationV3, AccountId, Self::AssetKind>;
|
||||||
type PoolAssetId = u32;
|
type PoolAssetId = u32;
|
||||||
type PoolAssets = PoolAssets;
|
type PoolAssets = PoolAssets;
|
||||||
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
type PoolSetupFee = ConstU128<0>; // Asset class deposit fees are sufficient to prevent spam
|
||||||
type PoolSetupFeeAsset = WestendLocation;
|
type PoolSetupFeeAsset = WestendLocationV3;
|
||||||
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
|
type PoolSetupFeeTarget = ResolveAssetTo<AssetConversionOrigin, Self::Assets>;
|
||||||
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
|
type LiquidityWithdrawalFee = LiquidityWithdrawalFee;
|
||||||
type LPFee = ConstU32<3>;
|
type LPFee = ConstU32<3>;
|
||||||
@@ -338,9 +343,10 @@ impl pallet_asset_conversion::Config for Runtime {
|
|||||||
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_asset_conversion::WeightInfo<Runtime>;
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
|
type BenchmarkHelper = assets_common::benchmarks::AssetPairFactory<
|
||||||
WestendLocation,
|
WestendLocationV3,
|
||||||
parachain_info::Pallet<Runtime>,
|
parachain_info::Pallet<Runtime>,
|
||||||
xcm_config::AssetsPalletIndex,
|
xcm_config::TrustBackedAssetsPalletIndex,
|
||||||
|
xcm::v3::Location,
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,13 +368,14 @@ pub type ForeignAssetsInstance = pallet_assets::Instance2;
|
|||||||
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
|
||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
type AssetId = MultiLocationForAssetId;
|
type AssetId = xcm::v3::Location;
|
||||||
type AssetIdParameter = MultiLocationForAssetId;
|
type AssetIdParameter = xcm::v3::Location;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
type CreateOrigin = ForeignCreators<
|
type CreateOrigin = ForeignCreators<
|
||||||
(FromSiblingParachain<parachain_info::Pallet<Runtime>>,),
|
FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v3::Location>,
|
||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
AccountId,
|
AccountId,
|
||||||
|
xcm::v3::Location,
|
||||||
>;
|
>;
|
||||||
type ForceOrigin = AssetsForceOrigin;
|
type ForceOrigin = AssetsForceOrigin;
|
||||||
type AssetDeposit = ForeignAssetsAssetDeposit;
|
type AssetDeposit = ForeignAssetsAssetDeposit;
|
||||||
@@ -644,7 +651,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(xcm_config::WestendLocation::get());
|
pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||||
}
|
}
|
||||||
@@ -728,7 +735,7 @@ impl pallet_asset_conversion_tx_payment::Config for Runtime {
|
|||||||
type RuntimeEvent = RuntimeEvent;
|
type RuntimeEvent = RuntimeEvent;
|
||||||
type Fungibles = LocalAndForeignAssets;
|
type Fungibles = LocalAndForeignAssets;
|
||||||
type OnChargeAssetTransaction =
|
type OnChargeAssetTransaction =
|
||||||
AssetConversionAdapter<Balances, AssetConversion, WestendLocation>;
|
AssetConversionAdapter<Balances, AssetConversion, WestendLocationV3>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -1229,18 +1236,18 @@ impl_runtime_apis! {
|
|||||||
impl pallet_asset_conversion::AssetConversionApi<
|
impl pallet_asset_conversion::AssetConversionApi<
|
||||||
Block,
|
Block,
|
||||||
Balance,
|
Balance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
> for Runtime
|
> for Runtime
|
||||||
{
|
{
|
||||||
fn quote_price_exact_tokens_for_tokens(asset1: MultiLocation, asset2: MultiLocation, amount: Balance, include_fee: bool) -> Option<Balance> {
|
fn quote_price_exact_tokens_for_tokens(asset1: xcm::v3::Location, asset2: xcm::v3::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
|
||||||
AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
|
AssetConversion::quote_price_exact_tokens_for_tokens(asset1, asset2, amount, include_fee)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quote_price_tokens_for_exact_tokens(asset1: MultiLocation, asset2: MultiLocation, amount: Balance, include_fee: bool) -> Option<Balance> {
|
fn quote_price_tokens_for_exact_tokens(asset1: xcm::v3::Location, asset2: xcm::v3::Location, amount: Balance, include_fee: bool) -> Option<Balance> {
|
||||||
AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
|
AssetConversion::quote_price_tokens_for_exact_tokens(asset1, asset2, amount, include_fee)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_reserves(asset1: MultiLocation, asset2: MultiLocation) -> Option<(Balance, Balance)> {
|
fn get_reserves(asset1: xcm::v3::Location, asset2: xcm::v3::Location) -> Option<(Balance, Balance)> {
|
||||||
AssetConversion::get_reserves(asset1, asset2).ok()
|
AssetConversion::get_reserves(asset1, asset2).ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1294,7 +1301,7 @@ impl_runtime_apis! {
|
|||||||
AccountId,
|
AccountId,
|
||||||
> for Runtime
|
> for Runtime
|
||||||
{
|
{
|
||||||
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedMultiAssets, assets_common::runtime_api::FungiblesAccessError> {
|
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedAssets, assets_common::runtime_api::FungiblesAccessError> {
|
||||||
use assets_common::fungible_conversion::{convert, convert_balance};
|
use assets_common::fungible_conversion::{convert, convert_balance};
|
||||||
Ok([
|
Ok([
|
||||||
// collect pallet_balance
|
// collect pallet_balance
|
||||||
@@ -1413,45 +1420,45 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||||
fn reachable_dest() -> Option<MultiLocation> {
|
fn reachable_dest() -> Option<Location> {
|
||||||
Some(Parent.into())
|
Some(Parent.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Relay/native token can be teleported between AH and Relay.
|
// Relay/native token can be teleported between AH and Relay.
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
Parent.into(),
|
Parent.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// AH can reserve transfer native token to some random parachain.
|
// AH can reserve transfer native token to some random parachain.
|
||||||
let random_para_id = 43211234;
|
let random_para_id = 43211234;
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
||||||
random_para_id.into()
|
random_para_id.into()
|
||||||
);
|
);
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
ParentThen(Parachain(random_para_id).into()).into(),
|
ParentThen(Parachain(random_para_id).into()).into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_complex_asset_transfer(
|
fn set_up_complex_asset_transfer(
|
||||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
) -> Option<(xcm::v4::Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||||
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
|
// Transfer to Relay some local AH asset (local-reserve-transfer) while paying
|
||||||
// fees using teleported native token.
|
// fees using teleported native token.
|
||||||
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
|
// (We don't care that Relay doesn't accept incoming unknown AH local asset)
|
||||||
let dest = Parent.into();
|
let dest = Parent.into();
|
||||||
|
|
||||||
let fee_amount = EXISTENTIAL_DEPOSIT;
|
let fee_amount = EXISTENTIAL_DEPOSIT;
|
||||||
let fee_asset: MultiAsset = (MultiLocation::parent(), fee_amount).into();
|
let fee_asset: Asset = (Location::parent(), fee_amount).into();
|
||||||
|
|
||||||
let who = frame_benchmarking::whitelisted_caller();
|
let who = frame_benchmarking::whitelisted_caller();
|
||||||
// Give some multiple of the existential deposit
|
// Give some multiple of the existential deposit
|
||||||
@@ -1469,13 +1476,13 @@ impl_runtime_apis! {
|
|||||||
Runtime,
|
Runtime,
|
||||||
pallet_assets::Instance1
|
pallet_assets::Instance1
|
||||||
>(true, initial_asset_amount);
|
>(true, initial_asset_amount);
|
||||||
let asset_location = MultiLocation::new(
|
let asset_location = Location::new(
|
||||||
0,
|
0,
|
||||||
X2(PalletInstance(50), GeneralIndex(u32::from(asset_id).into()))
|
[PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]
|
||||||
);
|
);
|
||||||
let transfer_asset: MultiAsset = (asset_location, asset_amount).into();
|
let transfer_asset: Asset = (asset_location, asset_amount).into();
|
||||||
|
|
||||||
let assets: MultiAssets = vec![fee_asset.clone(), transfer_asset].into();
|
let assets: xcm::v4::Assets = vec![fee_asset.clone(), transfer_asset].into();
|
||||||
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
|
let fee_index = if assets.get(0).unwrap().eq(&fee_asset) { 0 } else { 1 };
|
||||||
|
|
||||||
// verify transferred successfully
|
// verify transferred successfully
|
||||||
@@ -1504,14 +1511,14 @@ impl_runtime_apis! {
|
|||||||
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
fn ensure_bridged_target_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn ensure_bridged_target_destination() -> Result<Location, BenchmarkError> {
|
||||||
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
|
||||||
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
|
||||||
);
|
);
|
||||||
let bridged_asset_hub = xcm_config::bridging::to_rococo::AssetHubRococo::get();
|
let bridged_asset_hub = xcm_config::bridging::to_rococo::AssetHubRococo::get();
|
||||||
let _ = PolkadotXcm::force_xcm_version(
|
let _ = PolkadotXcm::force_xcm_version(
|
||||||
RuntimeOrigin::root(),
|
RuntimeOrigin::root(),
|
||||||
Box::new(bridged_asset_hub),
|
Box::new(bridged_asset_hub.clone()),
|
||||||
XCM_VERSION,
|
XCM_VERSION,
|
||||||
).map_err(|e| {
|
).map_err(|e| {
|
||||||
log::error!(
|
log::error!(
|
||||||
@@ -1527,12 +1534,11 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use xcm::latest::prelude::*;
|
|
||||||
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
|
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
|
||||||
use pallet_xcm_benchmarks::asset_instance_from;
|
use pallet_xcm_benchmarks::asset_instance_from;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||||
WestendLocation::get(),
|
WestendLocation::get(),
|
||||||
ExistentialDeposit::get()
|
ExistentialDeposit::get()
|
||||||
).into());
|
).into());
|
||||||
@@ -1543,33 +1549,33 @@ impl_runtime_apis! {
|
|||||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||||
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
||||||
xcm_config::XcmConfig,
|
xcm_config::XcmConfig,
|
||||||
ExistentialDepositMultiAsset,
|
ExistentialDepositAsset,
|
||||||
xcm_config::PriceForParentDelivery,
|
xcm_config::PriceForParentDelivery,
|
||||||
>;
|
>;
|
||||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||||
Ok(WestendLocation::get())
|
Ok(WestendLocation::get())
|
||||||
}
|
}
|
||||||
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
|
fn worst_case_holding(depositable_count: u32) -> xcm::v4::Assets {
|
||||||
// A mix of fungible, non-fungible, and concrete assets.
|
// A mix of fungible, non-fungible, and concrete assets.
|
||||||
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
|
||||||
let holding_fungibles = holding_non_fungibles - 1;
|
let holding_fungibles = holding_non_fungibles - 1;
|
||||||
let fungibles_amount: u128 = 100;
|
let fungibles_amount: u128 = 100;
|
||||||
let mut assets = (0..holding_fungibles)
|
let mut assets = (0..holding_fungibles)
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(GeneralIndex(i as u128).into()),
|
id: AssetId(GeneralIndex(i as u128).into()),
|
||||||
fun: Fungible(fungibles_amount * i as u128),
|
fun: Fungible(fungibles_amount * i as u128),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
.chain(core::iter::once(Asset { id: AssetId(Here.into()), fun: Fungible(u128::MAX) }))
|
||||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
.chain((0..holding_non_fungibles).map(|i| Asset {
|
||||||
id: Concrete(GeneralIndex(i as u128).into()),
|
id: AssetId(GeneralIndex(i as u128).into()),
|
||||||
fun: NonFungible(asset_instance_from(i)),
|
fun: NonFungible(asset_instance_from(i)),
|
||||||
}))
|
}))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
assets.push(MultiAsset {
|
assets.push(Asset {
|
||||||
id: Concrete(WestendLocation::get()),
|
id: AssetId(WestendLocation::get()),
|
||||||
fun: Fungible(1_000_000 * UNITS),
|
fun: Fungible(1_000_000 * UNITS),
|
||||||
});
|
});
|
||||||
assets.into()
|
assets.into()
|
||||||
@@ -1577,16 +1583,16 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||||
WestendLocation::get(),
|
WestendLocation::get(),
|
||||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(WestendLocation::get()) },
|
Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },
|
||||||
));
|
));
|
||||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||||
// AssetHubWestend trusts AssetHubRococo as reserve for ROCs
|
// AssetHubWestend trusts AssetHubRococo as reserve for ROCs
|
||||||
pub TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(
|
pub TrustedReserve: Option<(Location, Asset)> = Some(
|
||||||
(
|
(
|
||||||
xcm_config::bridging::to_rococo::AssetHubRococo::get(),
|
xcm_config::bridging::to_rococo::AssetHubRococo::get(),
|
||||||
MultiAsset::from((xcm_config::bridging::to_rococo::RocLocation::get(), 1000000000000 as u128))
|
Asset::from((xcm_config::bridging::to_rococo::RocLocation::get(), 1000000000000 as u128))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1598,9 +1604,9 @@ impl_runtime_apis! {
|
|||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
type TrustedReserve = TrustedReserve;
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_asset() -> Asset {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(WestendLocation::get()),
|
id: AssetId(WestendLocation::get()),
|
||||||
fun: Fungible(UNITS),
|
fun: Fungible(UNITS),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1614,42 +1620,42 @@ impl_runtime_apis! {
|
|||||||
(0u64, Response::Version(Default::default()))
|
(0u64, Response::Version(Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
fn worst_case_asset_exchange() -> Result<(xcm::v4::Assets, xcm::v4::Assets), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||||
match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() {
|
match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() {
|
||||||
Some(alias) => Ok(alias),
|
Some(alias) => Ok(alias),
|
||||||
None => Err(BenchmarkError::Skip)
|
None => Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||||
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||||
Ok(WestendLocation::get())
|
Ok(WestendLocation::get())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
fn claimable_asset() -> Result<(Location, Location, xcm::v4::Assets), BenchmarkError> {
|
||||||
let origin = WestendLocation::get();
|
let origin = WestendLocation::get();
|
||||||
let assets: MultiAssets = (Concrete(WestendLocation::get()), 1_000 * UNITS).into();
|
let assets: xcm::v4::Assets = (AssetId(WestendLocation::get()), 1_000 * UNITS).into();
|
||||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
let ticket = Location { parents: 0, interior: Here };
|
||||||
Ok((origin, ticket, assets))
|
Ok((origin, ticket, assets))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_message_origin_and_destination(
|
fn export_message_origin_and_destination(
|
||||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||||
|
|
||||||
trait WeighMultiAssets {
|
trait WeighAssets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
fn weigh_assets(&self, weight: Weight) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_ASSETS: u64 = 100;
|
const MAX_ASSETS: u64 = 100;
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssetFilter {
|
impl WeighAssets for AssetFilter {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
match self {
|
match self {
|
||||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||||
Self::Wild(asset) => match asset {
|
Self::Wild(asset) => match asset {
|
||||||
@@ -49,40 +49,36 @@ impl WeighMultiAssets for MultiAssetFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssets {
|
impl WeighAssets for Assets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AssetHubWestendXcmWeight<Call>(core::marker::PhantomData<Call>);
|
pub struct AssetHubWestendXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||||
impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
||||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||||
}
|
}
|
||||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||||
}
|
}
|
||||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||||
}
|
}
|
||||||
fn query_response(
|
fn query_response(
|
||||||
_query_id: &u64,
|
_query_id: &u64,
|
||||||
_response: &Response,
|
_response: &Response,
|
||||||
_max_weight: &Weight,
|
_max_weight: &Weight,
|
||||||
_querier: &Option<MultiLocation>,
|
_querier: &Option<Location>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
XcmGeneric::<Runtime>::query_response()
|
XcmGeneric::<Runtime>::query_response()
|
||||||
}
|
}
|
||||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||||
}
|
}
|
||||||
fn transfer_reserve_asset(
|
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssets,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn transact(
|
fn transact(
|
||||||
_origin_type: &OriginKind,
|
_origin_type: &OriginKind,
|
||||||
@@ -110,44 +106,36 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
|||||||
fn clear_origin() -> Weight {
|
fn clear_origin() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_origin()
|
XcmGeneric::<Runtime>::clear_origin()
|
||||||
}
|
}
|
||||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||||
XcmGeneric::<Runtime>::descend_origin()
|
XcmGeneric::<Runtime>::descend_origin()
|
||||||
}
|
}
|
||||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_error()
|
XcmGeneric::<Runtime>::report_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||||
}
|
}
|
||||||
fn deposit_reserve_asset(
|
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn initiate_reserve_withdraw(
|
fn initiate_reserve_withdraw(
|
||||||
assets: &MultiAssetFilter,
|
assets: &AssetFilter,
|
||||||
_reserve: &MultiLocation,
|
_reserve: &Location,
|
||||||
_xcm: &Xcm<()>,
|
_xcm: &Xcm<()>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||||
}
|
}
|
||||||
fn initiate_teleport(
|
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
|
||||||
}
|
}
|
||||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_holding()
|
XcmGeneric::<Runtime>::report_holding()
|
||||||
}
|
}
|
||||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||||
XcmGeneric::<Runtime>::buy_execution()
|
XcmGeneric::<Runtime>::buy_execution()
|
||||||
}
|
}
|
||||||
fn refund_surplus() -> Weight {
|
fn refund_surplus() -> Weight {
|
||||||
@@ -162,7 +150,7 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
|||||||
fn clear_error() -> Weight {
|
fn clear_error() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_error()
|
XcmGeneric::<Runtime>::clear_error()
|
||||||
}
|
}
|
||||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||||
XcmGeneric::<Runtime>::claim_asset()
|
XcmGeneric::<Runtime>::claim_asset()
|
||||||
}
|
}
|
||||||
fn trap(_code: &u64) -> Weight {
|
fn trap(_code: &u64) -> Weight {
|
||||||
@@ -174,13 +162,13 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
|||||||
fn unsubscribe_version() -> Weight {
|
fn unsubscribe_version() -> Weight {
|
||||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||||
}
|
}
|
||||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
fn burn_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||||
}
|
}
|
||||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
fn expect_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||||
}
|
}
|
||||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::expect_origin()
|
XcmGeneric::<Runtime>::expect_origin()
|
||||||
}
|
}
|
||||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||||
@@ -213,16 +201,16 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
|||||||
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn set_fees_mode(_: &bool) -> Weight {
|
fn set_fees_mode(_: &bool) -> Weight {
|
||||||
@@ -234,11 +222,11 @@ impl<Call> XcmWeightInfo<Call> for AssetHubWestendXcmWeight<Call> {
|
|||||||
fn clear_topic() -> Weight {
|
fn clear_topic() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_topic()
|
XcmGeneric::<Runtime>::clear_topic()
|
||||||
}
|
}
|
||||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
fn alias_origin(_: &Location) -> Weight {
|
||||||
// XCM Executor does not currently support alias origin operations
|
// XCM Executor does not currently support alias origin operations
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::unpaid_execution()
|
XcmGeneric::<Runtime>::unpaid_execution()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ use super::{
|
|||||||
ToRococoXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
|
ToRococoXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
|
||||||
};
|
};
|
||||||
use assets_common::{
|
use assets_common::{
|
||||||
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
|
local_and_foreign_assets::MatchesLocalAndForeignAssetsLocation,
|
||||||
matching::{FromSiblingParachain, IsForeignConcreteAsset},
|
matching::{FromSiblingParachain, IsForeignConcreteAsset},
|
||||||
TrustBackedAssetsAsMultiLocation,
|
TrustBackedAssetsAsLocation,
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{
|
traits::{
|
||||||
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
|
tokens::imbalance::ResolveAssetTo, ConstU32, Contains, Equals, Everything, Nothing,
|
||||||
PalletInfoAccess,
|
PalletInfoAccess,
|
||||||
@@ -61,25 +61,31 @@ use xcm_builder::{
|
|||||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const WestendLocation: MultiLocation = MultiLocation::parent();
|
pub const WestendLocation: Location = Location::parent();
|
||||||
|
pub const WestendLocationV3: xcm::v3::Location = xcm::v3::Location::parent();
|
||||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||||
pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap();
|
pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap();
|
||||||
pub AssetsPalletIndex: u32 = <Assets as PalletInfoAccess>::index() as u32;
|
pub TrustBackedAssetsPalletLocation: Location =
|
||||||
pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(AssetsPalletIndex::get() as u8).into();
|
PalletInstance(TrustBackedAssetsPalletIndex::get()).into();
|
||||||
pub ForeignAssetsPalletLocation: MultiLocation =
|
pub TrustBackedAssetsPalletIndex: u8 = <Assets as PalletInfoAccess>::index() as u8;
|
||||||
|
pub TrustBackedAssetsPalletLocationV3: xcm::v3::Location =
|
||||||
|
xcm::v3::Junction::PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
|
||||||
|
pub ForeignAssetsPalletLocation: Location =
|
||||||
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
|
PalletInstance(<ForeignAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
pub PoolAssetsPalletLocation: MultiLocation =
|
pub PoolAssetsPalletLocation: Location =
|
||||||
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
|
pub PoolAssetsPalletLocationV3: xcm::v3::Location =
|
||||||
|
xcm::v3::Junction::PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
|
||||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||||
pub StakingPot: AccountId = CollatorSelection::account_id();
|
pub StakingPot: AccountId = CollatorSelection::account_id();
|
||||||
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
||||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -104,7 +110,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<WestendLocation>,
|
IsConcrete<WestendLocation>,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -122,7 +128,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
|
|||||||
Assets,
|
Assets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
TrustBackedAssetsConvertedConcreteId,
|
TrustBackedAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -139,8 +145,8 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
|
|||||||
// Ignore `TrustBackedAssets` explicitly
|
// Ignore `TrustBackedAssets` explicitly
|
||||||
StartsWith<TrustBackedAssetsPalletLocation>,
|
StartsWith<TrustBackedAssetsPalletLocation>,
|
||||||
// Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means:
|
// Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means:
|
||||||
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
|
// - foreign assets from our consensus should be: `Location {parents: 1, X*(Parachain(xyz),
|
||||||
// X*(Parachain(xyz), ..)}
|
// ..)}
|
||||||
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont
|
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont
|
||||||
// be accepted here
|
// be accepted here
|
||||||
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
|
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
|
||||||
@@ -154,7 +160,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
|
|||||||
ForeignAssets,
|
ForeignAssets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
ForeignAssetsConvertedConcreteId,
|
ForeignAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -174,7 +180,7 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
|
|||||||
PoolAssets,
|
PoolAssets,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
PoolAssetsConvertedConcreteId,
|
PoolAssetsConvertedConcreteId,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -189,21 +195,33 @@ pub type PoolFungiblesTransactor = FungiblesAdapter<
|
|||||||
pub type AssetTransactors =
|
pub type AssetTransactors =
|
||||||
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
|
(CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor, PoolFungiblesTransactor);
|
||||||
|
|
||||||
/// Simple `MultiLocation` matcher for Local and Foreign asset `MultiLocation`.
|
/// Simple `Location` matcher for Local and Foreign asset `Location`.
|
||||||
pub struct LocalAndForeignAssetsMultiLocationMatcher;
|
pub struct LocalAndForeignAssetsLocationMatcher;
|
||||||
impl MatchesLocalAndForeignAssetsMultiLocation for LocalAndForeignAssetsMultiLocationMatcher {
|
impl MatchesLocalAndForeignAssetsLocation<xcm::v3::Location>
|
||||||
fn is_local(location: &MultiLocation) -> bool {
|
for LocalAndForeignAssetsLocationMatcher
|
||||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
{
|
||||||
TrustBackedAssetsConvertedConcreteId::contains(location)
|
fn is_local(location: &xcm::v3::Location) -> bool {
|
||||||
|
use assets_common::fungible_conversion::MatchesLocation;
|
||||||
|
let latest_location: Location = if let Ok(location) = (*location).try_into() {
|
||||||
|
location
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
TrustBackedAssetsConvertedConcreteId::contains(&latest_location)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_foreign(location: &MultiLocation) -> bool {
|
fn is_foreign(location: &xcm::v3::Location) -> bool {
|
||||||
use assets_common::fungible_conversion::MatchesMultiLocation;
|
use assets_common::fungible_conversion::MatchesLocation;
|
||||||
ForeignAssetsConvertedConcreteId::contains(location)
|
let latest_location: Location = if let Ok(location) = (*location).try_into() {
|
||||||
|
location
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
ForeignAssetsConvertedConcreteId::contains(&latest_location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Contains<MultiLocation> for LocalAndForeignAssetsMultiLocationMatcher {
|
impl Contains<xcm::v3::Location> for LocalAndForeignAssetsLocationMatcher {
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &xcm::v3::Location) -> bool {
|
||||||
Self::is_local(location) || Self::is_foreign(location)
|
Self::is_local(location) || Self::is_foreign(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,23 +256,30 @@ parameter_types! {
|
|||||||
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
|
||||||
}
|
}
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsPlurality;
|
||||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsPlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||||
};
|
}
|
||||||
pub type FellowshipEntities: impl Contains<MultiLocation> = {
|
}
|
||||||
// Fellowship Plurality
|
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } |
|
pub struct FellowshipEntities;
|
||||||
// Fellowship Salary Pallet
|
impl Contains<Location> for FellowshipEntities {
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(64)) } |
|
fn contains(location: &Location) -> bool {
|
||||||
// Fellowship Treasury Pallet
|
matches!(
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(65)) }
|
location.unpack(),
|
||||||
};
|
(1, [Parachain(1001), Plurality { id: BodyId::Technical, .. }]) |
|
||||||
pub type AmbassadorEntities: impl Contains<MultiLocation> = {
|
(1, [Parachain(1001), PalletInstance(64)]) |
|
||||||
// Ambassador Salary Pallet
|
(1, [Parachain(1001), PalletInstance(65)])
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1001), PalletInstance(74)) }
|
)
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AmbassadorEntities;
|
||||||
|
impl Contains<Location> for AmbassadorEntities {
|
||||||
|
fn contains(location: &Location) -> bool {
|
||||||
|
matches!(location.unpack(), (1, [Parachain(1001), PalletInstance(74)]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||||
@@ -573,12 +598,12 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type Trader = (
|
type Trader = (
|
||||||
UsingComponents<WeightToFee, WestendLocation, AccountId, Balances, ToStakingPot<Runtime>>,
|
UsingComponents<WeightToFee, WestendLocation, AccountId, Balances, ToStakingPot<Runtime>>,
|
||||||
cumulus_primitives_utility::SwapFirstAssetTrader<
|
cumulus_primitives_utility::SwapFirstAssetTrader<
|
||||||
WestendLocation,
|
WestendLocationV3,
|
||||||
crate::AssetConversion,
|
crate::AssetConversion,
|
||||||
WeightToFee,
|
WeightToFee,
|
||||||
crate::NativeAndAssets,
|
crate::NativeAndAssets,
|
||||||
(
|
(
|
||||||
TrustBackedAssetsAsMultiLocation<TrustBackedAssetsPalletLocation, Balance>,
|
TrustBackedAssetsAsLocation<TrustBackedAssetsPalletLocation, Balance>,
|
||||||
ForeignAssetsConvertedConcreteId,
|
ForeignAssetsConvertedConcreteId,
|
||||||
),
|
),
|
||||||
ResolveAssetTo<StakingPot, crate::NativeAndAssets>,
|
ResolveAssetTo<StakingPot, crate::NativeAndAssets>,
|
||||||
@@ -671,9 +696,9 @@ pub type ForeignCreatorsSovereignAccountOf = (
|
|||||||
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
|
||||||
pub struct XcmBenchmarkHelper;
|
pub struct XcmBenchmarkHelper;
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
|
impl pallet_assets::BenchmarkHelper<xcm::v3::Location> for XcmBenchmarkHelper {
|
||||||
fn create_asset_id_parameter(id: u32) -> MultiLocation {
|
fn create_asset_id_parameter(id: u32) -> xcm::v3::Location {
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
|
xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(id)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,7 +729,7 @@ pub mod bridging {
|
|||||||
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
|
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
|
||||||
|
|
||||||
pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID;
|
pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID;
|
||||||
pub SiblingBridgeHub: MultiLocation = MultiLocation::new(1, X1(Parachain(SiblingBridgeHubParaId::get())));
|
pub SiblingBridgeHub: Location = Location::new(1, [Parachain(SiblingBridgeHubParaId::get())]);
|
||||||
/// Router expects payment with this `AssetId`.
|
/// Router expects payment with this `AssetId`.
|
||||||
/// (`AssetId` has to be aligned with `BridgeTable`)
|
/// (`AssetId` has to be aligned with `BridgeTable`)
|
||||||
pub XcmBridgeHubRouterFeeAssetId: AssetId = WestendLocation::get().into();
|
pub XcmBridgeHubRouterFeeAssetId: AssetId = WestendLocation::get().into();
|
||||||
@@ -721,25 +746,25 @@ pub mod bridging {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub SiblingBridgeHubWithBridgeHubRococoInstance: MultiLocation = MultiLocation::new(
|
pub SiblingBridgeHubWithBridgeHubRococoInstance: Location = Location::new(
|
||||||
1,
|
1,
|
||||||
X2(
|
[
|
||||||
Parachain(SiblingBridgeHubParaId::get()),
|
Parachain(SiblingBridgeHubParaId::get()),
|
||||||
PalletInstance(bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX)
|
PalletInstance(bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX)
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
|
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
|
||||||
pub AssetHubRococo: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(RococoNetwork::get()), Parachain(bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID)));
|
pub AssetHubRococo: Location = Location::new(2, [GlobalConsensus(RococoNetwork::get()), Parachain(bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID)]);
|
||||||
pub RocLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(RococoNetwork::get())));
|
pub RocLocation: Location = Location::new(2, [GlobalConsensus(RococoNetwork::get())]);
|
||||||
|
|
||||||
pub RocFromAssetHubRococo: (MultiAssetFilter, MultiLocation) = (
|
pub RocFromAssetHubRococo: (AssetFilter, Location) = (
|
||||||
Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) }),
|
Wild(AllOf { fun: WildFungible, id: AssetId(RocLocation::get()) }),
|
||||||
AssetHubRococo::get()
|
AssetHubRococo::get()
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Set up exporters configuration.
|
/// Set up exporters configuration.
|
||||||
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
|
/// `Option<Asset>` represents static "base fee" which is used for total delivery fee calculation.
|
||||||
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
|
||||||
NetworkExportTableItem::new(
|
NetworkExportTableItem::new(
|
||||||
RococoNetwork::get(),
|
RococoNetwork::get(),
|
||||||
@@ -756,15 +781,15 @@ pub mod bridging {
|
|||||||
];
|
];
|
||||||
|
|
||||||
/// Universal aliases
|
/// Universal aliases
|
||||||
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
|
pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter(
|
||||||
sp_std::vec![
|
sp_std::vec![
|
||||||
(SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get()))
|
(SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get()))
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Contains<(MultiLocation, Junction)> for UniversalAliases {
|
impl Contains<(Location, Junction)> for UniversalAliases {
|
||||||
fn contains(alias: &(MultiLocation, Junction)) -> bool {
|
fn contains(alias: &(Location, Junction)) -> bool {
|
||||||
UniversalAliases::get().contains(alias)
|
UniversalAliases::get().contains(alias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -799,7 +824,7 @@ pub mod bridging {
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
impl BridgingBenchmarksHelper {
|
impl BridgingBenchmarksHelper {
|
||||||
pub fn prepare_universal_alias() -> Option<(MultiLocation, Junction)> {
|
pub fn prepare_universal_alias() -> Option<(Location, Junction)> {
|
||||||
let alias =
|
let alias =
|
||||||
to_rococo::UniversalAliases::get().into_iter().find_map(|(location, junction)| {
|
to_rococo::UniversalAliases::get().into_iter().find_map(|(location, junction)| {
|
||||||
match to_rococo::SiblingBridgeHubWithBridgeHubRococoInstance::get()
|
match to_rococo::SiblingBridgeHubWithBridgeHubRococoInstance::get()
|
||||||
|
|||||||
@@ -21,12 +21,16 @@ use asset_hub_westend_runtime::{
|
|||||||
xcm_config,
|
xcm_config,
|
||||||
xcm_config::{
|
xcm_config::{
|
||||||
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, WestendLocation,
|
bridging, ForeignCreatorsSovereignAccountOf, LocationToAccountId, WestendLocation,
|
||||||
|
WestendLocationV3,
|
||||||
},
|
},
|
||||||
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, PolkadotXcm, RuntimeCall,
|
AllPalletsWithoutSystem, MetadataDepositBase, MetadataDepositPerByte, PolkadotXcm, RuntimeCall,
|
||||||
RuntimeEvent, RuntimeOrigin, ToRococoXcmRouterInstance, XcmpQueue,
|
RuntimeEvent, RuntimeOrigin, ToRococoXcmRouterInstance, XcmpQueue,
|
||||||
};
|
};
|
||||||
pub use asset_hub_westend_runtime::{
|
pub use asset_hub_westend_runtime::{
|
||||||
xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, XcmConfig},
|
xcm_config::{
|
||||||
|
CheckingAccount, TrustBackedAssetsPalletLocation, TrustBackedAssetsPalletLocationV3,
|
||||||
|
XcmConfig,
|
||||||
|
},
|
||||||
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
|
AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection, ExistentialDeposit,
|
||||||
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
|
ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System,
|
||||||
TrustBackedAssetsInstance,
|
TrustBackedAssetsInstance,
|
||||||
@@ -51,14 +55,18 @@ use parachains_common::{
|
|||||||
};
|
};
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||||
use xcm_executor::traits::{Identity, JustTry, WeightTrader};
|
use xcm_builder::V4V3LocationConverter;
|
||||||
|
use xcm_executor::traits::{JustTry, WeightTrader};
|
||||||
|
|
||||||
const ALICE: [u8; 32] = [1u8; 32];
|
const ALICE: [u8; 32] = [1u8; 32];
|
||||||
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
|
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
|
||||||
|
|
||||||
type AssetIdForTrustBackedAssetsConvert =
|
type AssetIdForTrustBackedAssetsConvert =
|
||||||
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>;
|
assets_common::AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocationV3>;
|
||||||
|
|
||||||
|
type AssetIdForTrustBackedAssetsConvertLatest =
|
||||||
|
assets_common::AssetIdForTrustBackedAssetsConvertLatest<TrustBackedAssetsPalletLocation>;
|
||||||
|
|
||||||
type RuntimeHelper = asset_test_utils::RuntimeHelper<Runtime, AllPalletsWithoutSystem>;
|
type RuntimeHelper = asset_test_utils::RuntimeHelper<Runtime, AllPalletsWithoutSystem>;
|
||||||
|
|
||||||
@@ -101,7 +109,7 @@ fn test_buy_and_refund_weight_in_native() {
|
|||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (native_location, fee + extra_amount).into();
|
let payment: Asset = (native_location.clone(), fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -110,7 +118,7 @@ fn test_buy_and_refund_weight_in_native() {
|
|||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount =
|
||||||
unused_asset.fungible.get(&native_location.into()).map_or(0, |a| *a);
|
unused_asset.fungible.get(&native_location.clone().into()).map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(Balances::total_issuance(), total_issuance);
|
assert_eq!(Balances::total_issuance(), total_issuance);
|
||||||
|
|
||||||
@@ -146,7 +154,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
||||||
let staking_pot = CollatorSelection::account_id();
|
let staking_pot = CollatorSelection::account_id();
|
||||||
let asset_1: u32 = 1;
|
let asset_1: u32 = 1;
|
||||||
let native_location = WestendLocation::get();
|
let native_location = WestendLocationV3::get();
|
||||||
let asset_1_location =
|
let asset_1_location =
|
||||||
AssetIdForTrustBackedAssetsConvert::convert_back(&asset_1).unwrap();
|
AssetIdForTrustBackedAssetsConvert::convert_back(&asset_1).unwrap();
|
||||||
// bob's initial balance for native and `asset1` assets.
|
// bob's initial balance for native and `asset1` assets.
|
||||||
@@ -182,6 +190,8 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
let asset_total_issuance = Assets::total_issuance(asset_1);
|
let asset_total_issuance = Assets::total_issuance(asset_1);
|
||||||
let native_total_issuance = Balances::total_issuance();
|
let native_total_issuance = Balances::total_issuance();
|
||||||
|
|
||||||
|
let asset_1_location_latest: Location = asset_1_location.try_into().unwrap();
|
||||||
|
|
||||||
// prepare input to buy weight.
|
// prepare input to buy weight.
|
||||||
let weight = Weight::from_parts(4_000_000_000, 0);
|
let weight = Weight::from_parts(4_000_000_000, 0);
|
||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
@@ -189,7 +199,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (asset_1_location, asset_fee + extra_amount).into();
|
let payment: Asset = (asset_1_location_latest.clone(), asset_fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -197,8 +207,10 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount = unused_asset
|
||||||
unused_asset.fungible.get(&asset_1_location.into()).map_or(0, |a| *a);
|
.fungible
|
||||||
|
.get(&asset_1_location_latest.clone().into())
|
||||||
|
.map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);
|
assert_eq!(Assets::total_issuance(asset_1), asset_total_issuance + asset_fee);
|
||||||
|
|
||||||
@@ -212,7 +224,7 @@ fn test_buy_and_refund_weight_with_swap_local_asset_xcm_trader() {
|
|||||||
|
|
||||||
// refund.
|
// refund.
|
||||||
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
||||||
assert_eq!(actual_refund, (asset_1_location, asset_refund).into());
|
assert_eq!(actual_refund, (asset_1_location_latest, asset_refund).into());
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
||||||
@@ -241,9 +253,15 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
.execute_with(|| {
|
.execute_with(|| {
|
||||||
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
let bob: AccountId = SOME_ASSET_ADMIN.into();
|
||||||
let staking_pot = CollatorSelection::account_id();
|
let staking_pot = CollatorSelection::account_id();
|
||||||
let native_location = WestendLocation::get();
|
let native_location = WestendLocationV3::get();
|
||||||
let foreign_location =
|
let foreign_location = xcm::v3::Location {
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1234), GeneralIndex(12345)) };
|
parents: 1,
|
||||||
|
interior: (
|
||||||
|
xcm::v3::Junction::Parachain(1234),
|
||||||
|
xcm::v3::Junction::GeneralIndex(12345),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
};
|
||||||
// bob's initial balance for native and `asset1` assets.
|
// bob's initial balance for native and `asset1` assets.
|
||||||
let initial_balance = 200 * UNITS;
|
let initial_balance = 200 * UNITS;
|
||||||
// liquidity for both arms of (native, asset1) pool.
|
// liquidity for both arms of (native, asset1) pool.
|
||||||
@@ -282,6 +300,8 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
let asset_total_issuance = ForeignAssets::total_issuance(foreign_location);
|
let asset_total_issuance = ForeignAssets::total_issuance(foreign_location);
|
||||||
let native_total_issuance = Balances::total_issuance();
|
let native_total_issuance = Balances::total_issuance();
|
||||||
|
|
||||||
|
let foreign_location_latest: Location = foreign_location.try_into().unwrap();
|
||||||
|
|
||||||
// prepare input to buy weight.
|
// prepare input to buy weight.
|
||||||
let weight = Weight::from_parts(4_000_000_000, 0);
|
let weight = Weight::from_parts(4_000_000_000, 0);
|
||||||
let fee = WeightToFee::weight_to_fee(&weight);
|
let fee = WeightToFee::weight_to_fee(&weight);
|
||||||
@@ -289,7 +309,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
AssetConversion::get_amount_in(&fee, &pool_liquidity, &pool_liquidity).unwrap();
|
||||||
let extra_amount = 100;
|
let extra_amount = 100;
|
||||||
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };
|
||||||
let payment: MultiAsset = (foreign_location, asset_fee + extra_amount).into();
|
let payment: Asset = (foreign_location_latest.clone(), asset_fee + extra_amount).into();
|
||||||
|
|
||||||
// init trader and buy weight.
|
// init trader and buy weight.
|
||||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||||
@@ -297,8 +317,10 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
trader.buy_weight(weight, payment.into(), &ctx).expect("Expected Ok");
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
let unused_amount =
|
let unused_amount = unused_asset
|
||||||
unused_asset.fungible.get(&foreign_location.into()).map_or(0, |a| *a);
|
.fungible
|
||||||
|
.get(&foreign_location_latest.clone().into())
|
||||||
|
.map_or(0, |a| *a);
|
||||||
assert_eq!(unused_amount, extra_amount);
|
assert_eq!(unused_amount, extra_amount);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::total_issuance(foreign_location),
|
ForeignAssets::total_issuance(foreign_location),
|
||||||
@@ -315,7 +337,7 @@ fn test_buy_and_refund_weight_with_swap_foreign_asset_xcm_trader() {
|
|||||||
|
|
||||||
// refund.
|
// refund.
|
||||||
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
let actual_refund = trader.refund_weight(refund_weight, &ctx).unwrap();
|
||||||
assert_eq!(actual_refund, (foreign_location, asset_refund).into());
|
assert_eq!(actual_refund, (foreign_location_latest, asset_refund).into());
|
||||||
|
|
||||||
// assert.
|
// assert.
|
||||||
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
assert_eq!(Balances::balance(&staking_pot), initial_balance);
|
||||||
@@ -345,19 +367,25 @@ fn test_assets_balances_api_works() {
|
|||||||
.build()
|
.build()
|
||||||
.execute_with(|| {
|
.execute_with(|| {
|
||||||
let local_asset_id = 1;
|
let local_asset_id = 1;
|
||||||
let foreign_asset_id_multilocation =
|
let foreign_asset_id_location = xcm::v3::Location {
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1234), GeneralIndex(12345)) };
|
parents: 1,
|
||||||
|
interior: [
|
||||||
|
xcm::v3::Junction::Parachain(1234),
|
||||||
|
xcm::v3::Junction::GeneralIndex(12345),
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
|
};
|
||||||
|
|
||||||
// check before
|
// check before
|
||||||
assert_eq!(Assets::balance(local_asset_id, AccountId::from(ALICE)), 0);
|
assert_eq!(Assets::balance(local_asset_id, AccountId::from(ALICE)), 0);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)),
|
ForeignAssets::balance(foreign_asset_id_location, AccountId::from(ALICE)),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0);
|
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0);
|
||||||
assert!(Runtime::query_account_balances(AccountId::from(ALICE))
|
assert!(Runtime::query_account_balances(AccountId::from(ALICE))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_as::<MultiAssets>()
|
.try_as::<XcmAssets>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_none());
|
.is_none());
|
||||||
|
|
||||||
@@ -388,7 +416,7 @@ fn test_assets_balances_api_works() {
|
|||||||
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
||||||
assert_ok!(ForeignAssets::force_create(
|
assert_ok!(ForeignAssets::force_create(
|
||||||
RuntimeHelper::root_origin(),
|
RuntimeHelper::root_origin(),
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
AccountId::from(SOME_ASSET_ADMIN).into(),
|
AccountId::from(SOME_ASSET_ADMIN).into(),
|
||||||
false,
|
false,
|
||||||
foreign_asset_minimum_asset_balance
|
foreign_asset_minimum_asset_balance
|
||||||
@@ -397,7 +425,7 @@ fn test_assets_balances_api_works() {
|
|||||||
// We first mint enough asset for the account to exist for assets
|
// We first mint enough asset for the account to exist for assets
|
||||||
assert_ok!(ForeignAssets::mint(
|
assert_ok!(ForeignAssets::mint(
|
||||||
RuntimeHelper::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
RuntimeHelper::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
AccountId::from(ALICE).into(),
|
AccountId::from(ALICE).into(),
|
||||||
6 * foreign_asset_minimum_asset_balance
|
6 * foreign_asset_minimum_asset_balance
|
||||||
));
|
));
|
||||||
@@ -408,12 +436,12 @@ fn test_assets_balances_api_works() {
|
|||||||
minimum_asset_balance
|
minimum_asset_balance
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)),
|
ForeignAssets::balance(foreign_asset_id_location, AccountId::from(ALICE)),
|
||||||
6 * minimum_asset_balance
|
6 * minimum_asset_balance
|
||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency);
|
assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency);
|
||||||
|
|
||||||
let result: MultiAssets = Runtime::query_account_balances(AccountId::from(ALICE))
|
let result: XcmAssets = Runtime::query_account_balances(AccountId::from(ALICE))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -428,13 +456,13 @@ fn test_assets_balances_api_works() {
|
|||||||
)));
|
)));
|
||||||
// check trusted asset
|
// check trusted asset
|
||||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||||
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap(),
|
AssetIdForTrustBackedAssetsConvertLatest::convert_back(&local_asset_id).unwrap(),
|
||||||
minimum_asset_balance
|
minimum_asset_balance
|
||||||
)
|
)
|
||||||
.into())));
|
.into())));
|
||||||
// check foreign asset
|
// check foreign asset
|
||||||
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
assert!(result.inner().iter().any(|asset| asset.eq(&(
|
||||||
Identity::convert_back(&foreign_asset_id_multilocation).unwrap(),
|
V4V3LocationConverter::convert_back(&foreign_asset_id_location).unwrap(),
|
||||||
6 * foreign_asset_minimum_asset_balance
|
6 * foreign_asset_minimum_asset_balance
|
||||||
)
|
)
|
||||||
.into())));
|
.into())));
|
||||||
@@ -505,7 +533,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_
|
|||||||
XcmConfig,
|
XcmConfig,
|
||||||
TrustBackedAssetsInstance,
|
TrustBackedAssetsInstance,
|
||||||
AssetIdForTrustBackedAssets,
|
AssetIdForTrustBackedAssets,
|
||||||
AssetIdForTrustBackedAssetsConvert,
|
AssetIdForTrustBackedAssetsConvertLatest,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
12345,
|
12345,
|
||||||
@@ -522,11 +550,15 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_
|
|||||||
Runtime,
|
Runtime,
|
||||||
XcmConfig,
|
XcmConfig,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
JustTry,
|
JustTry,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(1313), GeneralIndex(12345)) },
|
xcm::v3::Location {
|
||||||
|
parents: 1,
|
||||||
|
interior: [xcm::v3::Junction::Parachain(1313), xcm::v3::Junction::GeneralIndex(12345)]
|
||||||
|
.into()
|
||||||
|
},
|
||||||
Box::new(|| {
|
Box::new(|| {
|
||||||
assert!(Assets::asset_ids().collect::<Vec<_>>().is_empty());
|
assert!(Assets::asset_ids().collect::<Vec<_>>().is_empty());
|
||||||
}),
|
}),
|
||||||
@@ -541,8 +573,8 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
MultiLocation,
|
xcm::v3::Location,
|
||||||
JustTry,
|
V4V3LocationConverter,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AssetDeposit::get(),
|
AssetDeposit::get(),
|
||||||
@@ -626,12 +658,12 @@ fn receive_reserve_asset_deposited_roc_from_asset_hub_rococo_works() {
|
|||||||
AccountId::from([73; 32]),
|
AccountId::from([73; 32]),
|
||||||
AccountId::from(BLOCK_AUTHOR_ACCOUNT),
|
AccountId::from(BLOCK_AUTHOR_ACCOUNT),
|
||||||
// receiving ROCs
|
// receiving ROCs
|
||||||
(MultiLocation { parents: 2, interior: X1(GlobalConsensus(Rococo)) }, 1000000000000, 1_000_000_000),
|
(xcm::v3::Location::new(2, [xcm::v3::Junction::GlobalConsensus(xcm::v3::NetworkId::Rococo)]), 1000000000000, 1_000_000_000),
|
||||||
bridging_to_asset_hub_rococo,
|
bridging_to_asset_hub_rococo,
|
||||||
(
|
(
|
||||||
X1(PalletInstance(bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX)),
|
[PalletInstance(bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX)].into(),
|
||||||
GlobalConsensus(Rococo),
|
GlobalConsensus(Rococo),
|
||||||
X1(Parachain(1000))
|
[Parachain(1000)].into()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,26 +19,25 @@ use sp_std::marker::PhantomData;
|
|||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
|
|
||||||
/// Creates asset pairs for liquidity pools with `Target` always being the first asset.
|
/// Creates asset pairs for liquidity pools with `Target` always being the first asset.
|
||||||
pub struct AssetPairFactory<Target, SelfParaId, PalletId>(
|
pub struct AssetPairFactory<Target, SelfParaId, PalletId, L = Location>(
|
||||||
PhantomData<(Target, SelfParaId, PalletId)>,
|
PhantomData<(Target, SelfParaId, PalletId, L)>,
|
||||||
);
|
);
|
||||||
impl<Target: Get<MultiLocation>, SelfParaId: Get<ParaId>, PalletId: Get<u32>>
|
impl<Target: Get<L>, SelfParaId: Get<ParaId>, PalletId: Get<u32>, L: TryFrom<Location>>
|
||||||
pallet_asset_conversion::BenchmarkHelper<MultiLocation>
|
pallet_asset_conversion::BenchmarkHelper<L> for AssetPairFactory<Target, SelfParaId, PalletId, L>
|
||||||
for AssetPairFactory<Target, SelfParaId, PalletId>
|
|
||||||
{
|
{
|
||||||
fn create_pair(seed1: u32, seed2: u32) -> (MultiLocation, MultiLocation) {
|
fn create_pair(seed1: u32, seed2: u32) -> (L, L) {
|
||||||
let with_id = MultiLocation::new(
|
let with_id = Location::new(
|
||||||
1,
|
1,
|
||||||
X3(
|
[
|
||||||
Parachain(SelfParaId::get().into()),
|
Parachain(SelfParaId::get().into()),
|
||||||
PalletInstance(PalletId::get() as u8),
|
PalletInstance(PalletId::get() as u8),
|
||||||
GeneralIndex(seed2.into()),
|
GeneralIndex(seed2.into()),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
if seed1 % 2 == 0 {
|
if seed1 % 2 == 0 {
|
||||||
(with_id, Target::get())
|
(with_id.try_into().map_err(|_| "Something went wrong").unwrap(), Target::get())
|
||||||
} else {
|
} else {
|
||||||
(Target::get(), with_id)
|
(Target::get(), with_id.try_into().map_err(|_| "Something went wrong").unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,21 +17,21 @@ use frame_support::traits::{
|
|||||||
ContainsPair, EnsureOrigin, EnsureOriginWithArg, Everything, OriginTrait,
|
ContainsPair, EnsureOrigin, EnsureOriginWithArg, Everything, OriginTrait,
|
||||||
};
|
};
|
||||||
use pallet_xcm::{EnsureXcm, Origin as XcmOrigin};
|
use pallet_xcm::{EnsureXcm, Origin as XcmOrigin};
|
||||||
use xcm::latest::MultiLocation;
|
use xcm::latest::Location;
|
||||||
use xcm_executor::traits::ConvertLocation;
|
use xcm_executor::traits::ConvertLocation;
|
||||||
|
|
||||||
/// `EnsureOriginWithArg` impl for `CreateOrigin` that allows only XCM origins that are locations
|
/// `EnsureOriginWithArg` impl for `CreateOrigin` that allows only XCM origins that are locations
|
||||||
/// containing the class location.
|
/// containing the class location.
|
||||||
pub struct ForeignCreators<IsForeign, AccountOf, AccountId>(
|
pub struct ForeignCreators<IsForeign, AccountOf, AccountId, L = Location>(
|
||||||
sp_std::marker::PhantomData<(IsForeign, AccountOf, AccountId)>,
|
sp_std::marker::PhantomData<(IsForeign, AccountOf, AccountId, L)>,
|
||||||
);
|
);
|
||||||
impl<
|
impl<
|
||||||
IsForeign: ContainsPair<MultiLocation, MultiLocation>,
|
IsForeign: ContainsPair<L, L>,
|
||||||
AccountOf: ConvertLocation<AccountId>,
|
AccountOf: ConvertLocation<AccountId>,
|
||||||
AccountId: Clone,
|
AccountId: Clone,
|
||||||
RuntimeOrigin: From<XcmOrigin> + OriginTrait + Clone,
|
RuntimeOrigin: From<XcmOrigin> + OriginTrait + Clone,
|
||||||
> EnsureOriginWithArg<RuntimeOrigin, MultiLocation>
|
L: TryFrom<Location> + TryInto<Location> + Clone,
|
||||||
for ForeignCreators<IsForeign, AccountOf, AccountId>
|
> EnsureOriginWithArg<RuntimeOrigin, L> for ForeignCreators<IsForeign, AccountOf, AccountId, L>
|
||||||
where
|
where
|
||||||
RuntimeOrigin::PalletsOrigin:
|
RuntimeOrigin::PalletsOrigin:
|
||||||
From<XcmOrigin> + TryInto<XcmOrigin, Error = RuntimeOrigin::PalletsOrigin>,
|
From<XcmOrigin> + TryInto<XcmOrigin, Error = RuntimeOrigin::PalletsOrigin>,
|
||||||
@@ -40,17 +40,20 @@ where
|
|||||||
|
|
||||||
fn try_origin(
|
fn try_origin(
|
||||||
origin: RuntimeOrigin,
|
origin: RuntimeOrigin,
|
||||||
asset_location: &MultiLocation,
|
asset_location: &L,
|
||||||
) -> sp_std::result::Result<Self::Success, RuntimeOrigin> {
|
) -> sp_std::result::Result<Self::Success, RuntimeOrigin> {
|
||||||
let origin_location = EnsureXcm::<Everything>::try_origin(origin.clone())?;
|
let origin_location = EnsureXcm::<Everything, L>::try_origin(origin.clone())?;
|
||||||
if !IsForeign::contains(asset_location, &origin_location) {
|
if !IsForeign::contains(asset_location, &origin_location) {
|
||||||
return Err(origin)
|
return Err(origin)
|
||||||
}
|
}
|
||||||
AccountOf::convert_location(&origin_location).ok_or(origin)
|
let latest_location: Location =
|
||||||
|
origin_location.clone().try_into().map_err(|_| origin.clone())?;
|
||||||
|
AccountOf::convert_location(&latest_location).ok_or(origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
fn try_successful_origin(a: &MultiLocation) -> Result<RuntimeOrigin, ()> {
|
fn try_successful_origin(a: &L) -> Result<RuntimeOrigin, ()> {
|
||||||
Ok(pallet_xcm::Origin::Xcm(*a).into())
|
let latest_location: Location = (*a).clone().try_into().map_err(|_| ())?;
|
||||||
|
Ok(pallet_xcm::Origin::Xcm(latest_location).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,52 +19,48 @@ use crate::runtime_api::FungiblesAccessError;
|
|||||||
use frame_support::traits::Contains;
|
use frame_support::traits::Contains;
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use sp_std::{borrow::Borrow, vec::Vec};
|
use sp_std::{borrow::Borrow, vec::Vec};
|
||||||
use xcm::latest::{MultiAsset, MultiLocation};
|
use xcm::latest::{Asset, Location};
|
||||||
use xcm_builder::{ConvertedConcreteId, MatchedConvertedConcreteId};
|
use xcm_builder::{ConvertedConcreteId, MatchedConvertedConcreteId};
|
||||||
use xcm_executor::traits::MatchesFungibles;
|
use xcm_executor::traits::MatchesFungibles;
|
||||||
|
|
||||||
/// Converting any [`(AssetId, Balance)`] to [`MultiAsset`]
|
/// Converting any [`(AssetId, Balance)`] to [`Asset`]
|
||||||
pub trait MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>:
|
pub trait AssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>:
|
||||||
MatchesFungibles<AssetId, Balance>
|
MatchesFungibles<AssetId, Balance>
|
||||||
where
|
where
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
{
|
{
|
||||||
fn convert_ref(
|
fn convert_ref(value: impl Borrow<(AssetId, Balance)>) -> Result<Asset, FungiblesAccessError>;
|
||||||
value: impl Borrow<(AssetId, Balance)>,
|
|
||||||
) -> Result<MultiAsset, FungiblesAccessError>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks for `MultiLocation`.
|
/// Checks for `Location`.
|
||||||
pub trait MatchesMultiLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>:
|
pub trait MatchesLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>:
|
||||||
MatchesFungibles<AssetId, Balance>
|
MatchesFungibles<AssetId, Balance>
|
||||||
where
|
where
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
MatchAssetId: Contains<MultiLocation>,
|
MatchAssetId: Contains<Location>,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
{
|
{
|
||||||
fn contains(location: &MultiLocation) -> bool;
|
fn contains(location: &Location) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
> MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
> AssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
||||||
for ConvertedConcreteId<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
for ConvertedConcreteId<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
||||||
{
|
{
|
||||||
fn convert_ref(
|
fn convert_ref(value: impl Borrow<(AssetId, Balance)>) -> Result<Asset, FungiblesAccessError> {
|
||||||
value: impl Borrow<(AssetId, Balance)>,
|
|
||||||
) -> Result<MultiAsset, FungiblesAccessError> {
|
|
||||||
let (asset_id, balance) = value.borrow();
|
let (asset_id, balance) = value.borrow();
|
||||||
match ConvertAssetId::convert_back(asset_id) {
|
match ConvertAssetId::convert_back(asset_id) {
|
||||||
Some(asset_id_as_multilocation) => match ConvertBalance::convert_back(balance) {
|
Some(asset_id_as_location) => match ConvertBalance::convert_back(balance) {
|
||||||
Some(amount) => Ok((asset_id_as_multilocation, amount).into()),
|
Some(amount) => Ok((asset_id_as_location, amount).into()),
|
||||||
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
||||||
},
|
},
|
||||||
None => Err(FungiblesAccessError::AssetIdConversionFailed),
|
None => Err(FungiblesAccessError::AssetIdConversionFailed),
|
||||||
@@ -75,19 +71,17 @@ impl<
|
|||||||
impl<
|
impl<
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
MatchAssetId: Contains<MultiLocation>,
|
MatchAssetId: Contains<Location>,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
> MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
> AssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
|
||||||
for MatchedConvertedConcreteId<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
for MatchedConvertedConcreteId<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
||||||
{
|
{
|
||||||
fn convert_ref(
|
fn convert_ref(value: impl Borrow<(AssetId, Balance)>) -> Result<Asset, FungiblesAccessError> {
|
||||||
value: impl Borrow<(AssetId, Balance)>,
|
|
||||||
) -> Result<MultiAsset, FungiblesAccessError> {
|
|
||||||
let (asset_id, balance) = value.borrow();
|
let (asset_id, balance) = value.borrow();
|
||||||
match ConvertAssetId::convert_back(asset_id) {
|
match ConvertAssetId::convert_back(asset_id) {
|
||||||
Some(asset_id_as_multilocation) => match ConvertBalance::convert_back(balance) {
|
Some(asset_id_as_location) => match ConvertBalance::convert_back(balance) {
|
||||||
Some(amount) => Ok((asset_id_as_multilocation, amount).into()),
|
Some(amount) => Ok((asset_id_as_location, amount).into()),
|
||||||
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
||||||
},
|
},
|
||||||
None => Err(FungiblesAccessError::AssetIdConversionFailed),
|
None => Err(FungiblesAccessError::AssetIdConversionFailed),
|
||||||
@@ -98,13 +92,13 @@ impl<
|
|||||||
impl<
|
impl<
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
MatchAssetId: Contains<MultiLocation>,
|
MatchAssetId: Contains<Location>,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
> MatchesMultiLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
> MatchesLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
||||||
for MatchedConvertedConcreteId<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
for MatchedConvertedConcreteId<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
|
||||||
{
|
{
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &Location) -> bool {
|
||||||
MatchAssetId::contains(location)
|
MatchAssetId::contains(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,12 +107,12 @@ impl<
|
|||||||
impl<
|
impl<
|
||||||
AssetId: Clone,
|
AssetId: Clone,
|
||||||
Balance: Clone,
|
Balance: Clone,
|
||||||
MatchAssetId: Contains<MultiLocation>,
|
MatchAssetId: Contains<Location>,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
> MatchesMultiLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance> for Tuple
|
> MatchesLocation<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance> for Tuple
|
||||||
{
|
{
|
||||||
fn contains(location: &MultiLocation) -> bool {
|
fn contains(location: &Location) -> bool {
|
||||||
for_tuples!( #(
|
for_tuples!( #(
|
||||||
match Tuple::contains(location) { o @ true => return o, _ => () }
|
match Tuple::contains(location) { o @ true => return o, _ => () }
|
||||||
)* );
|
)* );
|
||||||
@@ -127,27 +121,24 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to convert collections with [`(AssetId, Balance)`] to [`MultiAsset`]
|
/// Helper function to convert collections with [`(AssetId, Balance)`] to [`Asset`]
|
||||||
pub fn convert<'a, AssetId, Balance, ConvertAssetId, ConvertBalance, Converter>(
|
pub fn convert<'a, AssetId, Balance, ConvertAssetId, ConvertBalance, Converter>(
|
||||||
items: impl Iterator<Item = &'a (AssetId, Balance)>,
|
items: impl Iterator<Item = &'a (AssetId, Balance)>,
|
||||||
) -> Result<Vec<MultiAsset>, FungiblesAccessError>
|
) -> Result<Vec<Asset>, FungiblesAccessError>
|
||||||
where
|
where
|
||||||
AssetId: Clone + 'a,
|
AssetId: Clone + 'a,
|
||||||
Balance: Clone + 'a,
|
Balance: Clone + 'a,
|
||||||
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
|
ConvertAssetId: MaybeEquivalence<Location, AssetId>,
|
||||||
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
ConvertBalance: MaybeEquivalence<u128, Balance>,
|
||||||
Converter: MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>,
|
Converter: AssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>,
|
||||||
{
|
{
|
||||||
items.map(Converter::convert_ref).collect()
|
items.map(Converter::convert_ref).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to convert `Balance` with MultiLocation` to `MultiAsset`
|
/// Helper function to convert `Balance` with Location` to `Asset`
|
||||||
pub fn convert_balance<
|
pub fn convert_balance<T: frame_support::pallet_prelude::Get<Location>, Balance: TryInto<u128>>(
|
||||||
T: frame_support::pallet_prelude::Get<MultiLocation>,
|
|
||||||
Balance: TryInto<u128>,
|
|
||||||
>(
|
|
||||||
balance: Balance,
|
balance: Balance,
|
||||||
) -> Result<MultiAsset, FungiblesAccessError> {
|
) -> Result<Asset, FungiblesAccessError> {
|
||||||
match balance.try_into() {
|
match balance.try_into() {
|
||||||
Ok(balance) => Ok((T::get(), balance).into()),
|
Ok(balance) => Ok((T::get(), balance).into()),
|
||||||
Err(_) => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
Err(_) => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
|
||||||
@@ -162,20 +153,20 @@ mod tests {
|
|||||||
use xcm::latest::prelude::*;
|
use xcm::latest::prelude::*;
|
||||||
use xcm_executor::traits::{Identity, JustTry};
|
use xcm_executor::traits::{Identity, JustTry};
|
||||||
|
|
||||||
type Converter = MatchedConvertedConcreteId<MultiLocation, u64, Everything, Identity, JustTry>;
|
type Converter = MatchedConvertedConcreteId<Location, u64, Everything, Identity, JustTry>;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converted_concrete_id_fungible_multi_asset_conversion_roundtrip_works() {
|
fn converted_concrete_id_fungible_multi_asset_conversion_roundtrip_works() {
|
||||||
let location = MultiLocation::new(0, X1(GlobalConsensus(ByGenesis([0; 32]))));
|
let location = Location::new(0, [GlobalConsensus(ByGenesis([0; 32]))]);
|
||||||
let amount = 123456_u64;
|
let amount = 123456_u64;
|
||||||
let expected_multi_asset = MultiAsset {
|
let expected_multi_asset = Asset {
|
||||||
id: Concrete(MultiLocation::new(0, X1(GlobalConsensus(ByGenesis([0; 32]))))),
|
id: AssetId(Location::new(0, [GlobalConsensus(ByGenesis([0; 32]))])),
|
||||||
fun: Fungible(123456_u128),
|
fun: Fungible(123456_u128),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Converter::matches_fungibles(&expected_multi_asset).map_err(|_| ()),
|
Converter::matches_fungibles(&expected_multi_asset).map_err(|_| ()),
|
||||||
Ok((location, amount))
|
Ok((location.clone(), amount))
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(Converter::convert_ref((location, amount)), Ok(expected_multi_asset));
|
assert_eq!(Converter::convert_ref((location, amount)), Ok(expected_multi_asset));
|
||||||
@@ -184,17 +175,17 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn converted_concrete_id_fungible_multi_asset_conversion_collection_works() {
|
fn converted_concrete_id_fungible_multi_asset_conversion_collection_works() {
|
||||||
let data = vec![
|
let data = vec![
|
||||||
(MultiLocation::new(0, X1(GlobalConsensus(ByGenesis([0; 32])))), 123456_u64),
|
(Location::new(0, [GlobalConsensus(ByGenesis([0; 32]))]), 123456_u64),
|
||||||
(MultiLocation::new(1, X1(GlobalConsensus(ByGenesis([1; 32])))), 654321_u64),
|
(Location::new(1, [GlobalConsensus(ByGenesis([1; 32]))]), 654321_u64),
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected_data = vec![
|
let expected_data = vec![
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(MultiLocation::new(0, X1(GlobalConsensus(ByGenesis([0; 32]))))),
|
id: AssetId(Location::new(0, [GlobalConsensus(ByGenesis([0; 32]))])),
|
||||||
fun: Fungible(123456_u128),
|
fun: Fungible(123456_u128),
|
||||||
},
|
},
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(MultiLocation::new(1, X1(GlobalConsensus(ByGenesis([1; 32]))))),
|
id: AssetId(Location::new(1, [GlobalConsensus(ByGenesis([1; 32]))])),
|
||||||
fun: Fungible(654321_u128),
|
fun: Fungible(654321_u128),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,15 +23,24 @@ pub mod local_and_foreign_assets;
|
|||||||
pub mod matching;
|
pub mod matching;
|
||||||
pub mod runtime_api;
|
pub mod runtime_api;
|
||||||
|
|
||||||
use crate::matching::{LocalMultiLocationPattern, ParentLocation};
|
use crate::matching::{LocalLocationPattern, ParentLocation};
|
||||||
use frame_support::traits::{Equals, EverythingBut};
|
use frame_support::traits::{Equals, EverythingBut};
|
||||||
use parachains_common::AssetIdForTrustBackedAssets;
|
use parachains_common::AssetIdForTrustBackedAssets;
|
||||||
use xcm::prelude::MultiLocation;
|
use xcm_builder::{
|
||||||
use xcm_builder::{AsPrefixedGeneralIndex, MatchedConvertedConcreteId, StartsWith};
|
AsPrefixedGeneralIndex, MatchedConvertedConcreteId, StartsWith, V4V3LocationConverter,
|
||||||
use xcm_executor::traits::{Identity, JustTry};
|
};
|
||||||
|
use xcm_executor::traits::JustTry;
|
||||||
|
|
||||||
/// `MultiLocation` vs `AssetIdForTrustBackedAssets` converter for `TrustBackedAssets`
|
/// `Location` vs `AssetIdForTrustBackedAssets` converter for `TrustBackedAssets`
|
||||||
pub type AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation> =
|
pub type AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation> =
|
||||||
|
AsPrefixedGeneralIndex<
|
||||||
|
TrustBackedAssetsPalletLocation,
|
||||||
|
AssetIdForTrustBackedAssets,
|
||||||
|
JustTry,
|
||||||
|
xcm::v3::Location,
|
||||||
|
>;
|
||||||
|
|
||||||
|
pub type AssetIdForTrustBackedAssetsConvertLatest<TrustBackedAssetsPalletLocation> =
|
||||||
AsPrefixedGeneralIndex<TrustBackedAssetsPalletLocation, AssetIdForTrustBackedAssets, JustTry>;
|
AsPrefixedGeneralIndex<TrustBackedAssetsPalletLocation, AssetIdForTrustBackedAssets, JustTry>;
|
||||||
|
|
||||||
/// [`MatchedConvertedConcreteId`] converter dedicated for `TrustBackedAssets`
|
/// [`MatchedConvertedConcreteId`] converter dedicated for `TrustBackedAssets`
|
||||||
@@ -40,59 +49,55 @@ pub type TrustBackedAssetsConvertedConcreteId<TrustBackedAssetsPalletLocation, B
|
|||||||
AssetIdForTrustBackedAssets,
|
AssetIdForTrustBackedAssets,
|
||||||
Balance,
|
Balance,
|
||||||
StartsWith<TrustBackedAssetsPalletLocation>,
|
StartsWith<TrustBackedAssetsPalletLocation>,
|
||||||
AssetIdForTrustBackedAssetsConvert<TrustBackedAssetsPalletLocation>,
|
AssetIdForTrustBackedAssetsConvertLatest<TrustBackedAssetsPalletLocation>,
|
||||||
JustTry,
|
JustTry,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// AssetId used for identifying assets by MultiLocation.
|
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `AssetId` as `Location`.
|
||||||
pub type MultiLocationForAssetId = MultiLocation;
|
pub type LocationConvertedConcreteId<LocationFilter, Balance> = MatchedConvertedConcreteId<
|
||||||
|
xcm::v3::Location,
|
||||||
|
Balance,
|
||||||
|
LocationFilter,
|
||||||
|
V4V3LocationConverter,
|
||||||
|
JustTry,
|
||||||
|
>;
|
||||||
|
|
||||||
/// [`MatchedConvertedConcreteId`] converter dedicated for `TrustBackedAssets`
|
/// [`MatchedConvertedConcreteId`] converter dedicated for `TrustBackedAssets`
|
||||||
pub type TrustBackedAssetsAsMultiLocation<TrustBackedAssetsPalletLocation, Balance> =
|
pub type TrustBackedAssetsAsLocation<TrustBackedAssetsPalletLocation, Balance> =
|
||||||
MatchedConvertedConcreteId<
|
MatchedConvertedConcreteId<
|
||||||
MultiLocationForAssetId,
|
xcm::v3::Location,
|
||||||
Balance,
|
Balance,
|
||||||
StartsWith<TrustBackedAssetsPalletLocation>,
|
StartsWith<TrustBackedAssetsPalletLocation>,
|
||||||
Identity,
|
V4V3LocationConverter,
|
||||||
JustTry,
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `AssetId` as `MultiLocation`.
|
|
||||||
pub type MultiLocationConvertedConcreteId<MultiLocationFilter, Balance> =
|
|
||||||
MatchedConvertedConcreteId<
|
|
||||||
MultiLocationForAssetId,
|
|
||||||
Balance,
|
|
||||||
MultiLocationFilter,
|
|
||||||
Identity,
|
|
||||||
JustTry,
|
JustTry,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `ForeignAssets` with `AssetId` as
|
/// [`MatchedConvertedConcreteId`] converter dedicated for storing `ForeignAssets` with `AssetId` as
|
||||||
/// `MultiLocation`.
|
/// `Location`.
|
||||||
///
|
///
|
||||||
/// Excludes by default:
|
/// Excludes by default:
|
||||||
/// - parent as relay chain
|
/// - parent as relay chain
|
||||||
/// - all local MultiLocations
|
/// - all local Locations
|
||||||
///
|
///
|
||||||
/// `AdditionalMultiLocationExclusionFilter` can customize additional excluded MultiLocations
|
/// `AdditionalLocationExclusionFilter` can customize additional excluded Locations
|
||||||
pub type ForeignAssetsConvertedConcreteId<AdditionalMultiLocationExclusionFilter, Balance> =
|
pub type ForeignAssetsConvertedConcreteId<AdditionalLocationExclusionFilter, Balance> =
|
||||||
MultiLocationConvertedConcreteId<
|
LocationConvertedConcreteId<
|
||||||
EverythingBut<(
|
EverythingBut<(
|
||||||
// Excludes relay/parent chain currency
|
// Excludes relay/parent chain currency
|
||||||
Equals<ParentLocation>,
|
Equals<ParentLocation>,
|
||||||
// Here we rely on fact that something like this works:
|
// Here we rely on fact that something like this works:
|
||||||
// assert!(MultiLocation::new(1,
|
// assert!(Location::new(1,
|
||||||
// X1(Parachain(100))).starts_with(&MultiLocation::parent()));
|
// [Parachain(100)]).starts_with(&Location::parent()));
|
||||||
// assert!(X1(Parachain(100)).starts_with(&Here));
|
// assert!([Parachain(100)].into().starts_with(&Here));
|
||||||
StartsWith<LocalMultiLocationPattern>,
|
StartsWith<LocalLocationPattern>,
|
||||||
// Here we can exclude more stuff or leave it as `()`
|
// Here we can exclude more stuff or leave it as `()`
|
||||||
AdditionalMultiLocationExclusionFilter,
|
AdditionalLocationExclusionFilter,
|
||||||
)>,
|
)>,
|
||||||
Balance,
|
Balance,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type AssetIdForPoolAssets = u32;
|
type AssetIdForPoolAssets = u32;
|
||||||
/// `MultiLocation` vs `AssetIdForPoolAssets` converter for `PoolAssets`.
|
/// `Location` vs `AssetIdForPoolAssets` converter for `PoolAssets`.
|
||||||
pub type AssetIdForPoolAssetsConvert<PoolAssetsPalletLocation> =
|
pub type AssetIdForPoolAssetsConvert<PoolAssetsPalletLocation> =
|
||||||
AsPrefixedGeneralIndex<PoolAssetsPalletLocation, AssetIdForPoolAssets, JustTry>;
|
AsPrefixedGeneralIndex<PoolAssetsPalletLocation, AssetIdForPoolAssets, JustTry>;
|
||||||
/// [`MatchedConvertedConcreteId`] converter dedicated for `PoolAssets`
|
/// [`MatchedConvertedConcreteId`] converter dedicated for `PoolAssets`
|
||||||
@@ -109,28 +114,28 @@ pub type PoolAssetsConvertedConcreteId<PoolAssetsPalletLocation, Balance> =
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use xcm::latest::prelude::*;
|
use xcm::prelude::*;
|
||||||
use xcm_builder::StartsWithExplicitGlobalConsensus;
|
use xcm_builder::StartsWithExplicitGlobalConsensus;
|
||||||
use xcm_executor::traits::{Error as MatchError, MatchesFungibles};
|
use xcm_executor::traits::{Error as MatchError, MatchesFungibles};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn asset_id_for_trust_backed_assets_convert_works() {
|
fn asset_id_for_trust_backed_assets_convert_works() {
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub TrustBackedAssetsPalletLocation: MultiLocation = MultiLocation::new(5, X1(PalletInstance(13)));
|
pub TrustBackedAssetsPalletLocation: Location = Location::new(5, [PalletInstance(13)]);
|
||||||
}
|
}
|
||||||
let local_asset_id = 123456789 as AssetIdForTrustBackedAssets;
|
let local_asset_id = 123456789 as AssetIdForTrustBackedAssets;
|
||||||
let expected_reverse_ref =
|
let expected_reverse_ref =
|
||||||
MultiLocation::new(5, X2(PalletInstance(13), GeneralIndex(local_asset_id.into())));
|
Location::new(5, [PalletInstance(13), GeneralIndex(local_asset_id.into())]);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::convert_back(
|
AssetIdForTrustBackedAssetsConvertLatest::<TrustBackedAssetsPalletLocation>::convert_back(
|
||||||
&local_asset_id
|
&local_asset_id
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
expected_reverse_ref
|
expected_reverse_ref
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::convert(
|
AssetIdForTrustBackedAssetsConvertLatest::<TrustBackedAssetsPalletLocation>::convert(
|
||||||
&expected_reverse_ref
|
&expected_reverse_ref
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@@ -141,7 +146,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn trust_backed_assets_match_fungibles_works() {
|
fn trust_backed_assets_match_fungibles_works() {
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub TrustBackedAssetsPalletLocation: MultiLocation = MultiLocation::new(0, X1(PalletInstance(13)));
|
pub TrustBackedAssetsPalletLocation: Location = Location::new(0, [PalletInstance(13)]);
|
||||||
}
|
}
|
||||||
// setup convert
|
// setup convert
|
||||||
type TrustBackedAssetsConvert =
|
type TrustBackedAssetsConvert =
|
||||||
@@ -149,85 +154,86 @@ mod tests {
|
|||||||
|
|
||||||
let test_data = vec![
|
let test_data = vec![
|
||||||
// missing GeneralIndex
|
// missing GeneralIndex
|
||||||
(ma_1000(0, X1(PalletInstance(13))), Err(MatchError::AssetIdConversionFailed)),
|
(ma_1000(0, [PalletInstance(13)].into()), Err(MatchError::AssetIdConversionFailed)),
|
||||||
(
|
(
|
||||||
ma_1000(0, X2(PalletInstance(13), GeneralKey { data: [0; 32], length: 32 })),
|
ma_1000(0, [PalletInstance(13), GeneralKey { data: [0; 32], length: 32 }].into()),
|
||||||
Err(MatchError::AssetIdConversionFailed),
|
Err(MatchError::AssetIdConversionFailed),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(0, X2(PalletInstance(13), Parachain(1000))),
|
ma_1000(0, [PalletInstance(13), Parachain(1000)].into()),
|
||||||
Err(MatchError::AssetIdConversionFailed),
|
Err(MatchError::AssetIdConversionFailed),
|
||||||
),
|
),
|
||||||
// OK
|
// OK
|
||||||
(ma_1000(0, X2(PalletInstance(13), GeneralIndex(1234))), Ok((1234, 1000))),
|
(ma_1000(0, [PalletInstance(13), GeneralIndex(1234)].into()), Ok((1234, 1000))),
|
||||||
(
|
(
|
||||||
ma_1000(0, X3(PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222))),
|
ma_1000(0, [PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222)].into()),
|
||||||
Ok((1234, 1000)),
|
Ok((1234, 1000)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(
|
ma_1000(
|
||||||
0,
|
0,
|
||||||
X4(
|
[
|
||||||
PalletInstance(13),
|
PalletInstance(13),
|
||||||
GeneralIndex(1234),
|
GeneralIndex(1234),
|
||||||
GeneralIndex(2222),
|
GeneralIndex(2222),
|
||||||
GeneralKey { data: [0; 32], length: 32 },
|
GeneralKey { data: [0; 32], length: 32 },
|
||||||
),
|
]
|
||||||
|
.into(),
|
||||||
),
|
),
|
||||||
Ok((1234, 1000)),
|
Ok((1234, 1000)),
|
||||||
),
|
),
|
||||||
// wrong pallet instance
|
// wrong pallet instance
|
||||||
(
|
(
|
||||||
ma_1000(0, X2(PalletInstance(77), GeneralIndex(1234))),
|
ma_1000(0, [PalletInstance(77), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(0, X3(PalletInstance(77), GeneralIndex(1234), GeneralIndex(2222))),
|
ma_1000(0, [PalletInstance(77), GeneralIndex(1234), GeneralIndex(2222)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// wrong parent
|
// wrong parent
|
||||||
(
|
(
|
||||||
ma_1000(1, X2(PalletInstance(13), GeneralIndex(1234))),
|
ma_1000(1, [PalletInstance(13), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(1, X3(PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222))),
|
ma_1000(1, [PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(1, X2(PalletInstance(77), GeneralIndex(1234))),
|
ma_1000(1, [PalletInstance(77), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(1, X3(PalletInstance(77), GeneralIndex(1234), GeneralIndex(2222))),
|
ma_1000(1, [PalletInstance(77), GeneralIndex(1234), GeneralIndex(2222)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// wrong parent
|
// wrong parent
|
||||||
(
|
(
|
||||||
ma_1000(2, X2(PalletInstance(13), GeneralIndex(1234))),
|
ma_1000(2, [PalletInstance(13), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(2, X3(PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222))),
|
ma_1000(2, [PalletInstance(13), GeneralIndex(1234), GeneralIndex(2222)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// missing GeneralIndex
|
// missing GeneralIndex
|
||||||
(ma_1000(0, X1(PalletInstance(77))), Err(MatchError::AssetNotHandled)),
|
(ma_1000(0, [PalletInstance(77)].into()), Err(MatchError::AssetNotHandled)),
|
||||||
(ma_1000(1, X1(PalletInstance(13))), Err(MatchError::AssetNotHandled)),
|
(ma_1000(1, [PalletInstance(13)].into()), Err(MatchError::AssetNotHandled)),
|
||||||
(ma_1000(2, X1(PalletInstance(13))), Err(MatchError::AssetNotHandled)),
|
(ma_1000(2, [PalletInstance(13)].into()), Err(MatchError::AssetNotHandled)),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (multi_asset, expected_result) in test_data {
|
for (asset, expected_result) in test_data {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<TrustBackedAssetsConvert as MatchesFungibles<AssetIdForTrustBackedAssets, u128>>::matches_fungibles(&multi_asset),
|
<TrustBackedAssetsConvert as MatchesFungibles<AssetIdForTrustBackedAssets, u128>>::matches_fungibles(&asset.clone().try_into().unwrap()),
|
||||||
expected_result, "multi_asset: {:?}", multi_asset);
|
expected_result, "asset: {:?}", asset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn multi_location_converted_concrete_id_converter_works() {
|
fn location_converted_concrete_id_converter_works() {
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub Parachain100Pattern: MultiLocation = MultiLocation::new(1, X1(Parachain(100)));
|
pub Parachain100Pattern: Location = Location::new(1, [Parachain(100)]);
|
||||||
pub UniversalLocationNetworkId: NetworkId = NetworkId::ByGenesis([9; 32]);
|
pub UniversalLocationNetworkId: NetworkId = NetworkId::ByGenesis([9; 32]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,95 +249,125 @@ mod tests {
|
|||||||
let test_data = vec![
|
let test_data = vec![
|
||||||
// excluded as local
|
// excluded as local
|
||||||
(ma_1000(0, Here), Err(MatchError::AssetNotHandled)),
|
(ma_1000(0, Here), Err(MatchError::AssetNotHandled)),
|
||||||
(ma_1000(0, X1(Parachain(100))), Err(MatchError::AssetNotHandled)),
|
(ma_1000(0, [Parachain(100)].into()), Err(MatchError::AssetNotHandled)),
|
||||||
(
|
(
|
||||||
ma_1000(0, X2(PalletInstance(13), GeneralIndex(1234))),
|
ma_1000(0, [PalletInstance(13), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// excluded as parent
|
// excluded as parent
|
||||||
(ma_1000(1, Here), Err(MatchError::AssetNotHandled)),
|
(ma_1000(1, Here), Err(MatchError::AssetNotHandled)),
|
||||||
// excluded as additional filter - Parachain100Pattern
|
// excluded as additional filter - Parachain100Pattern
|
||||||
(ma_1000(1, X1(Parachain(100))), Err(MatchError::AssetNotHandled)),
|
(ma_1000(1, [Parachain(100)].into()), Err(MatchError::AssetNotHandled)),
|
||||||
(ma_1000(1, X2(Parachain(100), GeneralIndex(1234))), Err(MatchError::AssetNotHandled)),
|
|
||||||
(
|
(
|
||||||
ma_1000(1, X3(Parachain(100), PalletInstance(13), GeneralIndex(1234))),
|
ma_1000(1, [Parachain(100), GeneralIndex(1234)].into()),
|
||||||
|
Err(MatchError::AssetNotHandled),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
ma_1000(1, [Parachain(100), PalletInstance(13), GeneralIndex(1234)].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// excluded as additional filter - StartsWithExplicitGlobalConsensus
|
// excluded as additional filter - StartsWithExplicitGlobalConsensus
|
||||||
(
|
(
|
||||||
ma_1000(1, X1(GlobalConsensus(NetworkId::ByGenesis([9; 32])))),
|
ma_1000(1, [GlobalConsensus(NetworkId::ByGenesis([9; 32]))].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(2, X1(GlobalConsensus(NetworkId::ByGenesis([9; 32])))),
|
ma_1000(2, [GlobalConsensus(NetworkId::ByGenesis([9; 32]))].into()),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(
|
ma_1000(
|
||||||
2,
|
2,
|
||||||
X3(
|
[
|
||||||
GlobalConsensus(NetworkId::ByGenesis([9; 32])),
|
GlobalConsensus(NetworkId::ByGenesis([9; 32])),
|
||||||
Parachain(200),
|
Parachain(200),
|
||||||
GeneralIndex(1234),
|
GeneralIndex(1234),
|
||||||
),
|
]
|
||||||
|
.into(),
|
||||||
),
|
),
|
||||||
Err(MatchError::AssetNotHandled),
|
Err(MatchError::AssetNotHandled),
|
||||||
),
|
),
|
||||||
// ok
|
// ok
|
||||||
(ma_1000(1, X1(Parachain(200))), Ok((MultiLocation::new(1, X1(Parachain(200))), 1000))),
|
|
||||||
(ma_1000(2, X1(Parachain(200))), Ok((MultiLocation::new(2, X1(Parachain(200))), 1000))),
|
|
||||||
(
|
(
|
||||||
ma_1000(1, X2(Parachain(200), GeneralIndex(1234))),
|
ma_1000(1, [Parachain(200)].into()),
|
||||||
Ok((MultiLocation::new(1, X2(Parachain(200), GeneralIndex(1234))), 1000)),
|
Ok((xcm::v3::Location::new(1, [xcm::v3::Junction::Parachain(200)]), 1000)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(2, X2(Parachain(200), GeneralIndex(1234))),
|
ma_1000(2, [Parachain(200)].into()),
|
||||||
Ok((MultiLocation::new(2, X2(Parachain(200), GeneralIndex(1234))), 1000)),
|
Ok((xcm::v3::Location::new(2, [xcm::v3::Junction::Parachain(200)]), 1000)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(2, X1(GlobalConsensus(NetworkId::ByGenesis([7; 32])))),
|
ma_1000(1, [Parachain(200), GeneralIndex(1234)].into()),
|
||||||
Ok((
|
Ok((
|
||||||
MultiLocation::new(2, X1(GlobalConsensus(NetworkId::ByGenesis([7; 32])))),
|
xcm::v3::Location::new(
|
||||||
|
1,
|
||||||
|
[xcm::v3::Junction::Parachain(200), xcm::v3::Junction::GeneralIndex(1234)],
|
||||||
|
),
|
||||||
|
1000,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
ma_1000(2, [Parachain(200), GeneralIndex(1234)].into()),
|
||||||
|
Ok((
|
||||||
|
xcm::v3::Location::new(
|
||||||
|
2,
|
||||||
|
[xcm::v3::Junction::Parachain(200), xcm::v3::Junction::GeneralIndex(1234)],
|
||||||
|
),
|
||||||
|
1000,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
ma_1000(2, [GlobalConsensus(NetworkId::ByGenesis([7; 32]))].into()),
|
||||||
|
Ok((
|
||||||
|
xcm::v3::Location::new(
|
||||||
|
2,
|
||||||
|
[xcm::v3::Junction::GlobalConsensus(xcm::v3::NetworkId::ByGenesis(
|
||||||
|
[7; 32],
|
||||||
|
))],
|
||||||
|
),
|
||||||
1000,
|
1000,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
ma_1000(
|
ma_1000(
|
||||||
2,
|
2,
|
||||||
X3(
|
[
|
||||||
GlobalConsensus(NetworkId::ByGenesis([7; 32])),
|
GlobalConsensus(NetworkId::ByGenesis([7; 32])),
|
||||||
Parachain(200),
|
Parachain(200),
|
||||||
GeneralIndex(1234),
|
GeneralIndex(1234),
|
||||||
),
|
]
|
||||||
|
.into(),
|
||||||
),
|
),
|
||||||
Ok((
|
Ok((
|
||||||
MultiLocation::new(
|
xcm::v3::Location::new(
|
||||||
2,
|
2,
|
||||||
X3(
|
[
|
||||||
GlobalConsensus(NetworkId::ByGenesis([7; 32])),
|
xcm::v3::Junction::GlobalConsensus(xcm::v3::NetworkId::ByGenesis(
|
||||||
Parachain(200),
|
[7; 32],
|
||||||
GeneralIndex(1234),
|
)),
|
||||||
),
|
xcm::v3::Junction::Parachain(200),
|
||||||
|
xcm::v3::Junction::GeneralIndex(1234),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
1000,
|
1000,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (multi_asset, expected_result) in test_data {
|
for (asset, expected_result) in test_data {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<Convert as MatchesFungibles<MultiLocationForAssetId, u128>>::matches_fungibles(
|
<Convert as MatchesFungibles<xcm::v3::MultiLocation, u128>>::matches_fungibles(
|
||||||
&multi_asset
|
&asset.clone().try_into().unwrap()
|
||||||
),
|
),
|
||||||
expected_result,
|
expected_result,
|
||||||
"multi_asset: {:?}",
|
"asset: {:?}",
|
||||||
multi_asset
|
asset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create MultiAsset
|
// Create Asset
|
||||||
fn ma_1000(parents: u8, interior: Junctions) -> MultiAsset {
|
fn ma_1000(parents: u8, interior: Junctions) -> Asset {
|
||||||
(MultiLocation::new(parents, interior), 1000).into()
|
(Location::new(parents, interior), 1000).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,32 +20,32 @@ use sp_runtime::{
|
|||||||
Either::{Left, Right},
|
Either::{Left, Right},
|
||||||
};
|
};
|
||||||
use sp_std::marker::PhantomData;
|
use sp_std::marker::PhantomData;
|
||||||
use xcm::latest::MultiLocation;
|
use xcm::latest::Location;
|
||||||
|
|
||||||
/// Converts a given [`MultiLocation`] to [`Either::Left`] when equal to `Target`, or
|
/// Converts a given [`Location`] to [`Either::Left`] when equal to `Target`, or
|
||||||
/// [`Either::Right`] otherwise.
|
/// [`Either::Right`] otherwise.
|
||||||
///
|
///
|
||||||
/// Suitable for use as a `Criterion` with [`frame_support::traits::tokens::fungible::UnionOf`].
|
/// Suitable for use as a `Criterion` with [`frame_support::traits::tokens::fungible::UnionOf`].
|
||||||
pub struct TargetFromLeft<Target>(PhantomData<Target>);
|
pub struct TargetFromLeft<Target, L = Location>(PhantomData<(Target, L)>);
|
||||||
impl<Target: Get<MultiLocation>> Convert<MultiLocation, Either<(), MultiLocation>>
|
impl<Target: Get<L>, L: PartialEq + Eq> Convert<L, Either<(), L>> for TargetFromLeft<Target, L> {
|
||||||
for TargetFromLeft<Target>
|
fn convert(l: L) -> Either<(), L> {
|
||||||
{
|
|
||||||
fn convert(l: MultiLocation) -> Either<(), MultiLocation> {
|
|
||||||
Target::get().eq(&l).then(|| Left(())).map_or(Right(l), |n| n)
|
Target::get().eq(&l).then(|| Left(())).map_or(Right(l), |n| n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a given [`MultiLocation`] to [`Either::Left`] based on the `Equivalence` criteria.
|
/// Converts a given [`Location`] to [`Either::Left`] based on the `Equivalence` criteria.
|
||||||
/// Returns [`Either::Right`] if not equivalent.
|
/// Returns [`Either::Right`] if not equivalent.
|
||||||
///
|
///
|
||||||
/// Suitable for use as a `Criterion` with [`frame_support::traits::tokens::fungibles::UnionOf`].
|
/// Suitable for use as a `Criterion` with [`frame_support::traits::tokens::fungibles::UnionOf`].
|
||||||
pub struct LocalFromLeft<Equivalence, AssetId>(PhantomData<(Equivalence, AssetId)>);
|
pub struct LocalFromLeft<Equivalence, AssetId, L = Location>(
|
||||||
impl<Equivalence, AssetId> Convert<MultiLocation, Either<AssetId, MultiLocation>>
|
PhantomData<(Equivalence, AssetId, L)>,
|
||||||
for LocalFromLeft<Equivalence, AssetId>
|
);
|
||||||
|
impl<Equivalence, AssetId, L> Convert<L, Either<AssetId, L>>
|
||||||
|
for LocalFromLeft<Equivalence, AssetId, L>
|
||||||
where
|
where
|
||||||
Equivalence: MaybeEquivalence<MultiLocation, AssetId>,
|
Equivalence: MaybeEquivalence<L, AssetId>,
|
||||||
{
|
{
|
||||||
fn convert(l: MultiLocation) -> Either<AssetId, MultiLocation> {
|
fn convert(l: L) -> Either<AssetId, L> {
|
||||||
match Equivalence::convert(&l) {
|
match Equivalence::convert(&l) {
|
||||||
Some(id) => Left(id),
|
Some(id) => Left(id),
|
||||||
None => Right(l),
|
None => Right(l),
|
||||||
@@ -53,7 +53,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MatchesLocalAndForeignAssetsMultiLocation {
|
pub trait MatchesLocalAndForeignAssetsLocation<L = Location> {
|
||||||
fn is_local(location: &MultiLocation) -> bool;
|
fn is_local(location: &L) -> bool;
|
||||||
fn is_foreign(location: &MultiLocation) -> bool;
|
fn is_foreign(location: &L) -> bool;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,67 +15,72 @@
|
|||||||
|
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use frame_support::{pallet_prelude::Get, traits::ContainsPair};
|
use frame_support::{pallet_prelude::Get, traits::ContainsPair};
|
||||||
use xcm::{
|
use xcm::prelude::*;
|
||||||
latest::prelude::{MultiAsset, MultiLocation},
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use xcm_builder::ensure_is_remote;
|
use xcm_builder::ensure_is_remote;
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub LocalMultiLocationPattern: MultiLocation = MultiLocation::new(0, Here);
|
pub LocalLocationPattern: Location = Location::new(0, Here);
|
||||||
pub ParentLocation: MultiLocation = MultiLocation::parent();
|
pub ParentLocation: Location = Location::parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accepts an asset if it is from the origin.
|
/// Accepts an asset if it is from the origin.
|
||||||
pub struct IsForeignConcreteAsset<IsForeign>(sp_std::marker::PhantomData<IsForeign>);
|
pub struct IsForeignConcreteAsset<IsForeign>(sp_std::marker::PhantomData<IsForeign>);
|
||||||
impl<IsForeign: ContainsPair<MultiLocation, MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
|
impl<IsForeign: ContainsPair<Location, Location>> ContainsPair<Asset, Location>
|
||||||
for IsForeignConcreteAsset<IsForeign>
|
for IsForeignConcreteAsset<IsForeign>
|
||||||
{
|
{
|
||||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||||
log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
|
log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
|
||||||
matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, origin))
|
matches!(asset.id, AssetId(ref id) if IsForeign::contains(id, origin))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if `a` is from sibling location `b`. Checks that `MultiLocation-a` starts with
|
/// Checks if `a` is from sibling location `b`. Checks that `Location-a` starts with
|
||||||
/// `MultiLocation-b`, and that the `ParaId` of `b` is not equal to `a`.
|
/// `Location-b`, and that the `ParaId` of `b` is not equal to `a`.
|
||||||
pub struct FromSiblingParachain<SelfParaId>(sp_std::marker::PhantomData<SelfParaId>);
|
pub struct FromSiblingParachain<SelfParaId, L = Location>(
|
||||||
impl<SelfParaId: Get<ParaId>> ContainsPair<MultiLocation, MultiLocation>
|
sp_std::marker::PhantomData<(SelfParaId, L)>,
|
||||||
for FromSiblingParachain<SelfParaId>
|
);
|
||||||
|
impl<SelfParaId: Get<ParaId>, L: TryFrom<Location> + TryInto<Location> + Clone> ContainsPair<L, L>
|
||||||
|
for FromSiblingParachain<SelfParaId, L>
|
||||||
{
|
{
|
||||||
fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool {
|
fn contains(a: &L, b: &L) -> bool {
|
||||||
// `a` needs to be from `b` at least
|
// We convert locations to latest
|
||||||
if !a.starts_with(b) {
|
let a = match ((*a).clone().try_into(), (*b).clone().try_into()) {
|
||||||
return false
|
(Ok(a), Ok(b)) if a.starts_with(&b) => a, // `a` needs to be from `b` at least
|
||||||
}
|
_ => return false,
|
||||||
|
};
|
||||||
|
|
||||||
// here we check if sibling
|
// here we check if sibling
|
||||||
match a {
|
match a.unpack() {
|
||||||
MultiLocation { parents: 1, interior } =>
|
(1, interior) =>
|
||||||
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))),
|
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if `a` is from the expected global consensus network. Checks that `MultiLocation-a`
|
/// Checks if `a` is from the expected global consensus network. Checks that `Location-a`
|
||||||
/// starts with `MultiLocation-b`, and that network is a foreign consensus system.
|
/// starts with `Location-b`, and that network is a foreign consensus system.
|
||||||
pub struct FromNetwork<UniversalLocation, ExpectedNetworkId>(
|
pub struct FromNetwork<UniversalLocation, ExpectedNetworkId, L = Location>(
|
||||||
sp_std::marker::PhantomData<(UniversalLocation, ExpectedNetworkId)>,
|
sp_std::marker::PhantomData<(UniversalLocation, ExpectedNetworkId, L)>,
|
||||||
);
|
);
|
||||||
impl<UniversalLocation: Get<InteriorMultiLocation>, ExpectedNetworkId: Get<NetworkId>>
|
impl<
|
||||||
ContainsPair<MultiLocation, MultiLocation> for FromNetwork<UniversalLocation, ExpectedNetworkId>
|
UniversalLocation: Get<InteriorLocation>,
|
||||||
|
ExpectedNetworkId: Get<NetworkId>,
|
||||||
|
L: TryFrom<Location> + TryInto<Location> + Clone,
|
||||||
|
> ContainsPair<L, L> for FromNetwork<UniversalLocation, ExpectedNetworkId, L>
|
||||||
{
|
{
|
||||||
fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool {
|
fn contains(a: &L, b: &L) -> bool {
|
||||||
// `a` needs to be from `b` at least
|
// We convert locations to latest
|
||||||
if !a.starts_with(b) {
|
let a = match ((*a).clone().try_into(), (*b).clone().try_into()) {
|
||||||
return false
|
(Ok(a), Ok(b)) if a.starts_with(&b) => a, // `a` needs to be from `b` at least
|
||||||
}
|
_ => return false,
|
||||||
|
};
|
||||||
|
|
||||||
let universal_source = UniversalLocation::get();
|
let universal_source = UniversalLocation::get();
|
||||||
|
|
||||||
// ensure that `a`` is remote and from the expected network
|
// ensure that `a` is remote and from the expected network
|
||||||
match ensure_is_remote(universal_source, a) {
|
match ensure_is_remote(universal_source.clone(), a.clone()) {
|
||||||
Ok((network_id, _)) => network_id == ExpectedNetworkId::get(),
|
Ok((network_id, _)) => network_id == ExpectedNetworkId::get(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
@@ -89,19 +94,17 @@ impl<UniversalLocation: Get<InteriorMultiLocation>, ExpectedNetworkId: Get<Netwo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adapter verifies if it is allowed to receive `MultiAsset` from `MultiLocation`.
|
/// Adapter verifies if it is allowed to receive `Asset` from `Location`.
|
||||||
///
|
///
|
||||||
/// Note: `MultiLocation` has to be from a different global consensus.
|
/// Note: `Location` has to be from a different global consensus.
|
||||||
pub struct IsTrustedBridgedReserveLocationForConcreteAsset<UniversalLocation, Reserves>(
|
pub struct IsTrustedBridgedReserveLocationForConcreteAsset<UniversalLocation, Reserves>(
|
||||||
sp_std::marker::PhantomData<(UniversalLocation, Reserves)>,
|
sp_std::marker::PhantomData<(UniversalLocation, Reserves)>,
|
||||||
);
|
);
|
||||||
impl<
|
impl<UniversalLocation: Get<InteriorLocation>, Reserves: ContainsPair<Asset, Location>>
|
||||||
UniversalLocation: Get<InteriorMultiLocation>,
|
ContainsPair<Asset, Location>
|
||||||
Reserves: ContainsPair<MultiAsset, MultiLocation>,
|
|
||||||
> ContainsPair<MultiAsset, MultiLocation>
|
|
||||||
for IsTrustedBridgedReserveLocationForConcreteAsset<UniversalLocation, Reserves>
|
for IsTrustedBridgedReserveLocationForConcreteAsset<UniversalLocation, Reserves>
|
||||||
{
|
{
|
||||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
fn contains(asset: &Asset, origin: &Location) -> bool {
|
||||||
let universal_source = UniversalLocation::get();
|
let universal_source = UniversalLocation::get();
|
||||||
log::trace!(
|
log::trace!(
|
||||||
target: "xcm::contains",
|
target: "xcm::contains",
|
||||||
@@ -110,7 +113,7 @@ impl<
|
|||||||
);
|
);
|
||||||
|
|
||||||
// check remote origin
|
// check remote origin
|
||||||
let _ = match ensure_is_remote(universal_source, *origin) {
|
let _ = match ensure_is_remote(universal_source.clone(), origin.clone()) {
|
||||||
Ok(devolved) => devolved,
|
Ok(devolved) => devolved,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
@@ -133,14 +136,14 @@ mod tests {
|
|||||||
use frame_support::parameter_types;
|
use frame_support::parameter_types;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(Rococo), Parachain(1000));
|
pub UniversalLocation: InteriorLocation = [GlobalConsensus(Rococo), Parachain(1000)].into();
|
||||||
pub ExpectedNetworkId: NetworkId = Wococo;
|
pub ExpectedNetworkId: NetworkId = Wococo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_network_contains_works() {
|
fn from_network_contains_works() {
|
||||||
// asset and origin from foreign consensus works
|
// asset and origin from foreign consensus works
|
||||||
let asset: MultiLocation = (
|
let asset: Location = (
|
||||||
Parent,
|
Parent,
|
||||||
Parent,
|
Parent,
|
||||||
GlobalConsensus(Wococo),
|
GlobalConsensus(Wococo),
|
||||||
@@ -149,12 +152,11 @@ mod tests {
|
|||||||
GeneralIndex(1),
|
GeneralIndex(1),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
let origin: MultiLocation =
|
let origin: Location = (Parent, Parent, GlobalConsensus(Wococo), Parachain(1000)).into();
|
||||||
(Parent, Parent, GlobalConsensus(Wococo), Parachain(1000)).into();
|
|
||||||
assert!(FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
|
|
||||||
// asset and origin from local consensus fails
|
// asset and origin from local consensus fails
|
||||||
let asset: MultiLocation = (
|
let asset: Location = (
|
||||||
Parent,
|
Parent,
|
||||||
Parent,
|
Parent,
|
||||||
GlobalConsensus(Rococo),
|
GlobalConsensus(Rococo),
|
||||||
@@ -163,17 +165,16 @@ mod tests {
|
|||||||
GeneralIndex(1),
|
GeneralIndex(1),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
let origin: MultiLocation =
|
let origin: Location = (Parent, Parent, GlobalConsensus(Rococo), Parachain(1000)).into();
|
||||||
(Parent, Parent, GlobalConsensus(Rococo), Parachain(1000)).into();
|
|
||||||
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
|
|
||||||
// asset and origin from here fails
|
// asset and origin from here fails
|
||||||
let asset: MultiLocation = (PalletInstance(1), GeneralIndex(1)).into();
|
let asset: Location = (PalletInstance(1), GeneralIndex(1)).into();
|
||||||
let origin: MultiLocation = Here.into();
|
let origin: Location = Here.into();
|
||||||
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
|
|
||||||
// asset from different consensus fails
|
// asset from different consensus fails
|
||||||
let asset: MultiLocation = (
|
let asset: Location = (
|
||||||
Parent,
|
Parent,
|
||||||
Parent,
|
Parent,
|
||||||
GlobalConsensus(Polkadot),
|
GlobalConsensus(Polkadot),
|
||||||
@@ -182,12 +183,11 @@ mod tests {
|
|||||||
GeneralIndex(1),
|
GeneralIndex(1),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
let origin: MultiLocation =
|
let origin: Location = (Parent, Parent, GlobalConsensus(Wococo), Parachain(1000)).into();
|
||||||
(Parent, Parent, GlobalConsensus(Wococo), Parachain(1000)).into();
|
|
||||||
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
|
|
||||||
// origin from different consensus fails
|
// origin from different consensus fails
|
||||||
let asset: MultiLocation = (
|
let asset: Location = (
|
||||||
Parent,
|
Parent,
|
||||||
Parent,
|
Parent,
|
||||||
GlobalConsensus(Wococo),
|
GlobalConsensus(Wococo),
|
||||||
@@ -196,12 +196,11 @@ mod tests {
|
|||||||
GeneralIndex(1),
|
GeneralIndex(1),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
let origin: MultiLocation =
|
let origin: Location = (Parent, Parent, GlobalConsensus(Polkadot), Parachain(1000)).into();
|
||||||
(Parent, Parent, GlobalConsensus(Polkadot), Parachain(1000)).into();
|
|
||||||
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
|
|
||||||
// asset and origin from unexpected consensus fails
|
// asset and origin from unexpected consensus fails
|
||||||
let asset: MultiLocation = (
|
let asset: Location = (
|
||||||
Parent,
|
Parent,
|
||||||
Parent,
|
Parent,
|
||||||
GlobalConsensus(Polkadot),
|
GlobalConsensus(Polkadot),
|
||||||
@@ -210,8 +209,7 @@ mod tests {
|
|||||||
GeneralIndex(1),
|
GeneralIndex(1),
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
let origin: MultiLocation =
|
let origin: Location = (Parent, Parent, GlobalConsensus(Polkadot), Parachain(1000)).into();
|
||||||
(Parent, Parent, GlobalConsensus(Polkadot), Parachain(1000)).into();
|
|
||||||
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
use codec::{Codec, Decode, Encode};
|
use codec::{Codec, Decode, Encode};
|
||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use {sp_std::vec::Vec, xcm::latest::MultiAsset};
|
use {sp_std::vec::Vec, xcm::latest::Asset};
|
||||||
|
|
||||||
/// The possible errors that can happen querying the storage of assets.
|
/// The possible errors that can happen querying the storage of assets.
|
||||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
|
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
|
||||||
pub enum FungiblesAccessError {
|
pub enum FungiblesAccessError {
|
||||||
/// `MultiLocation` to `AssetId`/`ClassId` conversion failed.
|
/// `Location` to `AssetId`/`ClassId` conversion failed.
|
||||||
AssetIdConversionFailed,
|
AssetIdConversionFailed,
|
||||||
/// `u128` amount to currency `Balance` conversion failed.
|
/// `u128` amount to currency `Balance` conversion failed.
|
||||||
AmountToBalanceConversionFailed,
|
AmountToBalanceConversionFailed,
|
||||||
@@ -36,11 +36,11 @@ sp_api::decl_runtime_apis! {
|
|||||||
where
|
where
|
||||||
AccountId: Codec,
|
AccountId: Codec,
|
||||||
{
|
{
|
||||||
/// Returns the list of all [`MultiAsset`] that an `AccountId` has.
|
/// Returns the list of all [`Asset`] that an `AccountId` has.
|
||||||
#[changed_in(2)]
|
#[changed_in(2)]
|
||||||
fn query_account_balances(account: AccountId) -> Result<Vec<MultiAsset>, FungiblesAccessError>;
|
fn query_account_balances(account: AccountId) -> Result<Vec<Asset>, FungiblesAccessError>;
|
||||||
|
|
||||||
/// Returns the list of all [`MultiAsset`] that an `AccountId` has.
|
/// Returns the list of all [`Asset`] that an `AccountId` has.
|
||||||
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedMultiAssets, FungiblesAccessError>;
|
fn query_account_balances(account: AccountId) -> Result<xcm::VersionedAssets, FungiblesAccessError>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use xcm::latest::prelude::*;
|
|||||||
use xcm_builder::{CreateMatcher, MatchXcm};
|
use xcm_builder::{CreateMatcher, MatchXcm};
|
||||||
|
|
||||||
/// Given a message, a sender, and a destination, it returns the delivery fees
|
/// Given a message, a sender, and a destination, it returns the delivery fees
|
||||||
fn get_fungible_delivery_fees<S: SendXcm>(destination: MultiLocation, message: Xcm<()>) -> u128 {
|
fn get_fungible_delivery_fees<S: SendXcm>(destination: Location, message: Xcm<()>) -> u128 {
|
||||||
let Ok((_, delivery_fees)) = validate_send::<S>(destination, message) else {
|
let Ok((_, delivery_fees)) = validate_send::<S>(destination, message) else {
|
||||||
unreachable!("message can be sent; qed")
|
unreachable!("message can be sent; qed")
|
||||||
};
|
};
|
||||||
@@ -46,8 +46,8 @@ fn get_fungible_delivery_fees<S: SendXcm>(destination: MultiLocation, message: X
|
|||||||
/// chain as part of a reserve-asset-transfer.
|
/// chain as part of a reserve-asset-transfer.
|
||||||
pub(crate) fn assert_matches_reserve_asset_deposited_instructions<RuntimeCall: Debug>(
|
pub(crate) fn assert_matches_reserve_asset_deposited_instructions<RuntimeCall: Debug>(
|
||||||
xcm: &mut Xcm<RuntimeCall>,
|
xcm: &mut Xcm<RuntimeCall>,
|
||||||
expected_reserve_assets_deposited: &MultiAssets,
|
expected_reserve_assets_deposited: &Assets,
|
||||||
expected_beneficiary: &MultiLocation,
|
expected_beneficiary: &Location,
|
||||||
) {
|
) {
|
||||||
let _ = xcm
|
let _ = xcm
|
||||||
.0
|
.0
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ use sp_runtime::{
|
|||||||
traits::{MaybeEquivalence, StaticLookup, Zero},
|
traits::{MaybeEquivalence, StaticLookup, Zero},
|
||||||
DispatchError, Saturating,
|
DispatchError, Saturating,
|
||||||
};
|
};
|
||||||
use xcm::{latest::prelude::*, VersionedMultiAssets};
|
use xcm::{latest::prelude::*, VersionedAssets};
|
||||||
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
|
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
|
||||||
|
|
||||||
type RuntimeHelper<Runtime, AllPalletsWithoutSystem = ()> =
|
type RuntimeHelper<Runtime, AllPalletsWithoutSystem = ()> =
|
||||||
@@ -110,7 +110,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
|
|
||||||
let native_asset_id = MultiLocation::parent();
|
let native_asset_id = Location::parent();
|
||||||
let buy_execution_fee_amount_eta =
|
let buy_execution_fee_amount_eta =
|
||||||
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 1024));
|
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 1024));
|
||||||
let native_asset_amount_unit = existential_deposit;
|
let native_asset_amount_unit = existential_deposit;
|
||||||
@@ -119,38 +119,40 @@ pub fn teleports_for_native_asset_works<
|
|||||||
|
|
||||||
// 1. process received teleported assets from relaychain
|
// 1. process received teleported assets from relaychain
|
||||||
let xcm = Xcm(vec![
|
let xcm = Xcm(vec![
|
||||||
ReceiveTeleportedAsset(MultiAssets::from(vec![MultiAsset {
|
ReceiveTeleportedAsset(Assets::from(vec![Asset {
|
||||||
id: Concrete(native_asset_id),
|
id: AssetId(native_asset_id.clone()),
|
||||||
fun: Fungible(native_asset_amount_received.into()),
|
fun: Fungible(native_asset_amount_received.into()),
|
||||||
}])),
|
}])),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution {
|
BuyExecution {
|
||||||
fees: MultiAsset {
|
fees: Asset {
|
||||||
id: Concrete(native_asset_id),
|
id: AssetId(native_asset_id.clone()),
|
||||||
fun: Fungible(buy_execution_fee_amount_eta),
|
fun: Fungible(buy_execution_fee_amount_eta),
|
||||||
},
|
},
|
||||||
weight_limit: Limited(Weight::from_parts(3035310000, 65536)),
|
weight_limit: Limited(Weight::from_parts(3035310000, 65536)),
|
||||||
},
|
},
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: Wild(AllCounted(1)),
|
assets: Wild(AllCounted(1)),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 {
|
interior: [AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: target_account.clone().into(),
|
id: target_account.clone().into(),
|
||||||
}),
|
}]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectTransactStatus(MaybeErrorCode::Success),
|
ExpectTransactStatus(MaybeErrorCode::Success),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
Parent,
|
Parent,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Parent),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Parent),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
|
|
||||||
@@ -163,14 +165,14 @@ pub fn teleports_for_native_asset_works<
|
|||||||
|
|
||||||
// 2. try to teleport asset back to the relaychain
|
// 2. try to teleport asset back to the relaychain
|
||||||
{
|
{
|
||||||
let dest = MultiLocation::parent();
|
let dest = Location::parent();
|
||||||
let mut dest_beneficiary = MultiLocation::parent()
|
let mut dest_beneficiary = Location::parent()
|
||||||
.appended_with(AccountId32 {
|
.appended_with(AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dest_beneficiary.reanchor(&dest, XcmConfig::UniversalLocation::get()).unwrap();
|
dest_beneficiary.reanchor(&dest, &XcmConfig::UniversalLocation::get()).unwrap();
|
||||||
|
|
||||||
let target_account_balance_before_teleport =
|
let target_account_balance_before_teleport =
|
||||||
<pallet_balances::Pallet<Runtime>>::free_balance(&target_account);
|
<pallet_balances::Pallet<Runtime>>::free_balance(&target_account);
|
||||||
@@ -183,11 +185,11 @@ pub fn teleports_for_native_asset_works<
|
|||||||
// Mint funds into account to ensure it has enough balance to pay delivery fees
|
// Mint funds into account to ensure it has enough balance to pay delivery fees
|
||||||
let delivery_fees =
|
let delivery_fees =
|
||||||
xcm_helpers::transfer_assets_delivery_fees::<XcmConfig::XcmSender>(
|
xcm_helpers::transfer_assets_delivery_fees::<XcmConfig::XcmSender>(
|
||||||
(native_asset_id, native_asset_to_teleport_away.into()).into(),
|
(native_asset_id.clone(), native_asset_to_teleport_away.into()).into(),
|
||||||
0,
|
0,
|
||||||
Unlimited,
|
Unlimited,
|
||||||
dest_beneficiary,
|
dest_beneficiary.clone(),
|
||||||
dest,
|
dest.clone(),
|
||||||
);
|
);
|
||||||
<pallet_balances::Pallet<Runtime>>::mint_into(
|
<pallet_balances::Pallet<Runtime>>::mint_into(
|
||||||
&target_account,
|
&target_account,
|
||||||
@@ -199,7 +201,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||||
dest,
|
dest,
|
||||||
dest_beneficiary,
|
dest_beneficiary,
|
||||||
(native_asset_id, native_asset_to_teleport_away.into()),
|
(native_asset_id.clone(), native_asset_to_teleport_away.into()),
|
||||||
None,
|
None,
|
||||||
included_head.clone(),
|
included_head.clone(),
|
||||||
&alice,
|
&alice,
|
||||||
@@ -228,14 +230,14 @@ pub fn teleports_for_native_asset_works<
|
|||||||
// trust `IsTeleporter` for `(relay-native-asset, para(2345))` pair
|
// trust `IsTeleporter` for `(relay-native-asset, para(2345))` pair
|
||||||
{
|
{
|
||||||
let other_para_id = 2345;
|
let other_para_id = 2345;
|
||||||
let dest = MultiLocation::new(1, X1(Parachain(other_para_id)));
|
let dest = Location::new(1, [Parachain(other_para_id)]);
|
||||||
let mut dest_beneficiary = MultiLocation::new(1, X1(Parachain(other_para_id)))
|
let mut dest_beneficiary = Location::new(1, [Parachain(other_para_id)])
|
||||||
.appended_with(AccountId32 {
|
.appended_with(AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dest_beneficiary.reanchor(&dest, XcmConfig::UniversalLocation::get()).unwrap();
|
dest_beneficiary.reanchor(&dest, &XcmConfig::UniversalLocation::get()).unwrap();
|
||||||
|
|
||||||
let target_account_balance_before_teleport =
|
let target_account_balance_before_teleport =
|
||||||
<pallet_balances::Pallet<Runtime>>::free_balance(&target_account);
|
<pallet_balances::Pallet<Runtime>>::free_balance(&target_account);
|
||||||
@@ -245,6 +247,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
native_asset_to_teleport_away <
|
native_asset_to_teleport_away <
|
||||||
target_account_balance_before_teleport - existential_deposit
|
target_account_balance_before_teleport - existential_deposit
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
RuntimeHelper::<Runtime>::do_teleport_assets::<HrmpChannelOpener>(
|
RuntimeHelper::<Runtime>::do_teleport_assets::<HrmpChannelOpener>(
|
||||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||||
@@ -356,9 +359,9 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
<WeightToFee as frame_support::weights::WeightToFee>::Balance: From<u128> + Into<u128>,
|
<WeightToFee as frame_support::weights::WeightToFee>::Balance: From<u128> + Into<u128>,
|
||||||
SovereignAccountOf: ConvertLocation<AccountIdOf<Runtime>>,
|
SovereignAccountOf: ConvertLocation<AccountIdOf<Runtime>>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
|
||||||
From<MultiLocation> + Into<MultiLocation>,
|
From<xcm::v3::Location> + Into<xcm::v3::Location>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
|
||||||
From<MultiLocation> + Into<MultiLocation>,
|
From<xcm::v3::Location> + Into<xcm::v3::Location>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::Balance:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::Balance:
|
||||||
From<Balance> + Into<u128>,
|
From<Balance> + Into<u128>,
|
||||||
<Runtime as frame_system::Config>::AccountId:
|
<Runtime as frame_system::Config>::AccountId:
|
||||||
@@ -370,23 +373,25 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
{
|
{
|
||||||
// foreign parachain with the same consensus currency as asset
|
// foreign parachain with the same consensus currency as asset
|
||||||
let foreign_para_id = 2222;
|
let foreign_para_id = 2222;
|
||||||
let foreign_asset_id_multilocation = MultiLocation {
|
let foreign_asset_id_location = xcm::v3::Location {
|
||||||
parents: 1,
|
parents: 1,
|
||||||
interior: X2(Parachain(foreign_para_id), GeneralIndex(1234567)),
|
interior: [
|
||||||
|
xcm::v3::Junction::Parachain(foreign_para_id),
|
||||||
|
xcm::v3::Junction::GeneralIndex(1234567),
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// foreign creator, which can be sibling parachain to match ForeignCreators
|
// foreign creator, which can be sibling parachain to match ForeignCreators
|
||||||
let foreign_creator = MultiLocation { parents: 1, interior: X1(Parachain(foreign_para_id)) };
|
let foreign_creator = Location { parents: 1, interior: [Parachain(foreign_para_id)].into() };
|
||||||
let foreign_creator_as_account_id =
|
let foreign_creator_as_account_id =
|
||||||
SovereignAccountOf::convert_location(&foreign_creator).expect("");
|
SovereignAccountOf::convert_location(&foreign_creator).expect("");
|
||||||
|
|
||||||
// we want to buy execution with local relay chain currency
|
// we want to buy execution with local relay chain currency
|
||||||
let buy_execution_fee_amount =
|
let buy_execution_fee_amount =
|
||||||
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
|
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
|
||||||
let buy_execution_fee = MultiAsset {
|
let buy_execution_fee =
|
||||||
id: Concrete(MultiLocation::parent()),
|
Asset { id: AssetId(Location::parent()), fun: Fungible(buy_execution_fee_amount) };
|
||||||
fun: Fungible(buy_execution_fee_amount),
|
|
||||||
};
|
|
||||||
|
|
||||||
let teleported_foreign_asset_amount = 10_000_000_000_000;
|
let teleported_foreign_asset_amount = 10_000_000_000_000;
|
||||||
let runtime_para_id = 1000;
|
let runtime_para_id = 1000;
|
||||||
@@ -425,14 +430,14 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account
|
&target_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&CheckingAccount::get()
|
&CheckingAccount::get()
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -441,14 +446,14 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
assert_total::<
|
assert_total::<
|
||||||
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
||||||
AccountIdOf<Runtime>,
|
AccountIdOf<Runtime>,
|
||||||
>(foreign_asset_id_multilocation, 0, 0);
|
>(foreign_asset_id_location, 0, 0);
|
||||||
|
|
||||||
// create foreign asset (0 total issuance)
|
// create foreign asset (0 total issuance)
|
||||||
let asset_minimum_asset_balance = 3333333_u128;
|
let asset_minimum_asset_balance = 3333333_u128;
|
||||||
assert_ok!(
|
assert_ok!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::force_create(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::force_create(
|
||||||
RuntimeHelper::<Runtime>::root_origin(),
|
RuntimeHelper::<Runtime>::root_origin(),
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
asset_owner.into(),
|
asset_owner.into(),
|
||||||
false,
|
false,
|
||||||
asset_minimum_asset_balance.into()
|
asset_minimum_asset_balance.into()
|
||||||
@@ -457,47 +462,52 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
assert_total::<
|
assert_total::<
|
||||||
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
||||||
AccountIdOf<Runtime>,
|
AccountIdOf<Runtime>,
|
||||||
>(foreign_asset_id_multilocation, 0, 0);
|
>(foreign_asset_id_location, 0, 0);
|
||||||
assert!(teleported_foreign_asset_amount > asset_minimum_asset_balance);
|
assert!(teleported_foreign_asset_amount > asset_minimum_asset_balance);
|
||||||
|
|
||||||
|
let foreign_asset_id_location_latest: Location =
|
||||||
|
foreign_asset_id_location.try_into().unwrap();
|
||||||
|
|
||||||
// 1. process received teleported assets from sibling parachain (foreign_para_id)
|
// 1. process received teleported assets from sibling parachain (foreign_para_id)
|
||||||
let xcm = Xcm(vec![
|
let xcm = Xcm(vec![
|
||||||
// BuyExecution with relaychain native token
|
// BuyExecution with relaychain native token
|
||||||
WithdrawAsset(buy_execution_fee.clone().into()),
|
WithdrawAsset(buy_execution_fee.clone().into()),
|
||||||
BuyExecution {
|
BuyExecution {
|
||||||
fees: MultiAsset {
|
fees: Asset {
|
||||||
id: Concrete(MultiLocation::parent()),
|
id: AssetId(Location::parent()),
|
||||||
fun: Fungible(buy_execution_fee_amount),
|
fun: Fungible(buy_execution_fee_amount),
|
||||||
},
|
},
|
||||||
weight_limit: Limited(Weight::from_parts(403531000, 65536)),
|
weight_limit: Limited(Weight::from_parts(403531000, 65536)),
|
||||||
},
|
},
|
||||||
// Process teleported asset
|
// Process teleported asset
|
||||||
ReceiveTeleportedAsset(MultiAssets::from(vec![MultiAsset {
|
ReceiveTeleportedAsset(Assets::from(vec![Asset {
|
||||||
id: Concrete(foreign_asset_id_multilocation),
|
id: AssetId(foreign_asset_id_location_latest.clone()),
|
||||||
fun: Fungible(teleported_foreign_asset_amount),
|
fun: Fungible(teleported_foreign_asset_amount),
|
||||||
}])),
|
}])),
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: Wild(AllOf {
|
assets: Wild(AllOf {
|
||||||
id: Concrete(foreign_asset_id_multilocation),
|
id: AssetId(foreign_asset_id_location_latest.clone()),
|
||||||
fun: WildFungibility::Fungible,
|
fun: WildFungibility::Fungible,
|
||||||
}),
|
}),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 {
|
interior: [AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: target_account.clone().into(),
|
id: target_account.clone().into(),
|
||||||
}),
|
}]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ExpectTransactStatus(MaybeErrorCode::Success),
|
ExpectTransactStatus(MaybeErrorCode::Success),
|
||||||
]);
|
]);
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
foreign_creator,
|
foreign_creator,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
|
|
||||||
@@ -508,7 +518,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account
|
&target_account
|
||||||
),
|
),
|
||||||
teleported_foreign_asset_amount.into()
|
teleported_foreign_asset_amount.into()
|
||||||
@@ -520,7 +530,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&CheckingAccount::get()
|
&CheckingAccount::get()
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -530,25 +540,25 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
||||||
AccountIdOf<Runtime>,
|
AccountIdOf<Runtime>,
|
||||||
>(
|
>(
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
teleported_foreign_asset_amount,
|
teleported_foreign_asset_amount,
|
||||||
teleported_foreign_asset_amount,
|
teleported_foreign_asset_amount,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 2. try to teleport asset back to source parachain (foreign_para_id)
|
// 2. try to teleport asset back to source parachain (foreign_para_id)
|
||||||
{
|
{
|
||||||
let dest = MultiLocation::new(1, X1(Parachain(foreign_para_id)));
|
let dest = Location::new(1, [Parachain(foreign_para_id)]);
|
||||||
let mut dest_beneficiary = MultiLocation::new(1, X1(Parachain(foreign_para_id)))
|
let mut dest_beneficiary = Location::new(1, [Parachain(foreign_para_id)])
|
||||||
.appended_with(AccountId32 {
|
.appended_with(AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dest_beneficiary.reanchor(&dest, XcmConfig::UniversalLocation::get()).unwrap();
|
dest_beneficiary.reanchor(&dest, &XcmConfig::UniversalLocation::get()).unwrap();
|
||||||
|
|
||||||
let target_account_balance_before_teleport =
|
let target_account_balance_before_teleport =
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account,
|
&target_account,
|
||||||
);
|
);
|
||||||
let asset_to_teleport_away = asset_minimum_asset_balance * 3;
|
let asset_to_teleport_away = asset_minimum_asset_balance * 3;
|
||||||
@@ -562,11 +572,11 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
// Make sure the target account has enough native asset to pay for delivery fees
|
// Make sure the target account has enough native asset to pay for delivery fees
|
||||||
let delivery_fees =
|
let delivery_fees =
|
||||||
xcm_helpers::transfer_assets_delivery_fees::<XcmConfig::XcmSender>(
|
xcm_helpers::transfer_assets_delivery_fees::<XcmConfig::XcmSender>(
|
||||||
(foreign_asset_id_multilocation, asset_to_teleport_away).into(),
|
(foreign_asset_id_location_latest.clone(), asset_to_teleport_away).into(),
|
||||||
0,
|
0,
|
||||||
Unlimited,
|
Unlimited,
|
||||||
dest_beneficiary,
|
dest_beneficiary.clone(),
|
||||||
dest,
|
dest.clone(),
|
||||||
);
|
);
|
||||||
<pallet_balances::Pallet<Runtime>>::mint_into(
|
<pallet_balances::Pallet<Runtime>>::mint_into(
|
||||||
&target_account,
|
&target_account,
|
||||||
@@ -578,7 +588,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||||
dest,
|
dest,
|
||||||
dest_beneficiary,
|
dest_beneficiary,
|
||||||
(foreign_asset_id_multilocation, asset_to_teleport_away),
|
(foreign_asset_id_location_latest.clone(), asset_to_teleport_away),
|
||||||
Some((runtime_para_id, foreign_para_id)),
|
Some((runtime_para_id, foreign_para_id)),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
@@ -587,14 +597,14 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
// check balances
|
// check balances
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account
|
&target_account
|
||||||
),
|
),
|
||||||
(target_account_balance_before_teleport - asset_to_teleport_away.into())
|
(target_account_balance_before_teleport - asset_to_teleport_away.into())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&CheckingAccount::get()
|
&CheckingAccount::get()
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -604,7 +614,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
||||||
AccountIdOf<Runtime>,
|
AccountIdOf<Runtime>,
|
||||||
>(
|
>(
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
teleported_foreign_asset_amount - asset_to_teleport_away,
|
teleported_foreign_asset_amount - asset_to_teleport_away,
|
||||||
teleported_foreign_asset_amount - asset_to_teleport_away,
|
teleported_foreign_asset_amount - asset_to_teleport_away,
|
||||||
);
|
);
|
||||||
@@ -717,17 +727,19 @@ pub fn asset_transactor_transfer_with_local_consensus_currency_works<Runtime, Xc
|
|||||||
|
|
||||||
// transfer_asset (deposit/withdraw) ALICE -> BOB
|
// transfer_asset (deposit/withdraw) ALICE -> BOB
|
||||||
let _ = RuntimeHelper::<XcmConfig>::do_transfer(
|
let _ = RuntimeHelper::<XcmConfig>::do_transfer(
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 { network: None, id: source_account.clone().into() }),
|
interior: [AccountId32 { network: None, id: source_account.clone().into() }]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 { network: None, id: target_account.clone().into() }),
|
interior: [AccountId32 { network: None, id: target_account.clone().into() }]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
// local_consensus_currency_asset, e.g.: relaychain token (KSM, DOT, ...)
|
// local_consensus_currency_asset, e.g.: relaychain token (KSM, DOT, ...)
|
||||||
(
|
(
|
||||||
MultiLocation { parents: 1, interior: Here },
|
Location { parents: 1, interior: Here },
|
||||||
(BalanceOf::<Runtime>::from(1_u128) * unit).into(),
|
(BalanceOf::<Runtime>::from(1_u128) * unit).into(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -779,7 +791,7 @@ macro_rules! include_asset_transactor_transfer_with_local_consensus_currency_wor
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
///Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain
|
/// Test-case makes sure that `Runtime`'s `xcm::AssetTransactor` can handle native relay chain
|
||||||
/// currency
|
/// currency
|
||||||
pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
||||||
Runtime,
|
Runtime,
|
||||||
@@ -820,8 +832,8 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
||||||
From<<Runtime as frame_system::Config>::AccountId>,
|
From<<Runtime as frame_system::Config>::AccountId>,
|
||||||
AssetsPalletInstance: 'static,
|
AssetsPalletInstance: 'static,
|
||||||
AssetId: Clone + Copy,
|
AssetId: Clone,
|
||||||
AssetIdConverter: MaybeEquivalence<MultiLocation, AssetId>,
|
AssetIdConverter: MaybeEquivalence<Location, AssetId>,
|
||||||
{
|
{
|
||||||
ExtBuilder::<Runtime>::default()
|
ExtBuilder::<Runtime>::default()
|
||||||
.with_collators(collator_session_keys.collators())
|
.with_collators(collator_session_keys.collators())
|
||||||
@@ -836,10 +848,10 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
.execute_with(|| {
|
.execute_with(|| {
|
||||||
// create some asset class
|
// create some asset class
|
||||||
let asset_minimum_asset_balance = 3333333_u128;
|
let asset_minimum_asset_balance = 3333333_u128;
|
||||||
let asset_id_as_multilocation = AssetIdConverter::convert_back(&asset_id).unwrap();
|
let asset_id_as_location = AssetIdConverter::convert_back(&asset_id).unwrap();
|
||||||
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::force_create(
|
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::force_create(
|
||||||
RuntimeHelper::<Runtime>::root_origin(),
|
RuntimeHelper::<Runtime>::root_origin(),
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
asset_owner.clone().into(),
|
asset_owner.clone().into(),
|
||||||
false,
|
false,
|
||||||
asset_minimum_asset_balance.into()
|
asset_minimum_asset_balance.into()
|
||||||
@@ -848,7 +860,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
// We first mint enough asset for the account to exist for assets
|
// We first mint enough asset for the account to exist for assets
|
||||||
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::mint(
|
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::mint(
|
||||||
RuntimeHelper::<Runtime>::origin_of(asset_owner.clone()),
|
RuntimeHelper::<Runtime>::origin_of(asset_owner.clone()),
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
alice_account.clone().into(),
|
alice_account.clone().into(),
|
||||||
(6 * asset_minimum_asset_balance).into()
|
(6 * asset_minimum_asset_balance).into()
|
||||||
));
|
));
|
||||||
@@ -856,28 +868,28 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
// check Assets before
|
// check Assets before
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&alice_account
|
&alice_account
|
||||||
),
|
),
|
||||||
(6 * asset_minimum_asset_balance).into()
|
(6 * asset_minimum_asset_balance).into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&bob_account
|
&bob_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&charlie_account
|
&charlie_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&asset_owner
|
&asset_owner
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -904,21 +916,20 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
// ExistentialDeposit)
|
// ExistentialDeposit)
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
RuntimeHelper::<XcmConfig>::do_transfer(
|
RuntimeHelper::<XcmConfig>::do_transfer(
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 {
|
interior: [AccountId32 { network: None, id: alice_account.clone().into() }]
|
||||||
network: None,
|
.into(),
|
||||||
id: alice_account.clone().into()
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 {
|
interior: [AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: charlie_account.clone().into()
|
id: charlie_account.clone().into()
|
||||||
}),
|
}]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
(asset_id_as_multilocation, asset_minimum_asset_balance),
|
(asset_id_as_location.clone(), asset_minimum_asset_balance),
|
||||||
),
|
),
|
||||||
XcmError::FailedToTransactAsset(Into::<&str>::into(
|
XcmError::FailedToTransactAsset(Into::<&str>::into(
|
||||||
sp_runtime::TokenError::CannotCreate
|
sp_runtime::TokenError::CannotCreate
|
||||||
@@ -928,18 +939,17 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
// transfer_asset (deposit/withdraw) ALICE -> BOB (ok - has ExistentialDeposit)
|
// transfer_asset (deposit/withdraw) ALICE -> BOB (ok - has ExistentialDeposit)
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
RuntimeHelper::<XcmConfig>::do_transfer(
|
RuntimeHelper::<XcmConfig>::do_transfer(
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 {
|
interior: [AccountId32 { network: None, id: alice_account.clone().into() }]
|
||||||
network: None,
|
.into(),
|
||||||
id: alice_account.clone().into()
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
MultiLocation {
|
Location {
|
||||||
parents: 0,
|
parents: 0,
|
||||||
interior: X1(AccountId32 { network: None, id: bob_account.clone().into() }),
|
interior: [AccountId32 { network: None, id: bob_account.clone().into() }]
|
||||||
|
.into(),
|
||||||
},
|
},
|
||||||
(asset_id_as_multilocation, asset_minimum_asset_balance),
|
(asset_id_as_location, asset_minimum_asset_balance),
|
||||||
),
|
),
|
||||||
Ok(_)
|
Ok(_)
|
||||||
));
|
));
|
||||||
@@ -947,21 +957,21 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
|||||||
// check Assets after
|
// check Assets after
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&alice_account
|
&alice_account
|
||||||
),
|
),
|
||||||
(5 * asset_minimum_asset_balance).into()
|
(5 * asset_minimum_asset_balance).into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&bob_account
|
&bob_account
|
||||||
),
|
),
|
||||||
asset_minimum_asset_balance.into()
|
asset_minimum_asset_balance.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
&charlie_account
|
&charlie_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -1093,26 +1103,23 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
||||||
From<<Runtime as frame_system::Config>::AccountId>,
|
From<<Runtime as frame_system::Config>::AccountId>,
|
||||||
ForeignAssetsPalletInstance: 'static,
|
ForeignAssetsPalletInstance: 'static,
|
||||||
AssetId: Clone + Copy,
|
AssetId: Clone,
|
||||||
AssetIdConverter: MaybeEquivalence<MultiLocation, AssetId>,
|
AssetIdConverter: MaybeEquivalence<Location, AssetId>,
|
||||||
{
|
{
|
||||||
// foreign parachain with the same consensus currency as asset
|
// foreign parachain with the same consenus currency as asset
|
||||||
let foreign_asset_id_multilocation =
|
let foreign_asset_id_location = Location::new(1, [Parachain(2222), GeneralIndex(1234567)]);
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(2222), GeneralIndex(1234567)) };
|
let asset_id = AssetIdConverter::convert(&foreign_asset_id_location).unwrap();
|
||||||
let asset_id = AssetIdConverter::convert(&foreign_asset_id_multilocation).unwrap();
|
|
||||||
|
|
||||||
// foreign creator, which can be sibling parachain to match ForeignCreators
|
// foreign creator, which can be sibling parachain to match ForeignCreators
|
||||||
let foreign_creator = MultiLocation { parents: 1, interior: X1(Parachain(2222)) };
|
let foreign_creator = Location { parents: 1, interior: [Parachain(2222)].into() };
|
||||||
let foreign_creator_as_account_id =
|
let foreign_creator_as_account_id =
|
||||||
SovereignAccountOf::convert_location(&foreign_creator).expect("");
|
SovereignAccountOf::convert_location(&foreign_creator).expect("");
|
||||||
|
|
||||||
// we want to buy execution with local relay chain currency
|
// we want to buy execution with local relay chain currency
|
||||||
let buy_execution_fee_amount =
|
let buy_execution_fee_amount =
|
||||||
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
|
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
|
||||||
let buy_execution_fee = MultiAsset {
|
let buy_execution_fee =
|
||||||
id: Concrete(MultiLocation::parent()),
|
Asset { id: AssetId(Location::parent()), fun: Fungible(buy_execution_fee_amount) };
|
||||||
fun: Fungible(buy_execution_fee_amount),
|
|
||||||
};
|
|
||||||
|
|
||||||
const ASSET_NAME: &str = "My super coin";
|
const ASSET_NAME: &str = "My super coin";
|
||||||
const ASSET_SYMBOL: &str = "MY_S_COIN";
|
const ASSET_SYMBOL: &str = "MY_S_COIN";
|
||||||
@@ -1152,7 +1159,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
Runtime,
|
Runtime,
|
||||||
ForeignAssetsPalletInstance,
|
ForeignAssetsPalletInstance,
|
||||||
>::create {
|
>::create {
|
||||||
id: asset_id.into(),
|
id: asset_id.clone().into(),
|
||||||
// admin as sovereign_account
|
// admin as sovereign_account
|
||||||
admin: foreign_creator_as_account_id.clone().into(),
|
admin: foreign_creator_as_account_id.clone().into(),
|
||||||
min_balance: 1.into(),
|
min_balance: 1.into(),
|
||||||
@@ -1162,7 +1169,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
Runtime,
|
Runtime,
|
||||||
ForeignAssetsPalletInstance,
|
ForeignAssetsPalletInstance,
|
||||||
>::set_metadata {
|
>::set_metadata {
|
||||||
id: asset_id.into(),
|
id: asset_id.clone().into(),
|
||||||
name: Vec::from(ASSET_NAME),
|
name: Vec::from(ASSET_NAME),
|
||||||
symbol: Vec::from(ASSET_SYMBOL),
|
symbol: Vec::from(ASSET_SYMBOL),
|
||||||
decimals: 12,
|
decimals: 12,
|
||||||
@@ -1172,7 +1179,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
Runtime,
|
Runtime,
|
||||||
ForeignAssetsPalletInstance,
|
ForeignAssetsPalletInstance,
|
||||||
>::set_team {
|
>::set_team {
|
||||||
id: asset_id.into(),
|
id: asset_id.clone().into(),
|
||||||
issuer: foreign_creator_as_account_id.clone().into(),
|
issuer: foreign_creator_as_account_id.clone().into(),
|
||||||
admin: foreign_creator_as_account_id.clone().into(),
|
admin: foreign_creator_as_account_id.clone().into(),
|
||||||
freezer: bob_account.clone().into(),
|
freezer: bob_account.clone().into(),
|
||||||
@@ -1202,14 +1209,15 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// messages with different consensus should go through the local bridge-hub
|
// messages with different consensus should go through the local bridge-hub
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
// execute xcm as XcmpQueue would do
|
// execute xcm as XcmpQueue would do
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
foreign_creator,
|
foreign_creator.clone(),
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
|
|
||||||
@@ -1230,25 +1238,25 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
use frame_support::traits::fungibles::roles::Inspect as InspectRoles;
|
use frame_support::traits::fungibles::roles::Inspect as InspectRoles;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::owner(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::owner(
|
||||||
asset_id.into()
|
asset_id.clone().into()
|
||||||
),
|
),
|
||||||
Some(foreign_creator_as_account_id.clone())
|
Some(foreign_creator_as_account_id.clone())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::admin(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::admin(
|
||||||
asset_id.into()
|
asset_id.clone().into()
|
||||||
),
|
),
|
||||||
Some(foreign_creator_as_account_id.clone())
|
Some(foreign_creator_as_account_id.clone())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::issuer(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::issuer(
|
||||||
asset_id.into()
|
asset_id.clone().into()
|
||||||
),
|
),
|
||||||
Some(foreign_creator_as_account_id.clone())
|
Some(foreign_creator_as_account_id.clone())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::freezer(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::freezer(
|
||||||
asset_id.into()
|
asset_id.clone().into()
|
||||||
),
|
),
|
||||||
Some(bob_account.clone())
|
Some(bob_account.clone())
|
||||||
);
|
);
|
||||||
@@ -1262,13 +1270,13 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
assert_metadata::<
|
assert_metadata::<
|
||||||
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>,
|
||||||
AccountIdOf<Runtime>,
|
AccountIdOf<Runtime>,
|
||||||
>(asset_id, ASSET_NAME, ASSET_SYMBOL, 12);
|
>(asset_id.clone(), ASSET_NAME, ASSET_SYMBOL, 12);
|
||||||
|
|
||||||
// check if changed freezer, can freeze
|
// check if changed freezer, can freeze
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::freeze(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::freeze(
|
||||||
RuntimeHelper::<Runtime>::origin_of(bob_account),
|
RuntimeHelper::<Runtime>::origin_of(bob_account),
|
||||||
asset_id.into(),
|
asset_id.clone().into(),
|
||||||
alice_account.clone().into()
|
alice_account.clone().into()
|
||||||
),
|
),
|
||||||
pallet_assets::Error::<Runtime, ForeignAssetsPalletInstance>::NoAccount
|
pallet_assets::Error::<Runtime, ForeignAssetsPalletInstance>::NoAccount
|
||||||
@@ -1284,9 +1292,9 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
|
|
||||||
// lets try create asset for different parachain(3333) (foreign_creator(2222) can create
|
// lets try create asset for different parachain(3333) (foreign_creator(2222) can create
|
||||||
// just his assets)
|
// just his assets)
|
||||||
let foreign_asset_id_multilocation =
|
let foreign_asset_id_location =
|
||||||
MultiLocation { parents: 1, interior: X2(Parachain(3333), GeneralIndex(1234567)) };
|
Location { parents: 1, interior: [Parachain(3333), GeneralIndex(1234567)].into() };
|
||||||
let asset_id = AssetIdConverter::convert(&foreign_asset_id_multilocation).unwrap();
|
let asset_id = AssetIdConverter::convert(&foreign_asset_id_location).unwrap();
|
||||||
|
|
||||||
// prepare data for xcm::Transact(create)
|
// prepare data for xcm::Transact(create)
|
||||||
let foreign_asset_create = runtime_call_encode(pallet_assets::Call::<
|
let foreign_asset_create = runtime_call_encode(pallet_assets::Call::<
|
||||||
@@ -1310,14 +1318,15 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// messages with different consensus should go through the local bridge-hub
|
// messages with different consensus should go through the local bridge-hub
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
// execute xcm as XcmpQueue would do
|
// execute xcm as XcmpQueue would do
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
foreign_creator,
|
foreign_creator,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
|
|
||||||
@@ -1441,15 +1450,15 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
// reserve-transfer native asset with local reserve to remote parachain (2345)
|
// reserve-transfer native asset with local reserve to remote parachain (2345)
|
||||||
|
|
||||||
let other_para_id = 2345;
|
let other_para_id = 2345;
|
||||||
let native_asset = MultiLocation::parent();
|
let native_asset = Location::parent();
|
||||||
let dest = MultiLocation::new(1, X1(Parachain(other_para_id)));
|
let dest = Location::new(1, [Parachain(other_para_id)]);
|
||||||
let mut dest_beneficiary = MultiLocation::new(1, X1(Parachain(other_para_id)))
|
let mut dest_beneficiary = Location::new(1, [Parachain(other_para_id)])
|
||||||
.appended_with(AccountId32 {
|
.appended_with(AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
dest_beneficiary.reanchor(&dest, XcmConfig::UniversalLocation::get()).unwrap();
|
dest_beneficiary.reanchor(&dest, &XcmConfig::UniversalLocation::get()).unwrap();
|
||||||
|
|
||||||
let reserve_account = LocationToAccountId::convert_location(&dest)
|
let reserve_account = LocationToAccountId::convert_location(&dest)
|
||||||
.expect("Sovereign account for reserves");
|
.expect("Sovereign account for reserves");
|
||||||
@@ -1495,17 +1504,15 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
);
|
);
|
||||||
|
|
||||||
// local native asset (pallet_balances)
|
// local native asset (pallet_balances)
|
||||||
let asset_to_transfer = MultiAsset {
|
let asset_to_transfer =
|
||||||
fun: Fungible(balance_to_transfer.into()),
|
Asset { fun: Fungible(balance_to_transfer.into()), id: AssetId(native_asset) };
|
||||||
id: Concrete(native_asset),
|
|
||||||
};
|
|
||||||
|
|
||||||
// pallet_xcm call reserve transfer
|
// pallet_xcm call reserve transfer
|
||||||
assert_ok!(<pallet_xcm::Pallet<Runtime>>::limited_reserve_transfer_assets(
|
assert_ok!(<pallet_xcm::Pallet<Runtime>>::limited_reserve_transfer_assets(
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(alice_account.clone()),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(alice_account.clone()),
|
||||||
Box::new(dest.into_versioned()),
|
Box::new(dest.clone().into_versioned()),
|
||||||
Box::new(dest_beneficiary.into_versioned()),
|
Box::new(dest_beneficiary.clone().into_versioned()),
|
||||||
Box::new(VersionedMultiAssets::from(MultiAssets::from(asset_to_transfer))),
|
Box::new(VersionedAssets::from(Assets::from(asset_to_transfer))),
|
||||||
0,
|
0,
|
||||||
weight_limit,
|
weight_limit,
|
||||||
));
|
));
|
||||||
@@ -1535,9 +1542,12 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let v4_xcm: Xcm<()> = xcm_sent.clone().try_into().unwrap();
|
||||||
|
dbg!(&v4_xcm);
|
||||||
|
|
||||||
let delivery_fees = get_fungible_delivery_fees::<
|
let delivery_fees = get_fungible_delivery_fees::<
|
||||||
<XcmConfig as xcm_executor::Config>::XcmSender,
|
<XcmConfig as xcm_executor::Config>::XcmSender,
|
||||||
>(dest, Xcm::try_from(xcm_sent.clone()).unwrap());
|
>(dest.clone(), Xcm::try_from(xcm_sent.clone()).unwrap());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
xcm_sent_message_hash,
|
xcm_sent_message_hash,
|
||||||
@@ -1547,8 +1557,8 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
|
|
||||||
// check sent XCM Program to other parachain
|
// check sent XCM Program to other parachain
|
||||||
println!("reserve_transfer_native_asset_works sent xcm: {:?}", xcm_sent);
|
println!("reserve_transfer_native_asset_works sent xcm: {:?}", xcm_sent);
|
||||||
let reserve_assets_deposited = MultiAssets::from(vec![MultiAsset {
|
let reserve_assets_deposited = Assets::from(vec![Asset {
|
||||||
id: Concrete(MultiLocation { parents: 1, interior: Here }),
|
id: AssetId(Location { parents: 1, interior: Here }),
|
||||||
fun: Fungible(1000000000000),
|
fun: Fungible(1000000000000),
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ use parachains_runtimes_test_utils::{
|
|||||||
};
|
};
|
||||||
use sp_runtime::{traits::StaticLookup, Saturating};
|
use sp_runtime::{traits::StaticLookup, Saturating};
|
||||||
use sp_std::ops::Mul;
|
use sp_std::ops::Mul;
|
||||||
use xcm::{latest::prelude::*, VersionedMultiAssets};
|
use xcm::{latest::prelude::*, VersionedAssets};
|
||||||
use xcm_builder::{CreateMatcher, MatchXcm};
|
use xcm_builder::{CreateMatcher, MatchXcm};
|
||||||
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
|
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
|
||||||
|
|
||||||
pub struct TestBridgingConfig {
|
pub struct TestBridgingConfig {
|
||||||
pub bridged_network: NetworkId,
|
pub bridged_network: NetworkId,
|
||||||
pub local_bridge_hub_para_id: u32,
|
pub local_bridge_hub_para_id: u32,
|
||||||
pub local_bridge_hub_location: MultiLocation,
|
pub local_bridge_hub_location: Location,
|
||||||
pub bridged_target_location: MultiLocation,
|
pub bridged_target_location: Location,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test-case makes sure that `Runtime` can initiate **reserve transfer assets** over bridge.
|
/// Test-case makes sure that `Runtime` can initiate **reserve transfer assets** over bridge.
|
||||||
@@ -117,7 +117,7 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
|
|||||||
LocationToAccountId::convert_location(&target_location_from_different_consensus)
|
LocationToAccountId::convert_location(&target_location_from_different_consensus)
|
||||||
.expect("Sovereign account for reserves");
|
.expect("Sovereign account for reserves");
|
||||||
let balance_to_transfer = 1_000_000_000_000_u128;
|
let balance_to_transfer = 1_000_000_000_000_u128;
|
||||||
let native_asset = MultiLocation::parent();
|
let native_asset = Location::parent();
|
||||||
|
|
||||||
// open HRMP to bridge hub
|
// open HRMP to bridge hub
|
||||||
mock_open_hrmp_channel::<Runtime, HrmpChannelOpener>(
|
mock_open_hrmp_channel::<Runtime, HrmpChannelOpener>(
|
||||||
@@ -163,35 +163,33 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
|
|||||||
.unwrap_or(0.into());
|
.unwrap_or(0.into());
|
||||||
|
|
||||||
// local native asset (pallet_balances)
|
// local native asset (pallet_balances)
|
||||||
let asset_to_transfer = MultiAsset {
|
let asset_to_transfer =
|
||||||
fun: Fungible(balance_to_transfer.into()),
|
Asset { fun: Fungible(balance_to_transfer.into()), id: native_asset.into() };
|
||||||
id: Concrete(native_asset),
|
|
||||||
};
|
|
||||||
|
|
||||||
// destination is (some) account relative to the destination different consensus
|
// destination is (some) account relative to the destination different consensus
|
||||||
let target_destination_account = MultiLocation {
|
let target_destination_account = Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountId32 {
|
[AccountId32 {
|
||||||
network: Some(bridged_network),
|
network: Some(bridged_network),
|
||||||
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
id: sp_runtime::AccountId32::new([3; 32]).into(),
|
||||||
}),
|
}],
|
||||||
};
|
);
|
||||||
|
|
||||||
let assets_to_transfer = MultiAssets::from(asset_to_transfer);
|
let assets_to_transfer = Assets::from(asset_to_transfer);
|
||||||
let mut expected_assets = assets_to_transfer.clone();
|
let mut expected_assets = assets_to_transfer.clone();
|
||||||
let context = XcmConfig::UniversalLocation::get();
|
let context = XcmConfig::UniversalLocation::get();
|
||||||
expected_assets
|
expected_assets
|
||||||
.reanchor(&target_location_from_different_consensus, context)
|
.reanchor(&target_location_from_different_consensus, &context)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected_beneficiary = target_destination_account;
|
let expected_beneficiary = target_destination_account.clone();
|
||||||
|
|
||||||
// do pallet_xcm call reserve transfer
|
// do pallet_xcm call reserve transfer
|
||||||
assert_ok!(<pallet_xcm::Pallet<Runtime>>::limited_reserve_transfer_assets(
|
assert_ok!(<pallet_xcm::Pallet<Runtime>>::limited_reserve_transfer_assets(
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(alice_account.clone()),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(alice_account.clone()),
|
||||||
Box::new(target_location_from_different_consensus.into_versioned()),
|
Box::new(target_location_from_different_consensus.clone().into_versioned()),
|
||||||
Box::new(target_destination_account.into_versioned()),
|
Box::new(target_destination_account.into_versioned()),
|
||||||
Box::new(VersionedMultiAssets::from(assets_to_transfer)),
|
Box::new(VersionedAssets::from(assets_to_transfer)),
|
||||||
0,
|
0,
|
||||||
weight_limit,
|
weight_limit,
|
||||||
));
|
));
|
||||||
@@ -266,13 +264,17 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
|
|||||||
let (_, target_location_junctions_without_global_consensus) =
|
let (_, target_location_junctions_without_global_consensus) =
|
||||||
target_location_from_different_consensus
|
target_location_from_different_consensus
|
||||||
.interior
|
.interior
|
||||||
|
.clone()
|
||||||
.split_global()
|
.split_global()
|
||||||
.expect("split works");
|
.expect("split works");
|
||||||
assert_eq!(destination, &target_location_junctions_without_global_consensus);
|
assert_eq!(destination, &target_location_junctions_without_global_consensus);
|
||||||
// Call `SendXcm::validate` to get delivery fees.
|
// Call `SendXcm::validate` to get delivery fees.
|
||||||
delivery_fees = get_fungible_delivery_fees::<
|
delivery_fees = get_fungible_delivery_fees::<
|
||||||
<XcmConfig as xcm_executor::Config>::XcmSender,
|
<XcmConfig as xcm_executor::Config>::XcmSender,
|
||||||
>(target_location_from_different_consensus, inner_xcm.clone());
|
>(
|
||||||
|
target_location_from_different_consensus.clone(),
|
||||||
|
inner_xcm.clone(),
|
||||||
|
);
|
||||||
assert_matches_reserve_asset_deposited_instructions(
|
assert_matches_reserve_asset_deposited_instructions(
|
||||||
inner_xcm,
|
inner_xcm,
|
||||||
&expected_assets,
|
&expected_assets,
|
||||||
@@ -322,10 +324,10 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
target_account: AccountIdOf<Runtime>,
|
target_account: AccountIdOf<Runtime>,
|
||||||
block_author_account: AccountIdOf<Runtime>,
|
block_author_account: AccountIdOf<Runtime>,
|
||||||
(
|
(
|
||||||
foreign_asset_id_multilocation,
|
foreign_asset_id_location,
|
||||||
transfered_foreign_asset_id_amount,
|
transfered_foreign_asset_id_amount,
|
||||||
foreign_asset_id_minimum_balance,
|
foreign_asset_id_minimum_balance,
|
||||||
): (MultiLocation, u128, u128),
|
): (xcm::v3::Location, u128, u128),
|
||||||
prepare_configuration: fn() -> TestBridgingConfig,
|
prepare_configuration: fn() -> TestBridgingConfig,
|
||||||
(bridge_instance, universal_origin, descend_origin): (Junctions, Junction, Junctions), /* bridge adds origin manipulation on the way */
|
(bridge_instance, universal_origin, descend_origin): (Junctions, Junction, Junctions), /* bridge adds origin manipulation on the way */
|
||||||
) where
|
) where
|
||||||
@@ -347,9 +349,9 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
XcmConfig: xcm_executor::Config,
|
XcmConfig: xcm_executor::Config,
|
||||||
LocationToAccountId: ConvertLocation<AccountIdOf<Runtime>>,
|
LocationToAccountId: ConvertLocation<AccountIdOf<Runtime>>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
|
||||||
From<MultiLocation> + Into<MultiLocation>,
|
From<xcm::v3::Location> + Into<xcm::v3::Location>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
|
||||||
From<MultiLocation> + Into<MultiLocation>,
|
From<xcm::v3::Location> + Into<xcm::v3::Location>,
|
||||||
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::Balance:
|
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::Balance:
|
||||||
From<Balance> + Into<u128> + From<u128>,
|
From<Balance> + Into<u128> + From<u128>,
|
||||||
<Runtime as frame_system::Config>::AccountId: Into<<<Runtime as frame_system::Config>::RuntimeOrigin as OriginTrait>::AccountId>
|
<Runtime as frame_system::Config>::AccountId: Into<<<Runtime as frame_system::Config>::RuntimeOrigin as OriginTrait>::AccountId>
|
||||||
@@ -357,7 +359,7 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
<<Runtime as frame_system::Config>::Lookup as StaticLookup>::Source:
|
||||||
From<<Runtime as frame_system::Config>::AccountId>,
|
From<<Runtime as frame_system::Config>::AccountId>,
|
||||||
<Runtime as pallet_asset_conversion::Config>::AssetKind:
|
<Runtime as pallet_asset_conversion::Config>::AssetKind:
|
||||||
From<MultiLocation> + Into<MultiLocation>,
|
From<xcm::v3::Location> + Into<xcm::v3::Location>,
|
||||||
<Runtime as pallet_asset_conversion::Config>::Balance: From<Balance>,
|
<Runtime as pallet_asset_conversion::Config>::Balance: From<Balance>,
|
||||||
ForeignAssetsPalletInstance: 'static,
|
ForeignAssetsPalletInstance: 'static,
|
||||||
{
|
{
|
||||||
@@ -385,7 +387,7 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
// sovereign account as foreign asset owner (can be whoever for this scenario, doesnt
|
// sovereign account as foreign asset owner (can be whoever for this scenario, doesnt
|
||||||
// matter)
|
// matter)
|
||||||
let sovereign_account_as_owner_of_foreign_asset =
|
let sovereign_account_as_owner_of_foreign_asset =
|
||||||
LocationToAccountId::convert_location(&MultiLocation::parent()).unwrap();
|
LocationToAccountId::convert_location(&Location::parent()).unwrap();
|
||||||
|
|
||||||
// staking pot account for collecting local native fees from `BuyExecution`
|
// staking pot account for collecting local native fees from `BuyExecution`
|
||||||
let staking_pot = <pallet_collator_selection::Pallet<Runtime>>::account_id();
|
let staking_pot = <pallet_collator_selection::Pallet<Runtime>>::account_id();
|
||||||
@@ -398,16 +400,16 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
assert_ok!(
|
assert_ok!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::force_create(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::force_create(
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::root_origin(),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::root_origin(),
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
sovereign_account_as_owner_of_foreign_asset.clone().into(),
|
sovereign_account_as_owner_of_foreign_asset.clone().into(),
|
||||||
true, // is_sufficient=true
|
true, // is_sufficient=true
|
||||||
foreign_asset_id_minimum_balance.into()
|
foreign_asset_id_minimum_balance.into()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// setup a pool to pay fees with `foreign_asset_id_multilocation` tokens
|
// setup a pool to pay fees with `foreign_asset_id_location` tokens
|
||||||
let pool_owner: AccountIdOf<Runtime> = [1u8; 32].into();
|
let pool_owner: AccountIdOf<Runtime> = [1u8; 32].into();
|
||||||
let native_asset = MultiLocation::parent();
|
let native_asset = xcm::v3::Location::parent();
|
||||||
let pool_liquidity: u128 =
|
let pool_liquidity: u128 =
|
||||||
existential_deposit.into().max(foreign_asset_id_minimum_balance).mul(100_000);
|
existential_deposit.into().max(foreign_asset_id_minimum_balance).mul(100_000);
|
||||||
|
|
||||||
@@ -420,7 +422,7 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(
|
||||||
sovereign_account_as_owner_of_foreign_asset
|
sovereign_account_as_owner_of_foreign_asset
|
||||||
),
|
),
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
pool_owner.clone().into(),
|
pool_owner.clone().into(),
|
||||||
(foreign_asset_id_minimum_balance + pool_liquidity).mul(2).into(),
|
(foreign_asset_id_minimum_balance + pool_liquidity).mul(2).into(),
|
||||||
));
|
));
|
||||||
@@ -428,13 +430,13 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
assert_ok!(<pallet_asset_conversion::Pallet<Runtime>>::create_pool(
|
assert_ok!(<pallet_asset_conversion::Pallet<Runtime>>::create_pool(
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(pool_owner.clone()),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(pool_owner.clone()),
|
||||||
Box::new(native_asset.into()),
|
Box::new(native_asset.into()),
|
||||||
Box::new(foreign_asset_id_multilocation.into())
|
Box::new(foreign_asset_id_location.into())
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_ok!(<pallet_asset_conversion::Pallet<Runtime>>::add_liquidity(
|
assert_ok!(<pallet_asset_conversion::Pallet<Runtime>>::add_liquidity(
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(pool_owner.clone()),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::origin_of(pool_owner.clone()),
|
||||||
Box::new(native_asset.into()),
|
Box::new(native_asset.into()),
|
||||||
Box::new(foreign_asset_id_multilocation.into()),
|
Box::new(foreign_asset_id_location.into()),
|
||||||
pool_liquidity.into(),
|
pool_liquidity.into(),
|
||||||
pool_liquidity.into(),
|
pool_liquidity.into(),
|
||||||
1.into(),
|
1.into(),
|
||||||
@@ -459,34 +461,37 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
// ForeignAssets balances before
|
// ForeignAssets balances before
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account
|
&target_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&block_author_account
|
&block_author_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&staking_pot
|
&staking_pot
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_assets = MultiAssets::from(vec![MultiAsset {
|
let foreign_asset_id_location_latest: Location =
|
||||||
id: Concrete(foreign_asset_id_multilocation),
|
foreign_asset_id_location.try_into().unwrap();
|
||||||
|
|
||||||
|
let expected_assets = Assets::from(vec![Asset {
|
||||||
|
id: AssetId(foreign_asset_id_location_latest.clone()),
|
||||||
fun: Fungible(transfered_foreign_asset_id_amount),
|
fun: Fungible(transfered_foreign_asset_id_amount),
|
||||||
}]);
|
}]);
|
||||||
let expected_beneficiary = MultiLocation {
|
let expected_beneficiary = Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(AccountId32 { network: None, id: target_account.clone().into() }),
|
[AccountId32 { network: None, id: target_account.clone().into() }],
|
||||||
};
|
);
|
||||||
|
|
||||||
// Call received XCM execution
|
// Call received XCM execution
|
||||||
let xcm = Xcm(vec![
|
let xcm = Xcm(vec![
|
||||||
@@ -496,13 +501,16 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
ReserveAssetDeposited(expected_assets.clone()),
|
ReserveAssetDeposited(expected_assets.clone()),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution {
|
BuyExecution {
|
||||||
fees: MultiAsset {
|
fees: Asset {
|
||||||
id: Concrete(foreign_asset_id_multilocation),
|
id: AssetId(foreign_asset_id_location_latest.clone()),
|
||||||
fun: Fungible(transfered_foreign_asset_id_amount),
|
fun: Fungible(transfered_foreign_asset_id_amount),
|
||||||
},
|
},
|
||||||
weight_limit: Unlimited,
|
weight_limit: Unlimited,
|
||||||
},
|
},
|
||||||
DepositAsset { assets: Wild(AllCounted(1)), beneficiary: expected_beneficiary },
|
DepositAsset {
|
||||||
|
assets: Wild(AllCounted(1)),
|
||||||
|
beneficiary: expected_beneficiary.clone(),
|
||||||
|
},
|
||||||
SetTopic([
|
SetTopic([
|
||||||
220, 188, 144, 32, 213, 83, 111, 175, 44, 210, 111, 19, 90, 165, 191, 112, 140,
|
220, 188, 144, 32, 213, 83, 111, 175, 44, 210, 111, 19, 90, 165, 191, 112, 140,
|
||||||
247, 192, 124, 42, 17, 153, 141, 114, 34, 189, 20, 83, 69, 237, 173,
|
247, 192, 124, 42, 17, 153, 141, 114, 34, 189, 20, 83, 69, 237, 173,
|
||||||
@@ -514,16 +522,17 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
&expected_beneficiary,
|
&expected_beneficiary,
|
||||||
);
|
);
|
||||||
|
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
// execute xcm as XcmpQueue would do
|
// execute xcm as XcmpQueue would do
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
local_bridge_hub_location,
|
local_bridge_hub_location,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::xcm_max_weight(
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::xcm_max_weight(
|
||||||
XcmReceivedFrom::Sibling,
|
XcmReceivedFrom::Sibling,
|
||||||
),
|
),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
|
|
||||||
@@ -545,20 +554,20 @@ pub fn receive_reserve_asset_deposited_from_different_consensus_works<
|
|||||||
// ForeignAssets balances after
|
// ForeignAssets balances after
|
||||||
assert!(
|
assert!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&target_account
|
&target_account
|
||||||
) > 0.into()
|
) > 0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&staking_pot
|
&staking_pot
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
<pallet_assets::Pallet<Runtime, ForeignAssetsPalletInstance>>::balance(
|
||||||
foreign_asset_id_multilocation.into(),
|
foreign_asset_id_location.into(),
|
||||||
&block_author_account
|
&block_author_account
|
||||||
),
|
),
|
||||||
0.into()
|
0.into()
|
||||||
@@ -614,14 +623,15 @@ pub fn report_bridge_status_from_xcm_bridge_router_works<
|
|||||||
|
|
||||||
// Call received XCM execution
|
// Call received XCM execution
|
||||||
let xcm = if is_congested { congested_message() } else { uncongested_message() };
|
let xcm = if is_congested { congested_message() } else { uncongested_message() };
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
|
|
||||||
// execute xcm as XcmpQueue would do
|
// execute xcm as XcmpQueue would do
|
||||||
let outcome = XcmExecutor::<XcmConfig>::execute_xcm(
|
let outcome = XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
local_bridge_hub_location,
|
local_bridge_hub_location,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
);
|
);
|
||||||
assert_ok!(outcome.ensure_complete());
|
assert_ok!(outcome.ensure_complete());
|
||||||
assert_eq!(is_congested, pallet_xcm_bridge_hub_router::Pallet::<Runtime, XcmBridgeHubRouterInstance>::bridge().is_congested);
|
assert_eq!(is_congested, pallet_xcm_bridge_hub_router::Pallet::<Runtime, XcmBridgeHubRouterInstance>::bridge().is_congested);
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ use xcm::latest::prelude::*;
|
|||||||
/// Because it returns only a `u128`, it assumes delivery fees are only paid
|
/// Because it returns only a `u128`, it assumes delivery fees are only paid
|
||||||
/// in one asset and that asset is known.
|
/// in one asset and that asset is known.
|
||||||
pub fn transfer_assets_delivery_fees<S: SendXcm>(
|
pub fn transfer_assets_delivery_fees<S: SendXcm>(
|
||||||
assets: MultiAssets,
|
assets: Assets,
|
||||||
fee_asset_item: u32,
|
fee_asset_item: u32,
|
||||||
weight_limit: WeightLimit,
|
weight_limit: WeightLimit,
|
||||||
beneficiary: MultiLocation,
|
beneficiary: Location,
|
||||||
destination: MultiLocation,
|
destination: Location,
|
||||||
) -> u128 {
|
) -> u128 {
|
||||||
let message = teleport_assets_dummy_message(assets, fee_asset_item, weight_limit, beneficiary);
|
let message = teleport_assets_dummy_message(assets, fee_asset_item, weight_limit, beneficiary);
|
||||||
get_fungible_delivery_fees::<S>(destination, message)
|
get_fungible_delivery_fees::<S>(destination, message)
|
||||||
@@ -35,7 +35,7 @@ pub fn transfer_assets_delivery_fees<S: SendXcm>(
|
|||||||
|
|
||||||
/// Returns the delivery fees amount for a query response as a result of the execution
|
/// Returns the delivery fees amount for a query response as a result of the execution
|
||||||
/// of a `ExpectError` instruction with no error.
|
/// of a `ExpectError` instruction with no error.
|
||||||
pub fn query_response_delivery_fees<S: SendXcm>(querier: MultiLocation) -> u128 {
|
pub fn query_response_delivery_fees<S: SendXcm>(querier: Location) -> u128 {
|
||||||
// Message to calculate delivery fees, it's encoded size is what's important.
|
// Message to calculate delivery fees, it's encoded size is what's important.
|
||||||
// This message reports that there was no error, if an error is reported, the encoded size would
|
// This message reports that there was no error, if an error is reported, the encoded size would
|
||||||
// be different.
|
// be different.
|
||||||
@@ -45,7 +45,7 @@ pub fn query_response_delivery_fees<S: SendXcm>(querier: MultiLocation) -> u128
|
|||||||
query_id: 0, // Dummy query id
|
query_id: 0, // Dummy query id
|
||||||
response: Response::ExecutionResult(None),
|
response: Response::ExecutionResult(None),
|
||||||
max_weight: Weight::zero(),
|
max_weight: Weight::zero(),
|
||||||
querier: Some(querier),
|
querier: Some(querier.clone()),
|
||||||
},
|
},
|
||||||
SetTopic([0u8; 32]), // Dummy topic
|
SetTopic([0u8; 32]), // Dummy topic
|
||||||
]);
|
]);
|
||||||
@@ -55,9 +55,9 @@ pub fn query_response_delivery_fees<S: SendXcm>(querier: MultiLocation) -> u128
|
|||||||
/// Returns the delivery fees amount for the execution of `PayOverXcm`
|
/// Returns the delivery fees amount for the execution of `PayOverXcm`
|
||||||
pub fn pay_over_xcm_delivery_fees<S: SendXcm>(
|
pub fn pay_over_xcm_delivery_fees<S: SendXcm>(
|
||||||
interior: Junctions,
|
interior: Junctions,
|
||||||
destination: MultiLocation,
|
destination: Location,
|
||||||
beneficiary: MultiLocation,
|
beneficiary: Location,
|
||||||
asset: MultiAsset,
|
asset: Asset,
|
||||||
) -> u128 {
|
) -> u128 {
|
||||||
// This is a dummy message.
|
// This is a dummy message.
|
||||||
// The encoded size is all that matters for delivery fees.
|
// The encoded size is all that matters for delivery fees.
|
||||||
@@ -66,7 +66,11 @@ pub fn pay_over_xcm_delivery_fees<S: SendXcm>(
|
|||||||
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
|
||||||
SetAppendix(Xcm(vec![
|
SetAppendix(Xcm(vec![
|
||||||
SetFeesMode { jit_withdraw: true },
|
SetFeesMode { jit_withdraw: true },
|
||||||
ReportError(QueryResponseInfo { destination, query_id: 0, max_weight: Weight::zero() }),
|
ReportError(QueryResponseInfo {
|
||||||
|
destination: destination.clone(),
|
||||||
|
query_id: 0,
|
||||||
|
max_weight: Weight::zero(),
|
||||||
|
}),
|
||||||
])),
|
])),
|
||||||
TransferAsset { beneficiary, assets: vec![asset].into() },
|
TransferAsset { beneficiary, assets: vec![asset].into() },
|
||||||
]);
|
]);
|
||||||
@@ -78,10 +82,10 @@ pub fn pay_over_xcm_delivery_fees<S: SendXcm>(
|
|||||||
/// However, it should have the same encoded size, which is what matters for delivery fees.
|
/// However, it should have the same encoded size, which is what matters for delivery fees.
|
||||||
/// Also has same encoded size as the one created by the reserve transfer assets extrinsic.
|
/// Also has same encoded size as the one created by the reserve transfer assets extrinsic.
|
||||||
fn teleport_assets_dummy_message(
|
fn teleport_assets_dummy_message(
|
||||||
assets: MultiAssets,
|
assets: Assets,
|
||||||
fee_asset_item: u32,
|
fee_asset_item: u32,
|
||||||
weight_limit: WeightLimit,
|
weight_limit: WeightLimit,
|
||||||
beneficiary: MultiLocation,
|
beneficiary: Location,
|
||||||
) -> Xcm<()> {
|
) -> Xcm<()> {
|
||||||
Xcm(vec![
|
Xcm(vec![
|
||||||
ReceiveTeleportedAsset(assets.clone()), // Same encoded size as `ReserveAssetDeposited`
|
ReceiveTeleportedAsset(assets.clone()), // Same encoded size as `ReserveAssetDeposited`
|
||||||
@@ -93,7 +97,7 @@ fn teleport_assets_dummy_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Given a message, a sender, and a destination, it returns the delivery fees
|
/// Given a message, a sender, and a destination, it returns the delivery fees
|
||||||
fn get_fungible_delivery_fees<S: SendXcm>(destination: MultiLocation, message: Xcm<()>) -> u128 {
|
fn get_fungible_delivery_fees<S: SendXcm>(destination: Location, message: Xcm<()>) -> u128 {
|
||||||
let Ok((_, delivery_fees)) = validate_send::<S>(destination, message) else {
|
let Ok((_, delivery_fees)) = validate_send::<S>(destination, message) else {
|
||||||
unreachable!("message can be sent; qed")
|
unreachable!("message can be sent; qed")
|
||||||
};
|
};
|
||||||
|
|||||||
+15
-15
@@ -48,7 +48,7 @@ use frame_support::{parameter_types, traits::PalletInfoAccess};
|
|||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use xcm::{
|
use xcm::{
|
||||||
latest::prelude::*,
|
latest::prelude::*,
|
||||||
prelude::{InteriorMultiLocation, NetworkId},
|
prelude::{InteriorLocation, NetworkId},
|
||||||
};
|
};
|
||||||
use xcm_builder::BridgeBlobDispatcher;
|
use xcm_builder::BridgeBlobDispatcher;
|
||||||
|
|
||||||
@@ -65,16 +65,16 @@ parameter_types! {
|
|||||||
/// Bridge specific chain (network) identifier of the Rococo Bulletin Chain.
|
/// Bridge specific chain (network) identifier of the Rococo Bulletin Chain.
|
||||||
pub const RococoBulletinChainId: bp_runtime::ChainId = bp_runtime::POLKADOT_BULLETIN_CHAIN_ID;
|
pub const RococoBulletinChainId: bp_runtime::ChainId = bp_runtime::POLKADOT_BULLETIN_CHAIN_ID;
|
||||||
/// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet.
|
/// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet.
|
||||||
pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorMultiLocation = X1(
|
pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorLocation = [
|
||||||
PalletInstance(<BridgeRococoBulletinMessages as PalletInfoAccess>::index() as u8)
|
PalletInstance(<BridgeRococoBulletinMessages as PalletInfoAccess>::index() as u8)
|
||||||
);
|
].into();
|
||||||
/// Rococo Bulletin Network identifier.
|
/// Rococo Bulletin Network identifier.
|
||||||
pub RococoBulletinGlobalConsensusNetwork: NetworkId = NetworkId::PolkadotBulletin;
|
pub RococoBulletinGlobalConsensusNetwork: NetworkId = NetworkId::PolkadotBulletin;
|
||||||
/// Relative location of the Rococo Bulletin chain.
|
/// Relative location of the Rococo Bulletin chain.
|
||||||
pub RococoBulletinGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
|
pub RococoBulletinGlobalConsensusNetworkLocation: Location = Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X1(GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get()))
|
[GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get())]
|
||||||
};
|
);
|
||||||
/// All active lanes that the current bridge supports.
|
/// All active lanes that the current bridge supports.
|
||||||
pub ActiveOutboundLanesToRococoBulletin: &'static [bp_messages::LaneId]
|
pub ActiveOutboundLanesToRococoBulletin: &'static [bp_messages::LaneId]
|
||||||
= &[XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN];
|
= &[XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN];
|
||||||
@@ -94,11 +94,11 @@ parameter_types! {
|
|||||||
/// A route (XCM location and bridge lane) that the Rococo People Chain -> Rococo Bulletin Chain
|
/// A route (XCM location and bridge lane) that the Rococo People Chain -> Rococo Bulletin Chain
|
||||||
/// message is following.
|
/// message is following.
|
||||||
pub FromRococoPeopleToRococoBulletinRoute: SenderAndLane = SenderAndLane::new(
|
pub FromRococoPeopleToRococoBulletinRoute: SenderAndLane = SenderAndLane::new(
|
||||||
ParentThen(X1(Parachain(RococoPeopleParaId::get().into()))).into(),
|
ParentThen(Parachain(RococoPeopleParaId::get().into()).into()).into(),
|
||||||
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|
||||||
);
|
);
|
||||||
/// All active routes and their destinations.
|
/// All active routes and their destinations.
|
||||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||||
(
|
(
|
||||||
FromRococoPeopleToRococoBulletinRoute::get(),
|
FromRococoPeopleToRococoBulletinRoute::get(),
|
||||||
(RococoBulletinGlobalConsensusNetwork::get(), Here)
|
(RococoBulletinGlobalConsensusNetwork::get(), Here)
|
||||||
@@ -282,11 +282,11 @@ mod tests {
|
|||||||
PriorityBoostPerMessage,
|
PriorityBoostPerMessage,
|
||||||
>(FEE_BOOST_PER_MESSAGE);
|
>(FEE_BOOST_PER_MESSAGE);
|
||||||
|
|
||||||
assert_eq!(
|
let expected: InteriorLocation = PalletInstance(
|
||||||
BridgeRococoToRococoBulletinMessagesPalletInstance::get(),
|
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX,
|
||||||
X1(PalletInstance(
|
)
|
||||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX
|
.into();
|
||||||
))
|
|
||||||
);
|
assert_eq!(BridgeRococoToRococoBulletinMessagesPalletInstance::get(), expected,);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-20
@@ -48,7 +48,7 @@ use frame_support::{parameter_types, traits::PalletInfoAccess};
|
|||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use xcm::{
|
use xcm::{
|
||||||
latest::prelude::*,
|
latest::prelude::*,
|
||||||
prelude::{InteriorMultiLocation, NetworkId},
|
prelude::{InteriorLocation, NetworkId},
|
||||||
};
|
};
|
||||||
use xcm_builder::BridgeBlobDispatcher;
|
use xcm_builder::BridgeBlobDispatcher;
|
||||||
|
|
||||||
@@ -58,12 +58,12 @@ parameter_types! {
|
|||||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||||
pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
|
pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
|
||||||
pub BridgeRococoToWestendMessagesPalletInstance: InteriorMultiLocation = X1(PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8));
|
pub BridgeRococoToWestendMessagesPalletInstance: InteriorLocation = [PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8)].into();
|
||||||
pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend;
|
pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend;
|
||||||
pub WestendGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
|
pub WestendGlobalConsensusNetworkLocation: Location = Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X1(GlobalConsensus(WestendGlobalConsensusNetwork::get()))
|
[GlobalConsensus(WestendGlobalConsensusNetwork::get())]
|
||||||
};
|
);
|
||||||
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
|
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
|
||||||
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
|
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
|
||||||
|
|
||||||
@@ -74,26 +74,26 @@ parameter_types! {
|
|||||||
pub ActiveOutboundLanesToBridgeHubWestend: &'static [bp_messages::LaneId] = &[XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND];
|
pub ActiveOutboundLanesToBridgeHubWestend: &'static [bp_messages::LaneId] = &[XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND];
|
||||||
pub const AssetHubRococoToAssetHubWestendMessagesLane: bp_messages::LaneId = XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND;
|
pub const AssetHubRococoToAssetHubWestendMessagesLane: bp_messages::LaneId = XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND;
|
||||||
pub FromAssetHubRococoToAssetHubWestendRoute: SenderAndLane = SenderAndLane::new(
|
pub FromAssetHubRococoToAssetHubWestendRoute: SenderAndLane = SenderAndLane::new(
|
||||||
ParentThen(X1(Parachain(AssetHubRococoParaId::get().into()))).into(),
|
ParentThen([Parachain(AssetHubRococoParaId::get().into())].into()).into(),
|
||||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||||
);
|
);
|
||||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||||
(
|
(
|
||||||
FromAssetHubRococoToAssetHubWestendRoute::get(),
|
FromAssetHubRococoToAssetHubWestendRoute::get(),
|
||||||
(WestendGlobalConsensusNetwork::get(), X1(Parachain(AssetHubWestendParaId::get().into())))
|
(WestendGlobalConsensusNetwork::get(), [Parachain(AssetHubWestendParaId::get().into())].into())
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
|
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
|
||||||
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
|
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
|
||||||
|
|
||||||
pub BridgeHubWestendLocation: MultiLocation = MultiLocation {
|
pub BridgeHubWestendLocation: Location = Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[
|
||||||
GlobalConsensus(WestendGlobalConsensusNetwork::get()),
|
GlobalConsensus(WestendGlobalConsensusNetwork::get()),
|
||||||
Parachain(<bp_bridge_hub_westend::BridgeHubWestend as bp_runtime::Parachain>::PARACHAIN_ID)
|
Parachain(<bp_bridge_hub_westend::BridgeHubWestend as bp_runtime::Parachain>::PARACHAIN_ID)
|
||||||
)
|
]
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
pub const XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND: LaneId = LaneId([0, 0, 0, 2]);
|
pub const XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND: LaneId = LaneId([0, 0, 0, 2]);
|
||||||
|
|
||||||
@@ -327,11 +327,11 @@ mod tests {
|
|||||||
PriorityBoostPerMessage,
|
PriorityBoostPerMessage,
|
||||||
>(FEE_BOOST_PER_MESSAGE);
|
>(FEE_BOOST_PER_MESSAGE);
|
||||||
|
|
||||||
assert_eq!(
|
let expected: InteriorLocation = [PalletInstance(
|
||||||
BridgeRococoToWestendMessagesPalletInstance::get(),
|
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX,
|
||||||
X1(PalletInstance(
|
)]
|
||||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX
|
.into();
|
||||||
))
|
|
||||||
);
|
assert_eq!(BridgeRococoToWestendMessagesPalletInstance::get(), expected,);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ use bridge_hub_common::{
|
|||||||
use pallet_xcm::EnsureXcm;
|
use pallet_xcm::EnsureXcm;
|
||||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
pub use sp_runtime::{MultiAddress, Perbill, Permill};
|
pub use sp_runtime::{MultiAddress, Perbill, Permill};
|
||||||
use xcm::VersionedMultiLocation;
|
use xcm::VersionedLocation;
|
||||||
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
|
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
@@ -385,7 +385,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(xcm_config::TokenLocation::get());
|
pub FeeAssetId: AssetId = AssetId(xcm_config::TokenLocation::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||||
}
|
}
|
||||||
@@ -517,7 +517,7 @@ pub mod benchmark_helpers {
|
|||||||
use snowbridge_beacon_primitives::CompactExecutionHeader;
|
use snowbridge_beacon_primitives::CompactExecutionHeader;
|
||||||
use snowbridge_pallet_inbound_queue::BenchmarkHelper;
|
use snowbridge_pallet_inbound_queue::BenchmarkHelper;
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use xcm::latest::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash};
|
use xcm::latest::{Assets, Location, SendError, SendResult, SendXcm, Xcm, XcmHash};
|
||||||
|
|
||||||
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Runtime {
|
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Runtime {
|
||||||
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
|
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
|
||||||
@@ -530,10 +530,10 @@ pub mod benchmark_helpers {
|
|||||||
type Ticket = Xcm<()>;
|
type Ticket = Xcm<()>;
|
||||||
|
|
||||||
fn validate(
|
fn validate(
|
||||||
_dest: &mut Option<MultiLocation>,
|
_dest: &mut Option<Location>,
|
||||||
xcm: &mut Option<Xcm<()>>,
|
xcm: &mut Option<Xcm<()>>,
|
||||||
) -> SendResult<Self::Ticket> {
|
) -> SendResult<Self::Ticket> {
|
||||||
Ok((xcm.clone().unwrap(), MultiAssets::new()))
|
Ok((xcm.clone().unwrap(), Assets::new()))
|
||||||
}
|
}
|
||||||
fn deliver(xcm: Xcm<()>) -> Result<XcmHash, SendError> {
|
fn deliver(xcm: Xcm<()>) -> Result<XcmHash, SendError> {
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
@@ -542,7 +542,7 @@ pub mod benchmark_helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl snowbridge_pallet_system::BenchmarkHelper<RuntimeOrigin> for () {
|
impl snowbridge_pallet_system::BenchmarkHelper<RuntimeOrigin> for () {
|
||||||
fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
|
fn make_xcm_origin(location: Location) -> RuntimeOrigin {
|
||||||
RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location))
|
RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1016,7 +1016,7 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl snowbridge_system_runtime_api::ControlApi<Block> for Runtime {
|
impl snowbridge_system_runtime_api::ControlApi<Block> for Runtime {
|
||||||
fn agent_id(location: VersionedMultiLocation) -> Option<AgentId> {
|
fn agent_id(location: VersionedLocation) -> Option<AgentId> {
|
||||||
snowbridge_pallet_system::api::agent_id::<Runtime>(location)
|
snowbridge_pallet_system::api::agent_id::<Runtime>(location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1095,28 +1095,28 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||||
fn reachable_dest() -> Option<MultiLocation> {
|
fn reachable_dest() -> Option<Location> {
|
||||||
Some(Parent.into())
|
Some(Parent.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Relay/native token can be teleported between BH and Relay.
|
// Relay/native token can be teleported between BH and Relay.
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
Parent.into(),
|
Parent.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Reserve transfers are disabled on BH.
|
// Reserve transfers are disabled on BH.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_complex_asset_transfer(
|
fn set_up_complex_asset_transfer(
|
||||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||||
// BH only supports teleports to system parachain.
|
// BH only supports teleports to system parachain.
|
||||||
// Relay/native token can be teleported between BH and Relay.
|
// Relay/native token can be teleported between BH and Relay.
|
||||||
let native_location = Parent.into();
|
let native_location = Parent.into();
|
||||||
@@ -1132,7 +1132,7 @@ impl_runtime_apis! {
|
|||||||
use xcm_config::TokenLocation;
|
use xcm_config::TokenLocation;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||||
TokenLocation::get(),
|
TokenLocation::get(),
|
||||||
ExistentialDeposit::get()
|
ExistentialDeposit::get()
|
||||||
).into());
|
).into());
|
||||||
@@ -1143,17 +1143,17 @@ impl_runtime_apis! {
|
|||||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||||
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
||||||
xcm_config::XcmConfig,
|
xcm_config::XcmConfig,
|
||||||
ExistentialDepositMultiAsset,
|
ExistentialDepositAsset,
|
||||||
xcm_config::PriceForParentDelivery,
|
xcm_config::PriceForParentDelivery,
|
||||||
>;
|
>;
|
||||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||||
Ok(TokenLocation::get())
|
Ok(TokenLocation::get())
|
||||||
}
|
}
|
||||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
fn worst_case_holding(_depositable_count: u32) -> Assets {
|
||||||
// just concrete assets according to relay chain.
|
// just concrete assets according to relay chain.
|
||||||
let assets: Vec<MultiAsset> = vec![
|
let assets: Vec<Asset> = vec![
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(TokenLocation::get()),
|
id: AssetId(TokenLocation::get()),
|
||||||
fun: Fungible(1_000_000 * UNITS),
|
fun: Fungible(1_000_000 * UNITS),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -1162,12 +1162,12 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||||
TokenLocation::get(),
|
TokenLocation::get(),
|
||||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(TokenLocation::get()) },
|
Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
|
||||||
));
|
));
|
||||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
pub const TrustedReserve: Option<(Location, Asset)> = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||||
@@ -1177,9 +1177,9 @@ impl_runtime_apis! {
|
|||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
type TrustedReserve = TrustedReserve;
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_asset() -> Asset {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(TokenLocation::get()),
|
id: AssetId(TokenLocation::get()),
|
||||||
fun: Fungible(UNITS),
|
fun: Fungible(UNITS),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1193,35 +1193,35 @@ impl_runtime_apis! {
|
|||||||
(0u64, Response::Version(Default::default()))
|
(0u64, Response::Version(Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||||
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||||
Ok(TokenLocation::get())
|
Ok(TokenLocation::get())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
|
||||||
let origin = TokenLocation::get();
|
let origin = TokenLocation::get();
|
||||||
let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into();
|
let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
|
||||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
let ticket = Location { parents: 0, interior: Here };
|
||||||
Ok((origin, ticket, assets))
|
Ok((origin, ticket, assets))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_message_origin_and_destination(
|
fn export_message_origin_and_destination(
|
||||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||||
// save XCM version for remote bridge hub
|
// save XCM version for remote bridge hub
|
||||||
let _ = PolkadotXcm::force_xcm_version(
|
let _ = PolkadotXcm::force_xcm_version(
|
||||||
RuntimeOrigin::root(),
|
RuntimeOrigin::root(),
|
||||||
@@ -1241,12 +1241,12 @@ impl_runtime_apis! {
|
|||||||
(
|
(
|
||||||
bridge_to_westend_config::FromAssetHubRococoToAssetHubWestendRoute::get().location,
|
bridge_to_westend_config::FromAssetHubRococoToAssetHubWestendRoute::get().location,
|
||||||
NetworkId::Westend,
|
NetworkId::Westend,
|
||||||
X1(Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into()))
|
[Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into())].into()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1296,7 +1296,7 @@ impl_runtime_apis! {
|
|||||||
Runtime,
|
Runtime,
|
||||||
bridge_common_config::BridgeGrandpaWestendInstance,
|
bridge_common_config::BridgeGrandpaWestendInstance,
|
||||||
bridge_to_westend_config::WithBridgeHubWestendMessageBridge,
|
bridge_to_westend_config::WithBridgeHubWestendMessageBridge,
|
||||||
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Rococo), Parachain(42))))
|
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_message_delivery_proof(
|
fn prepare_message_delivery_proof(
|
||||||
@@ -1331,7 +1331,7 @@ impl_runtime_apis! {
|
|||||||
Runtime,
|
Runtime,
|
||||||
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
|
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
|
||||||
bridge_to_bulletin_config::WithRococoBulletinMessageBridge,
|
bridge_to_bulletin_config::WithRococoBulletinMessageBridge,
|
||||||
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Rococo), Parachain(42))))
|
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_message_delivery_proof(
|
fn prepare_message_delivery_proof(
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||||
|
|
||||||
trait WeighMultiAssets {
|
trait WeighAssets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
fn weigh_assets(&self, weight: Weight) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_ASSETS: u64 = 100;
|
const MAX_ASSETS: u64 = 100;
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssetFilter {
|
impl WeighAssets for AssetFilter {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
match self {
|
match self {
|
||||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||||
Self::Wild(asset) => match asset {
|
Self::Wild(asset) => match asset {
|
||||||
@@ -50,40 +50,36 @@ impl WeighMultiAssets for MultiAssetFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssets {
|
impl WeighAssets for Assets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BridgeHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
pub struct BridgeHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||||
impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||||
}
|
}
|
||||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||||
}
|
}
|
||||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||||
}
|
}
|
||||||
fn query_response(
|
fn query_response(
|
||||||
_query_id: &u64,
|
_query_id: &u64,
|
||||||
_response: &Response,
|
_response: &Response,
|
||||||
_max_weight: &Weight,
|
_max_weight: &Weight,
|
||||||
_querier: &Option<MultiLocation>,
|
_querier: &Option<Location>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
XcmGeneric::<Runtime>::query_response()
|
XcmGeneric::<Runtime>::query_response()
|
||||||
}
|
}
|
||||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||||
}
|
}
|
||||||
fn transfer_reserve_asset(
|
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssets,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn transact(
|
fn transact(
|
||||||
_origin_type: &OriginKind,
|
_origin_type: &OriginKind,
|
||||||
@@ -111,44 +107,36 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
|||||||
fn clear_origin() -> Weight {
|
fn clear_origin() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_origin()
|
XcmGeneric::<Runtime>::clear_origin()
|
||||||
}
|
}
|
||||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||||
XcmGeneric::<Runtime>::descend_origin()
|
XcmGeneric::<Runtime>::descend_origin()
|
||||||
}
|
}
|
||||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_error()
|
XcmGeneric::<Runtime>::report_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||||
}
|
}
|
||||||
fn deposit_reserve_asset(
|
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn initiate_reserve_withdraw(
|
fn initiate_reserve_withdraw(
|
||||||
assets: &MultiAssetFilter,
|
assets: &AssetFilter,
|
||||||
_reserve: &MultiLocation,
|
_reserve: &Location,
|
||||||
_xcm: &Xcm<()>,
|
_xcm: &Xcm<()>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||||
}
|
}
|
||||||
fn initiate_teleport(
|
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
|
||||||
}
|
}
|
||||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_holding()
|
XcmGeneric::<Runtime>::report_holding()
|
||||||
}
|
}
|
||||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||||
XcmGeneric::<Runtime>::buy_execution()
|
XcmGeneric::<Runtime>::buy_execution()
|
||||||
}
|
}
|
||||||
fn refund_surplus() -> Weight {
|
fn refund_surplus() -> Weight {
|
||||||
@@ -163,7 +151,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
|||||||
fn clear_error() -> Weight {
|
fn clear_error() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_error()
|
XcmGeneric::<Runtime>::clear_error()
|
||||||
}
|
}
|
||||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||||
XcmGeneric::<Runtime>::claim_asset()
|
XcmGeneric::<Runtime>::claim_asset()
|
||||||
}
|
}
|
||||||
fn trap(_code: &u64) -> Weight {
|
fn trap(_code: &u64) -> Weight {
|
||||||
@@ -175,13 +163,13 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
|||||||
fn unsubscribe_version() -> Weight {
|
fn unsubscribe_version() -> Weight {
|
||||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||||
}
|
}
|
||||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
fn burn_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||||
}
|
}
|
||||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
fn expect_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||||
}
|
}
|
||||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::expect_origin()
|
XcmGeneric::<Runtime>::expect_origin()
|
||||||
}
|
}
|
||||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||||
@@ -215,16 +203,16 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
|||||||
let inner_encoded_len = inner.encode().len() as u32;
|
let inner_encoded_len = inner.encode().len() as u32;
|
||||||
XcmGeneric::<Runtime>::export_message(inner_encoded_len)
|
XcmGeneric::<Runtime>::export_message(inner_encoded_len)
|
||||||
}
|
}
|
||||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn set_fees_mode(_: &bool) -> Weight {
|
fn set_fees_mode(_: &bool) -> Weight {
|
||||||
@@ -236,11 +224,11 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
|||||||
fn clear_topic() -> Weight {
|
fn clear_topic() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_topic()
|
XcmGeneric::<Runtime>::clear_topic()
|
||||||
}
|
}
|
||||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
fn alias_origin(_: &Location) -> Weight {
|
||||||
// XCM Executor does not currently support alias origin operations
|
// XCM Executor does not currently support alias origin operations
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::unpaid_execution()
|
XcmGeneric::<Runtime>::unpaid_execution()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use bp_messages::LaneId;
|
|||||||
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
|
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
|
||||||
use bp_runtime::ChainId;
|
use bp_runtime::ChainId;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -69,19 +69,19 @@ use xcm_executor::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TokenLocation: MultiLocation = MultiLocation::parent();
|
pub const TokenLocation: Location = Location::parent();
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub RelayNetwork: NetworkId = NetworkId::Rococo;
|
pub RelayNetwork: NetworkId = NetworkId::Rococo;
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
|
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||||
pub const MaxInstructions: u32 = 100;
|
pub const MaxInstructions: u32 = 100;
|
||||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||||
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
||||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||||
pub SiblingPeople: MultiLocation = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
|
pub SiblingPeople: Location = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -100,7 +100,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<TokenLocation>,
|
IsConcrete<TokenLocation>,
|
||||||
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
|
// Do a simple punn to convert an AccountId32 Location into a native chain account ID:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -132,11 +132,11 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
|||||||
XcmPassthrough<RuntimeOrigin>,
|
XcmPassthrough<RuntimeOrigin>,
|
||||||
);
|
);
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsPlurality;
|
||||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsPlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||||
@@ -331,7 +331,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
pub type PriceForParentDelivery =
|
pub type PriceForParentDelivery =
|
||||||
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
|
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
|
||||||
|
|
||||||
/// Converts a local signed origin into an XCM multilocation.
|
/// Converts a local signed origin into an XCM location.
|
||||||
/// Forms the basis for local origins sending/executing XCMs.
|
/// Forms the basis for local origins sending/executing XCMs.
|
||||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||||
|
|
||||||
@@ -407,14 +407,10 @@ impl<
|
|||||||
BridgeLaneId,
|
BridgeLaneId,
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
fn handle_fee(
|
fn handle_fee(fee: Assets, maybe_context: Option<&XcmContext>, reason: FeeReason) -> Assets {
|
||||||
fee: MultiAssets,
|
|
||||||
maybe_context: Option<&XcmContext>,
|
|
||||||
reason: FeeReason,
|
|
||||||
) -> MultiAssets {
|
|
||||||
if matches!(reason, FeeReason::Export { network: bridged_network, destination }
|
if matches!(reason, FeeReason::Export { network: bridged_network, destination }
|
||||||
if bridged_network == DestNetwork::get() &&
|
if bridged_network == DestNetwork::get() &&
|
||||||
destination == X1(Parachain(DestParaId::get().into())))
|
destination == [Parachain(DestParaId::get().into())])
|
||||||
{
|
{
|
||||||
// We have 2 relayer rewards accounts:
|
// We have 2 relayer rewards accounts:
|
||||||
// - the SA of the source parachain on this BH: this pays the relayers for delivering
|
// - the SA of the source parachain on this BH: this pays the relayers for delivering
|
||||||
@@ -445,14 +441,14 @@ impl<
|
|||||||
Fungible(total_fee) => {
|
Fungible(total_fee) => {
|
||||||
let source_fee = total_fee / 2;
|
let source_fee = total_fee / 2;
|
||||||
deposit_or_burn_fee::<AssetTransactor, _>(
|
deposit_or_burn_fee::<AssetTransactor, _>(
|
||||||
MultiAsset { id: asset.id, fun: Fungible(source_fee) }.into(),
|
Asset { id: asset.id.clone(), fun: Fungible(source_fee) }.into(),
|
||||||
maybe_context,
|
maybe_context,
|
||||||
source_para_account.clone(),
|
source_para_account.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let dest_fee = total_fee - source_fee;
|
let dest_fee = total_fee - source_fee;
|
||||||
deposit_or_burn_fee::<AssetTransactor, _>(
|
deposit_or_burn_fee::<AssetTransactor, _>(
|
||||||
MultiAsset { id: asset.id, fun: Fungible(dest_fee) }.into(),
|
Asset { id: asset.id, fun: Fungible(dest_fee) }.into(),
|
||||||
maybe_context,
|
maybe_context,
|
||||||
dest_para_account.clone(),
|
dest_para_account.clone(),
|
||||||
);
|
);
|
||||||
@@ -467,7 +463,7 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return MultiAssets::new()
|
return Assets::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fee
|
fee
|
||||||
@@ -477,10 +473,10 @@ impl<
|
|||||||
pub struct XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, HandleFee>(
|
pub struct XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, HandleFee>(
|
||||||
PhantomData<(WaivedLocations, HandleFee)>,
|
PhantomData<(WaivedLocations, HandleFee)>,
|
||||||
);
|
);
|
||||||
impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
|
impl<WaivedLocations: Contains<Location>, FeeHandler: HandleFee> FeeManager
|
||||||
for XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, FeeHandler>
|
for XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, FeeHandler>
|
||||||
{
|
{
|
||||||
fn is_waived(origin: Option<&MultiLocation>, fee_reason: FeeReason) -> bool {
|
fn is_waived(origin: Option<&Location>, fee_reason: FeeReason) -> bool {
|
||||||
let Some(loc) = origin else { return false };
|
let Some(loc) = origin else { return false };
|
||||||
if let Export { network, destination: Here } = fee_reason {
|
if let Export { network, destination: Here } = fee_reason {
|
||||||
return !(network == EthereumNetwork::get())
|
return !(network == EthereumNetwork::get())
|
||||||
@@ -488,7 +484,7 @@ impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
|
|||||||
WaivedLocations::contains(loc)
|
WaivedLocations::contains(loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_fee(fee: MultiAssets, context: Option<&XcmContext>, reason: FeeReason) {
|
fn handle_fee(fee: Assets, context: Option<&XcmContext>, reason: FeeReason) {
|
||||||
FeeHandler::handle_fee(fee, context, reason);
|
FeeHandler::handle_fee(fee, context, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ mod bridge_hub_westend_tests {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|| ExportMessage { network: Westend, destination: X1(Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into())), xcm: Xcm(vec![]) },
|
|| ExportMessage { network: Westend, destination: [Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into())].into(), xcm: Xcm(vec![]) },
|
||||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||||
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
|
Some((TokenLocation::get(), ExistentialDeposit::get()).into()),
|
||||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||||
|
|||||||
+16
-16
@@ -47,7 +47,7 @@ use frame_support::{
|
|||||||
use sp_runtime::RuntimeDebug;
|
use sp_runtime::RuntimeDebug;
|
||||||
use xcm::{
|
use xcm::{
|
||||||
latest::prelude::*,
|
latest::prelude::*,
|
||||||
prelude::{InteriorMultiLocation, NetworkId},
|
prelude::{InteriorLocation, NetworkId},
|
||||||
};
|
};
|
||||||
use xcm_builder::BridgeBlobDispatcher;
|
use xcm_builder::BridgeBlobDispatcher;
|
||||||
|
|
||||||
@@ -63,12 +63,12 @@ parameter_types! {
|
|||||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
||||||
bp_bridge_hub_westend::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
bp_bridge_hub_westend::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||||
pub const BridgeHubRococoChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID;
|
pub const BridgeHubRococoChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID;
|
||||||
pub BridgeWestendToRococoMessagesPalletInstance: InteriorMultiLocation = X1(PalletInstance(<BridgeRococoMessages as PalletInfoAccess>::index() as u8));
|
pub BridgeWestendToRococoMessagesPalletInstance: InteriorLocation = [PalletInstance(<BridgeRococoMessages as PalletInfoAccess>::index() as u8)].into();
|
||||||
pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::Rococo;
|
pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::Rococo;
|
||||||
pub RococoGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
|
pub RococoGlobalConsensusNetworkLocation: Location = Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X1(GlobalConsensus(RococoGlobalConsensusNetwork::get()))
|
[GlobalConsensus(RococoGlobalConsensusNetwork::get())]
|
||||||
};
|
);
|
||||||
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
|
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
|
||||||
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
|
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
|
||||||
|
|
||||||
@@ -79,26 +79,26 @@ parameter_types! {
|
|||||||
pub ActiveOutboundLanesToBridgeHubRococo: &'static [bp_messages::LaneId] = &[XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO];
|
pub ActiveOutboundLanesToBridgeHubRococo: &'static [bp_messages::LaneId] = &[XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO];
|
||||||
pub const AssetHubWestendToAssetHubRococoMessagesLane: bp_messages::LaneId = XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO;
|
pub const AssetHubWestendToAssetHubRococoMessagesLane: bp_messages::LaneId = XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO;
|
||||||
pub FromAssetHubWestendToAssetHubRococoRoute: SenderAndLane = SenderAndLane::new(
|
pub FromAssetHubWestendToAssetHubRococoRoute: SenderAndLane = SenderAndLane::new(
|
||||||
ParentThen(X1(Parachain(AssetHubWestendParaId::get().into()))).into(),
|
ParentThen([Parachain(AssetHubWestendParaId::get().into())].into()).into(),
|
||||||
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
||||||
);
|
);
|
||||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||||
(
|
(
|
||||||
FromAssetHubWestendToAssetHubRococoRoute::get(),
|
FromAssetHubWestendToAssetHubRococoRoute::get(),
|
||||||
(RococoGlobalConsensusNetwork::get(), X1(Parachain(AssetHubRococoParaId::get().into())))
|
(RococoGlobalConsensusNetwork::get(), [Parachain(AssetHubRococoParaId::get().into())].into())
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
|
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
|
||||||
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
|
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
|
||||||
|
|
||||||
pub BridgeHubRococoLocation: MultiLocation = MultiLocation {
|
pub BridgeHubRococoLocation: Location = Location::new(
|
||||||
parents: 2,
|
2,
|
||||||
interior: X2(
|
[
|
||||||
GlobalConsensus(RococoGlobalConsensusNetwork::get()),
|
GlobalConsensus(RococoGlobalConsensusNetwork::get()),
|
||||||
Parachain(<bp_bridge_hub_rococo::BridgeHubRococo as bp_runtime::Parachain>::PARACHAIN_ID)
|
Parachain(<bp_bridge_hub_rococo::BridgeHubRococo as bp_runtime::Parachain>::PARACHAIN_ID)
|
||||||
)
|
]
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
pub const XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO: LaneId = LaneId([0, 0, 0, 2]);
|
pub const XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO: LaneId = LaneId([0, 0, 0, 2]);
|
||||||
|
|
||||||
@@ -363,9 +363,9 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
BridgeWestendToRococoMessagesPalletInstance::get(),
|
BridgeWestendToRococoMessagesPalletInstance::get(),
|
||||||
X1(PalletInstance(
|
[PalletInstance(
|
||||||
bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX
|
bp_bridge_hub_westend::WITH_BRIDGE_WESTEND_TO_ROCOCO_MESSAGES_PALLET_INDEX
|
||||||
))
|
)]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(xcm_config::WestendLocation::get());
|
pub FeeAssetId: AssetId = AssetId(xcm_config::WestendLocation::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||||
}
|
}
|
||||||
@@ -797,28 +797,28 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||||
fn reachable_dest() -> Option<MultiLocation> {
|
fn reachable_dest() -> Option<Location> {
|
||||||
Some(Parent.into())
|
Some(Parent.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Relay/native token can be teleported between BH and Relay.
|
// Relay/native token can be teleported between BH and Relay.
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
},
|
},
|
||||||
Parent.into(),
|
Parent.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Reserve transfers are disabled on BH.
|
// Reserve transfers are disabled on BH.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_complex_asset_transfer(
|
fn set_up_complex_asset_transfer(
|
||||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||||
// BH only supports teleports to system parachain.
|
// BH only supports teleports to system parachain.
|
||||||
// Relay/native token can be teleported between BH and Relay.
|
// Relay/native token can be teleported between BH and Relay.
|
||||||
let native_location = Parent.into();
|
let native_location = Parent.into();
|
||||||
@@ -834,7 +834,7 @@ impl_runtime_apis! {
|
|||||||
use xcm_config::WestendLocation;
|
use xcm_config::WestendLocation;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||||
WestendLocation::get(),
|
WestendLocation::get(),
|
||||||
ExistentialDeposit::get()
|
ExistentialDeposit::get()
|
||||||
).into());
|
).into());
|
||||||
@@ -845,17 +845,17 @@ impl_runtime_apis! {
|
|||||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||||
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
||||||
xcm_config::XcmConfig,
|
xcm_config::XcmConfig,
|
||||||
ExistentialDepositMultiAsset,
|
ExistentialDepositAsset,
|
||||||
xcm_config::PriceForParentDelivery,
|
xcm_config::PriceForParentDelivery,
|
||||||
>;
|
>;
|
||||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||||
Ok(WestendLocation::get())
|
Ok(WestendLocation::get())
|
||||||
}
|
}
|
||||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
fn worst_case_holding(_depositable_count: u32) -> Assets {
|
||||||
// just concrete assets according to relay chain.
|
// just assets according to relay chain.
|
||||||
let assets: Vec<MultiAsset> = vec![
|
let assets: Vec<Asset> = vec![
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(WestendLocation::get()),
|
id: AssetId(WestendLocation::get()),
|
||||||
fun: Fungible(1_000_000 * UNITS),
|
fun: Fungible(1_000_000 * UNITS),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -864,12 +864,12 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||||
WestendLocation::get(),
|
WestendLocation::get(),
|
||||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(WestendLocation::get()) },
|
Asset { fun: Fungible(UNITS), id: AssetId(WestendLocation::get()) },
|
||||||
));
|
));
|
||||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
pub const TrustedReserve: Option<(Location, Asset)> = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||||
@@ -879,9 +879,9 @@ impl_runtime_apis! {
|
|||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
type TrustedReserve = TrustedReserve;
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_asset() -> Asset {
|
||||||
MultiAsset {
|
Asset {
|
||||||
id: Concrete(WestendLocation::get()),
|
id: AssetId(WestendLocation::get()),
|
||||||
fun: Fungible(UNITS),
|
fun: Fungible(UNITS),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -895,35 +895,35 @@ impl_runtime_apis! {
|
|||||||
(0u64, Response::Version(Default::default()))
|
(0u64, Response::Version(Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||||
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||||
Ok(WestendLocation::get())
|
Ok(WestendLocation::get())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
|
||||||
let origin = WestendLocation::get();
|
let origin = WestendLocation::get();
|
||||||
let assets: MultiAssets = (Concrete(WestendLocation::get()), 1_000 * UNITS).into();
|
let assets: Assets = (AssetId(WestendLocation::get()), 1_000 * UNITS).into();
|
||||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
let ticket = Location { parents: 0, interior: Here };
|
||||||
Ok((origin, ticket, assets))
|
Ok((origin, ticket, assets))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn export_message_origin_and_destination(
|
fn export_message_origin_and_destination(
|
||||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||||
// save XCM version for remote bridge hub
|
// save XCM version for remote bridge hub
|
||||||
let _ = PolkadotXcm::force_xcm_version(
|
let _ = PolkadotXcm::force_xcm_version(
|
||||||
RuntimeOrigin::root(),
|
RuntimeOrigin::root(),
|
||||||
@@ -943,12 +943,12 @@ impl_runtime_apis! {
|
|||||||
(
|
(
|
||||||
bridge_to_rococo_config::FromAssetHubWestendToAssetHubRococoRoute::get().location,
|
bridge_to_rococo_config::FromAssetHubWestendToAssetHubRococoRoute::get().location,
|
||||||
NetworkId::Rococo,
|
NetworkId::Rococo,
|
||||||
X1(Parachain(bridge_to_rococo_config::AssetHubRococoParaId::get().into()))
|
[Parachain(bridge_to_rococo_config::AssetHubRococoParaId::get().into())].into()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||||
Err(BenchmarkError::Skip)
|
Err(BenchmarkError::Skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -995,7 +995,7 @@ impl_runtime_apis! {
|
|||||||
Runtime,
|
Runtime,
|
||||||
bridge_to_rococo_config::BridgeGrandpaRococoInstance,
|
bridge_to_rococo_config::BridgeGrandpaRococoInstance,
|
||||||
bridge_to_rococo_config::WithBridgeHubRococoMessageBridge,
|
bridge_to_rococo_config::WithBridgeHubRococoMessageBridge,
|
||||||
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Westend), Parachain(42))))
|
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Westend), Parachain(42)].into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_message_delivery_proof(
|
fn prepare_message_delivery_proof(
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||||
|
|
||||||
trait WeighMultiAssets {
|
trait WeighAssets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
fn weigh_assets(&self, weight: Weight) -> Weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_ASSETS: u64 = 100;
|
const MAX_ASSETS: u64 = 100;
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssetFilter {
|
impl WeighAssets for AssetFilter {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
match self {
|
match self {
|
||||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||||
Self::Wild(asset) => match asset {
|
Self::Wild(asset) => match asset {
|
||||||
@@ -51,40 +51,36 @@ impl WeighMultiAssets for MultiAssetFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeighMultiAssets for MultiAssets {
|
impl WeighAssets for Assets {
|
||||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BridgeHubWestendXcmWeight<Call>(core::marker::PhantomData<Call>);
|
pub struct BridgeHubWestendXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||||
impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
||||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||||
}
|
}
|
||||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||||
}
|
}
|
||||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||||
}
|
}
|
||||||
fn query_response(
|
fn query_response(
|
||||||
_query_id: &u64,
|
_query_id: &u64,
|
||||||
_response: &Response,
|
_response: &Response,
|
||||||
_max_weight: &Weight,
|
_max_weight: &Weight,
|
||||||
_querier: &Option<MultiLocation>,
|
_querier: &Option<Location>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
XcmGeneric::<Runtime>::query_response()
|
XcmGeneric::<Runtime>::query_response()
|
||||||
}
|
}
|
||||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||||
}
|
}
|
||||||
fn transfer_reserve_asset(
|
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssets,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn transact(
|
fn transact(
|
||||||
_origin_type: &OriginKind,
|
_origin_type: &OriginKind,
|
||||||
@@ -112,44 +108,36 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
|||||||
fn clear_origin() -> Weight {
|
fn clear_origin() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_origin()
|
XcmGeneric::<Runtime>::clear_origin()
|
||||||
}
|
}
|
||||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||||
XcmGeneric::<Runtime>::descend_origin()
|
XcmGeneric::<Runtime>::descend_origin()
|
||||||
}
|
}
|
||||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_error()
|
XcmGeneric::<Runtime>::report_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||||
}
|
}
|
||||||
fn deposit_reserve_asset(
|
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
|
||||||
}
|
}
|
||||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn initiate_reserve_withdraw(
|
fn initiate_reserve_withdraw(
|
||||||
assets: &MultiAssetFilter,
|
assets: &AssetFilter,
|
||||||
_reserve: &MultiLocation,
|
_reserve: &Location,
|
||||||
_xcm: &Xcm<()>,
|
_xcm: &Xcm<()>,
|
||||||
) -> Weight {
|
) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||||
}
|
}
|
||||||
fn initiate_teleport(
|
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||||
assets: &MultiAssetFilter,
|
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||||
_dest: &MultiLocation,
|
|
||||||
_xcm: &Xcm<()>,
|
|
||||||
) -> Weight {
|
|
||||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
|
||||||
}
|
}
|
||||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||||
XcmGeneric::<Runtime>::report_holding()
|
XcmGeneric::<Runtime>::report_holding()
|
||||||
}
|
}
|
||||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||||
XcmGeneric::<Runtime>::buy_execution()
|
XcmGeneric::<Runtime>::buy_execution()
|
||||||
}
|
}
|
||||||
fn refund_surplus() -> Weight {
|
fn refund_surplus() -> Weight {
|
||||||
@@ -164,7 +152,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
|||||||
fn clear_error() -> Weight {
|
fn clear_error() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_error()
|
XcmGeneric::<Runtime>::clear_error()
|
||||||
}
|
}
|
||||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||||
XcmGeneric::<Runtime>::claim_asset()
|
XcmGeneric::<Runtime>::claim_asset()
|
||||||
}
|
}
|
||||||
fn trap(_code: &u64) -> Weight {
|
fn trap(_code: &u64) -> Weight {
|
||||||
@@ -176,13 +164,13 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
|||||||
fn unsubscribe_version() -> Weight {
|
fn unsubscribe_version() -> Weight {
|
||||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||||
}
|
}
|
||||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
fn burn_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||||
}
|
}
|
||||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
fn expect_asset(assets: &Assets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||||
}
|
}
|
||||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::expect_origin()
|
XcmGeneric::<Runtime>::expect_origin()
|
||||||
}
|
}
|
||||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||||
@@ -216,16 +204,16 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
|||||||
let inner_encoded_len = inner.encode().len() as u32;
|
let inner_encoded_len = inner.encode().len() as u32;
|
||||||
XcmGeneric::<Runtime>::export_message(inner_encoded_len)
|
XcmGeneric::<Runtime>::export_message(inner_encoded_len)
|
||||||
}
|
}
|
||||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn set_fees_mode(_: &bool) -> Weight {
|
fn set_fees_mode(_: &bool) -> Weight {
|
||||||
@@ -237,11 +225,11 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubWestendXcmWeight<Call> {
|
|||||||
fn clear_topic() -> Weight {
|
fn clear_topic() -> Weight {
|
||||||
XcmGeneric::<Runtime>::clear_topic()
|
XcmGeneric::<Runtime>::clear_topic()
|
||||||
}
|
}
|
||||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
fn alias_origin(_: &Location) -> Weight {
|
||||||
// XCM Executor does not currently support alias origin operations
|
// XCM Executor does not currently support alias origin operations
|
||||||
Weight::MAX
|
Weight::MAX
|
||||||
}
|
}
|
||||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||||
XcmGeneric::<Runtime>::unpaid_execution()
|
XcmGeneric::<Runtime>::unpaid_execution()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::bridge_common_config::{DeliveryRewardInBalance, RequiredStakeForStakeAndSlash};
|
use crate::bridge_common_config::{DeliveryRewardInBalance, RequiredStakeForStakeAndSlash};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
||||||
};
|
};
|
||||||
use frame_system::EnsureRoot;
|
use frame_system::EnsureRoot;
|
||||||
@@ -52,18 +52,18 @@ use xcm_builder::{
|
|||||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const WestendLocation: MultiLocation = MultiLocation::parent();
|
pub const WestendLocation: Location = Location::parent();
|
||||||
pub const RelayNetwork: NetworkId = NetworkId::Westend;
|
pub const RelayNetwork: NetworkId = NetworkId::Westend;
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
|
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||||
pub const MaxInstructions: u32 = 100;
|
pub const MaxInstructions: u32 = 100;
|
||||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||||
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
||||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -82,7 +82,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<WestendLocation>,
|
IsConcrete<WestendLocation>,
|
||||||
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
|
// Do a simple punn to convert an AccountId32 Location into a native chain account ID:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -114,11 +114,11 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
|||||||
XcmPassthrough<RuntimeOrigin>,
|
XcmPassthrough<RuntimeOrigin>,
|
||||||
);
|
);
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsPlurality;
|
||||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsPlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||||
@@ -270,7 +270,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
pub type PriceForParentDelivery =
|
pub type PriceForParentDelivery =
|
||||||
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
|
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
|
||||||
|
|
||||||
/// Converts a local signed origin into an XCM multilocation.
|
/// Converts a local signed origin into an XCM location.
|
||||||
/// Forms the basis for local origins sending/executing XCMs.
|
/// Forms the basis for local origins sending/executing XCMs.
|
||||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|| ExportMessage { network: Rococo, destination: X1(Parachain(bridge_to_rococo_config::AssetHubRococoParaId::get().into())), xcm: Xcm(vec![]) },
|
|| ExportMessage { network: Rococo, destination: [Parachain(bridge_to_rococo_config::AssetHubRococoParaId::get().into())].into(), xcm: Xcm(vec![]) },
|
||||||
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
||||||
Some((WestendLocation::get(), ExistentialDeposit::get()).into()),
|
Some((WestendLocation::get(), ExistentialDeposit::get()).into()),
|
||||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use pallet_message_queue::OnQueueChanged;
|
|||||||
use scale_info::TypeInfo;
|
use scale_info::TypeInfo;
|
||||||
use snowbridge_core::ChannelId;
|
use snowbridge_core::ChannelId;
|
||||||
use sp_std::{marker::PhantomData, prelude::*};
|
use sp_std::{marker::PhantomData, prelude::*};
|
||||||
use xcm::v3::{Junction, MultiLocation};
|
use xcm::v4::{Junction, Location};
|
||||||
|
|
||||||
/// The aggregate origin of an inbound message.
|
/// The aggregate origin of an inbound message.
|
||||||
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
|
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
|
||||||
@@ -46,16 +46,16 @@ pub enum AggregateMessageOrigin {
|
|||||||
Snowbridge(ChannelId),
|
Snowbridge(ChannelId),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AggregateMessageOrigin> for MultiLocation {
|
impl From<AggregateMessageOrigin> for Location {
|
||||||
fn from(origin: AggregateMessageOrigin) -> Self {
|
fn from(origin: AggregateMessageOrigin) -> Self {
|
||||||
use AggregateMessageOrigin::*;
|
use AggregateMessageOrigin::*;
|
||||||
match origin {
|
match origin {
|
||||||
Here => MultiLocation::here(),
|
Here => Location::here(),
|
||||||
Parent => MultiLocation::parent(),
|
Parent => Location::parent(),
|
||||||
Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())),
|
Sibling(id) => Location::new(1, Junction::Parachain(id.into())),
|
||||||
// NOTE: We don't need this conversion for Snowbridge. However we have to
|
// NOTE: We don't need this conversion for Snowbridge. However we have to
|
||||||
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
|
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
|
||||||
Snowbridge(_) => MultiLocation::default(),
|
Snowbridge(_) => Location::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -336,9 +336,9 @@ where
|
|||||||
(),
|
(),
|
||||||
>(
|
>(
|
||||||
LaneId::default(),
|
LaneId::default(),
|
||||||
vec![xcm::v3::Instruction::<()>::ClearOrigin; 1_024].into(),
|
vec![Instruction::<()>::ClearOrigin; 1_024].into(),
|
||||||
1,
|
1,
|
||||||
X2(GlobalConsensus(Polkadot), Parachain(1_000)),
|
[GlobalConsensus(Polkadot), Parachain(1_000)].into(),
|
||||||
1u32.into(),
|
1u32.into(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -418,9 +418,9 @@ where
|
|||||||
(),
|
(),
|
||||||
>(
|
>(
|
||||||
LaneId::default(),
|
LaneId::default(),
|
||||||
vec![xcm::v3::Instruction::<()>::ClearOrigin; 1_024].into(),
|
vec![Instruction::<()>::ClearOrigin; 1_024].into(),
|
||||||
1,
|
1,
|
||||||
X2(GlobalConsensus(Polkadot), Parachain(1_000)),
|
[GlobalConsensus(Polkadot), Parachain(1_000)].into(),
|
||||||
1,
|
1,
|
||||||
5,
|
5,
|
||||||
1_000,
|
1_000,
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
prepare_message_proof_import: impl FnOnce(
|
prepare_message_proof_import: impl FnOnce(
|
||||||
Runtime::AccountId,
|
Runtime::AccountId,
|
||||||
Runtime::InboundRelayer,
|
Runtime::InboundRelayer,
|
||||||
InteriorMultiLocation,
|
InteriorLocation,
|
||||||
MessageNonce,
|
MessageNonce,
|
||||||
Xcm<()>,
|
Xcm<()>,
|
||||||
) -> CallsAndVerifiers<Runtime>,
|
) -> CallsAndVerifiers<Runtime>,
|
||||||
@@ -276,21 +276,21 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
|
|
||||||
// set up relayer details and proofs
|
// set up relayer details and proofs
|
||||||
|
|
||||||
let message_destination =
|
let message_destination: InteriorLocation =
|
||||||
X2(GlobalConsensus(local_relay_chain_id), Parachain(sibling_parachain_id));
|
[GlobalConsensus(local_relay_chain_id), Parachain(sibling_parachain_id)].into();
|
||||||
// some random numbers (checked by test)
|
// some random numbers (checked by test)
|
||||||
let message_nonce = 1;
|
let message_nonce = 1;
|
||||||
|
|
||||||
let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42];
|
let xcm = vec![Instruction::<()>::ClearOrigin; 42];
|
||||||
let expected_dispatch = xcm::latest::Xcm::<()>({
|
let expected_dispatch = xcm::latest::Xcm::<()>({
|
||||||
let mut expected_instructions = xcm.clone();
|
let mut expected_instructions = xcm.clone();
|
||||||
// dispatch prepends bridge pallet instance
|
// dispatch prepends bridge pallet instance
|
||||||
expected_instructions.insert(
|
expected_instructions.insert(
|
||||||
0,
|
0,
|
||||||
DescendOrigin(X1(PalletInstance(
|
DescendOrigin([PalletInstance(
|
||||||
<pallet_bridge_messages::Pallet<Runtime, MPI> as PalletInfoAccess>::index()
|
<pallet_bridge_messages::Pallet<Runtime, MPI> as PalletInfoAccess>::index()
|
||||||
as u8,
|
as u8,
|
||||||
))),
|
)].into()),
|
||||||
);
|
);
|
||||||
expected_instructions
|
expected_instructions
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -319,8 +319,8 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
|||||||
>,
|
>,
|
||||||
export_message_instruction: fn() -> Instruction<XcmConfig::RuntimeCall>,
|
export_message_instruction: fn() -> Instruction<XcmConfig::RuntimeCall>,
|
||||||
expected_lane_id: LaneId,
|
expected_lane_id: LaneId,
|
||||||
existential_deposit: Option<MultiAsset>,
|
existential_deposit: Option<Asset>,
|
||||||
maybe_paid_export_message: Option<MultiAsset>,
|
maybe_paid_export_message: Option<Asset>,
|
||||||
prepare_configuration: impl Fn(),
|
prepare_configuration: impl Fn(),
|
||||||
) where
|
) where
|
||||||
Runtime: BasicParachainRuntime + BridgeMessagesConfig<MessagesPalletInstance>,
|
Runtime: BasicParachainRuntime + BridgeMessagesConfig<MessagesPalletInstance>,
|
||||||
@@ -328,7 +328,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
|||||||
MessagesPalletInstance: 'static,
|
MessagesPalletInstance: 'static,
|
||||||
{
|
{
|
||||||
assert_ne!(runtime_para_id, sibling_parachain_id);
|
assert_ne!(runtime_para_id, sibling_parachain_id);
|
||||||
let sibling_parachain_location = MultiLocation::new(1, Parachain(sibling_parachain_id));
|
let sibling_parachain_location = Location::new(1, [Parachain(sibling_parachain_id)]);
|
||||||
|
|
||||||
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
run_test::<Runtime, _>(collator_session_key, runtime_para_id, vec![], || {
|
||||||
prepare_configuration();
|
prepare_configuration();
|
||||||
@@ -361,7 +361,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
|||||||
.expect("deposited fee");
|
.expect("deposited fee");
|
||||||
|
|
||||||
Xcm(vec![
|
Xcm(vec![
|
||||||
WithdrawAsset(MultiAssets::from(vec![fee.clone()])),
|
WithdrawAsset(Assets::from(vec![fee.clone()])),
|
||||||
BuyExecution { fees: fee, weight_limit: Unlimited },
|
BuyExecution { fees: fee, weight_limit: Unlimited },
|
||||||
export_message_instruction(),
|
export_message_instruction(),
|
||||||
])
|
])
|
||||||
@@ -373,12 +373,13 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
|||||||
};
|
};
|
||||||
|
|
||||||
// execute XCM
|
// execute XCM
|
||||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||||
assert_ok!(XcmExecutor::<XcmConfig>::execute_xcm(
|
assert_ok!(XcmExecutor::<XcmConfig>::prepare_and_execute(
|
||||||
sibling_parachain_location,
|
sibling_parachain_location,
|
||||||
xcm,
|
xcm,
|
||||||
hash,
|
&mut hash,
|
||||||
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
RuntimeHelper::<Runtime>::xcm_max_weight(XcmReceivedFrom::Sibling),
|
||||||
|
Weight::zero(),
|
||||||
)
|
)
|
||||||
.ensure_complete());
|
.ensure_complete());
|
||||||
|
|
||||||
@@ -446,9 +447,9 @@ pub fn message_dispatch_routing_works<
|
|||||||
NetworkDistanceAsParentCount: Get<u8>,
|
NetworkDistanceAsParentCount: Get<u8>,
|
||||||
{
|
{
|
||||||
struct NetworkWithParentCount<N, C>(core::marker::PhantomData<(N, C)>);
|
struct NetworkWithParentCount<N, C>(core::marker::PhantomData<(N, C)>);
|
||||||
impl<N: Get<NetworkId>, C: Get<u8>> Get<MultiLocation> for NetworkWithParentCount<N, C> {
|
impl<N: Get<NetworkId>, C: Get<u8>> Get<Location> for NetworkWithParentCount<N, C> {
|
||||||
fn get() -> MultiLocation {
|
fn get() -> Location {
|
||||||
MultiLocation { parents: C::get(), interior: X1(GlobalConsensus(N::get())) }
|
Location::new(C::get(), [GlobalConsensus(N::get())])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,7 +496,7 @@ pub fn message_dispatch_routing_works<
|
|||||||
BridgedNetwork,
|
BridgedNetwork,
|
||||||
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
|
NetworkWithParentCount<RuntimeNetwork, NetworkDistanceAsParentCount>,
|
||||||
AlwaysLatest,
|
AlwaysLatest,
|
||||||
>((RuntimeNetwork::get(), X1(Parachain(sibling_parachain_id))));
|
>((RuntimeNetwork::get(), [Parachain(sibling_parachain_id)].into()));
|
||||||
|
|
||||||
// 2.1. WITHOUT opened hrmp channel -> RoutingError
|
// 2.1. WITHOUT opened hrmp channel -> RoutingError
|
||||||
let result =
|
let result =
|
||||||
@@ -565,52 +566,43 @@ where
|
|||||||
{
|
{
|
||||||
// data here are not relevant for weighing
|
// data here are not relevant for weighing
|
||||||
let mut xcm = Xcm(vec![
|
let mut xcm = Xcm(vec![
|
||||||
WithdrawAsset(MultiAssets::from(vec![MultiAsset {
|
WithdrawAsset(Assets::from(vec![Asset {
|
||||||
id: Concrete(MultiLocation { parents: 1, interior: Here }),
|
id: AssetId(Location::new(1, [])),
|
||||||
fun: Fungible(34333299),
|
fun: Fungible(34333299),
|
||||||
}])),
|
}])),
|
||||||
BuyExecution {
|
BuyExecution {
|
||||||
fees: MultiAsset {
|
fees: Asset { id: AssetId(Location::new(1, [])), fun: Fungible(34333299) },
|
||||||
id: Concrete(MultiLocation { parents: 1, interior: Here }),
|
|
||||||
fun: Fungible(34333299),
|
|
||||||
},
|
|
||||||
weight_limit: Unlimited,
|
weight_limit: Unlimited,
|
||||||
},
|
},
|
||||||
ExportMessage {
|
ExportMessage {
|
||||||
network: Polkadot,
|
network: Polkadot,
|
||||||
destination: X1(Parachain(1000)),
|
destination: [Parachain(1000)].into(),
|
||||||
xcm: Xcm(vec![
|
xcm: Xcm(vec![
|
||||||
ReserveAssetDeposited(MultiAssets::from(vec![MultiAsset {
|
ReserveAssetDeposited(Assets::from(vec![Asset {
|
||||||
id: Concrete(MultiLocation {
|
id: AssetId(Location::new(2, [GlobalConsensus(Kusama)])),
|
||||||
parents: 2,
|
|
||||||
interior: X1(GlobalConsensus(Kusama)),
|
|
||||||
}),
|
|
||||||
fun: Fungible(1000000000000),
|
fun: Fungible(1000000000000),
|
||||||
}])),
|
}])),
|
||||||
ClearOrigin,
|
ClearOrigin,
|
||||||
BuyExecution {
|
BuyExecution {
|
||||||
fees: MultiAsset {
|
fees: Asset {
|
||||||
id: Concrete(MultiLocation {
|
id: AssetId(Location::new(2, [GlobalConsensus(Kusama)])),
|
||||||
parents: 2,
|
|
||||||
interior: X1(GlobalConsensus(Kusama)),
|
|
||||||
}),
|
|
||||||
fun: Fungible(1000000000000),
|
fun: Fungible(1000000000000),
|
||||||
},
|
},
|
||||||
weight_limit: Unlimited,
|
weight_limit: Unlimited,
|
||||||
},
|
},
|
||||||
DepositAsset {
|
DepositAsset {
|
||||||
assets: Wild(AllCounted(1)),
|
assets: Wild(AllCounted(1)),
|
||||||
beneficiary: MultiLocation {
|
beneficiary: Location::new(
|
||||||
parents: 0,
|
0,
|
||||||
interior: X1(xcm::latest::prelude::AccountId32 {
|
[xcm::latest::prelude::AccountId32 {
|
||||||
network: None,
|
network: None,
|
||||||
id: [
|
id: [
|
||||||
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159,
|
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159,
|
||||||
214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165,
|
214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165,
|
||||||
109, 162, 125,
|
109, 162, 125,
|
||||||
],
|
],
|
||||||
}),
|
}],
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
SetTopic([
|
SetTopic([
|
||||||
116, 82, 194, 132, 171, 114, 217, 165, 23, 37, 161, 177, 165, 179, 247, 114,
|
116, 82, 194, 132, 171, 114, 217, 165, 23, 37, 161, 177, 165, 179, 247, 114,
|
||||||
@@ -618,10 +610,7 @@ where
|
|||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
DepositAsset {
|
DepositAsset { assets: Wild(All), beneficiary: Location::new(1, [Parachain(1000)]) },
|
||||||
assets: Wild(All),
|
|
||||||
beneficiary: MultiLocation { parents: 1, interior: X1(Parachain(1000)) },
|
|
||||||
},
|
|
||||||
SetTopic([
|
SetTopic([
|
||||||
36, 224, 250, 165, 82, 195, 67, 110, 160, 170, 140, 87, 217, 62, 201, 164, 42, 98, 219,
|
36, 224, 250, 165, 82, 195, 67, 110, 160, 170, 140, 87, 217, 62, 201, 164, 42, 98, 219,
|
||||||
157, 124, 105, 248, 25, 131, 218, 199, 36, 109, 173, 100, 122,
|
157, 124, 105, 248, 25, 131, 218, 199, 36, 109, 173, 100, 122,
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ use xcm_executor::traits::{validate_export, ExportXcm};
|
|||||||
|
|
||||||
pub fn prepare_inbound_xcm<InnerXcmRuntimeCall>(
|
pub fn prepare_inbound_xcm<InnerXcmRuntimeCall>(
|
||||||
xcm_message: Xcm<InnerXcmRuntimeCall>,
|
xcm_message: Xcm<InnerXcmRuntimeCall>,
|
||||||
destination: InteriorMultiLocation,
|
destination: InteriorLocation,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
let location = xcm::VersionedInteriorMultiLocation::V3(destination);
|
let location = xcm::VersionedInteriorLocation::V4(destination);
|
||||||
let xcm = xcm::VersionedXcm::<InnerXcmRuntimeCall>::V3(xcm_message);
|
let xcm = xcm::VersionedXcm::<InnerXcmRuntimeCall>::V4(xcm_message);
|
||||||
// this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor
|
// this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor
|
||||||
// or public fields, so just tuple
|
// or public fields, so just tuple
|
||||||
// (double encoding, because `.encode()` is called on original Xcm BLOB when it is pushed
|
// (double encoding, because `.encode()` is called on original Xcm BLOB when it is pushed
|
||||||
@@ -101,7 +101,7 @@ macro_rules! grab_haul_blob (
|
|||||||
/// which are transferred over bridge.
|
/// which are transferred over bridge.
|
||||||
pub(crate) fn simulate_message_exporter_on_bridged_chain<
|
pub(crate) fn simulate_message_exporter_on_bridged_chain<
|
||||||
SourceNetwork: Get<NetworkId>,
|
SourceNetwork: Get<NetworkId>,
|
||||||
DestinationNetwork: Get<MultiLocation>,
|
DestinationNetwork: Get<Location>,
|
||||||
DestinationVersion: GetVersion,
|
DestinationVersion: GetVersion,
|
||||||
>(
|
>(
|
||||||
(destination_network, destination_junctions): (NetworkId, Junctions),
|
(destination_network, destination_junctions): (NetworkId, Junctions),
|
||||||
@@ -109,8 +109,8 @@ pub(crate) fn simulate_message_exporter_on_bridged_chain<
|
|||||||
grab_haul_blob!(GrabbingHaulBlob, GRABBED_HAUL_BLOB_PAYLOAD);
|
grab_haul_blob!(GrabbingHaulBlob, GRABBED_HAUL_BLOB_PAYLOAD);
|
||||||
|
|
||||||
// lets pretend that some parachain on bridged chain exported the message
|
// lets pretend that some parachain on bridged chain exported the message
|
||||||
let universal_source_on_bridged_chain =
|
let universal_source_on_bridged_chain: Junctions =
|
||||||
X2(GlobalConsensus(SourceNetwork::get()), Parachain(5678));
|
[GlobalConsensus(SourceNetwork::get()), Parachain(5678)].into();
|
||||||
let channel = 1_u32;
|
let channel = 1_u32;
|
||||||
|
|
||||||
// simulate XCM message export
|
// simulate XCM message export
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ pub type AmbassadorSalaryInstance = pallet_salary::Instance2;
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
// The interior location on AssetHub for the paying account. This is the Ambassador Salary
|
// The interior location on AssetHub for the paying account. This is the Ambassador Salary
|
||||||
// pallet instance (which sits at index 74). This sovereign account will need funding.
|
// pallet instance (which sits at index 74). This sovereign account will need funding.
|
||||||
pub AmbassadorSalaryLocation: InteriorMultiLocation = PalletInstance(74).into();
|
pub AmbassadorSalaryLocation: InteriorLocation = PalletInstance(74).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`PayOverXcm`] setup to pay the Ambassador salary on the AssetHub in WND.
|
/// [`PayOverXcm`] setup to pay the Ambassador salary on the AssetHub in WND.
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ use parachains_common::{
|
|||||||
westend::{account, currency::GRAND},
|
westend::{account, currency::GRAND},
|
||||||
};
|
};
|
||||||
use polkadot_runtime_common::impls::{
|
use polkadot_runtime_common::impls::{
|
||||||
LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter,
|
LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
|
||||||
};
|
};
|
||||||
use sp_arithmetic::Permill;
|
use sp_arithmetic::Permill;
|
||||||
use sp_core::{ConstU128, ConstU32};
|
use sp_core::{ConstU128, ConstU32};
|
||||||
@@ -202,7 +202,7 @@ pub type FellowshipSalaryInstance = pallet_salary::Instance1;
|
|||||||
parameter_types! {
|
parameter_types! {
|
||||||
// The interior location on AssetHub for the paying account. This is the Fellowship Salary
|
// The interior location on AssetHub for the paying account. This is the Fellowship Salary
|
||||||
// pallet instance (which sits at index 64). This sovereign account will need funding.
|
// pallet instance (which sits at index 64). This sovereign account will need funding.
|
||||||
pub Interior: InteriorMultiLocation = PalletInstance(64).into();
|
pub Interior: InteriorLocation = PalletInstance(64).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
const USDT_UNITS: u128 = 1_000_000;
|
const USDT_UNITS: u128 = 1_000_000;
|
||||||
@@ -250,7 +250,7 @@ parameter_types! {
|
|||||||
pub const MaxBalance: Balance = Balance::max_value();
|
pub const MaxBalance: Balance = Balance::max_value();
|
||||||
// The asset's interior location for the paying account. This is the Fellowship Treasury
|
// The asset's interior location for the paying account. This is the Fellowship Treasury
|
||||||
// pallet instance (which sits at index 65).
|
// pallet instance (which sits at index 65).
|
||||||
pub FellowshipTreasuryInteriorLocation: InteriorMultiLocation = PalletInstance(65).into();
|
pub FellowshipTreasuryInteriorLocation: InteriorLocation = PalletInstance(65).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
@@ -269,10 +269,10 @@ pub type FellowshipTreasuryPaymaster = PayOverXcm<
|
|||||||
crate::xcm_config::XcmRouter,
|
crate::xcm_config::XcmRouter,
|
||||||
crate::PolkadotXcm,
|
crate::PolkadotXcm,
|
||||||
ConstU32<{ 6 * HOURS }>,
|
ConstU32<{ 6 * HOURS }>,
|
||||||
VersionedMultiLocation,
|
VersionedLocation,
|
||||||
VersionedLocatableAsset,
|
VersionedLocatableAsset,
|
||||||
LocatableAssetConverter,
|
LocatableAssetConverter,
|
||||||
VersionedMultiLocationConverter,
|
VersionedLocationConverter,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;
|
pub type FellowshipTreasuryInstance = pallet_treasury::Instance1;
|
||||||
@@ -327,7 +327,7 @@ impl pallet_treasury::Config<FellowshipTreasuryInstance> for Runtime {
|
|||||||
>,
|
>,
|
||||||
>;
|
>;
|
||||||
type AssetKind = VersionedLocatableAsset;
|
type AssetKind = VersionedLocatableAsset;
|
||||||
type Beneficiary = VersionedMultiLocation;
|
type Beneficiary = VersionedLocation;
|
||||||
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
|
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
|
||||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||||
type Paymaster = FellowshipTreasuryPaymaster;
|
type Paymaster = FellowshipTreasuryPaymaster;
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||||
pub FeeAssetId: AssetId = Concrete(xcm_config::WndLocation::get());
|
pub FeeAssetId: AssetId = AssetId(xcm_config::WndLocation::get());
|
||||||
/// The base fee for the message delivery fees.
|
/// The base fee for the message delivery fees.
|
||||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||||
}
|
}
|
||||||
@@ -974,28 +974,28 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||||
fn reachable_dest() -> Option<MultiLocation> {
|
fn reachable_dest() -> Option<Location> {
|
||||||
Some(Parent.into())
|
Some(Parent.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Relay/native token can be teleported between Collectives and Relay.
|
// Relay/native token can be teleported between Collectives and Relay.
|
||||||
Some((
|
Some((
|
||||||
MultiAsset {
|
Asset {
|
||||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||||
id: Concrete(Parent.into())
|
id: AssetId(Parent.into())
|
||||||
}.into(),
|
}.into(),
|
||||||
Parent.into(),
|
Parent.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||||
// Reserve transfers are disabled on Collectives.
|
// Reserve transfers are disabled on Collectives.
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_up_complex_asset_transfer(
|
fn set_up_complex_asset_transfer(
|
||||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||||
// Collectives only supports teleports to system parachain.
|
// Collectives only supports teleports to system parachain.
|
||||||
// Relay/native token can be teleported between Collectives and Relay.
|
// Relay/native token can be teleported between Collectives and Relay.
|
||||||
let native_location = Parent.into();
|
let native_location = Parent.into();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use super::{
|
|||||||
TransactionByteFee, WeightToFee, WestendTreasuryAccount, XcmpQueue,
|
TransactionByteFee, WeightToFee, WestendTreasuryAccount, XcmpQueue,
|
||||||
};
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
match_types, parameter_types,
|
parameter_types,
|
||||||
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
@@ -51,17 +51,17 @@ use xcm_builder::{
|
|||||||
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const WndLocation: MultiLocation = MultiLocation::parent();
|
pub const WndLocation: Location = Location::parent();
|
||||||
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
|
||||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||||
pub UniversalLocation: InteriorMultiLocation =
|
pub UniversalLocation: InteriorLocation =
|
||||||
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
|
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||||
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
|
||||||
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
|
pub const GovernanceLocation: Location = Location::parent();
|
||||||
pub const FellowshipAdminBodyId: BodyId = BodyId::Index(xcm_constants::body::FELLOWSHIP_ADMIN_INDEX);
|
pub const FellowshipAdminBodyId: BodyId = BodyId::Index(xcm_constants::body::FELLOWSHIP_ADMIN_INDEX);
|
||||||
|
pub AssetHub: Location = (Parent, Parachain(1000)).into();
|
||||||
pub const TreasurerBodyId: BodyId = BodyId::Index(xcm_constants::body::TREASURER_INDEX);
|
pub const TreasurerBodyId: BodyId = BodyId::Index(xcm_constants::body::TREASURER_INDEX);
|
||||||
pub AssetHub: MultiLocation = (Parent, Parachain(1000)).into();
|
|
||||||
pub AssetHubUsdtId: AssetId = (PalletInstance(50), GeneralIndex(1984)).into();
|
pub AssetHubUsdtId: AssetId = (PalletInstance(50), GeneralIndex(1984)).into();
|
||||||
pub UsdtAssetHub: LocatableAssetId = LocatableAssetId {
|
pub UsdtAssetHub: LocatableAssetId = LocatableAssetId {
|
||||||
location: AssetHub::get(),
|
location: AssetHub::get(),
|
||||||
@@ -73,7 +73,7 @@ parameter_types! {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
|
||||||
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
|
||||||
/// `Transact` in order to determine the dispatch Origin.
|
/// `Transact` in order to determine the dispatch Origin.
|
||||||
pub type LocationToAccountId = (
|
pub type LocationToAccountId = (
|
||||||
@@ -92,7 +92,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
|||||||
Balances,
|
Balances,
|
||||||
// Use this currency when it is a fungible asset matching the given location or name:
|
// Use this currency when it is a fungible asset matching the given location or name:
|
||||||
IsConcrete<WndLocation>,
|
IsConcrete<WndLocation>,
|
||||||
// Convert an XCM MultiLocation into a local account id:
|
// Convert an XCM Location into a local account id:
|
||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||||
AccountId,
|
AccountId,
|
||||||
@@ -136,11 +136,11 @@ parameter_types! {
|
|||||||
pub const FellowsBodyId: BodyId = BodyId::Technical;
|
pub const FellowsBodyId: BodyId = BodyId::Technical;
|
||||||
}
|
}
|
||||||
|
|
||||||
match_types! {
|
pub struct ParentOrParentsPlurality;
|
||||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
impl Contains<Location> for ParentOrParentsPlurality {
|
||||||
MultiLocation { parents: 1, interior: Here } |
|
fn contains(location: &Location) -> bool {
|
||||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||||
@@ -292,7 +292,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type Aliasers = Nothing;
|
type Aliasers = Nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a local signed origin into an XCM multilocation.
|
/// Converts a local signed origin into an XCM location.
|
||||||
/// Forms the basis for local origins sending/executing XCMs.
|
/// Forms the basis for local origins sending/executing XCMs.
|
||||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||||
|
|
||||||
@@ -310,10 +310,10 @@ pub type XcmRouter = WithUniqueTopic<(
|
|||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
|
pub ReachableDest: Option<Location> = Some(Parent.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type to convert the Fellows origin to a Plurality `MultiLocation` value.
|
/// Type to convert the Fellows origin to a Plurality `Location` value.
|
||||||
pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, FellowsBodyId>;
|
pub type FellowsToPlurality = OriginToPluralityVoice<RuntimeOrigin, Fellows, FellowsBodyId>;
|
||||||
|
|
||||||
impl pallet_xcm::Config for Runtime {
|
impl pallet_xcm::Config for Runtime {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user