From eb22d9647ef8d276996589ee967de75d648eb225 Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 13 Jun 2023 14:12:23 +0200 Subject: [PATCH 1/2] Use Incrementable from frame_support::traits --- frame/nfts/src/lib.rs | 5 ++++- frame/nfts/src/macros.rs | 19 ------------------- frame/nfts/src/types.rs | 6 ------ 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 052a017f67092..384dcaa4f50fd 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -67,7 +67,10 @@ type AccountIdLookupOf = <::Lookup as StaticLookup>::Sourc #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{pallet_prelude::*, traits::ExistenceRequirement}; + use frame_support::{ + pallet_prelude::*, + traits::{ExistenceRequirement, Incrementable}, + }; use frame_system::pallet_prelude::*; /// The current storage version. diff --git a/frame/nfts/src/macros.rs b/frame/nfts/src/macros.rs index 8b0b8358dd7ff..db560cfbc33f0 100644 --- a/frame/nfts/src/macros.rs +++ b/frame/nfts/src/macros.rs @@ -15,25 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -macro_rules! impl_incrementable { - ($($type:ty),+) => { - $( - impl Incrementable for $type { - fn increment(&self) -> Self { - let mut val = self.clone(); - val.saturating_inc(); - val - } - - fn initial_value() -> Self { - 0 - } - } - )+ - }; -} -pub(crate) use impl_incrementable; - macro_rules! impl_codec_bitflags { ($wrapper:ty, $size:ty, $bitflag_enum:ty) => { impl MaxEncodedLen for $wrapper { diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index fe648792237c5..ab966f0d73828 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -75,12 +75,6 @@ pub(super) type PreSignedAttributesOf = PreSignedAttributes< ::BlockNumber, >; -pub trait Incrementable { - fn increment(&self) -> Self; - fn initial_value() -> Self; -} -impl_incrementable!(u8, u16, u32, u64, u128, i8, i16, i32, i64, i128); - /// Information about a collection. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct CollectionDetails { From c74e0aa9c02d9d7edd5fad9bcf31794fa581024d Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko Date: Tue, 13 Jun 2023 14:25:38 +0200 Subject: [PATCH 2/2] Chore --- frame/nfts/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 384dcaa4f50fd..f2812674a5408 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -46,7 +46,8 @@ pub mod weights; use codec::{Decode, Encode}; use frame_support::traits::{ - tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency, + tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, Incrementable, + ReservableCurrency, }; use frame_system::Config as SystemConfig; use sp_runtime::{ @@ -67,10 +68,7 @@ type AccountIdLookupOf = <::Lookup as StaticLookup>::Sourc #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{ - pallet_prelude::*, - traits::{ExistenceRequirement, Incrementable}, - }; + use frame_support::{pallet_prelude::*, traits::ExistenceRequirement}; use frame_system::pallet_prelude::*; /// The current storage version.