diff --git a/substrate/frame/assets-freezer/README.md b/substrate/frame/assets-freezer/README.md index a38cd4bd3f4b7..bc9cb9d3eb4d4 100644 --- a/substrate/frame/assets-freezer/README.md +++ b/substrate/frame/assets-freezer/README.md @@ -21,12 +21,9 @@ This pallet provides the following functionality: - Pallet hooks that implement custom logic to let `pallet-assets` know whether an balance is frozen for an account on a given asset (see: [`pallet_assets::types::FrozenBalance`][docs:frozen_balance]). -- An implementation of fungibles [inspect][docs:inspect_freeze] and - [mutation][docs:mutate_freeze] APIs. -- Support for force freezing and thawing assets, given a Freezer ID - (see [`Config::RuntimeFreezeReason`][src:lib]). +- An implementation of the fungibles [inspect][docs:inspect_freeze] and the [mutation][docs:mutate_freeze] + APIs for freezes. [docs:frozen_balance]: https://docs.rs/pallet-assets/latest/pallet_assets/trait.FrozenBalance.html [docs:inspect_freeze]: https://docs.rs/frame-support/latest/frame_support/traits/tokens/fungibles/index.html#reexport.InspectFreeze [docs:mutate_freeze]: https://docs.rs/frame-support/latest/frame_support/traits/tokens/fungibles/index.html#reexport.MutateFreeze -[src:lib]: ./src/lib.rs diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index a4981a84d1b6f..7711f4a525095 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -38,25 +38,14 @@ //! //! - Pallet hooks that implement custom logic to let `pallet-assets` know whether an balance is //! frozen for an account on a given asset (see: [`pallet_assets::FrozenBalance`]). -//! - An implementation of fungibles [inspect][docs:inspect_freeze] and -//! [mutation][docs:mutate_freeze] APIs. -//! - Support for force freezing and thawing assets, given a Freezer ID -//! (see [`Config::RuntimeFreezeReason`]). +//! - An implementation of the fungibles [inspect][docs:inspect_freeze] and the [mutation][docs:mutate_freeze] +//! APIs for freezes. //! //! [docs:inspect_freeze]: `frame_support::traits::fungibles::InspectFreeze` //! [docs:mutate_freeze]: `frame_support::traits::fungibles::MutateFreeze` #![cfg_attr(not(feature = "std"), no_std)] -use codec::Encode; -use frame_support::pallet_prelude::*; -use scale_info::prelude::fmt::Debug; -use sp_runtime::{ - traits::{Saturating, Zero}, - BoundedSlice, -}; - -// Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; #[cfg(test)] @@ -71,9 +60,10 @@ pub use types::*; #[frame_support::pallet] pub mod pallet { use super::*; + use codec::FullCodec; - use frame_support::{traits::VariantCount, BoundedVec}; - // use frame_system::pallet_prelude::*; + use core::fmt::Debug; + use frame_support::{pallet_prelude::*, traits::VariantCount, BoundedVec}; #[pallet::config] pub trait Config: frame_system::Config + pallet_assets::Config { @@ -91,6 +81,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// The maximum number of individual freeze locks that can exist on an account at any time. #[pallet::constant] type MaxFreezes: Get; } @@ -101,14 +92,9 @@ pub mod pallet { TooManyFreezes, } - // Simple declaration of the `Pallet` type. It is placeholder we use to implement traits and - // method. #[pallet::pallet] pub struct Pallet(_); - #[pallet::call(weight(::WeightInfo))] - impl, I: 'static> Pallet {} - #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { @@ -142,6 +128,12 @@ pub mod pallet { >; } +use frame_support::pallet_prelude::DispatchResult; +use sp_runtime::{ + traits::{Saturating, Zero}, + BoundedSlice, +}; + impl, I: 'static> Pallet { fn update_freezes( asset: AssetIdOf, diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index 24692aed3e1d3..7fefcd1abc4ba 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Tests mock for pallet-assets-freezer. +//! Tests mock for `pallet-assets-freezer`. pub use crate::*; use codec::{Compact, Decode, Encode, MaxEncodedLen}; @@ -25,13 +25,10 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_core::{ConstU32, H256}; -// The testing primitives are very useful for avoiding having to work with signatures -// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -// Reexport crate as its pallet name for construct_runtime. use crate as pallet_assets_freezer; pub type AccountId = u64; @@ -39,7 +36,6 @@ type Balance = u64; pub type AssetId = u32; type Block = frame_system::mocking::MockBlock; -// For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( pub enum Test { @@ -130,17 +126,12 @@ impl frame_support::traits::VariantCount for DummyFreezeReason { impl Config for Test { type RuntimeFreezeReason = DummyFreezeReason; - // type FreezeOrigin = - // AsEnsureOriginWithArg, ConstU64<0>>>; type RuntimeEvent = RuntimeEvent; type MaxFreezes = ConstU32<2>; } -// This function basically just builds a genesis storage key/value store according to -// our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { let t = RuntimeGenesisConfig { - // We use default for brevity, but you can configure as desired if needed. assets: pallet_assets::GenesisConfig { assets: vec![(1, 0, true, 1)], metadata: vec![], diff --git a/substrate/frame/assets-freezer/src/types.rs b/substrate/frame/assets-freezer/src/types.rs index c311304c66b88..a53f07e97a51d 100644 --- a/substrate/frame/assets-freezer/src/types.rs +++ b/substrate/frame/assets-freezer/src/types.rs @@ -16,7 +16,7 @@ // limitations under the License. use frame_support::traits::fungibles::Inspect; -use super::*; +use frame_support::pallet_prelude::{Decode, Encode, MaxEncodedLen, RuntimeDebug, TypeInfo}; pub type AssetIdOf = as Inspect>>::AssetId; pub type AssetBalanceOf = as Inspect>>::Balance;