From ddc828d820c2be20d521866e7488d8d0320c2abe Mon Sep 17 00:00:00 2001 From: Raid Ateir Date: Mon, 6 Nov 2023 15:17:38 +0100 Subject: [PATCH] move BucketId to ddc-primitives --- pallets/ddc-customers/src/lib.rs | 16 ++++++++-------- primitives/src/lib.rs | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pallets/ddc-customers/src/lib.rs b/pallets/ddc-customers/src/lib.rs index a5a734003..8528b577b 100644 --- a/pallets/ddc-customers/src/lib.rs +++ b/pallets/ddc-customers/src/lib.rs @@ -3,7 +3,7 @@ use codec::{Decode, Encode, HasCompact}; -use ddc_primitives::ClusterId; +use ddc_primitives::{BucketId, ClusterId}; use frame_support::{ parameter_types, traits::{Currency, DefensiveSaturating, ExistenceRequirement}, @@ -43,7 +43,7 @@ pub struct UnlockChunk { #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct Bucket { - bucket_id: u64, + bucket_id: BucketId, owner_id: AccountId, cluster_id: Option, public_availability: bool, @@ -51,7 +51,7 @@ pub struct Bucket { #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct BucketsDetails { - pub bucket_id: u64, + pub bucket_id: BucketId, pub amount: Balance, } @@ -165,19 +165,19 @@ pub mod pallet { StorageMap<_, Identity, T::AccountId, AccountsLedger>>; #[pallet::type_value] - pub fn DefaultBucketCount() -> u64 { - 0_u64 + pub fn DefaultBucketCount() -> BucketId { + 0 } #[pallet::storage] #[pallet::getter(fn buckets_count)] pub type BucketsCount = - StorageValue>; + StorageValue>; /// Map from bucket ID to to the bucket structure #[pallet::storage] #[pallet::getter(fn buckets)] pub type Buckets = - StorageMap<_, Twox64Concat, u64, Bucket, OptionQuery>; + StorageMap<_, Twox64Concat, BucketId, Bucket, OptionQuery>; #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] @@ -269,7 +269,7 @@ pub mod pallet { #[pallet::weight(10_000)] pub fn allocate_bucket_to_cluster( origin: OriginFor, - bucket_id: u64, + bucket_id: BucketId, cluster_id: ClusterId, ) -> DispatchResult { let bucket_owner = ensure_signed(origin)?; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 0f1efd446..a3abee7c4 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -9,6 +9,7 @@ use sp_core::hash::H160; use sp_runtime::{AccountId32, RuntimeDebug}; pub type ClusterId = H160; +pub type BucketId = u64; #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo, PartialEq)]