diff --git a/Cargo.lock b/Cargo.lock index 182d8f6bacad..6bb5e0dd6f50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11723,19 +11723,13 @@ dependencies = [ name = "pallet-asset-conversion-tx-payment" version = "10.0.0" dependencies = [ - "frame-benchmarking 28.0.0", - "frame-support 28.0.0", - "frame-system 28.0.0", "pallet-asset-conversion 10.0.0", "pallet-assets 29.1.0", "pallet-balances 28.0.0", "pallet-transaction-payment 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", - "sp-storage 19.0.0", ] [[package]] diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index 0ca36ca8545a..1c93421c343f 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -202,7 +202,7 @@ pub mod prelude { /// Dispatch types from `frame-support`, other fundamental traits #[doc(no_inline)] - pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; + pub use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo}; pub use frame_support::traits::{Contains, IsSubType, OnRuntimeUpgrade}; /// Pallet prelude of `frame-system`. diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml b/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml index 7c98d157f6ff..815b76e841e5 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml @@ -17,19 +17,13 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # Substrate dependencies -sp-runtime = { workspace = true } -frame-benchmarking = { optional = true, workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } +frame = { workspace = true, features = ["experimental", "runtime"] } pallet-asset-conversion = { workspace = true } pallet-transaction-payment = { workspace = true } codec = { features = ["derive"], workspace = true } scale-info = { features = ["derive"], workspace = true } [dev-dependencies] -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-storage = { workspace = true } pallet-assets = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } @@ -37,35 +31,24 @@ pallet-balances = { workspace = true, default-features = true } default = ["std"] std = [ "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", + "frame/std", "pallet-asset-conversion/std", "pallet-assets/std", "pallet-balances/std", "pallet-transaction-payment/std", "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-storage/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", "pallet-transaction-payment/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", "pallet-transaction-payment/try-runtime", - "sp-runtime/try-runtime", ] diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/benchmarking.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/benchmarking.rs index eb2635694e9c..d256aaf61c8a 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/benchmarking.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/benchmarking.rs @@ -21,6 +21,8 @@ extern crate alloc; use super::*; use crate::Pallet; + +/* use frame_benchmarking::v2::*; use frame_support::{ dispatch::{DispatchInfo, PostDispatchInfo}, @@ -30,7 +32,8 @@ use frame_system::RawOrigin; use sp_runtime::traits::{ AsSystemOriginSigner, AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable, }; - +*/ +use frame::{benchmarking::prelude::*, traits::{AsSystemOriginSigner, AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable}, prelude::{DispatchInfo, PostDispatchInfo}}; #[benchmarks(where T::RuntimeOrigin: AsTransactionAuthorizedOrigin, T::RuntimeCall: Dispatchable, diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs index d6721c46422b..afb50ac40830 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs @@ -45,21 +45,9 @@ extern crate alloc; use codec::{Decode, Encode}; -use frame_support::{ - dispatch::{DispatchInfo, DispatchResult, PostDispatchInfo}, - pallet_prelude::TransactionSource, - traits::IsType, - DefaultNoBound, -}; +use frame::{prelude::*, deps::{frame_support::{dispatch::{DispatchInfo, DispatchResult, PostDispatchInfo}, traits::{IsType, tokens::AssetId}}, sp_runtime::{traits::{AsSystemOriginSigner, DispatchInfoOf, Dispatchable, PostDispatchInfoOf, RefundWeight, TransactionExtension, ValidateResult, Zero}, transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction}}}}; use pallet_transaction_payment::{ChargeTransactionPayment, OnChargeTransaction}; use scale_info::TypeInfo; -use sp_runtime::{ - traits::{ - AsSystemOriginSigner, DispatchInfoOf, Dispatchable, PostDispatchInfoOf, RefundWeight, - TransactionExtension, ValidateResult, Zero, - }, - transaction_validity::{InvalidTransaction, TransactionValidityError, ValidTransaction}, -}; #[cfg(test)] mod mock; @@ -71,7 +59,6 @@ pub mod weights; mod benchmarking; mod payment; -use frame_support::{pallet_prelude::Weight, traits::tokens::AssetId}; pub use payment::*; pub use weights::WeightInfo; @@ -104,7 +91,8 @@ pub enum InitialPayment { pub use pallet::*; -#[frame_support::pallet] +// #[frame_support::pallet] +#[frame::pallet] pub mod pallet { use super::*; diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs index a86b86c223ef..393529672e1a 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -15,7 +15,9 @@ use super::*; use crate as pallet_asset_conversion_tx_payment; - +use frame::{testing_prelude::*, traits::{fungible, fungibles::{self, Mutate}, AsEnsureOriginWithArg, Currency, AsTransactionAuthorizedOrigin, ConstU32, ConstU64, ConstU8, Imbalance, OnUnbalanced, tokens::{fungible::{NativeFromLeft, NativeOrWithId, UnionOf, /*imbalance::ResolveAssetTo*/}}, AccountIdConversion, IdentityLookup, SaturatedConversion}, deps::{frame_support::{derive_impl, weights::{Weight, WeightToFee as WeightToFeeT}, +PalletId, dispatch::{DispatchClass, PostDispatchInfo}, instances::Instance2, ord_parameter_types, parameter_types, traits::tokens::imbalance::ResolveAssetTo}, frame_system::{self as system, EnsureRoot, EnsureSignedBy}, sp_runtime::Permill}}; +/* use frame_support::{ derive_impl, dispatch::DispatchClass, @@ -36,18 +38,20 @@ use frame_support::{ }; use frame_system as system; use frame_system::{EnsureRoot, EnsureSignedBy}; +*/ use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset}; use pallet_transaction_payment::FungibleAdapter; +/* use sp_runtime::{ traits::{AccountIdConversion, IdentityLookup, SaturatedConversion}, Permill, }; - +*/ type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; -frame_support::construct_runtime!( +frame::runtime::prelude::construct_runtime!( pub enum Runtime { System: system, @@ -302,7 +306,7 @@ impl Config for Runtime { } #[cfg(feature = "runtime-benchmarks")] -pub fn new_test_ext() -> sp_io::TestExternalities { +pub fn new_test_ext() -> frame::deps::sp_io::TestExternalities { let base_weight = 5; let balance_factor = 100; crate::tests::ExtBuilder::default() @@ -321,8 +325,8 @@ impl BenchmarkHelperTrait, NativeOrWithId> for Hel } fn setup_balances_and_pool(asset_id: NativeOrWithId, account: u64) { - use frame_support::{assert_ok, traits::fungibles::Mutate}; - use sp_runtime::traits::StaticLookup; + //use frame_support::{assert_ok, traits::fungibles::Mutate}; + //use sp_runtime::traits::StaticLookup; let NativeOrWithId::WithId(asset_idx) = asset_id.clone() else { unimplemented!() }; assert_ok!(Assets::force_create( RuntimeOrigin::root(), @@ -356,7 +360,7 @@ impl BenchmarkHelperTrait, NativeOrWithId> for Hel lp_provider_account, )); - use frame_support::traits::Currency; + //use frame_support::traits::Currency; let _ = Balances::deposit_creating(&account, u32::MAX.into()); let beneficiary = ::Lookup::unlookup(account); diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs index 05182c3c9ee6..de3603f02b1f 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs @@ -19,6 +19,7 @@ use crate::Config; use alloc::vec; use core::marker::PhantomData; +/* use frame_support::{ defensive, ensure, traits::{ @@ -28,13 +29,16 @@ use frame_support::{ }, unsigned::TransactionValidityError, }; +*/ use pallet_asset_conversion::{QuotePrice, SwapCredit}; +/* use sp_runtime::{ traits::{DispatchInfoOf, Get, PostDispatchInfoOf, Zero}, transaction_validity::InvalidTransaction, Saturating, }; - +*/ +use frame::{deps::{frame_support::{self, defensive, ensure, unsigned::TransactionValidityError, traits::{fungibles, Defensive, OnUnbalanced, SameOrOther, tokens::{Balance, Fortitude, Precision, Preservation, WithdrawConsequence}}}, sp_runtime::{transaction_validity::InvalidTransaction, Saturating, traits::{DispatchInfoOf, Get, PostDispatchInfoOf, Zero}}}}; /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeAssetTransaction { /// The underlying integer type in which fees are calculated. diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs index 6ce4652fd42f..2314ba2cc43a 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs @@ -14,7 +14,9 @@ // limitations under the License. use super::*; - +use frame::{prelude::*, deps::{frame_support::{assert_ok, dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo}, traits::{fungible::{Inspect, NativeOrWithId}, fungibles::{Inspect as FungiblesInspect, Mutate}, tokens::{Fortitude, Precision, Preservation}, OriginTrait}, weights::Weight}, frame_system::{self as system}, sp_runtime::{traits::{DispatchTransaction, StaticLookup}, BuildStorage}}}; +// use frame::testing_prelude::*; +/* use frame_support::{ assert_ok, dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo}, @@ -28,13 +30,15 @@ use frame_support::{ weights::Weight, }; use frame_system as system; +*/ use mock::{ExtrinsicBaseWeight, *}; use pallet_balances::Call as BalancesCall; +/* use sp_runtime::{ traits::{DispatchTransaction, StaticLookup}, BuildStorage, }; - +*/ const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 }); @@ -70,7 +74,7 @@ impl ExtBuilder { TRANSACTION_BYTE_FEE.with(|v| *v.borrow_mut() = self.byte_fee); WEIGHT_TO_FEE.with(|v| *v.borrow_mut() = self.weight_to_fee); } - pub fn build(self) -> sp_io::TestExternalities { + pub fn build(self) -> frame::deps::sp_io::TestExternalities { self.set_constants(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { @@ -907,7 +911,7 @@ fn no_fee_and_no_weight_for_other_origins() { assert!(origin.as_system_ref().unwrap().is_root()); let pd_res = Ok(()); - let mut post_info = frame_support::dispatch::PostDispatchInfo { + let mut post_info = PostDispatchInfo { actual_weight: Some(info.total_weight()), pays_fee: Default::default(), }; diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/weights.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/weights.rs index 587a399634b7..75d684c61917 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/weights.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/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_tx_payment`.