mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 00:31: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
@@ -37,10 +37,10 @@ use xcm_executor::traits::{validate_export, ExportXcm};
|
||||
|
||||
pub fn prepare_inbound_xcm<InnerXcmRuntimeCall>(
|
||||
xcm_message: Xcm<InnerXcmRuntimeCall>,
|
||||
destination: InteriorMultiLocation,
|
||||
destination: InteriorLocation,
|
||||
) -> Vec<u8> {
|
||||
let location = xcm::VersionedInteriorMultiLocation::V3(destination);
|
||||
let xcm = xcm::VersionedXcm::<InnerXcmRuntimeCall>::V3(xcm_message);
|
||||
let location = xcm::VersionedInteriorLocation::V4(destination);
|
||||
let xcm = xcm::VersionedXcm::<InnerXcmRuntimeCall>::V4(xcm_message);
|
||||
// this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor
|
||||
// or public fields, so just tuple
|
||||
// (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.
|
||||
pub(crate) fn simulate_message_exporter_on_bridged_chain<
|
||||
SourceNetwork: Get<NetworkId>,
|
||||
DestinationNetwork: Get<MultiLocation>,
|
||||
DestinationNetwork: Get<Location>,
|
||||
DestinationVersion: GetVersion,
|
||||
>(
|
||||
(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);
|
||||
|
||||
// lets pretend that some parachain on bridged chain exported the message
|
||||
let universal_source_on_bridged_chain =
|
||||
X2(GlobalConsensus(SourceNetwork::get()), Parachain(5678));
|
||||
let universal_source_on_bridged_chain: Junctions =
|
||||
[GlobalConsensus(SourceNetwork::get()), Parachain(5678)].into();
|
||||
let channel = 1_u32;
|
||||
|
||||
// simulate XCM message export
|
||||
|
||||
Reference in New Issue
Block a user