Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pallet-transaction-payment to umbrella crate #6625

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,38 @@ 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 }

[features]
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",
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extern crate alloc;

use super::*;
use crate::Pallet;

/*
use frame_benchmarking::v2::*;
use frame_support::{
dispatch::{DispatchInfo, PostDispatchInfo},
Expand All @@ -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<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -104,7 +91,8 @@ pub enum InitialPayment<T: Config> {

pub use pallet::*;

#[frame_support::pallet]
// #[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Runtime>;
type Balance = u64;
type AccountId = u64;

frame_support::construct_runtime!(
frame::runtime::prelude::construct_runtime!(
pub enum Runtime
{
System: system,
Expand Down Expand Up @@ -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()
Expand All @@ -321,8 +325,8 @@ impl BenchmarkHelperTrait<u64, NativeOrWithId<u32>, NativeOrWithId<u32>> for Hel
}

fn setup_balances_and_pool(asset_id: NativeOrWithId<u32>, 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(),
Expand Down Expand Up @@ -356,7 +360,7 @@ impl BenchmarkHelperTrait<u64, NativeOrWithId<u32>, NativeOrWithId<u32>> 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 = <Runtime as system::Config>::Lookup::unlookup(account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::Config;

use alloc::vec;
use core::marker::PhantomData;
/*
use frame_support::{
defensive, ensure,
traits::{
Expand All @@ -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<T: Config> {
/// The underlying integer type in which fees are calculated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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: &<Runtime as frame_system::Config>::RuntimeCall =
&RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 2, value: 69 });

Expand Down Expand Up @@ -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::<Runtime>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Runtime> {
Expand Down Expand Up @@ -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(),
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.