Skip to content

Commit dd5fa9f

Browse files
authored
asset-conversion pallet: pool's AccountId derivation warn docs (#14811)
* pool_id docs * fmt
1 parent fde8c1f commit dd5fa9f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

substrate/frame/asset-conversion/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ pub mod pallet {
147147

148148
/// Type that identifies either the native currency or a token class from `Assets`.
149149
/// `Ord` is added because of `get_pool_id`.
150+
///
151+
/// The pool's `AccountId` is derived from this type. Any changes to the type may
152+
/// necessitate a migration.
150153
type MultiAssetId: AssetId + Ord + From<Self::AssetId>;
151154

152155
/// Type to convert an `AssetId` into `MultiAssetId`.
@@ -1193,7 +1196,9 @@ pub mod pallet {
11931196
()
11941197
);
11951198
} else {
1196-
let MultiAssetIdConversionResult::Converted(asset_id) = T::MultiAssetIdConverter::try_convert(asset) else {
1199+
let MultiAssetIdConversionResult::Converted(asset_id) =
1200+
T::MultiAssetIdConverter::try_convert(asset)
1201+
else {
11971202
return Err(())
11981203
};
11991204
let minimal = T::Assets::minimum_balance(asset_id);

substrate/frame/asset-conversion/src/tests.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ fn pool_assets() -> Vec<u32> {
6666

6767
fn create_tokens(owner: u128, tokens: Vec<NativeOrAssetId<u32>>) {
6868
for token_id in tokens {
69-
let MultiAssetIdConversionResult::Converted(asset_id) = NativeOrAssetIdConverter::try_convert(&token_id) else { unreachable!("invalid token") };
69+
let MultiAssetIdConversionResult::Converted(asset_id) =
70+
NativeOrAssetIdConverter::try_convert(&token_id)
71+
else {
72+
unreachable!("invalid token")
73+
};
7074
assert_ok!(Assets::force_create(RuntimeOrigin::root(), asset_id, owner, false, 1));
7175
}
7276
}

substrate/frame/asset-conversion/src/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ use codec::{Decode, Encode, MaxEncodedLen};
2121
use scale_info::TypeInfo;
2222
use sp_std::{cmp::Ordering, marker::PhantomData};
2323

24+
/// Pool ID.
25+
///
26+
/// The pool's `AccountId` is derived from this type. Any changes to the type may necessitate a
27+
/// migration.
2428
pub(super) type PoolIdOf<T> = (<T as Config>::MultiAssetId, <T as Config>::MultiAssetId);
2529

2630
/// Stores the lp_token asset id a particular pool has been assigned.

0 commit comments

Comments
 (0)