From 5ff5cb7472965a23569aa2eb9099eb83ee676790 Mon Sep 17 00:00:00 2001 From: runcomet Date: Thu, 21 Nov 2024 08:50:22 -0800 Subject: [PATCH 01/17] frame import --- Cargo.lock | 7 +------ substrate/frame/assets-freezer/Cargo.toml | 23 ++++----------------- substrate/frame/assets-freezer/src/impls.rs | 6 +++++- substrate/frame/assets-freezer/src/lib.rs | 13 +++++++----- substrate/frame/assets-freezer/src/mock.rs | 17 +++++++++------ substrate/frame/assets-freezer/src/tests.rs | 5 ++++- substrate/frame/src/lib.rs | 6 +++--- 7 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02d7da8f7657..85388fbed437 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11861,17 +11861,12 @@ dependencies = [ name = "pallet-assets-freezer" version = "0.1.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "pallet-assets 29.1.0", "pallet-balances 28.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", ] [[package]] diff --git a/substrate/frame/assets-freezer/Cargo.toml b/substrate/frame/assets-freezer/Cargo.toml index 68bfdd7cfb62..dcc8d62cb81c 100644 --- a/substrate/frame/assets-freezer/Cargo.toml +++ b/substrate/frame/assets-freezer/Cargo.toml @@ -18,44 +18,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 } +frame = { workspace = true, features = ["experimental", "runtime"] } pallet-assets = { workspace = true } -sp-runtime = { workspace = true } [dev-dependencies] -sp-io = { workspace = true } -sp-core = { workspace = true } pallet-balances = { workspace = true } [features] default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "pallet-assets/std", "pallet-balances/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-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-assets/try-runtime", "pallet-balances/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/assets-freezer/src/impls.rs b/substrate/frame/assets-freezer/src/impls.rs index cd383f1c3cd1..07c195883179 100644 --- a/substrate/frame/assets-freezer/src/impls.rs +++ b/substrate/frame/assets-freezer/src/impls.rs @@ -17,12 +17,16 @@ use super::*; +/* use frame_support::traits::{ fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, }; +*/ use pallet_assets::FrozenBalance; -use sp_runtime::traits::Zero; +// use sp_runtime::traits::Zero; + +use frame::{deps::sp_runtime, traits::{fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, Zero}}; // Implements [`FrozenBalance`] from [`pallet-assets`], so it can understand how much of an // account balance is frozen, and is able to signal to this pallet when to clear the state of an diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index b42d41ac1d92..b447db1ac1f2 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -42,6 +42,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +/* use frame_support::{ pallet_prelude::*, traits::{tokens::IdAmount, VariantCount, VariantCountOf}, @@ -52,7 +53,8 @@ use sp_runtime::{ traits::{Saturating, Zero}, BoundedSlice, }; - +*/ +use frame::{prelude::*, traits::{tokens::IdAmount, VariantCount, VariantCountOf, Saturating, Zero}}; pub use pallet::*; #[cfg(test)] @@ -62,7 +64,8 @@ mod tests; mod impls; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; @@ -125,7 +128,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { #[cfg(feature = "try-runtime")] - fn try_state(_: BlockNumberFor) -> Result<(), sp_runtime::TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), frame::deps::sp_runtime::TryRuntimeError> { Self::do_try_state() } } @@ -160,12 +163,12 @@ impl, I: 'static> Pallet { } #[cfg(any(test, feature = "try-runtime"))] - fn do_try_state() -> Result<(), sp_runtime::TryRuntimeError> { + fn do_try_state() -> Result<(), frame::deps::sp_runtime::TryRuntimeError> { for (asset, who, _) in FrozenBalances::::iter() { let max_frozen_amount = Freezes::::get(asset.clone(), who.clone()).iter().map(|l| l.amount).max(); - frame_support::ensure!( + ensure!( FrozenBalances::::get(asset, who) == max_frozen_amount, "The `FrozenAmount` is not equal to the maximum amount in `Freezes` for (`asset`, `who`)" ); diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index bc903a018f7b..a2a4c6254f4c 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -20,23 +20,28 @@ use crate as pallet_assets_freezer; pub use crate::*; use codec::{Compact, Decode, Encode, MaxEncodedLen}; +use frame::{pallet_macros::derive_impl, runtime::testing_prelude::BuildStorage, testing_prelude::{TestExternalities, assert_ok}, traits::{AsEnsureOriginWithArg, BlakeTwo256, IdentityLookup, Everything}, hashing::H256, runtime::prelude::{ConstU32, ConstU64, construct_runtime}}; +/* use frame_support::{ derive_impl, traits::{AsEnsureOriginWithArg, ConstU64}, }; +*/ use scale_info::TypeInfo; +/* use sp_core::{ConstU32, H256}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; +*/ pub type AccountId = u64; pub type Balance = u64; pub type AssetId = u32; type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -48,7 +53,7 @@ frame_support::construct_runtime!( #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for Test { - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); type DbWeight = (); @@ -70,7 +75,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { @@ -132,7 +137,7 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; } -pub fn new_test_ext(execute: impl FnOnce()) -> sp_io::TestExternalities { +pub fn new_test_ext(execute: impl FnOnce()) -> TestExternalities { let t = RuntimeGenesisConfig { assets: pallet_assets::GenesisConfig { assets: vec![(1, 0, true, 1)], @@ -145,11 +150,11 @@ pub fn new_test_ext(execute: impl FnOnce()) -> sp_io::TestExternalities { } .build_storage() .unwrap(); - let mut ext: sp_io::TestExternalities = t.into(); + let mut ext: TestExternalities = t.into(); ext.execute_with(|| { System::set_block_number(1); execute(); - frame_support::assert_ok!(AssetsFreezer::do_try_state()); + assert_ok!(AssetsFreezer::do_try_state()); }); ext diff --git a/substrate/frame/assets-freezer/src/tests.rs b/substrate/frame/assets-freezer/src/tests.rs index 4f2dea79c705..6d42ebc00d4b 100644 --- a/substrate/frame/assets-freezer/src/tests.rs +++ b/substrate/frame/assets-freezer/src/tests.rs @@ -20,6 +20,7 @@ use crate::mock::*; use codec::Compact; +/* use frame_support::{ assert_ok, assert_storage_noop, traits::{ @@ -27,6 +28,8 @@ use frame_support::{ tokens::{Fortitude, Preservation}, }, }; +*/ +use frame::{testing_prelude::*, traits::{fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{Fortitude, Preservation}}}; use pallet_assets::FrozenBalance; const WHO: AccountId = 1; @@ -281,7 +284,7 @@ mod impl_mutate_freeze { } mod with_pallet_assets { - use frame_support::assert_noop; + // use frame_support::assert_noop; use super::*; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 0ca36ca8545a..c6d325f4f5fa 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -218,10 +218,10 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] - pub use sp_runtime::traits::{ + pub use sp_runtime::{traits::{ Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, - }; + }, BoundedSlice}; /// Other error/result types for runtime #[doc(no_inline)] @@ -307,7 +307,7 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ - assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, + assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, ensure, assert_storage_noop, storage_alias, }; From cd5b79815e8fe1898a5de60957d3ba0eb2dba0cd Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 22 Nov 2024 19:03:37 -0800 Subject: [PATCH 02/17] cargo +fmt --- substrate/frame/assets-freezer/src/impls.rs | 15 +++++++------- substrate/frame/assets-freezer/src/lib.rs | 16 +++------------ substrate/frame/assets-freezer/src/mock.rs | 22 +++++++++------------ substrate/frame/assets-freezer/src/tests.rs | 9 ++------- 4 files changed, 21 insertions(+), 41 deletions(-) diff --git a/substrate/frame/assets-freezer/src/impls.rs b/substrate/frame/assets-freezer/src/impls.rs index 07c195883179..c6113559ac67 100644 --- a/substrate/frame/assets-freezer/src/impls.rs +++ b/substrate/frame/assets-freezer/src/impls.rs @@ -17,16 +17,15 @@ use super::*; -/* -use frame_support::traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, +use frame::{ + deps::sp_runtime, + traits::{ + fungibles::{Inspect, InspectFreeze, MutateFreeze}, + tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, + Zero, + }, }; -*/ use pallet_assets::FrozenBalance; -// use sp_runtime::traits::Zero; - -use frame::{deps::sp_runtime, traits::{fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, Zero}}; // Implements [`FrozenBalance`] from [`pallet-assets`], so it can understand how much of an // account balance is frozen, and is able to signal to this pallet when to clear the state of an diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index b447db1ac1f2..d9cc75d579dd 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -42,19 +42,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -/* -use frame_support::{ - pallet_prelude::*, - traits::{tokens::IdAmount, VariantCount, VariantCountOf}, - BoundedVec, +use frame::{ + prelude::*, + traits::{tokens::IdAmount, Saturating, VariantCount, VariantCountOf, Zero}, }; -use frame_system::pallet_prelude::BlockNumberFor; -use sp_runtime::{ - traits::{Saturating, Zero}, - BoundedSlice, -}; -*/ -use frame::{prelude::*, traits::{tokens::IdAmount, VariantCount, VariantCountOf, Saturating, Zero}}; pub use pallet::*; #[cfg(test)] @@ -64,7 +55,6 @@ mod tests; mod impls; -// #[frame_support::pallet] #[frame::pallet] pub mod pallet { use super::*; diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index a2a4c6254f4c..b4dabf327fcb 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -20,21 +20,17 @@ use crate as pallet_assets_freezer; pub use crate::*; use codec::{Compact, Decode, Encode, MaxEncodedLen}; -use frame::{pallet_macros::derive_impl, runtime::testing_prelude::BuildStorage, testing_prelude::{TestExternalities, assert_ok}, traits::{AsEnsureOriginWithArg, BlakeTwo256, IdentityLookup, Everything}, hashing::H256, runtime::prelude::{ConstU32, ConstU64, construct_runtime}}; -/* -use frame_support::{ - derive_impl, - traits::{AsEnsureOriginWithArg, ConstU64}, +use frame::{ + hashing::H256, + pallet_macros::derive_impl, + runtime::{ + prelude::{construct_runtime, ConstU32, ConstU64}, + testing_prelude::BuildStorage, + }, + testing_prelude::{assert_ok, TestExternalities}, + traits::{AsEnsureOriginWithArg, BlakeTwo256, Everything, IdentityLookup}, }; -*/ use scale_info::TypeInfo; -/* -use sp_core::{ConstU32, H256}; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, -}; -*/ pub type AccountId = u64; pub type Balance = u64; diff --git a/substrate/frame/assets-freezer/src/tests.rs b/substrate/frame/assets-freezer/src/tests.rs index 6d42ebc00d4b..87fc69f11b34 100644 --- a/substrate/frame/assets-freezer/src/tests.rs +++ b/substrate/frame/assets-freezer/src/tests.rs @@ -20,16 +20,13 @@ use crate::mock::*; use codec::Compact; -/* -use frame_support::{ - assert_ok, assert_storage_noop, +use frame::{ + testing_prelude::*, traits::{ fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{Fortitude, Preservation}, }, }; -*/ -use frame::{testing_prelude::*, traits::{fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{Fortitude, Preservation}}}; use pallet_assets::FrozenBalance; const WHO: AccountId = 1; @@ -284,8 +281,6 @@ mod impl_mutate_freeze { } mod with_pallet_assets { - // use frame_support::assert_noop; - use super::*; #[test] From 21edc7076e6e5295458a7c9d6ef421dcc5918562 Mon Sep 17 00:00:00 2001 From: runcomet Date: Sun, 1 Dec 2024 01:18:49 -0800 Subject: [PATCH 03/17] add prdoc --- prdoc/pr_6599.prdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prdoc/pr_6599.prdoc diff --git a/prdoc/pr_6599.prdoc b/prdoc/pr_6599.prdoc new file mode 100644 index 000000000000..1a84354d7483 --- /dev/null +++ b/prdoc/pr_6599.prdoc @@ -0,0 +1,13 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: migrate pallet-assets-freezer to umbrella crate + +doc: + - audience: Runtime Dev + description: | + Imports frame umbrella crate systems into pallet-assets-freezer. + +crates: + - name: pallet-assets-freezer + bump: minor From 88861fb4656cf9212c1f50e507418ee45f9e2f21 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 6 Dec 2024 17:52:56 -0800 Subject: [PATCH 04/17] reframe to just prelude --- substrate/frame/assets-freezer/src/impls.rs | 18 +++++++----------- substrate/frame/assets-freezer/src/lib.rs | 2 +- substrate/frame/assets-freezer/src/mock.rs | 10 ++-------- substrate/frame/assets-freezer/src/tests.rs | 1 + 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/substrate/frame/assets-freezer/src/impls.rs b/substrate/frame/assets-freezer/src/impls.rs index c6113559ac67..2afb183a1fe7 100644 --- a/substrate/frame/assets-freezer/src/impls.rs +++ b/substrate/frame/assets-freezer/src/impls.rs @@ -16,15 +16,11 @@ // limitations under the License. use super::*; - -use frame::{ - deps::sp_runtime, - traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, - Zero, - }, +use frame::traits::{ + fungibles::{Inspect, InspectFreeze, MutateFreeze}, + tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, }; + use pallet_assets::FrozenBalance; // Implements [`FrozenBalance`] from [`pallet-assets`], so it can understand how much of an @@ -118,7 +114,7 @@ impl, I: 'static> MutateFreeze for Pallet { id: &Self::Id, who: &T::AccountId, amount: Self::Balance, - ) -> sp_runtime::DispatchResult { + ) -> DispatchResult { if amount.is_zero() { return Self::thaw(asset, id, who); } @@ -138,7 +134,7 @@ impl, I: 'static> MutateFreeze for Pallet { id: &Self::Id, who: &T::AccountId, amount: Self::Balance, - ) -> sp_runtime::DispatchResult { + ) -> DispatchResult { if amount.is_zero() { return Ok(()); } @@ -153,7 +149,7 @@ impl, I: 'static> MutateFreeze for Pallet { Self::update_freezes(asset, who, freezes.as_bounded_slice()) } - fn thaw(asset: Self::AssetId, id: &Self::Id, who: &T::AccountId) -> sp_runtime::DispatchResult { + fn thaw(asset: Self::AssetId, id: &Self::Id, who: &T::AccountId) -> DispatchResult { let mut freezes = Freezes::::get(asset.clone(), who); freezes.retain(|f| &f.id != id); Self::update_freezes(asset, who, freezes.as_bounded_slice()) diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index d9cc75d579dd..898d0ff4fc46 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -44,7 +44,7 @@ use frame::{ prelude::*, - traits::{tokens::IdAmount, Saturating, VariantCount, VariantCountOf, Zero}, + traits::{tokens::IdAmount, VariantCount, VariantCountOf}, }; pub use pallet::*; diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index b4dabf327fcb..27bf11e57ac0 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -21,14 +21,8 @@ use crate as pallet_assets_freezer; pub use crate::*; use codec::{Compact, Decode, Encode, MaxEncodedLen}; use frame::{ - hashing::H256, - pallet_macros::derive_impl, - runtime::{ - prelude::{construct_runtime, ConstU32, ConstU64}, - testing_prelude::BuildStorage, - }, - testing_prelude::{assert_ok, TestExternalities}, - traits::{AsEnsureOriginWithArg, BlakeTwo256, Everything, IdentityLookup}, + testing_prelude::*, + traits::{AsEnsureOriginWithArg, Everything, IdentityLookup}, }; use scale_info::TypeInfo; diff --git a/substrate/frame/assets-freezer/src/tests.rs b/substrate/frame/assets-freezer/src/tests.rs index 87fc69f11b34..f560c682a0e5 100644 --- a/substrate/frame/assets-freezer/src/tests.rs +++ b/substrate/frame/assets-freezer/src/tests.rs @@ -27,6 +27,7 @@ use frame::{ tokens::{Fortitude, Preservation}, }, }; + use pallet_assets::FrozenBalance; const WHO: AccountId = 1; From 7a04cfb2fef5a3d849a50d67feeede5b401360e0 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 6 Dec 2024 17:57:18 -0800 Subject: [PATCH 05/17] nit --- substrate/frame/assets-freezer/src/impls.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/assets-freezer/src/impls.rs b/substrate/frame/assets-freezer/src/impls.rs index 2afb183a1fe7..7e2e477850b1 100644 --- a/substrate/frame/assets-freezer/src/impls.rs +++ b/substrate/frame/assets-freezer/src/impls.rs @@ -20,7 +20,6 @@ use frame::traits::{ fungibles::{Inspect, InspectFreeze, MutateFreeze}, tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, }; - use pallet_assets::FrozenBalance; // Implements [`FrozenBalance`] from [`pallet-assets`], so it can understand how much of an From c4bf18420f0e8dde00d1c088d1fa4690cfe23242 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 6 Dec 2024 17:58:59 -0800 Subject: [PATCH 06/17] nit spaces --- substrate/frame/assets-freezer/src/tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/assets-freezer/src/tests.rs b/substrate/frame/assets-freezer/src/tests.rs index f560c682a0e5..87fc69f11b34 100644 --- a/substrate/frame/assets-freezer/src/tests.rs +++ b/substrate/frame/assets-freezer/src/tests.rs @@ -27,7 +27,6 @@ use frame::{ tokens::{Fortitude, Preservation}, }, }; - use pallet_assets::FrozenBalance; const WHO: AccountId = 1; From e99453bb8db20656ccfec7c365d437cae9315442 Mon Sep 17 00:00:00 2001 From: runcomet Date: Sat, 7 Dec 2024 11:45:56 -0800 Subject: [PATCH 07/17] TryRuntimeError feature flag --- substrate/frame/assets-freezer/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 898d0ff4fc46..528291ef9864 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -46,6 +46,10 @@ use frame::{ prelude::*, traits::{tokens::IdAmount, VariantCount, VariantCountOf}, }; + +#[cfg(feature = "try-runtime")] +use frame::try_runtime::TryRuntimeError; + pub use pallet::*; #[cfg(test)] @@ -118,7 +122,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { #[cfg(feature = "try-runtime")] - fn try_state(_: BlockNumberFor) -> Result<(), frame::deps::sp_runtime::TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -153,7 +157,7 @@ impl, I: 'static> Pallet { } #[cfg(any(test, feature = "try-runtime"))] - fn do_try_state() -> Result<(), frame::deps::sp_runtime::TryRuntimeError> { + fn do_try_state() -> Result<(), TryRuntimeError> { for (asset, who, _) in FrozenBalances::::iter() { let max_frozen_amount = Freezes::::get(asset.clone(), who.clone()).iter().map(|l| l.amount).max(); From 5610a999b9d6a2f9ec80ff112656dfd664e2ac33 Mon Sep 17 00:00:00 2001 From: runcomet Date: Wed, 11 Dec 2024 14:14:57 -0800 Subject: [PATCH 08/17] remove prdoc --- prdoc/pr_6599.prdoc | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 prdoc/pr_6599.prdoc diff --git a/prdoc/pr_6599.prdoc b/prdoc/pr_6599.prdoc deleted file mode 100644 index 1a84354d7483..000000000000 --- a/prdoc/pr_6599.prdoc +++ /dev/null @@ -1,13 +0,0 @@ -# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 -# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json - -title: migrate pallet-assets-freezer to umbrella crate - -doc: - - audience: Runtime Dev - description: | - Imports frame umbrella crate systems into pallet-assets-freezer. - -crates: - - name: pallet-assets-freezer - bump: minor From b5639b1692273f7770f4fbac5f0ba252d96ea369 Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 27 Dec 2024 16:23:29 -0800 Subject: [PATCH 09/17] only preludes --- substrate/frame/assets-freezer/src/impls.rs | 4 -- substrate/frame/assets-freezer/src/lib.rs | 14 ++----- substrate/frame/assets-freezer/src/mock.rs | 6 +-- substrate/frame/assets-freezer/src/tests.rs | 14 ++----- substrate/frame/src/lib.rs | 43 +++++++++++++++++++-- 5 files changed, 49 insertions(+), 32 deletions(-) diff --git a/substrate/frame/assets-freezer/src/impls.rs b/substrate/frame/assets-freezer/src/impls.rs index 7e2e477850b1..8c9f148e1e9a 100644 --- a/substrate/frame/assets-freezer/src/impls.rs +++ b/substrate/frame/assets-freezer/src/impls.rs @@ -16,10 +16,6 @@ // limitations under the License. use super::*; -use frame::traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::{DepositConsequence, Fortitude, Preservation, Provenance, WithdrawConsequence}, -}; use pallet_assets::FrozenBalance; // Implements [`FrozenBalance`] from [`pallet-assets`], so it can understand how much of an diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 528291ef9864..48bd0707d287 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -42,13 +42,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame::{ - prelude::*, - traits::{tokens::IdAmount, VariantCount, VariantCountOf}, -}; - -#[cfg(feature = "try-runtime")] -use frame::try_runtime::TryRuntimeError; +use frame::prelude::*; pub use pallet::*; @@ -122,7 +116,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { #[cfg(feature = "try-runtime")] - fn try_state(_: BlockNumberFor) -> Result<(), TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), frame::try_runtime::TryRuntimeError> { Self::do_try_state() } } @@ -156,8 +150,8 @@ impl, I: 'static> Pallet { Ok(()) } - #[cfg(any(test, feature = "try-runtime"))] - fn do_try_state() -> Result<(), TryRuntimeError> { + #[cfg(feature = "try-runtime")] + fn do_try_state() -> Result<(), frame::try_runtime::TryRuntimeError> { for (asset, who, _) in FrozenBalances::::iter() { let max_frozen_amount = Freezes::::get(asset.clone(), who.clone()).iter().map(|l| l.amount).max(); diff --git a/substrate/frame/assets-freezer/src/mock.rs b/substrate/frame/assets-freezer/src/mock.rs index 27bf11e57ac0..ad08787aba27 100644 --- a/substrate/frame/assets-freezer/src/mock.rs +++ b/substrate/frame/assets-freezer/src/mock.rs @@ -20,10 +20,7 @@ use crate as pallet_assets_freezer; pub use crate::*; use codec::{Compact, Decode, Encode, MaxEncodedLen}; -use frame::{ - testing_prelude::*, - traits::{AsEnsureOriginWithArg, Everything, IdentityLookup}, -}; +use frame::testing_prelude::*; use scale_info::TypeInfo; pub type AccountId = u64; @@ -144,6 +141,7 @@ pub fn new_test_ext(execute: impl FnOnce()) -> TestExternalities { ext.execute_with(|| { System::set_block_number(1); execute(); + #[cfg(feature = "try-runtime")] assert_ok!(AssetsFreezer::do_try_state()); }); diff --git a/substrate/frame/assets-freezer/src/tests.rs b/substrate/frame/assets-freezer/src/tests.rs index 87fc69f11b34..b890dc98b574 100644 --- a/substrate/frame/assets-freezer/src/tests.rs +++ b/substrate/frame/assets-freezer/src/tests.rs @@ -17,22 +17,16 @@ //! Tests for pallet-assets-freezer. -use crate::mock::*; +use crate::mock::{self, *}; use codec::Compact; -use frame::{ - testing_prelude::*, - traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::{Fortitude, Preservation}, - }, -}; +use frame::testing_prelude::*; use pallet_assets::FrozenBalance; const WHO: AccountId = 1; -const ASSET_ID: AssetId = 1; +const ASSET_ID: mock::AssetId = 1; -fn test_set_freeze(id: DummyFreezeReason, amount: Balance) { +fn test_set_freeze(id: DummyFreezeReason, amount: mock::Balance) { let mut freezes = Freezes::::get(ASSET_ID, WHO); if let Some(i) = freezes.iter_mut().find(|l| l.id == id) { diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index c6d325f4f5fa..f3d5456d9d4f 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -216,12 +216,23 @@ pub mod prelude { /// All hashing related things pub use super::hashing::*; + /// All currency related things. + pub use super::currency::*; + + pub use super::utility::*; + + /// All account related things. + pub use super::account::*; + /// Runtime traits #[doc(no_inline)] - pub use sp_runtime::{traits::{ + pub use sp_runtime::traits::{ Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput, - }, BoundedSlice}; + }; + + /// Bounded storage related types. + pub use sp_runtime::{BoundedSlice, BoundedVec}; /// Other error/result types for runtime #[doc(no_inline)] @@ -307,8 +318,8 @@ pub mod testing_prelude { /// Other helper macros from `frame_support` that help with asserting in tests. pub use frame_support::{ - assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, ensure, - assert_storage_noop, storage_alias, + assert_err, assert_err_ignore_postinfo, assert_error_encoded_size, assert_noop, assert_ok, + assert_storage_noop, ensure, storage_alias, }; pub use frame_system::{self, mocking::*}; @@ -532,6 +543,30 @@ pub mod hashing { pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256}; } +/// Currency related traits. +pub mod currency { + pub use frame_support::traits::{ + fungibles::{Inspect, InspectFreeze, MutateFreeze}, + tokens::*, + Currency, + ExistenceRequirement::KeepAlive, + OnUnbalanced, ReservableCurrency, + }; +} + +/// Traits related to Accounts on substrate based chains. +pub mod account { + pub use frame_support::traits::{ + AsEnsureOriginWithArg, ChangeMembers, EitherOfDiverse, InitializeMembers, + }; + pub use sp_runtime::traits::{IdentifyAccount, IdentityLookup}; +} + +/// Utility traits and types not tied to any direct operation in the runtime. +pub mod utility { + pub use frame_support::traits::{Everything, VariantCount, VariantCountOf}; +} + /// Access to all of the dependencies of this crate. In case the prelude re-exports are not enough, /// this module can be used. /// From 22d166e0bf3e021bf9d66e5963837538deff3d6b Mon Sep 17 00:00:00 2001 From: runcomet Date: Sat, 28 Dec 2024 07:11:52 -0800 Subject: [PATCH 10/17] commets account prelude --- substrate/frame/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index f3d5456d9d4f..5c3aaec66eaf 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -544,6 +544,8 @@ pub mod hashing { } /// Currency related traits. +/// +/// This is already part of the [`prelude`]. pub mod currency { pub use frame_support::traits::{ fungibles::{Inspect, InspectFreeze, MutateFreeze}, @@ -554,7 +556,9 @@ pub mod currency { }; } -/// Traits related to Accounts on substrate based chains. +/// All account management related traits. +/// +/// This is already part of the [`prelude`]. pub mod account { pub use frame_support::traits::{ AsEnsureOriginWithArg, ChangeMembers, EitherOfDiverse, InitializeMembers, From 85277d83855ca2cc046d4da678228324198ad8f7 Mon Sep 17 00:00:00 2001 From: runcomet Date: Sat, 28 Dec 2024 07:30:55 -0800 Subject: [PATCH 11/17] utility mod comment fix --- substrate/frame/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 5c3aaec66eaf..9801c5ca72b6 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -566,7 +566,7 @@ pub mod account { pub use sp_runtime::traits::{IdentifyAccount, IdentityLookup}; } -/// Utility traits and types not tied to any direct operation in the runtime. +/// Utility traits not tied to any direct operation in the runtime. pub mod utility { pub use frame_support::traits::{Everything, VariantCount, VariantCountOf}; } From 137b5f5bb615465e2efe64390cfab1012905bc02 Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 30 Dec 2024 18:46:11 +0100 Subject: [PATCH 12/17] BlockNumberProvider in --- Cargo.lock | 140 ++++++++++++---------- substrate/frame/assets-freezer/Cargo.toml | 5 +- substrate/frame/src/lib.rs | 4 +- 3 files changed, 79 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99fa6e430f6f..b274f40f6064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1396,7 +1396,7 @@ dependencies = [ "futures-lite 2.3.0", "parking", "polling 3.4.0", - "rustix 0.38.21", + "rustix 0.38.25", "slab", "tracing", "windows-sys 0.52.0", @@ -1478,7 +1478,7 @@ dependencies = [ "cfg-if", "event-listener 5.3.1", "futures-lite 2.3.0", - "rustix 0.38.21", + "rustix 0.38.25", "tracing", ] @@ -1494,7 +1494,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.21", + "rustix 0.38.25", "signal-hook-registry", "slab", "windows-sys 0.52.0", @@ -6978,9 +6978,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "foreign-types" @@ -7819,7 +7819,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" dependencies = [ - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -8640,9 +8640,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.3.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -8683,7 +8683,7 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-util", "log", "rustls 0.23.18", @@ -8722,20 +8722,19 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.5.2", "pin-project-lite", "socket2 0.5.7", "tokio", - "tower", "tower-service", "tracing", ] @@ -9082,7 +9081,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.9", - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -9339,7 +9338,7 @@ dependencies = [ "async-trait", "base64 0.22.1", "http-body 1.0.0", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-rustls 0.27.3", "hyper-util", "jsonrpsee-core", @@ -9350,7 +9349,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tower", + "tower 0.4.13", "tracing", "url", ] @@ -9378,7 +9377,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", @@ -9391,7 +9390,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "tower", + "tower 0.4.13", "tracing", ] @@ -9568,7 +9567,7 @@ dependencies = [ "tokio", "tokio-tungstenite", "tokio-util", - "tower", + "tower 0.4.13", "tower-http 0.4.4", "tracing", ] @@ -10276,7 +10275,7 @@ dependencies = [ "thiserror", "tracing", "yamux 0.12.1", - "yamux 0.13.3", + "yamux 0.13.4", ] [[package]] @@ -10401,9 +10400,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lioness" @@ -11273,13 +11272,14 @@ dependencies = [ [[package]] name = "nix" -version = "0.26.4" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", + "static_assertions", ] [[package]] @@ -17892,7 +17892,7 @@ dependencies = [ "futures", "futures-timer", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-util", "log", "parity-scale-codec", @@ -20172,7 +20172,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.21", + "rustix 0.38.25", "tracing", "windows-sys 0.52.0", ] @@ -20232,7 +20232,7 @@ dependencies = [ "findshlibs", "libc", "log", - "nix 0.26.4", + "nix 0.26.2", "once_cell", "parking_lot 0.12.3", "smallvec", @@ -20480,7 +20480,7 @@ dependencies = [ "hex", "lazy_static", "procfs-core", - "rustix 0.38.21", + "rustix 0.38.25", ] [[package]] @@ -20683,7 +20683,7 @@ dependencies = [ "log", "names", "prost 0.11.9", - "reqwest 0.11.27", + "reqwest 0.11.20", "thiserror", "url", "winapi", @@ -21227,9 +21227,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.27" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ "base64 0.21.7", "bytes", @@ -21255,8 +21255,6 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls 0.24.1", @@ -21271,9 +21269,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.9" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +checksum = "7fe060fe50f524be480214aba758c71f99f90ee8c83c5a36b5e9e1d568eb4eb3" dependencies = [ "base64 0.22.1", "bytes", @@ -21283,7 +21281,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-rustls 0.27.3", "hyper-util", "ipnet", @@ -21300,9 +21298,10 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", "tokio-rustls 0.26.0", + "tower 0.5.2", "tower-service", "url", "wasm-bindgen", @@ -21849,14 +21848,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.10", + "linux-raw-sys 0.4.11", "windows-sys 0.48.0", ] @@ -23284,7 +23283,7 @@ dependencies = [ "futures", "futures-timer", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-rustls 0.27.3", "hyper-util", "log", @@ -23394,7 +23393,7 @@ dependencies = [ "governor", "http 1.1.0", "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "ip_network", "jsonrpsee", "log", @@ -23403,7 +23402,7 @@ dependencies = [ "serde_json", "substrate-prometheus-endpoint", "tokio", - "tower", + "tower 0.4.13", "tower-http 0.5.2", ] @@ -26395,7 +26394,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.4.1" -source = "git+https://github.com/paritytech/polkadot-sdk#82912acb33a9030c0ef3bf590a34fca09b72dc5f" +source = "git+https://github.com/paritytech/polkadot-sdk#838a534da874cf6071fba1df07643c6c5b033ae0" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -27218,7 +27217,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#82912acb33a9030c0ef3bf590a34fca09b72dc5f" +source = "git+https://github.com/paritytech/polkadot-sdk#838a534da874cf6071fba1df07643c6c5b033ae0" dependencies = [ "Inflector", "proc-macro-crate 1.3.1", @@ -28549,7 +28548,7 @@ name = "substrate-prometheus-endpoint" version = "0.17.0" dependencies = [ "http-body-util", - "hyper 1.3.1", + "hyper 1.5.2", "hyper-util", "log", "prometheus", @@ -28848,7 +28847,7 @@ dependencies = [ "log", "num-format", "rand", - "reqwest 0.12.9", + "reqwest 0.12.11", "scale-info", "semver 1.0.18", "serde", @@ -29181,12 +29180,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.1" @@ -29287,7 +29280,7 @@ dependencies = [ "cfg-if", "fastrand 2.1.0", "redox_syscall 0.4.1", - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -29317,7 +29310,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "rustix 0.38.21", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -29895,6 +29888,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.4.4" @@ -29934,15 +29942,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -31978,9 +31986,9 @@ dependencies = [ [[package]] name = "yamux" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31b5e376a8b012bee9c423acdbb835fc34d45001cfa3106236a624e4b738028" +checksum = "17610762a1207ee816c6fadc29220904753648aba0a9ed61c7b8336e80a559c4" dependencies = [ "futures", "log", @@ -32059,7 +32067,7 @@ version = "1.0.0" dependencies = [ "futures-util", "parity-scale-codec", - "reqwest 0.12.9", + "reqwest 0.12.11", "serde", "serde_json", "thiserror", @@ -32079,7 +32087,7 @@ dependencies = [ "lazy_static", "multiaddr 0.18.1", "regex", - "reqwest 0.11.27", + "reqwest 0.11.20", "serde", "serde_json", "thiserror", @@ -32105,7 +32113,7 @@ dependencies = [ "multiaddr 0.18.1", "rand", "regex", - "reqwest 0.11.27", + "reqwest 0.11.20", "serde", "serde_json", "sha2 0.10.8", @@ -32148,7 +32156,7 @@ dependencies = [ "kube", "nix 0.27.1", "regex", - "reqwest 0.11.27", + "reqwest 0.11.20", "serde", "serde_json", "serde_yaml", @@ -32194,7 +32202,7 @@ dependencies = [ "nix 0.27.1", "rand", "regex", - "reqwest 0.11.27", + "reqwest 0.11.20", "thiserror", "tokio", "tracing", diff --git a/substrate/frame/assets-freezer/Cargo.toml b/substrate/frame/assets-freezer/Cargo.toml index ad35ab3c0279..8b36cceb64e1 100644 --- a/substrate/frame/assets-freezer/Cargo.toml +++ b/substrate/frame/assets-freezer/Cargo.toml @@ -21,6 +21,9 @@ scale-info = { features = ["derive"], workspace = true } frame = { workspace = true, features = ["experimental", "runtime"] } pallet-assets = { workspace = true } +[dev-dependencies] +pallet-balances = { workspace = true } + [features] default = ["std"] std = [ @@ -34,10 +37,8 @@ std = [ runtime-benchmarks = [ "frame/runtime-benchmarks", "pallet-assets/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", ] try-runtime = [ "frame/try-runtime", "pallet-assets/try-runtime", - "pallet-balances/try-runtime", ] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 8c1a6d18fe8b..0e3c65172b3b 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -227,8 +227,8 @@ pub mod prelude { /// Runtime traits #[doc(no_inline)] pub use sp_runtime::traits::{ - Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, Saturating, StaticLookup, - TrailingZeroInput, + BlockNumberProvider, Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion, + Saturating, StaticLookup, TrailingZeroInput, }; /// Bounded storage related types. From 1c3d103e768917779f03c7c8c0dcd851c6db5203 Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 30 Dec 2024 19:59:34 +0100 Subject: [PATCH 13/17] cargo features pallet-balances dev --- substrate/frame/assets-freezer/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/substrate/frame/assets-freezer/Cargo.toml b/substrate/frame/assets-freezer/Cargo.toml index 8b36cceb64e1..dcc8d62cb81c 100644 --- a/substrate/frame/assets-freezer/Cargo.toml +++ b/substrate/frame/assets-freezer/Cargo.toml @@ -37,8 +37,10 @@ std = [ runtime-benchmarks = [ "frame/runtime-benchmarks", "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", ] try-runtime = [ "frame/try-runtime", "pallet-assets/try-runtime", + "pallet-balances/try-runtime", ] From 7052024a63d79ef370a005544f6c0b7667f4ffc7 Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 30 Dec 2024 21:01:33 +0100 Subject: [PATCH 14/17] TryRuntimeError import, tokens::* adds Balance --- substrate/frame/assets-freezer/src/lib.rs | 7 +++++-- substrate/frame/src/lib.rs | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 48bd0707d287..4c5306b314bb 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -46,6 +46,9 @@ use frame::prelude::*; pub use pallet::*; +#[cfg(feature = "try-runtime")] +use frame::try_runtime::TryRuntimeError; + #[cfg(test)] mod mock; #[cfg(test)] @@ -116,7 +119,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { #[cfg(feature = "try-runtime")] - fn try_state(_: BlockNumberFor) -> Result<(), frame::try_runtime::TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -151,7 +154,7 @@ impl, I: 'static> Pallet { } #[cfg(feature = "try-runtime")] - fn do_try_state() -> Result<(), frame::try_runtime::TryRuntimeError> { + fn do_try_state() -> Result<(), TryRuntimeError> { for (asset, who, _) in FrozenBalances::::iter() { let max_frozen_amount = Freezes::::get(asset.clone(), who.clone()).iter().map(|l| l.amount).max(); diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 0e3c65172b3b..da883445281a 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -216,9 +216,6 @@ pub mod prelude { /// All hashing related things pub use super::hashing::*; - /// All currency related things. - pub use super::currency::*; - pub use super::utility::*; /// All account related things. @@ -234,6 +231,17 @@ pub mod prelude { /// Bounded storage related types. pub use sp_runtime::{BoundedSlice, BoundedVec}; + /// Currency related traits. + pub use frame_support::traits::{ + fungibles::{Inspect, InspectFreeze, MutateFreeze}, + tokens::{ + DepositConsequence, Fortitude, IdAmount, Preservation, Provenance, WithdrawConsequence, + }, + Currency, + ExistenceRequirement::KeepAlive, + OnUnbalanced, ReservableCurrency, + }; + /// Other error/result types for runtime #[doc(no_inline)] pub use sp_runtime::{DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError}; From bf34a2933dcd36677689bddc2cb97ca6a7fe9b1b Mon Sep 17 00:00:00 2001 From: runcomet Date: Tue, 31 Dec 2024 00:25:05 +0100 Subject: [PATCH 15/17] no mod needed for currency related systems --- substrate/frame/src/lib.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index da883445281a..9abf20986742 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -551,19 +551,6 @@ pub mod hashing { pub use sp_runtime::traits::{BlakeTwo256, Hash, Keccak256}; } -/// Currency related traits. -/// -/// This is already part of the [`prelude`]. -pub mod currency { - pub use frame_support::traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::*, - Currency, - ExistenceRequirement::KeepAlive, - OnUnbalanced, ReservableCurrency, - }; -} - /// All account management related traits. /// /// This is already part of the [`prelude`]. From 46c70713f00d2090671d96414856c7d48f74505f Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 3 Jan 2025 07:25:27 +0100 Subject: [PATCH 16/17] fix pallet docs import --- substrate/frame/assets-freezer/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 4c5306b314bb..1b94d443d8ab 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -18,10 +18,10 @@ //! # Assets Freezer Pallet //! //! A pallet capable of freezing fungibles from `pallet-assets`. This is an extension of -//! `pallet-assets`, wrapping [`fungibles::Inspect`](`frame_support::traits::fungibles::Inspect`). +//! `pallet-assets`, wrapping [`fungibles::Inspect`](`frame::prelude::Inspect`). //! It implements both -//! [`fungibles::freeze::Inspect`](frame_support::traits::fungibles::freeze::Inspect) and -//! [`fungibles::freeze::Mutate`](frame_support::traits::fungibles::freeze::Mutate). The complexity +//! [`fungibles::freeze::Inspect`](frame::prelude::InspectFreeze) and +//! [`fungibles::freeze::Mutate`](frame::prelude::MutateFreeze). The complexity //! of the operations is `O(n)`. where `n` is the variant count of `RuntimeFreezeReason`. //! //! ## Pallet API @@ -35,10 +35,9 @@ //! //! - Pallet hooks allowing [`pallet-assets`] to know the frozen balance for an account on a given //! asset (see [`pallet_assets::FrozenBalance`]). -//! - An implementation of -//! [`fungibles::freeze::Inspect`](frame_support::traits::fungibles::freeze::Inspect) and -//! [`fungibles::freeze::Mutate`](frame_support::traits::fungibles::freeze::Mutate), allowing -//! other pallets to manage freezes for the `pallet-assets` assets. +//! - An implementation of [`fungibles::freeze::Inspect`](frame::prelude::InspectFreeze) and +//! [`fungibles::freeze::Mutate`](frame::prelude::MutateFreeze), allowing other pallets to manage +//! freezes for the `pallet-assets` assets. #![cfg_attr(not(feature = "std"), no_std)] From a7c3cea14d11e57812151905d4caf6dfc8b89b08 Mon Sep 17 00:00:00 2001 From: runcomet Date: Sat, 4 Jan 2025 00:19:29 +0100 Subject: [PATCH 17/17] nit --- substrate/frame/assets-freezer/src/lib.rs | 22 +++++++++++++++------- substrate/frame/src/lib.rs | 17 +++-------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/substrate/frame/assets-freezer/src/lib.rs b/substrate/frame/assets-freezer/src/lib.rs index 1b94d443d8ab..5f718ed84820 100644 --- a/substrate/frame/assets-freezer/src/lib.rs +++ b/substrate/frame/assets-freezer/src/lib.rs @@ -18,10 +18,10 @@ //! # Assets Freezer Pallet //! //! A pallet capable of freezing fungibles from `pallet-assets`. This is an extension of -//! `pallet-assets`, wrapping [`fungibles::Inspect`](`frame::prelude::Inspect`). +//! `pallet-assets`, wrapping [`fungibles::Inspect`](`Inspect`). //! It implements both -//! [`fungibles::freeze::Inspect`](frame::prelude::InspectFreeze) and -//! [`fungibles::freeze::Mutate`](frame::prelude::MutateFreeze). The complexity +//! [`fungibles::freeze::Inspect`](InspectFreeze) and +//! [`fungibles::freeze::Mutate`](MutateFreeze). The complexity //! of the operations is `O(n)`. where `n` is the variant count of `RuntimeFreezeReason`. //! //! ## Pallet API @@ -35,13 +35,21 @@ //! //! - Pallet hooks allowing [`pallet-assets`] to know the frozen balance for an account on a given //! asset (see [`pallet_assets::FrozenBalance`]). -//! - An implementation of [`fungibles::freeze::Inspect`](frame::prelude::InspectFreeze) and -//! [`fungibles::freeze::Mutate`](frame::prelude::MutateFreeze), allowing other pallets to manage -//! freezes for the `pallet-assets` assets. +//! - An implementation of [`fungibles::freeze::Inspect`](InspectFreeze) and +//! [`fungibles::freeze::Mutate`](MutateFreeze), allowing other pallets to manage freezes for the +//! `pallet-assets` assets. #![cfg_attr(not(feature = "std"), no_std)] -use frame::prelude::*; +use frame::{ + prelude::*, + traits::{ + fungibles::{Inspect, InspectFreeze, MutateFreeze}, + tokens::{ + DepositConsequence, Fortitude, IdAmount, Preservation, Provenance, WithdrawConsequence, + }, + }, +}; pub use pallet::*; diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 9c6161f7ab7a..ce4fc31e00f3 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -240,22 +240,9 @@ pub mod prelude { /// Bounded storage related types. pub use sp_runtime::{BoundedSlice, BoundedVec}; - /// Currency related traits. - pub use frame_support::traits::{ - fungibles::{Inspect, InspectFreeze, MutateFreeze}, - tokens::{ - DepositConsequence, Fortitude, IdAmount, Preservation, Provenance, WithdrawConsequence, - }, - Currency, - ExistenceRequirement::KeepAlive, - OnUnbalanced, ReservableCurrency, - }; - /// Other error/result types for runtime #[doc(no_inline)] - pub use sp_runtime::{ - DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError, - }; + pub use sp_runtime::{DispatchErrorWithPostInfo, DispatchResultWithInfo, TokenError}; } #[cfg(any(feature = "try-runtime", test))] @@ -575,6 +562,8 @@ pub mod account { } /// Utility traits not tied to any direct operation in the runtime. +/// +/// This is already part of the [`prelude`].. pub mod utility { pub use frame_support::traits::{Everything, VariantCount, VariantCountOf}; }