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
@@ -23,7 +23,7 @@ use pallet_message_queue::OnQueueChanged;
|
||||
use scale_info::TypeInfo;
|
||||
use snowbridge_core::ChannelId;
|
||||
use sp_std::{marker::PhantomData, prelude::*};
|
||||
use xcm::v3::{Junction, MultiLocation};
|
||||
use xcm::v4::{Junction, Location};
|
||||
|
||||
/// The aggregate origin of an inbound message.
|
||||
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
|
||||
@@ -46,16 +46,16 @@ pub enum AggregateMessageOrigin {
|
||||
Snowbridge(ChannelId),
|
||||
}
|
||||
|
||||
impl From<AggregateMessageOrigin> for MultiLocation {
|
||||
impl From<AggregateMessageOrigin> for Location {
|
||||
fn from(origin: AggregateMessageOrigin) -> Self {
|
||||
use AggregateMessageOrigin::*;
|
||||
match origin {
|
||||
Here => MultiLocation::here(),
|
||||
Parent => MultiLocation::parent(),
|
||||
Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())),
|
||||
Here => Location::here(),
|
||||
Parent => Location::parent(),
|
||||
Sibling(id) => Location::new(1, Junction::Parachain(id.into())),
|
||||
// NOTE: We don't need this conversion for Snowbridge. However we have to
|
||||
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
|
||||
Snowbridge(_) => MultiLocation::default(),
|
||||
Snowbridge(_) => Location::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user