diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..df23693a9ff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15797,16 +15797,13 @@ dependencies = [ name = "pallet-vesting" 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", "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/src/lib.rs b/substrate/frame/src/lib.rs index 0ca36ca8545a..6e29218790b8 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -392,7 +392,7 @@ pub mod runtime { }; pub use sp_inherents::{CheckInherentsResult, InherentData}; pub use sp_keyring::AccountKeyring; - pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode}; + pub use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode, TransactionOutcome}; } /// Types and traits for runtimes that implement runtime APIs. diff --git a/substrate/frame/vesting/Cargo.toml b/substrate/frame/vesting/Cargo.toml index f896c3962eaa..2aaea0a2933f 100644 --- a/substrate/frame/vesting/Cargo.toml +++ b/substrate/frame/vesting/Cargo.toml @@ -21,10 +21,7 @@ codec = { features = [ ], 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 } +frame = { workspace = true, features = ["experimental", "runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -35,26 +32,16 @@ sp-io = { workspace = true } default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/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-balances/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", + "frame/try-runtime", "pallet-balances/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/vesting/src/benchmarking.rs b/substrate/frame/vesting/src/benchmarking.rs index 3797ee9079db..6e27f88193e4 100644 --- a/substrate/frame/vesting/src/benchmarking.rs +++ b/substrate/frame/vesting/src/benchmarking.rs @@ -18,12 +18,17 @@ //! Vesting pallet benchmarking. #![cfg(feature = "runtime-benchmarks")] - +/* use frame_benchmarking::{v2::*, BenchmarkError}; use frame_support::assert_ok; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul}; - +*/ +use frame::benchmarking::prelude::*; +use frame::testing_prelude::assert_ok; +use frame::traits::{Currency, Convert, WithdrawReasons, ExistenceRequirement, LockableCurrency, LockIdentifier, BlockNumberProvider, VestingSchedule, VestedTransfer}; +use frame::arithmetic::{AtLeast32BitUnsigned, One}; +use frame::runtime::{prelude::storage::with_transaction, prelude::TransactionOutcome}; use crate::*; const SEED: u32 = 0; diff --git a/substrate/frame/vesting/src/lib.rs b/substrate/frame/vesting/src/lib.rs index 15f8d397f81c..4ef1138f3864 100644 --- a/substrate/frame/vesting/src/lib.rs +++ b/substrate/frame/vesting/src/lib.rs @@ -61,6 +61,8 @@ extern crate alloc; use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; use core::{fmt::Debug, marker::PhantomData}; +use frame::prelude::*; +/* use frame_support::{ dispatch::DispatchResult, ensure, @@ -72,7 +74,14 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; +*/ use scale_info::TypeInfo; +use frame::traits::{Currency, Convert, WithdrawReasons, ExistenceRequirement, LockableCurrency, LockIdentifier, BlockNumberProvider, VestingSchedule, VestedTransfer}; +use frame::runtime::{prelude::storage::with_transaction, prelude::TransactionOutcome}; +use frame::arithmetic::One; + + +/* use sp_runtime::{ traits::{ AtLeast32BitUnsigned, BlockNumberProvider, Bounded, Convert, MaybeSerializeDeserialize, @@ -80,6 +89,7 @@ use sp_runtime::{ }, DispatchError, RuntimeDebug, }; +*/ pub use pallet::*; pub use vesting_info::*; @@ -151,11 +161,14 @@ impl Get for MaxVestingSchedulesGet { } } -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + */ #[pallet::config] pub trait Config: frame_system::Config { @@ -220,7 +233,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::genesis_config] - #[derive(frame_support::DefaultNoBound)] + #[derive(frame::derive::DefaultNoBound)] pub struct GenesisConfig { pub vesting: Vec<(T::AccountId, BlockNumberFor, BlockNumberFor, BalanceOf)>, } @@ -228,7 +241,7 @@ pub mod pallet { #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { - use sp_runtime::traits::Saturating; + // use sp_runtime::traits::Saturating; // Genesis uses the latest storage version. StorageVersion::::put(Releases::V1); @@ -244,7 +257,7 @@ pub mod pallet { // Total genesis `balance` minus `liquid` equals funds locked for vesting let locked = balance.saturating_sub(liquid); let length_as_balance = T::BlockNumberToBalance::convert(length); - let per_block = locked / length_as_balance.max(sp_runtime::traits::One::one()); + let per_block = locked / length_as_balance.max(One::one()); let vesting_info = VestingInfo::new(locked, per_block, begin); if !vesting_info.is_valid() { panic!("Invalid VestingInfo params at genesis") @@ -798,7 +811,7 @@ where per_block: BalanceOf, starting_block: BlockNumberFor, ) -> DispatchResult { - use frame_support::storage::{with_transaction, TransactionOutcome}; + // use frame_support::storage::{with_transaction, TransactionOutcome}; let schedule = VestingInfo::new(locked, per_block, starting_block); with_transaction(|| -> TransactionOutcome { let result = Self::do_vested_transfer(source, target, schedule); diff --git a/substrate/frame/vesting/src/mock.rs b/substrate/frame/vesting/src/mock.rs index f0954a5b989c..0a81384c69a5 100644 --- a/substrate/frame/vesting/src/mock.rs +++ b/substrate/frame/vesting/src/mock.rs @@ -15,15 +15,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +/* use frame_support::{derive_impl, parameter_types, traits::WithdrawReasons}; use sp_runtime::{traits::Identity, BuildStorage}; - +*/ +use frame::testing_prelude::*; use super::*; use crate as pallet_vesting; type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, diff --git a/substrate/frame/vesting/src/tests.rs b/substrate/frame/vesting/src/tests.rs index 0dd7133d930a..2a8e07fcdfeb 100644 --- a/substrate/frame/vesting/src/tests.rs +++ b/substrate/frame/vesting/src/tests.rs @@ -16,13 +16,15 @@ // limitations under the License. use codec::EncodeLike; +/* use frame_support::{assert_noop, assert_ok, assert_storage_noop}; use frame_system::RawOrigin; use sp_runtime::{ traits::{BadOrigin, Identity}, TokenError, }; - +*/ +use frame::testing_prelude::*; use super::{Vesting as VestingStorage, *}; use crate::mock::{Balances, ExtBuilder, System, Test, Vesting}; diff --git a/substrate/frame/vesting/src/vesting_info.rs b/substrate/frame/vesting/src/vesting_info.rs index 5d5ae31fc324..3e51c403f2c9 100644 --- a/substrate/frame/vesting/src/vesting_info.rs +++ b/substrate/frame/vesting/src/vesting_info.rs @@ -18,6 +18,10 @@ //! Module to enforce private fields on `VestingInfo`. use super::*; +use frame::arithmetic::{AtLeast32BitUnsigned, One}; +use frame::traits::Convert; + + /// Struct to encode the vesting schedule of an individual account. #[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)] diff --git a/substrate/frame/vesting/src/weights.rs b/substrate/frame/vesting/src/weights.rs index 3ab161e822e8..7a48796cfe21 100644 --- a/substrate/frame/vesting/src/weights.rs +++ b/substrate/frame/vesting/src/weights.rs @@ -46,7 +46,8 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +// use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame::weights_prelude::*; use core::marker::PhantomData; /// Weight functions needed for `pallet_vesting`.