Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

XCM v1 #2815

Merged
merged 87 commits into from
Aug 6, 2021
Merged

XCM v1 #2815

Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3e15173
MultiAsset TWO
gavofyork Apr 4, 2021
12054df
Merge remote-tracking branch 'origin/master' into gav-multiasset-2
gavofyork Jul 29, 2021
ee80e03
Draft next MultiAsset API.
gavofyork Jul 30, 2021
2661b91
XCM core builds
gavofyork Jul 30, 2021
6fc030e
XCM Executor builds
gavofyork Jul 30, 2021
8017453
XCM Builder builds
gavofyork Jul 31, 2021
5445d06
API changes making their way throughout
gavofyork Aug 1, 2021
958d79a
Some TODOs
gavofyork Aug 1, 2021
7d47d21
Further build fixes
gavofyork Aug 1, 2021
bb5bf44
Basic compile builds
gavofyork Aug 1, 2021
acef319
First test fixed
gavofyork Aug 1, 2021
7d700b6
All executor tests fixed
gavofyork Aug 1, 2021
3e62aa3
Typo
gavofyork Aug 1, 2021
ca477f0
Optimize subsume_assets and add test
gavofyork Aug 1, 2021
3cc428f
Optimize checked_sub
gavofyork Aug 1, 2021
099aea7
XCM Builder first test fixed
gavofyork Aug 1, 2021
5158442
Fix builder tests
gavofyork Aug 2, 2021
6814aa8
Fix doc test
gavofyork Aug 2, 2021
529a931
fix some doc tests
gavofyork Aug 2, 2021
3e93d54
spelling
gavofyork Aug 2, 2021
f42b3ab
named fields for AllOf
gavofyork Aug 2, 2021
97051b2
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
84b79cf
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
1f98872
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
0cc61de
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
4f57497
Merge branch 'master' into gav-multiasset-2-reformat
gavofyork Aug 3, 2021
723990c
Reformat
gavofyork Aug 3, 2021
9e2e009
Move to XCM version 1
gavofyork Aug 3, 2021
00ca37b
Spelling
gavofyork Aug 3, 2021
768c96a
warnings
gavofyork Aug 3, 2021
2936419
Replace some more v0->v1s
gavofyork Aug 3, 2021
015fff2
warnings
gavofyork Aug 3, 2021
b5fe03e
format
gavofyork Aug 3, 2021
608a212
Add max_assets param
gavofyork Aug 3, 2021
dee3be5
building
gavofyork Aug 3, 2021
a6eaaa2
test fixes
gavofyork Aug 3, 2021
f58a659
tests
gavofyork Aug 3, 2021
8a78100
another test
gavofyork Aug 3, 2021
6eb75ad
final test
gavofyork Aug 3, 2021
9d0b9f9
tests
gavofyork Aug 4, 2021
b5b63c8
Rename Null -> Here
gavofyork Aug 4, 2021
e9dbc72
Introduce
gavofyork Aug 4, 2021
36ccb47
More ergonomics
gavofyork Aug 4, 2021
de33d7d
More ergonomics
gavofyork Aug 4, 2021
7ff0493
test fix
gavofyork Aug 4, 2021
d43d987
Merge branch 'gav-multiasset-2' into gav-max-assets
gavofyork Aug 4, 2021
84c44f8
test fixes
gavofyork Aug 4, 2021
7d52b93
docs
gavofyork Aug 4, 2021
51c7d05
BuyExecution includes
gavofyork Aug 4, 2021
851b00e
Fix XCM extrinsics
gavofyork Aug 4, 2021
20bb714
fmt
gavofyork Aug 4, 2021
3f85ebd
Make Vec<MultiAsset>/MultiAssets conversions safe
gavofyork Aug 4, 2021
61a2231
More MultiAssets conversion safety
gavofyork Aug 4, 2021
7646446
Merge remote-tracking branch 'origin/master' into gav-multiasset-2
gavofyork Aug 4, 2021
8644265
spelling
gavofyork Aug 4, 2021
1e75953
fix doc test
gavofyork Aug 4, 2021
669dcb0
Apply suggestions from code review
gavofyork Aug 5, 2021
767bdb5
Apply suggestions from code review
gavofyork Aug 5, 2021
ec2c1e9
fmt
gavofyork Aug 5, 2021
740f6f3
Add v0, remove VersionedMultiAsset
gavofyork Aug 5, 2021
9f8606d
Remove VersionedMultiLocation
gavofyork Aug 5, 2021
1c4a89a
Update xcm/src/v1/order.rs
gavofyork Aug 5, 2021
d3fb090
Update xcm/src/v1/mod.rs
gavofyork Aug 5, 2021
a5c2bde
XCM v0 backwards compatibility
gavofyork Aug 5, 2021
2d0479a
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 5, 2021
7130ed7
Full compatibility
gavofyork Aug 5, 2021
efa012d
fmt
gavofyork Aug 5, 2021
a0658e1
Merge branch 'master' into gav-multiasset-2
gavofyork Aug 5, 2021
e33710b
Update xcm/pallet-xcm/src/lib.rs
shawntabrizi Aug 5, 2021
a31887c
Merge branch 'master' into gav-multiasset-2
gavofyork Aug 5, 2021
fe59886
Update xcm/src/v0/order.rs
gavofyork Aug 5, 2021
d2bd1e0
Tweaks to versioning system
gavofyork Aug 6, 2021
089d90c
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 6, 2021
d9ff88c
Fixes
gavofyork Aug 6, 2021
b40668e
fmt
gavofyork Aug 6, 2021
53baf5f
Update xcm/xcm-executor/src/assets.rs
gavofyork Aug 6, 2021
0309b2d
Update xcm/xcm-executor/src/assets.rs
gavofyork Aug 6, 2021
0383e58
Grumbles
gavofyork Aug 6, 2021
277f705
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 6, 2021
3eee7b3
Update xcm/src/v1/multiasset.rs
gavofyork Aug 6, 2021
c61cd59
fmt
gavofyork Aug 6, 2021
ac31e7e
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 6, 2021
0547932
Update xcm/src/v1/multiasset.rs
gavofyork Aug 6, 2021
18dca5f
Update xcm/src/v1/multiasset.rs
gavofyork Aug 6, 2021
48e3eba
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 6, 2021
04e32dc
Fixes
gavofyork Aug 6, 2021
c234c51
Formatting
gavofyork Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,18 @@ pub enum VersionedMultiLocation {
pub enum VersionedMultiAsset {
V0(v0::MultiAsset),
}

impl From<v0::MultiAsset> for VersionedMultiAsset {
fn from(x: v0::MultiAsset) -> Self {
VersionedMultiAsset::V0(x)
}
}

impl core::convert::TryFrom<VersionedMultiAsset> for v0::MultiAsset {
type Error = ();
fn try_from(x: VersionedMultiAsset) -> core::result::Result<Self, ()> {
match x {
VersionedMultiAsset::V0(x) => Ok(x),
}
}
}
31 changes: 21 additions & 10 deletions xcm/src/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,41 @@ use core::{result, convert::TryFrom, fmt::Debug};
use derivative::Derivative;
use alloc::vec::Vec;
use parity_scale_codec::{self, Encode, Decode};
use crate::{VersionedMultiAsset, DoubleEncoded, VersionedXcm};
use crate::{DoubleEncoded, VersionedXcm};

mod junction;
mod multi_asset;
mod multi_location;
mod order;
mod traits;
pub mod multiasset; // the new multiasset.

pub use junction::{Junction, NetworkId, BodyId, BodyPart};
pub use multi_asset::{MultiAsset, AssetInstance};
pub use multiasset::{
AssetId, AssetInstance, MultiAsset, MultiAssets, MultiAssetFilter, Fungibility, WildMultiAsset, WildFungibility
};
pub use multi_location::MultiLocation;
pub use order::Order;
pub use traits::{Error, Result, SendXcm, ExecuteXcm, Outcome};

/// A prelude for importing all types typically used when interacting with XCM messages.
pub mod prelude {
pub use super::junction::{Junction::*, NetworkId, BodyId, BodyPart};
pub use super::multi_asset::{MultiAsset::{self, *}, AssetInstance::{self, *}};
pub use super::multiasset::{
AssetId, MultiAssets, MultiAsset,
AssetInstance::{self, *},
MultiAssetFilter::{self, *},
Fungibility::{self, *},
WildMultiAsset::{self, *},
WildFungibility::{self, Fungible as WildFungible, NonFungible as WildNonFungible},
};
pub use super::multi_location::MultiLocation::{self, *};
pub use super::order::Order::{self, *};
pub use super::traits::{Error as XcmError, Result as XcmResult, SendXcm, ExecuteXcm, Outcome};
pub use super::{Xcm::{self, *}, OriginKind};
}

// TODO: #2841 #XCMENCODE Efficient encodings for Vec<MultiAsset>, Vec<Order>, using initial byte values 128+ to encode
// TODO: #2841 #XCMENCODE Efficient encodings for MultiAssets, Vec<Order>, using initial byte values 128+ to encode
// the number of items in the vector.

/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`.
Expand Down Expand Up @@ -73,7 +84,7 @@ pub enum OriginKind {
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
pub enum Response {
/// Some assets.
Assets(Vec<MultiAsset>),
Assets(MultiAssets),
}

/// Cross-Consensus Message: A message from one consensus system to another.
Expand All @@ -99,7 +110,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 0)]
WithdrawAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
WithdrawAsset { assets: MultiAssets, effects: Vec<Order<Call>> },

/// Asset(s) (`assets`) have been received into the ownership of this system on the `origin` system.
///
Expand All @@ -116,7 +127,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 1)]
ReserveAssetDeposit { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
ReserveAssetDeposit { assets: MultiAssets, effects: Vec<Order<Call>> },

/// Asset(s) (`assets`) have been destroyed on the `origin` system and equivalent assets should be
/// created on this system.
Expand All @@ -134,7 +145,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 2)]
TeleportAsset { assets: Vec<MultiAsset>, effects: Vec<Order<Call>> },
TeleportAsset { assets: MultiAssets, effects: Vec<Order<Call>> },

/// Indication of the contents of the holding account corresponding to the `QueryHolding` order of `query_id`.
///
Expand All @@ -161,7 +172,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 4)]
TransferAsset { assets: Vec<MultiAsset>, dest: MultiLocation },
TransferAsset { assets: MultiAssets, dest: MultiLocation },

/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place equivalent assets under the
/// ownership of `dest` within this consensus system.
Expand All @@ -179,7 +190,7 @@ pub enum Xcm<Call> {
///
/// Errors:
#[codec(index = 5)]
TransferReserveAsset { assets: Vec<MultiAsset>, dest: MultiLocation, effects: Vec<Order<()>> },
TransferReserveAsset { assets: MultiAssets, dest: MultiLocation, effects: Vec<Order<()>> },

/// Apply the encoded transaction `call`, whose dispatch-origin should be `origin` as expressed by the kind
/// of origin `origin_type`.
Expand Down
44 changes: 1 addition & 43 deletions xcm/src/v0/multi_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,10 @@

//! Cross-Consensus Message format data structures.

use core::{result, convert::TryFrom};
use alloc::vec::Vec;

use parity_scale_codec::{self, Encode, Decode};
use super::{MultiLocation, VersionedMultiAsset};

/// A general identifier for an instance of a non-fungible asset class.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)]
pub enum AssetInstance {
/// Undefined - used if the NFA class has only one instance.
Undefined,

/// A compact index. Technically this could be greater than `u128`, but this implementation supports only
/// values up to `2**128 - 1`.
Index { #[codec(compact)] id: u128 },

/// A 4-byte fixed-length datum.
Array4([u8; 4]),

/// An 8-byte fixed-length datum.
Array8([u8; 8]),

/// A 16-byte fixed-length datum.
Array16([u8; 16]),

/// A 32-byte fixed-length datum.
Array32([u8; 32]),

/// An arbitrary piece of data. Use only when necessary.
Blob(Vec<u8>),
}
use super::{MultiLocation, AssetInstance};

/// A single general identifier for an asset.
///
Expand Down Expand Up @@ -306,21 +279,6 @@ impl MultiAsset {
}
}

impl From<MultiAsset> for VersionedMultiAsset {
fn from(x: MultiAsset) -> Self {
VersionedMultiAsset::V0(x)
}
}

impl TryFrom<VersionedMultiAsset> for MultiAsset {
type Error = ();
fn try_from(x: VersionedMultiAsset) -> result::Result<Self, ()> {
match x {
VersionedMultiAsset::V0(x) => Ok(x),
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading