diff --git a/pallets/asset-registry/README.md b/pallets/asset-registry/README.md index c7575bab..85a9fbf2 100644 --- a/pallets/asset-registry/README.md +++ b/pallets/asset-registry/README.md @@ -9,6 +9,8 @@ The `asset-registry` pallet provides a solution to this problem by implementing This trait is used by a struct (`AsAssetMultiLocation`) that is added to the runtime (as an extra XCM primitive) and used as the `xcm_executor::traits::Convert` implementor needed by the `ConvertedConcreteAssetId` of `FungiblesAdapter`. +The pallet needs to be used in conjunction with the [`xcm-primitives` crate](https://github.com/paritytech/trappist/tree/master/primitives/xcm) or an equivalent implementation. + ## Configuration ### Types @@ -51,49 +53,6 @@ Unregister a Reserve Asset. ## How to add `pallet-asset-registry` to a runtime -### XCM Primitives - -Create a new crate called `xcm-primitives` with the following contents on its `lib.rs`: -```rust -#![cfg_attr(not(feature = "std"), no_std)] - -use sp_std::{borrow::Borrow, marker::PhantomData}; -use xcm::latest::MultiLocation; - -pub struct AsAssetMultiLocation( - PhantomData<(AssetId, AssetIdInfoGetter)>, -); -impl xcm_executor::traits::Convert - for AsAssetMultiLocation -where - AssetId: Clone, - AssetIdInfoGetter: AssetMultiLocationGetter, -{ - fn convert_ref(asset_multi_location: impl Borrow) -> Result { - if let Some(asset_id) = AssetIdInfoGetter::get_asset_id(asset_multi_location.borrow().clone().into()) { - Ok(asset_id) - } else { - Err(()) - } - } - - fn reverse_ref(asset_id: impl Borrow) -> Result { - if let Some(asset_multi_location) = - AssetIdInfoGetter::get_asset_multi_location(asset_id.borrow().clone()) - { - Ok(asset_multi_location) - } else { - Err(()) - } - } -} - -pub trait AssetMultiLocationGetter { - fn get_asset_multi_location(asset_id: AssetId) -> Option; - fn get_asset_id(asset_multi_location: MultiLocation) -> Option; -} -``` - ### Runtime's `Cargo.toml` Add `pallet-assets`, `pallet-asset-registry` and `xcm-primitives` to the dependencies: @@ -111,8 +70,10 @@ git = "https://github.com/paritytech/trappist.git" branch = "master" [dependencies.xcm-primitives] -path = "path/to/xcm-primitives/crate" +version = "0.1.0" default-features = false +git = "https://github.com/paritytech/trappist.git" +branch = "master" ``` Update the runtime's `std` feature: diff --git a/primitives/xcm/Cargo.toml b/primitives/xcm/Cargo.toml index 598385a8..bebb449f 100644 --- a/primitives/xcm/Cargo.toml +++ b/primitives/xcm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xcm-primitives" -version = "0.1.0" +version = "0.0.1" edition = "2021" [dependencies]