From 3aac4b88a7a6330e2866cbebfcb9fcec6c2308a9 Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 22 Aug 2023 16:59:58 +0200 Subject: [PATCH 1/2] pool_id docs --- frame/asset-conversion/src/lib.rs | 3 +++ frame/asset-conversion/src/types.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 3a16ab875c06a..c5dc3fc3d1460 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -147,6 +147,9 @@ pub mod pallet { /// Type that identifies either the native currency or a token class from `Assets`. /// `Ord` is added because of `get_pool_id`. + /// + /// The pool's `AccountId` is derived from this type. Any changes to the type may + /// necessitate a migration. type MultiAssetId: AssetId + Ord + From; /// Type to convert an `AssetId` into `MultiAssetId`. diff --git a/frame/asset-conversion/src/types.rs b/frame/asset-conversion/src/types.rs index 7cd9743ff04b8..9c28bd7666b71 100644 --- a/frame/asset-conversion/src/types.rs +++ b/frame/asset-conversion/src/types.rs @@ -21,6 +21,10 @@ use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_std::{cmp::Ordering, marker::PhantomData}; +/// Pool ID. +/// +/// The pool's `AccountId` is derived from this type. Any changes to the type may necessitate a +/// migration. pub(super) type PoolIdOf = (::MultiAssetId, ::MultiAssetId); /// Stores the lp_token asset id a particular pool has been assigned. From e29d2913aa68d2e1e04e98580740fef463dc154f Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 22 Aug 2023 17:00:50 +0200 Subject: [PATCH 2/2] fmt --- frame/asset-conversion/src/lib.rs | 4 +++- frame/asset-conversion/src/tests.rs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index c5dc3fc3d1460..d1d68f3e10fbb 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -1196,7 +1196,9 @@ pub mod pallet { () ); } else { - let MultiAssetIdConversionResult::Converted(asset_id) = T::MultiAssetIdConverter::try_convert(asset) else { + let MultiAssetIdConversionResult::Converted(asset_id) = + T::MultiAssetIdConverter::try_convert(asset) + else { return Err(()) }; let minimal = T::Assets::minimum_balance(asset_id); diff --git a/frame/asset-conversion/src/tests.rs b/frame/asset-conversion/src/tests.rs index 80faf5363b011..450a074ec3675 100644 --- a/frame/asset-conversion/src/tests.rs +++ b/frame/asset-conversion/src/tests.rs @@ -66,7 +66,11 @@ fn pool_assets() -> Vec { fn create_tokens(owner: u128, tokens: Vec>) { for token_id in tokens { - let MultiAssetIdConversionResult::Converted(asset_id) = NativeOrAssetIdConverter::try_convert(&token_id) else { unreachable!("invalid token") }; + let MultiAssetIdConversionResult::Converted(asset_id) = + NativeOrAssetIdConverter::try_convert(&token_id) + else { + unreachable!("invalid token") + }; assert_ok!(Assets::force_create(RuntimeOrigin::root(), asset_id, owner, false, 1)); } }