From eec3c7ac3ccb2d7e241b553900c6f416821b4fe2 Mon Sep 17 00:00:00 2001 From: bennethxyz Date: Sun, 17 Nov 2024 01:29:54 -0800 Subject: [PATCH] add frame::prelues::* --- Cargo.lock | 9 ++---- substrate/frame/uniques/Cargo.toml | 28 ++++++------------- substrate/frame/uniques/src/benchmarking.rs | 4 ++- substrate/frame/uniques/src/functions.rs | 3 ++ .../frame/uniques/src/impl_nonfungibles.rs | 12 ++++++-- substrate/frame/uniques/src/lib.rs | 11 ++++++-- substrate/frame/uniques/src/migration.rs | 7 +++-- substrate/frame/uniques/src/mock.rs | 3 +- substrate/frame/uniques/src/tests.rs | 4 +++ substrate/frame/uniques/src/types.rs | 4 +++ substrate/frame/uniques/src/weights.rs | 4 ++- 11 files changed, 51 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..bb258a530e5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15712,17 +15712,12 @@ dependencies = [ name = "pallet-uniques" version = "28.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "pallet-balances 28.0.0", + "pallet-nfts 22.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "scale-info", - "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", - "sp-std 14.0.0", ] [[package]] diff --git a/substrate/frame/uniques/Cargo.toml b/substrate/frame/uniques/Cargo.toml index abd456d97556..4a25272a2d59 100644 --- a/substrate/frame/uniques/Cargo.toml +++ b/substrate/frame/uniques/Cargo.toml @@ -19,41 +19,29 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { workspace = true } log = { workspace = true } scale-info = { features = ["derive"], workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -sp-runtime = { workspace = true } +pallet-nfts = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } -sp-core = { workspace = true, default-features = true } -sp-io = { workspace = true, default-features = true } -sp-std = { workspace = true, default-features = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "pallet-balances/std", + "pallet-nfts/std", "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "pallet-nfts/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", - "sp-runtime/try-runtime", + "pallet-nfts/try-runtime", ] diff --git a/substrate/frame/uniques/src/benchmarking.rs b/substrate/frame/uniques/src/benchmarking.rs index a8a83010c51f..0873812a0f84 100644 --- a/substrate/frame/uniques/src/benchmarking.rs +++ b/substrate/frame/uniques/src/benchmarking.rs @@ -21,6 +21,8 @@ use super::*; use alloc::{vec, vec::Vec}; +use frame::benchmarking::prelude::*; +/* use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; @@ -30,7 +32,7 @@ use frame_support::{ }; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::traits::Bounded; - +*/ use crate::Pallet as Uniques; const SEED: u32 = 0; diff --git a/substrate/frame/uniques/src/functions.rs b/substrate/frame/uniques/src/functions.rs index 1977c23f67e5..1d097dd70965 100644 --- a/substrate/frame/uniques/src/functions.rs +++ b/substrate/frame/uniques/src/functions.rs @@ -18,11 +18,14 @@ //! Various pieces of common functionality. use super::*; +/* use frame_support::{ ensure, traits::{ExistenceRequirement, Get}, }; use sp_runtime::{DispatchError, DispatchResult}; +*/ +use frame::{prelude::*, arithmetic::ArithmeticError, traits::{ExistenceRequirement, Currency}}; impl, I: 'static> Pallet { /// Perform a transfer of an item from one account to another within a collection. diff --git a/substrate/frame/uniques/src/impl_nonfungibles.rs b/substrate/frame/uniques/src/impl_nonfungibles.rs index 8e4af723f803..f57eac366be1 100644 --- a/substrate/frame/uniques/src/impl_nonfungibles.rs +++ b/substrate/frame/uniques/src/impl_nonfungibles.rs @@ -19,12 +19,16 @@ use super::*; use alloc::vec::Vec; +/* use frame_support::{ storage::KeyPrefixIterator, traits::{tokens::nonfungibles::*, Get}, BoundedSlice, }; use sp_runtime::{DispatchError, DispatchResult}; +*/ +use pallet_nfts::{CollectionConfigFor, CollectionSettings, ItemConfig, MintSettings}; +use frame::{prelude::*, traits::{tokens::nonfungibles_v2::*, Currency}, runtime::prelude::storage::{bounded_vec::BoundedSlice, KeyPrefixIterator}}; impl, I: 'static> Inspect<::AccountId> for Pallet { type ItemId = T::ItemId; @@ -86,7 +90,7 @@ impl, I: 'static> Inspect<::AccountId> for Palle } } -impl, I: 'static> Create<::AccountId> for Pallet { +impl, I: 'static> Create<::AccountId, CollectionConfigFor> for Pallet { /// Create a `collection` of nonfungible items to be owned by `who` and managed by `admin`. fn create_collection( collection: &Self::CollectionId, @@ -97,7 +101,7 @@ impl, I: 'static> Create<::AccountId> for Pallet collection.clone(), who.clone(), admin.clone(), - T::CollectionDeposit::get(), + >::CollectionDeposit::get(), false, Event::Created { collection: collection.clone(), @@ -124,11 +128,13 @@ impl, I: 'static> Destroy<::AccountId> for Palle } } -impl, I: 'static> Mutate<::AccountId> for Pallet { +impl, I: 'static> Mutate<::AccountId, ItemConfig> for Pallet { fn mint_into( collection: &Self::CollectionId, item: &Self::ItemId, who: &T::AccountId, + _item_config: &ItemConfig, + _deposit_collection_owner: bool, ) -> DispatchResult { Self::do_mint(collection.clone(), *item, who.clone(), |_| Ok(())) } diff --git a/substrate/frame/uniques/src/lib.rs b/substrate/frame/uniques/src/lib.rs index 84f122c08bb7..1d2c522c42fb 100644 --- a/substrate/frame/uniques/src/lib.rs +++ b/substrate/frame/uniques/src/lib.rs @@ -45,15 +45,20 @@ pub mod weights; extern crate alloc; use alloc::vec::Vec; +/* use codec::{Decode, Encode}; use frame_support::traits::{ tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency, }; +*/ +use frame::{prelude::*, traits::{ReservableCurrency, EnsureOriginWithArg, Locker, BalanceStatus::Reserved}}; use frame_system::Config as SystemConfig; +/* use sp_runtime::{ traits::{Saturating, StaticLookup, Zero}, ArithmeticError, RuntimeDebug, }; +*/ pub use pallet::*; pub use types::*; @@ -65,12 +70,14 @@ const LOG_TARGET: &str = "runtime::uniques"; /// A type alias for the account ID type used in the dispatchable functions of this pallet. type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - + */ const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); #[pallet::pallet] diff --git a/substrate/frame/uniques/src/migration.rs b/substrate/frame/uniques/src/migration.rs index 90d44e7790d6..72013c1c7117 100644 --- a/substrate/frame/uniques/src/migration.rs +++ b/substrate/frame/uniques/src/migration.rs @@ -18,8 +18,9 @@ //! Various pieces of common functionality. use super::*; use core::marker::PhantomData; -use frame_support::traits::{Get, UncheckedOnRuntimeUpgrade}; +// use frame_support::traits::{Get, UncheckedOnRuntimeUpgrade}; +use frame::{prelude::*, traits::UncheckedOnRuntimeUpgrade, weights_prelude::Weight, migration}; mod v1 { use super::*; @@ -27,7 +28,7 @@ mod v1 { pub struct UncheckedMigrateToV1Impl(PhantomData<(T, I)>); impl, I: 'static> UncheckedOnRuntimeUpgrade for UncheckedMigrateToV1Impl { - fn on_runtime_upgrade() -> frame_support::weights::Weight { + fn on_runtime_upgrade() -> Weight { let mut count = 0; for (collection, detail) in Collection::::iter() { CollectionAccount::::insert(&detail.owner, &collection, ()); @@ -46,7 +47,7 @@ mod v1 { } /// Migrate the pallet storage from `0` to `1`. -pub type MigrateV0ToV1 = frame_support::migrations::VersionedMigration< +pub type MigrateV0ToV1 = migrations::VersionedMigration< 0, 1, v1::UncheckedMigrateToV1Impl, diff --git a/substrate/frame/uniques/src/mock.rs b/substrate/frame/uniques/src/mock.rs index c3b74eb8c255..82ccc82f1dc3 100644 --- a/substrate/frame/uniques/src/mock.rs +++ b/substrate/frame/uniques/src/mock.rs @@ -19,12 +19,13 @@ use super::*; use crate as pallet_uniques; - +/* use frame_support::{ construct_runtime, derive_impl, traits::{AsEnsureOriginWithArg, ConstU32, ConstU64}, }; use sp_runtime::BuildStorage; +*/ type Block = frame_system::mocking::MockBlock; diff --git a/substrate/frame/uniques/src/tests.rs b/substrate/frame/uniques/src/tests.rs index a8428c420b3e..5112f6bf860e 100644 --- a/substrate/frame/uniques/src/tests.rs +++ b/substrate/frame/uniques/src/tests.rs @@ -18,9 +18,13 @@ //! Tests for Uniques pallet. use crate::{mock::*, Event, *}; +/* use frame_support::{assert_noop, assert_ok, traits::Currency}; use pallet_balances::Error as BalancesError; use sp_runtime::traits::Dispatchable; +*/ + +use frame::testing_prelude::*; fn items() -> Vec<(u64, u32, u32)> { let mut r: Vec<_> = Account::::iter().map(|x| x.0).collect(); diff --git a/substrate/frame/uniques/src/types.rs b/substrate/frame/uniques/src/types.rs index e2e170c72f21..b2d45ec7cac2 100644 --- a/substrate/frame/uniques/src/types.rs +++ b/substrate/frame/uniques/src/types.rs @@ -18,11 +18,15 @@ //! Various basic types for use in the Uniques pallet. use super::*; +/* use frame_support::{ pallet_prelude::{BoundedVec, MaxEncodedLen}, traits::Get, }; use scale_info::TypeInfo; +*/ + +use frame::{prelude::*, traits::Currency}; /// A type alias for handling balance deposits. pub(super) type DepositBalanceOf = diff --git a/substrate/frame/uniques/src/weights.rs b/substrate/frame/uniques/src/weights.rs index 60c6f9316ec7..d2fb249ae8df 100644 --- a/substrate/frame/uniques/src/weights.rs +++ b/substrate/frame/uniques/src/weights.rs @@ -46,9 +46,11 @@ #![allow(unused_imports)] #![allow(missing_docs)] +/* use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; - +*/ +use frame::weights_prelude::*; /// Weight functions needed for `pallet_uniques`. pub trait WeightInfo { fn create() -> Weight;