diff --git a/Cargo.lock b/Cargo.lock index 02d7da8f7657..8e38ff81c715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11685,20 +11685,15 @@ dependencies = [ name = "pallet-asset-conversion-ops" version = "0.1.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "log", "pallet-asset-conversion 10.0.0", "pallet-assets 29.1.0", "pallet-balances 28.0.0", "parity-scale-codec", + "polkadot-sdk-frame 0.1.0", "primitive-types 0.13.1", "scale-info", "sp-arithmetic 23.0.0", - "sp-core 28.0.0", - "sp-io 30.0.0", - "sp-runtime 31.0.1", ] [[package]] diff --git a/substrate/frame/asset-conversion/ops/Cargo.toml b/substrate/frame/asset-conversion/ops/Cargo.toml index 66333f973d7f..7ac176fbcc11 100644 --- a/substrate/frame/asset-conversion/ops/Cargo.toml +++ b/substrate/frame/asset-conversion/ops/Cargo.toml @@ -17,14 +17,9 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { workspace = true } log = { workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -frame-benchmarking = { optional = true, workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } pallet-asset-conversion = { workspace = true } scale-info = { features = ["derive"], workspace = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } sp-arithmetic = { workspace = true } [dev-dependencies] @@ -36,9 +31,7 @@ primitive-types = { features = ["codec", "num-traits", "scale-info"], workspace default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "log/std", "pallet-asset-conversion/std", "pallet-assets/std", @@ -46,24 +39,16 @@ std = [ "primitive-types/std", "scale-info/std", "sp-arithmetic/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-asset-conversion/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-asset-conversion/try-runtime", "pallet-assets/try-runtime", "pallet-balances/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/asset-conversion/ops/src/benchmarking.rs b/substrate/frame/asset-conversion/ops/src/benchmarking.rs index 384e17c9f0aa..ea364ba400b2 100644 --- a/substrate/frame/asset-conversion/ops/src/benchmarking.rs +++ b/substrate/frame/asset-conversion/ops/src/benchmarking.rs @@ -19,15 +19,20 @@ use super::*; use crate::Pallet as AssetConversionOps; +use frame::{benchmarking::prelude::*, traits::{fungibles::{Create, Inspect, Mutate}, One}, deps::sp_core::Get}; +/* use frame_benchmarking::{v2::*, whitelisted_caller}; use frame_support::{ assert_ok, traits::fungibles::{Create, Inspect, Mutate}, }; use frame_system::RawOrigin as SystemOrigin; +*/ use pallet_asset_conversion::{BenchmarkHelper, Pallet as AssetConversion}; +/* use sp_core::Get; use sp_runtime::traits::One; +*/ /// Provides a pair of amounts expected to serve as sufficient initial liquidity for a pool. fn valid_liquidity_amount(ed1: T::Balance, ed2: T::Balance) -> (T::Balance, T::Balance) @@ -113,7 +118,7 @@ where mint_setup_fee_asset::(caller, asset1, asset2, &lp_token); assert_ok!(AssetConversion::::create_pool( - SystemOrigin::Signed(caller.clone()).into(), + RawOrigin::Signed(caller.clone()).into(), Box::new(asset1.clone()), Box::new(asset2.clone()) )); @@ -142,7 +147,7 @@ mod benchmarks { let (_, liquidity1, liquidity2) = create_asset_and_pool::(&caller, &asset1, &asset2); assert_ok!(AssetConversion::::add_liquidity( - SystemOrigin::Signed(caller.clone()).into(), + RawOrigin::Signed(caller.clone()).into(), Box::new(asset1.clone()), Box::new(asset2.clone()), liquidity1, @@ -153,7 +158,7 @@ mod benchmarks { )); #[extrinsic_call] - _(SystemOrigin::Signed(caller.clone()), Box::new(asset1.clone()), Box::new(asset2.clone())); + _(RawOrigin::Signed(caller.clone()), Box::new(asset1.clone()), Box::new(asset2.clone())); let pool_id = T::PoolLocator::pool_id(&asset1, &asset2).unwrap(); let (prior_account, new_account) = AssetConversionOps::::addresses(&pool_id).unwrap(); diff --git a/substrate/frame/asset-conversion/ops/src/lib.rs b/substrate/frame/asset-conversion/ops/src/lib.rs index 58c15b47a3eb..da978d9e089b 100644 --- a/substrate/frame/asset-conversion/ops/src/lib.rs +++ b/substrate/frame/asset-conversion/ops/src/lib.rs @@ -45,20 +45,26 @@ pub use weights::WeightInfo; extern crate alloc; use alloc::boxed::Box; +/* use frame_support::traits::{ fungible::{Inspect as FungibleInspect, Mutate as FungibleMutate}, fungibles::{roles::ResetTeam, Inspect, Mutate, Refund}, tokens::{Fortitude, Precision, Preservation}, AccountTouch, }; +*/ +use frame::{prelude::*, traits::{fungible::{Inspect as FungibleInspect, Mutate as FungibleMutate}, fungibles::{roles::ResetTeam, Inspect, Mutate, Refund}, tokens::{Fortitude, Precision, Preservation}, AccountTouch, TryConvert, Zero}}; use pallet_asset_conversion::{PoolLocator, Pools}; -use sp_runtime::traits::{TryConvert, Zero}; +// use sp_runtime::traits::{TryConvert, Zero}; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; + /* use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + */ #[pallet::pallet] pub struct Pallet(_); diff --git a/substrate/frame/asset-conversion/ops/src/mock.rs b/substrate/frame/asset-conversion/ops/src/mock.rs index 5c05faa6aa88..7a80cea4f00d 100644 --- a/substrate/frame/asset-conversion/ops/src/mock.rs +++ b/substrate/frame/asset-conversion/ops/src/mock.rs @@ -19,6 +19,8 @@ use crate as pallet_asset_conversion_ops; use core::default::Default; +use frame::{prelude::*, testing_prelude::*, hashing::U256, arithmetic::Permill, runtime::{prelude::{construct_runtime, derive_impl, ord_parameter_types, parameter_types, EnsureSigned, EnsureSignedBy}}, traits::{AccountIdConversion, tokens::{fungible::{NativeFromLeft, NativeOrWithId, UnionOf}, imbalance::ResolveAssetTo}, AsEnsureOriginWithArg, ConstU32, ConstU64}, deps::frame_support::{PalletId, instances::{Instance1, Instance2}}}; +/* use frame_support::{ construct_runtime, derive_impl, instances::{Instance1, Instance2}, @@ -33,10 +35,12 @@ use frame_support::{ PalletId, }; use frame_system::{EnsureSigned, EnsureSignedBy}; +*/ use pallet_asset_conversion::{self, AccountIdConverter, AccountIdConverterNoSeed, Ascending}; +/* use sp_arithmetic::Permill; use sp_runtime::{traits::AccountIdConversion, BuildStorage}; - +*/ type Block = frame_system::mocking::MockBlock; construct_runtime!( @@ -97,7 +101,7 @@ pub type AscendingLocator = Ascending, PoolIdToAccountI impl pallet_asset_conversion::Config for Test { type RuntimeEvent = RuntimeEvent; type Balance = ::Balance; - type HigherPrecisionBalance = sp_core::U256; + type HigherPrecisionBalance = U256; type AssetKind = NativeOrWithId; type Assets = NativeAndAssets; type PoolId = (Self::AssetKind, Self::AssetKind); @@ -130,7 +134,7 @@ impl pallet_asset_conversion_ops::Config for Test { type WeightInfo = (); } -pub(crate) fn new_test_ext() -> sp_io::TestExternalities { +pub(crate) fn new_test_ext() -> TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { @@ -139,7 +143,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let mut ext = TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext } diff --git a/substrate/frame/asset-conversion/ops/src/tests.rs b/substrate/frame/asset-conversion/ops/src/tests.rs index 84bbe6336747..bbfcc899050d 100644 --- a/substrate/frame/asset-conversion/ops/src/tests.rs +++ b/substrate/frame/asset-conversion/ops/src/tests.rs @@ -18,6 +18,7 @@ //! Asset Conversion Ops pallet tests. use crate::{mock::*, *}; +/* use frame_support::{ assert_noop, assert_ok, traits::{ @@ -26,6 +27,8 @@ use frame_support::{ Incrementable, }, }; +*/ +use frame::{testing_prelude::*, traits::{fungible::{Inspect as FungibleInspect, NativeOrWithId}, fungibles::{Create, Inspect}, Incrementable}}; #[test] fn migrate_pool_account_id_with_native() { diff --git a/substrate/frame/asset-conversion/ops/src/weights.rs b/substrate/frame/asset-conversion/ops/src/weights.rs index 65762bed72e2..9250fa8f319e 100644 --- a/substrate/frame/asset-conversion/ops/src/weights.rs +++ b/substrate/frame/asset-conversion/ops/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_asset_conversion_ops`.