From beadf5edbf21d08918f9c4e035f7204a38a9a777 Mon Sep 17 00:00:00 2001 From: runcomet Date: Thu, 21 Nov 2024 09:43:39 -0800 Subject: [PATCH 1/3] frame import --- Cargo.lock | 6 +----- substrate/frame/atomic-swap/Cargo.toml | 16 +++------------- substrate/frame/atomic-swap/src/lib.rs | 10 +++++++++- substrate/frame/atomic-swap/src/tests.rs | 7 +++++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02d7da8f7657..9d758af5ef0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11894,14 +11894,10 @@ dependencies = [ name = "pallet-atomic-swap" version = "28.0.0" dependencies = [ - "frame-support 28.0.0", - "frame-system 28.0.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/atomic-swap/Cargo.toml b/substrate/frame/atomic-swap/Cargo.toml index db89a58da8f0..1f97f60149ba 100644 --- a/substrate/frame/atomic-swap/Cargo.toml +++ b/substrate/frame/atomic-swap/Cargo.toml @@ -18,11 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true } scale-info = { features = ["derive"], workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } [dev-dependencies] pallet-balances = { workspace = true, default-features = true } @@ -31,17 +27,11 @@ pallet-balances = { workspace = true, default-features = true } default = ["std"] std = [ "codec/std", - "frame-support/std", - "frame-system/std", + "frame/std", "pallet-balances/std", "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", ] 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/atomic-swap/src/lib.rs b/substrate/frame/atomic-swap/src/lib.rs index c3010f5c9c03..1355c84887c4 100644 --- a/substrate/frame/atomic-swap/src/lib.rs +++ b/substrate/frame/atomic-swap/src/lib.rs @@ -50,6 +50,7 @@ use core::{ marker::PhantomData, ops::{Deref, DerefMut}, }; +/* use frame_support::{ dispatch::DispatchResult, pallet_prelude::MaxEncodedLen, @@ -58,9 +59,13 @@ use frame_support::{ RuntimeDebugNoBound, }; use frame_system::pallet_prelude::BlockNumberFor; +*/ use scale_info::TypeInfo; +use frame::{prelude::*, deps::{frame_support::{dispatch::DispatchResult, pallet_prelude::MaxEncodedLen, traits::{BalanceStatus, Currency, Get, ReservableCurrency}, weights::Weight}, sp_io::hashing::blake2_256}, derive::{RuntimeDebug, RuntimeDebugNoBound}}; +/* use sp_io::hashing::blake2_256; use sp_runtime::RuntimeDebug; +*/ /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] @@ -159,11 +164,14 @@ where pub use pallet::*; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + */ /// Atomic swap's pallet configuration trait. #[pallet::config] diff --git a/substrate/frame/atomic-swap/src/tests.rs b/substrate/frame/atomic-swap/src/tests.rs index 47ebe6a8f0ac..9148f22609c9 100644 --- a/substrate/frame/atomic-swap/src/tests.rs +++ b/substrate/frame/atomic-swap/src/tests.rs @@ -20,12 +20,15 @@ use super::*; use crate as pallet_atomic_swap; +/* use frame_support::{derive_impl, traits::ConstU32}; use sp_runtime::BuildStorage; +*/ +use frame::{runtime::{prelude::{derive_impl, ConstU32, construct_runtime}, testing_prelude::BuildStorage}, testing_prelude::TestExternalities}; type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test { System: frame_system, @@ -54,7 +57,7 @@ impl Config for Test { const A: u64 = 1; const B: u64 = 2; -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let genesis = pallet_balances::GenesisConfig:: { balances: vec![(A, 100), (B, 200)] }; genesis.assimilate_storage(&mut t).unwrap(); From c55eef92dcc7acf64801c4b926285a8b152b605d Mon Sep 17 00:00:00 2001 From: runcomet Date: Fri, 22 Nov 2024 18:53:51 -0800 Subject: [PATCH 2/3] cargo fmt --- substrate/frame/atomic-swap/src/lib.rs | 30 ++++++++++-------------- substrate/frame/atomic-swap/src/tests.rs | 13 +++++----- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/substrate/frame/atomic-swap/src/lib.rs b/substrate/frame/atomic-swap/src/lib.rs index 1355c84887c4..37aaf01d7885 100644 --- a/substrate/frame/atomic-swap/src/lib.rs +++ b/substrate/frame/atomic-swap/src/lib.rs @@ -50,22 +50,20 @@ use core::{ marker::PhantomData, ops::{Deref, DerefMut}, }; -/* -use frame_support::{ - dispatch::DispatchResult, - pallet_prelude::MaxEncodedLen, - traits::{BalanceStatus, Currency, Get, ReservableCurrency}, - weights::Weight, - RuntimeDebugNoBound, +use frame::{ + deps::{ + frame_support::{ + dispatch::DispatchResult, + pallet_prelude::MaxEncodedLen, + traits::{BalanceStatus, Currency, Get, ReservableCurrency}, + weights::Weight, + }, + sp_io::hashing::blake2_256, + }, + derive::{RuntimeDebug, RuntimeDebugNoBound}, + prelude::*, }; -use frame_system::pallet_prelude::BlockNumberFor; -*/ use scale_info::TypeInfo; -use frame::{prelude::*, deps::{frame_support::{dispatch::DispatchResult, pallet_prelude::MaxEncodedLen, traits::{BalanceStatus, Currency, Get, ReservableCurrency}, weights::Weight}, sp_io::hashing::blake2_256}, derive::{RuntimeDebug, RuntimeDebugNoBound}}; -/* -use sp_io::hashing::blake2_256; -use sp_runtime::RuntimeDebug; -*/ /// Pending atomic swap operation. #[derive(Clone, Eq, PartialEq, RuntimeDebugNoBound, Encode, Decode, TypeInfo, MaxEncodedLen)] @@ -168,10 +166,6 @@ pub use pallet::*; #[frame::pallet] pub mod pallet { use super::*; - /* - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - */ /// Atomic swap's pallet configuration trait. #[pallet::config] diff --git a/substrate/frame/atomic-swap/src/tests.rs b/substrate/frame/atomic-swap/src/tests.rs index 9148f22609c9..839fd1f7402e 100644 --- a/substrate/frame/atomic-swap/src/tests.rs +++ b/substrate/frame/atomic-swap/src/tests.rs @@ -19,12 +19,13 @@ use super::*; use crate as pallet_atomic_swap; - -/* -use frame_support::{derive_impl, traits::ConstU32}; -use sp_runtime::BuildStorage; -*/ -use frame::{runtime::{prelude::{derive_impl, ConstU32, construct_runtime}, testing_prelude::BuildStorage}, testing_prelude::TestExternalities}; +use frame::{ + runtime::{ + prelude::{construct_runtime, derive_impl, ConstU32}, + testing_prelude::BuildStorage, + }, + testing_prelude::TestExternalities, +}; type Block = frame_system::mocking::MockBlock; From 12f14e60944cc56ec34d4785c043338c2b0fda1d Mon Sep 17 00:00:00 2001 From: runcomet Date: Sun, 1 Dec 2024 01:10:17 -0800 Subject: [PATCH 3/3] add prdoc --- prdoc/pr_6601.prdoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prdoc/pr_6601.prdoc diff --git a/prdoc/pr_6601.prdoc b/prdoc/pr_6601.prdoc new file mode 100644 index 000000000000..852e78337bb6 --- /dev/null +++ b/prdoc/pr_6601.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-atomic-swap to umbrella crate + +doc: + - audience: Runtime Dev + description: | + Imports frame umbrella crate systems into pallet-atomic-swap. + +crates: + - name: pallet-atomic-swap + bump: minor