From 776f9cd759fe64bb00ca92beb03135aaf8e0265d Mon Sep 17 00:00:00 2001 From: martinfridrich Date: Mon, 23 Oct 2023 11:21:50 +0200 Subject: [PATCH] asset-registry: removed NativeAssetId from config + make clippy happy --- pallets/asset-registry/src/benchmarking.rs | 2 +- pallets/asset-registry/src/lib.rs | 13 +++++++------ pallets/asset-registry/src/tests/mock.rs | 2 +- pallets/asset-registry/src/tests/register.rs | 12 ++++++------ pallets/asset-registry/src/tests/update.rs | 8 ++++---- pallets/xyk/src/tests/mock.rs | 2 +- runtime/hydradx/src/assets.rs | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/pallets/asset-registry/src/benchmarking.rs b/pallets/asset-registry/src/benchmarking.rs index 7879a8e10..95804aea1 100644 --- a/pallets/asset-registry/src/benchmarking.rs +++ b/pallets/asset-registry/src/benchmarking.rs @@ -92,7 +92,7 @@ benchmarks! { register_external { let caller: T::AccountId = account("caller", 0, 1); - T::Currency::update_balance(T::NativeAssetId::get(), &caller, (100_000 * UNIT) as i128)?; + T::Currency::update_balance(T::StorageFeesAssetId::get(), &caller, (100_000 * UNIT) as i128)?; let expected_asset_id = Pallet::::next_asset_id().unwrap(); let location: T::AssetNativeLocation = Default::default(); diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 8b1c4abd5..b16fedc35 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -93,9 +93,9 @@ pub mod pallet { #[pallet::constant] type SequentialIdStartAt: Get; - /// Native Asset Id + /// Id of the asset that is used to pay storage fees. #[pallet::constant] - type NativeAssetId: Get; + type StorageFeesAssetId: Get; /// Storage fees for external asset creation. #[pallet::constant] @@ -237,9 +237,10 @@ pub mod pallet { let native_symbol = Pallet::::try_into_bounded(Some(self.native_symbol.to_vec())) .expect("Invalid native asset symbol!"); + let native_asset_id = T::AssetId::from(0); AssetIds::::insert( native_asset_name.as_ref().expect("Invalid native asset name!"), - T::NativeAssetId::get(), + native_asset_id, ); let details = AssetDetails { name: native_asset_name, @@ -251,7 +252,7 @@ pub mod pallet { is_sufficient: true, }; - Assets::::insert(T::NativeAssetId::get(), details); + Assets::::insert(native_asset_id, details); self.registered_assets.iter().for_each( |(id, name, ed, symbol, decimals, xcm_rate_limit, is_sufficient)| { @@ -470,12 +471,12 @@ pub mod pallet { if !T::StorageFees::get().is_zero() { ensure!( - T::Currency::ensure_can_withdraw(T::NativeAssetId::get(), &who, T::StorageFees::get()).is_ok(), + T::Currency::ensure_can_withdraw(T::StorageFeesAssetId::get(), &who, T::StorageFees::get()).is_ok(), Error::::InsufficientBalance ); T::Currency::transfer( - T::NativeAssetId::get(), + T::StorageFeesAssetId::get(), &who, &T::StorageFeesBeneficiary::get(), T::StorageFees::get(), diff --git a/pallets/asset-registry/src/tests/mock.rs b/pallets/asset-registry/src/tests/mock.rs index 9dc90e806..d3aa3aa08 100644 --- a/pallets/asset-registry/src/tests/mock.rs +++ b/pallets/asset-registry/src/tests/mock.rs @@ -111,7 +111,7 @@ impl pallet_asset_registry::Config for Test { type AssetNativeLocation = AssetLocation; type StringLimit = RegistryStringLimit; type SequentialIdStartAt = SequentialIdStart; - type NativeAssetId = NativeAssetId; + type StorageFeesAssetId = NativeAssetId; type StorageFees = StoreFees; type StorageFeesBeneficiary = FeesBeneficiarry; type WeightInfo = (); diff --git a/pallets/asset-registry/src/tests/register.rs b/pallets/asset-registry/src/tests/register.rs index 91a9db98d..766af4159 100644 --- a/pallets/asset-registry/src/tests/register.rs +++ b/pallets/asset-registry/src/tests/register.rs @@ -521,12 +521,12 @@ fn register_should_fail_when_name_is_too_long() { Registry::register( RuntimeOrigin::root(), Some(asset_id), - Some(name.clone()), + Some(name), AssetType::Token, Some(ed), - Some(symbol.clone()), + Some(symbol), Some(decimals), - Some(asset_location.clone()), + Some(asset_location), Some(xcm_rate_limit), is_sufficient ), @@ -554,12 +554,12 @@ fn register_should_fail_when_symbol_is_too_long() { Registry::register( RuntimeOrigin::root(), Some(asset_id), - Some(name.clone()), + Some(name), AssetType::Token, Some(ed), - Some(symbol.clone()), + Some(symbol), Some(decimals), - Some(asset_location.clone()), + Some(asset_location), Some(xcm_rate_limit), is_sufficient ), diff --git a/pallets/asset-registry/src/tests/update.rs b/pallets/asset-registry/src/tests/update.rs index 52606def0..e40252a0e 100644 --- a/pallets/asset-registry/src/tests/update.rs +++ b/pallets/asset-registry/src/tests/update.rs @@ -642,12 +642,12 @@ fn update_should_fail_when_name_is_too_long() { Registry::update( RuntimeOrigin::root(), asset_id, - Some(name.clone()), + Some(name), Some(AssetType::External), Some(ed), Some(xcm_rate_limit), Some(is_sufficient), - Some(symbol.clone()), + Some(symbol), Some(decimals), None ), @@ -679,12 +679,12 @@ fn update_should_fail_when_symbolis_too_long() { Registry::update( RuntimeOrigin::root(), asset_id, - Some(name.clone()), + Some(name), Some(AssetType::External), Some(ed), Some(xcm_rate_limit), Some(is_sufficient), - Some(symbol.clone()), + Some(symbol), Some(decimals), None ), diff --git a/pallets/xyk/src/tests/mock.rs b/pallets/xyk/src/tests/mock.rs index 942cd405d..69619aa3f 100644 --- a/pallets/xyk/src/tests/mock.rs +++ b/pallets/xyk/src/tests/mock.rs @@ -115,7 +115,7 @@ impl pallet_asset_registry::Config for Test { type AssetNativeLocation = u8; type StringLimit = RegistryStringLimit; type SequentialIdStartAt = SequentialIdOffset; - type NativeAssetId = NativeAssetId; + type StorageFeesAssetId = NativeAssetId; type StorageFees = StoreFees; type StorageFeesBeneficiary = FeesBeneficiarry; type WeightInfo = (); diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 76329b8dd..6be97934a 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -349,7 +349,7 @@ impl pallet_asset_registry::Config for Runtime { type AssetNativeLocation = AssetLocation; type StringLimit = RegistryStrLimit; type SequentialIdStartAt = SequentialIdOffset; - type NativeAssetId = NativeAssetId; + type StorageFeesAssetId = NativeAssetId; type StorageFees = StoreFees; type StorageFeesBeneficiary = TreasuryAccount; type WeightInfo = weights::registry::HydraWeight;