# 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:
Francisco Aguirre
2024-01-16 19:18:04 +01:00
committed by GitHub
parent ec7bfae00a
commit 8428f678fe
255 changed files with 12425 additions and 6726 deletions
@@ -3,11 +3,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
use snowbridge_core::AgentId;
use xcm::VersionedMultiLocation;
use xcm::VersionedLocation;
sp_api::decl_runtime_apis! {
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
use snowbridge_core::AgentId;
use xcm::{prelude::*, VersionedMultiLocation};
use xcm::{prelude::*, VersionedLocation};
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
Runtime: Config,
{
let location: MultiLocation = location.try_into().ok()?;
let location: Location = location.try_into().ok()?;
agent_id_of::<Runtime>(&location).ok()
}
@@ -63,7 +63,7 @@ mod benchmarks {
#[benchmark]
fn create_agent() -> Result<(), BenchmarkError> {
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);
fund_sovereign_account::<T>(origin_para_id.into())?;
@@ -76,7 +76,7 @@ mod benchmarks {
#[benchmark]
fn create_channel() -> Result<(), BenchmarkError> {
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);
fund_sovereign_account::<T>(origin_para_id.into())?;
@@ -91,7 +91,7 @@ mod benchmarks {
#[benchmark]
fn update_channel() -> Result<(), BenchmarkError> {
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);
fund_sovereign_account::<T>(origin_para_id.into())?;
SnowbridgeControl::<T>::create_agent(origin.clone())?;
@@ -106,7 +106,7 @@ mod benchmarks {
#[benchmark]
fn force_update_channel() -> Result<(), BenchmarkError> {
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 channel_id: ChannelId = ParaId::from(origin_para_id).into();
@@ -123,7 +123,7 @@ mod benchmarks {
#[benchmark]
fn transfer_native_from_agent() -> Result<(), BenchmarkError> {
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);
fund_sovereign_account::<T>(origin_para_id.into())?;
SnowbridgeControl::<T>::create_agent(origin.clone())?;
@@ -138,12 +138,12 @@ mod benchmarks {
#[benchmark]
fn force_transfer_native_from_agent() -> Result<(), BenchmarkError> {
let origin_para_id = 2000;
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
let origin = T::Helper::make_xcm_origin(origin_location);
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
let origin = T::Helper::make_xcm_origin(origin_location.clone());
fund_sovereign_account::<T>(origin_para_id.into())?;
SnowbridgeControl::<T>::create_agent(origin.clone())?;
let versioned_location: VersionedMultiLocation = origin_location.into();
let versioned_location: VersionedLocation = origin_location.into();
#[extrinsic_call]
_(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>>;
/// 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
T: Config,
{
match location {
MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } => {
match location.unpack() {
(1, [Parachain(para_id)]) => {
let agent_id = agent_id_of::<T>(location)?;
Ok(((*para_id).into(), agent_id))
},
@@ -101,7 +101,7 @@ where
}
/// 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())
}
@@ -110,7 +110,7 @@ pub trait BenchmarkHelper<O>
where
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
@@ -145,9 +145,9 @@ pub mod pallet {
type OutboundQueue: SendMessage<Balance = BalanceOf<Self>>;
/// 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>;
/// Token reserved for control operations
@@ -180,7 +180,7 @@ pub mod pallet {
},
/// An CreateAgent message was sent to the Gateway
CreateAgent {
location: Box<MultiLocation>,
location: Box<Location>,
agent_id: AgentId,
},
/// An CreateChannel message was sent to the Gateway
@@ -299,7 +299,7 @@ pub mod pallet {
///
/// Fee required: No
///
/// - `origin`: Must be `MultiLocation`
/// - `origin`: Must be `Location`
#[pallet::call_index(1)]
#[pallet::weight((T::WeightInfo::set_operating_mode(), DispatchClass::Operational))]
pub fn set_operating_mode(origin: OriginFor<T>, mode: OperatingMode) -> DispatchResult {
@@ -342,11 +342,11 @@ pub mod pallet {
///
/// Fee required: Yes
///
/// - `origin`: Must be `MultiLocation` of a sibling parachain
/// - `origin`: Must be `Location` of a sibling parachain
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::create_agent())]
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
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.
///
/// - `origin`: Must be `MultiLocation`
/// - `origin`: Must be `Location`
/// - `mode`: Initial operating mode of the channel
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::create_channel())]
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
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.
///
/// - `origin`: Must be `MultiLocation`
/// - `origin`: Must be `Location`
/// - `mode`: Initial operating mode of the channel
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::update_channel())]
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
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.
///
/// - `origin`: Must be `MultiLocation`
/// - `origin`: Must be `Location`
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::transfer_native_from_agent())]
pub fn transfer_native_from_agent(
@@ -469,7 +469,7 @@ pub mod pallet {
recipient: H160,
amount: u128,
) -> 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
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())]
pub fn force_transfer_native_from_agent(
origin: OriginFor<T>,
location: Box<VersionedMultiLocation>,
location: Box<VersionedLocation>,
recipient: H160,
amount: u128,
) -> DispatchResult {
ensure_root(origin)?;
// 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)?;
let (_, agent_id) =
ensure_sibling::<T>(&location).map_err(|_| Error::<T>::InvalidLocation)?;
@@ -621,8 +621,8 @@ pub mod pallet {
/// Initializes agents and channels.
pub fn initialize(para_id: ParaId, asset_hub_para_id: ParaId) -> Result<(), DispatchError> {
// Asset Hub
let asset_hub_location: MultiLocation =
ParentThen(X1(Parachain(asset_hub_para_id.into()))).into();
let asset_hub_location: Location =
ParentThen(Parachain(asset_hub_para_id.into()).into()).into();
let asset_hub_agent_id = agent_id_of::<T>(&asset_hub_location)?;
let asset_hub_channel_id: ChannelId = asset_hub_para_id.into();
Agents::<T>::insert(asset_hub_agent_id, ());
@@ -632,7 +632,7 @@ pub mod pallet {
);
// 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
Agents::<T>::insert(bridge_hub_agent_id, ());
@@ -49,22 +49,22 @@ mod pallet_xcm_origin {
// Insert this custom Origin into the aggregate RuntimeOrigin
#[pallet::origin]
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct Origin(pub MultiLocation);
pub struct Origin(pub Location);
impl From<MultiLocation> for Origin {
fn from(location: MultiLocation) -> Origin {
impl From<Location> for Origin {
fn from(location: Location) -> Origin {
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
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
O::PalletsOrigin: From<Origin> + TryInto<Origin, Error = O::PalletsOrigin>,
{
type Success = MultiLocation;
type Success = Location;
fn try_origin(outer: O) -> Result<Self::Success, O> {
outer.try_with_caller(|caller| {
@@ -77,7 +77,7 @@ mod pallet_xcm_origin {
#[cfg(feature = "runtime-benchmarks")]
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 AnyNetwork: Option<NetworkId> = None;
pub const RelayNetwork: Option<NetworkId> = Some(NetworkId::Kusama);
pub const RelayLocation: MultiLocation = MultiLocation::parent();
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(1013));
pub const RelayLocation: Location = Location::parent();
pub UniversalLocation: InteriorLocation =
[GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(1013)].into();
}
pub const DOT: u128 = 10_000_000_000;
@@ -211,7 +211,7 @@ parameter_types! {
#[cfg(feature = "runtime-benchmarks")]
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))
}
}
@@ -260,11 +260,11 @@ pub fn new_test_ext(genesis_build: bool) -> sp_io::TestExternalities {
// Test helpers
pub fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
pub fn make_xcm_origin(location: Location) -> RuntimeOrigin {
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)
.expect("convert location")
}
@@ -11,8 +11,8 @@ use sp_runtime::{AccountId32, DispatchError::BadOrigin, TokenError};
fn create_agent() {
new_test_ext(true).execute_with(|| {
let origin_para_id = 2000;
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para_id)) };
let agent_id = make_agent_id(origin_location);
let origin_location = Location::new(1, [Parachain(origin_para_id)]);
let agent_id = make_agent_id(origin_location.clone());
let sovereign_account = sibling_sovereign_account::<Test>(origin_para_id.into());
// fund sovereign account of origin
@@ -30,7 +30,7 @@ fn create_agent() {
#[test]
fn test_agent_for_here() {
new_test_ext(true).execute_with(|| {
let origin_location = MultiLocation::here();
let origin_location = Location::here();
let agent_id = make_agent_id(origin_location);
assert_eq!(
agent_id,
@@ -42,7 +42,7 @@ fn test_agent_for_here() {
#[test]
fn create_agent_fails_on_funds_unavailable() {
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);
// Reset balance of sovereign_account to zero so to trigger the FundsUnavailable error
let sovereign_account = sibling_sovereign_account::<Test>(2000.into());
@@ -56,19 +56,16 @@ fn create_agent_bad_origin() {
new_test_ext(true).execute_with(|| {
// relay chain location not allowed
assert_noop!(
EthereumSystem::create_agent(make_xcm_origin(MultiLocation {
parents: 1,
interior: Here,
})),
EthereumSystem::create_agent(make_xcm_origin(Location::new(1, [],))),
BadOrigin,
);
// local account location not allowed
assert_noop!(
EthereumSystem::create_agent(make_xcm_origin(MultiLocation {
parents: 0,
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
})),
EthereumSystem::create_agent(make_xcm_origin(Location::new(
0,
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
))),
BadOrigin,
);
@@ -243,7 +240,7 @@ fn set_token_transfer_fees_invalid() {
fn create_channel() {
new_test_ext(true).execute_with(|| {
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 origin = make_xcm_origin(origin_location);
@@ -259,7 +256,7 @@ fn create_channel() {
fn create_channel_fail_already_exists() {
new_test_ext(true).execute_with(|| {
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 origin = make_xcm_origin(origin_location);
@@ -282,7 +279,7 @@ fn create_channel_bad_origin() {
// relay chain location not allowed
assert_noop!(
EthereumSystem::create_channel(
make_xcm_origin(MultiLocation { parents: 1, interior: Here }),
make_xcm_origin(Location::new(1, [])),
OperatingMode::Normal,
),
BadOrigin,
@@ -291,13 +288,10 @@ fn create_channel_bad_origin() {
// child of sibling location not allowed
assert_noop!(
EthereumSystem::create_channel(
make_xcm_origin(MultiLocation {
parents: 1,
interior: X2(
Parachain(2000),
Junction::AccountId32 { network: None, id: [67u8; 32] }
),
}),
make_xcm_origin(Location::new(
1,
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
)),
OperatingMode::Normal,
),
BadOrigin,
@@ -306,10 +300,10 @@ fn create_channel_bad_origin() {
// local account location not allowed
assert_noop!(
EthereumSystem::create_channel(
make_xcm_origin(MultiLocation {
parents: 0,
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
}),
make_xcm_origin(Location::new(
0,
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
)),
OperatingMode::Normal,
),
BadOrigin,
@@ -333,7 +327,7 @@ fn create_channel_bad_origin() {
fn update_channel() {
new_test_ext(true).execute_with(|| {
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 origin = make_xcm_origin(origin_location);
@@ -359,23 +353,17 @@ fn update_channel_bad_origin() {
// relay chain location not allowed
assert_noop!(
EthereumSystem::update_channel(
make_xcm_origin(MultiLocation { parents: 1, interior: Here }),
mode,
),
EthereumSystem::update_channel(make_xcm_origin(Location::new(1, [])), mode,),
BadOrigin,
);
// child of sibling location not allowed
assert_noop!(
EthereumSystem::update_channel(
make_xcm_origin(MultiLocation {
parents: 1,
interior: X2(
Parachain(2000),
Junction::AccountId32 { network: None, id: [67u8; 32] }
),
}),
make_xcm_origin(Location::new(
1,
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
)),
mode,
),
BadOrigin,
@@ -384,10 +372,10 @@ fn update_channel_bad_origin() {
// local account location not allowed
assert_noop!(
EthereumSystem::update_channel(
make_xcm_origin(MultiLocation {
parents: 0,
interior: X1(Junction::AccountId32 { network: None, id: [67u8; 32] }),
}),
make_xcm_origin(Location::new(
0,
[Junction::AccountId32 { network: None, id: [67u8; 32] }],
)),
mode,
),
BadOrigin,
@@ -407,7 +395,7 @@ fn update_channel_bad_origin() {
#[test]
fn update_channel_fails_not_exist() {
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);
// Now try to update it
@@ -422,7 +410,7 @@ fn update_channel_fails_not_exist() {
fn force_update_channel() {
new_test_ext(true).execute_with(|| {
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 origin = make_xcm_origin(origin_location);
@@ -468,8 +456,8 @@ fn force_update_channel_bad_origin() {
#[test]
fn transfer_native_from_agent() {
new_test_ext(true).execute_with(|| {
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
let origin = make_xcm_origin(origin_location);
let origin_location = Location::new(1, [Parachain(2000)]);
let origin = make_xcm_origin(origin_location.clone());
let recipient: H160 = [27u8; 20].into();
let amount = 103435;
@@ -477,7 +465,7 @@ fn transfer_native_from_agent() {
assert_ok!(EthereumSystem::create_agent(origin.clone()));
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),);
System::assert_last_event(RuntimeEvent::EthereumSystem(
@@ -494,13 +482,13 @@ fn transfer_native_from_agent() {
fn force_transfer_native_from_agent() {
new_test_ext(true).execute_with(|| {
let origin = RuntimeOrigin::root();
let location = MultiLocation { parents: 1, interior: X1(Parachain(2000)) };
let versioned_location: Box<VersionedMultiLocation> = Box::new(location.into());
let location = Location::new(1, [Parachain(2000)]);
let versioned_location: Box<VersionedLocation> = Box::new(location.clone().into());
let recipient: H160 = [27u8; 20].into();
let amount = 103435;
// 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(
origin,
@@ -530,13 +518,10 @@ fn force_transfer_native_from_agent_bad_origin() {
EthereumSystem::force_transfer_native_from_agent(
RuntimeOrigin::signed([14; 32].into()),
Box::new(
MultiLocation {
parents: 1,
interior: X2(
Parachain(2000),
Junction::AccountId32 { network: None, id: [67u8; 32] }
),
}
Location::new(
1,
[Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }],
)
.into()
),
recipient,
@@ -571,8 +556,8 @@ fn check_sibling_sovereign_account() {
fn charge_fee_for_create_agent() {
new_test_ext(true).execute_with(|| {
let para_id: u32 = TestParaId::get();
let origin_location = MultiLocation { parents: 1, interior: X1(Parachain(para_id)) };
let origin = make_xcm_origin(origin_location);
let origin_location = Location::new(1, [Parachain(para_id)]);
let origin = make_xcm_origin(origin_location.clone());
let sovereign_account = sibling_sovereign_account::<Test>(para_id.into());
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() {
new_test_ext(true).execute_with(|| {
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 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 sovereign_account = sibling_sovereign_account::<Test>(para_id.into());