From 3ed7c0bb2bad93b127e80743062ecc04631d51e7 Mon Sep 17 00:00:00 2001 From: MJLNSN <96321798+MJLNSN@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:40:45 +0800 Subject: [PATCH] remove getter in asset-registry (#1322) --- pallets/asset-registry/src/lib.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index b7bab37f06..c35d14481e 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -129,21 +129,18 @@ pub mod pallet { /// /// NextForeignAssetId: ForeignAssetId #[pallet::storage] - #[pallet::getter(fn next_foreign_asset_id)] pub type NextForeignAssetId = StorageValue<_, ForeignAssetId, ValueQuery>; /// Next available TokenId ID. /// /// NextTokenId: TokenId #[pallet::storage] - #[pallet::getter(fn next_token_id)] pub type NextTokenId = StorageValue<_, TokenId, ValueQuery>; /// The storages for Locations. /// /// CurrencyIdToLocations: map CurrencyId => Option #[pallet::storage] - #[pallet::getter(fn currency_id_to_locations)] pub type CurrencyIdToLocations = StorageMap<_, Twox64Concat, CurrencyId, xcm::v3::Location, OptionQuery>; @@ -151,12 +148,10 @@ pub mod pallet { /// /// LocationToCurrencyIds: map Location => Option #[pallet::storage] - #[pallet::getter(fn location_to_currency_ids)] pub type LocationToCurrencyIds = StorageMap<_, Twox64Concat, xcm::v3::Location, CurrencyId, OptionQuery>; #[pallet::storage] - #[pallet::getter(fn currency_id_to_weight)] pub type CurrencyIdToWeights = StorageMap<_, Twox64Concat, CurrencyId, Weight, OptionQuery>; @@ -164,7 +159,6 @@ pub mod pallet { /// /// AssetMetadatas: map AssetIds => Option #[pallet::storage] - #[pallet::getter(fn asset_metadatas)] pub type AssetMetadatas = StorageMap<_, Twox64Concat, AssetIds, AssetMetadata>, OptionQuery>; @@ -172,7 +166,6 @@ pub mod pallet { /// /// CurrencyMetadatas: map CurrencyId => Option #[pallet::storage] - #[pallet::getter(fn currency_metadatas)] pub type CurrencyMetadatas = StorageMap<_, Twox64Concat, CurrencyId, AssetMetadata>, OptionQuery>; @@ -639,11 +632,11 @@ impl CurrencyIdMapping { fn get_asset_metadata(asset_ids: AssetIds) -> Option>> { - Pallet::::asset_metadatas(asset_ids) + AssetMetadatas::::get(asset_ids) } fn get_currency_metadata(currency_id: CurrencyId) -> Option>> { - Pallet::::currency_metadatas(currency_id) + CurrencyMetadatas::::get(currency_id) } fn get_all_currency() -> Vec { @@ -651,13 +644,12 @@ impl CurrencyIdMapping Option { - Pallet::::currency_id_to_locations(currency_id) - .map(|location| location.try_into().ok())? + CurrencyIdToLocations::::get(currency_id).map(|location| location.try_into().ok())? } fn get_currency_id(multi_location: Location) -> Option { let v3_location = xcm::v3::Location::try_from(multi_location).ok()?; - Pallet::::location_to_currency_ids(v3_location) + LocationToCurrencyIds::::get(v3_location) } } @@ -942,8 +934,8 @@ where let v3_location = xcm::v3::Location::try_from(location.clone()).map_err(|_| XcmError::InvalidLocation)?; - if let Some(currency_id) = Pallet::::location_to_currency_ids(v3_location) { - if let Some(currency_metadatas) = Pallet::::currency_metadatas(currency_id) { + if let Some(currency_id) = LocationToCurrencyIds::::get(v3_location) { + if let Some(currency_metadatas) = CurrencyMetadatas::::get(currency_id) { // The integration tests can ensure the ed is non-zero. let ed_ratio = FixedU128::saturating_from_rational( currency_metadatas.minimal_balance.into(),