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 fee payment from Currency to fungible #2292

Merged
merged 50 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
319838d
create FungibleAdapter
liamaharon Nov 13, 2023
9958cd2
allow deprecated
liamaharon Nov 13, 2023
47a02b4
convert weight trader to fungible
liamaharon Nov 15, 2023
bdbeea0
migrate to fungibleadapter
liamaharon Nov 16, 2023
b8d1575
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 16, 2023
f12e6a8
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 20, 2023
f695948
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 20, 2023
bbb4b0c
deprecate ToStakingPot and use ResolveTo
liamaharon Nov 21, 2023
5a8e1d7
update mock
liamaharon Nov 21, 2023
ed3a077
update mock
liamaharon Nov 21, 2023
360ceb1
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 23, 2023
98f2878
use fungible adapter in test runtime
liamaharon Nov 23, 2023
e0bc520
fix treasury on unbalanced usage
liamaharon Nov 23, 2023
78819c3
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 23, 2023
2a66ec5
remove unused imports
liamaharon Nov 23, 2023
230fd83
Merge branch 'liam-currency-adapter-fungible' of github.com:paritytec…
liamaharon Nov 23, 2023
6558225
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 24, 2023
6341e2a
fix imports
liamaharon Nov 24, 2023
dc0ecc9
remove unnecesarry comment
liamaharon Nov 24, 2023
e60f53d
add deprecated item removal date
liamaharon Nov 24, 2023
a41246a
fix traits
liamaharon Nov 24, 2023
f3ce8cd
fix collectives westend
liamaharon Nov 24, 2023
957dd6c
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Nov 24, 2023
bb47578
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 16, 2024
4f34664
finish merge
liamaharon Jan 16, 2024
3132975
format
liamaharon Jan 16, 2024
6293000
soft deprecate
liamaharon Jan 16, 2024
ef9d85a
update people westend and coretime westend runtimes
liamaharon Jan 16, 2024
f03fe17
prdoc
liamaharon Jan 16, 2024
49ac6eb
remove fellowship runtimes
liamaharon Jan 16, 2024
a633271
fix prdoc
liamaharon Jan 16, 2024
1b910c7
fix rustdoc link
liamaharon Jan 16, 2024
e5fde06
fix refund doesn't create new acc
liamaharon Jan 16, 2024
bf592df
doc link
liamaharon Jan 16, 2024
a4db3ef
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 17, 2024
8e3fb18
clippy
liamaharon Jan 17, 2024
b164843
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 19, 2024
18de1fd
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 23, 2024
1f93eaa
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 26, 2024
234a82e
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Jan 29, 2024
4121a9e
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Apr 4, 2024
78c6086
fix
liamaharon Apr 4, 2024
d0de2fd
clean up after merge
liamaharon Apr 4, 2024
2dfafec
remove parachain template
liamaharon Apr 4, 2024
a6ec2a5
update prdoc
liamaharon Apr 4, 2024
8b2bf1e
clippy
liamaharon Apr 4, 2024
3402af4
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Apr 4, 2024
d749035
remove redundant trait bound
liamaharon Apr 4, 2024
201e7cd
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Apr 4, 2024
1e738c0
Merge branch 'master' into liam-currency-adapter-fungible
liamaharon Apr 4, 2024
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
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl pallet_balances::Config for TestRuntime {
}

impl pallet_transaction_payment::Config for TestRuntime {
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<ThisChainBalance>;
type LengthToFee = ConstantMultiplier<ThisChainBalance, TransactionByteFee>;
Expand Down
24 changes: 15 additions & 9 deletions cumulus/parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
//! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains.

use frame_support::traits::{
fungibles::{self, Balanced, Credit},
Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced,
fungible::{self, Balanced as FungibleBalanced},
fungibles::{self, Balanced as FungiblesBalanced},
Contains, ContainsPair, Currency, Defensive, Get, Imbalance, OnUnbalanced,
};
use pallet_asset_tx_payment::HandleCredit;
use sp_runtime::traits::Zero;
Expand All @@ -35,28 +36,33 @@ pub type AccountIdOf<R> = <R as frame_system::Config>::AccountId;

/// Implementation of `OnUnbalanced` that deposits the fees into a staking pot for later payout.
pub struct ToStakingPot<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToStakingPot<R>
impl<R> OnUnbalanced<fungible::Credit<R::AccountId, pallet_balances::Pallet<R>>> for ToStakingPot<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
fn on_nonzero_unbalanced(amount: fungible::Credit<R::AccountId, pallet_balances::Pallet<R>>) {
let staking_pot = <pallet_collator_selection::Pallet<R>>::account_id();
<pallet_balances::Pallet<R>>::resolve_creating(&staking_pot, amount);
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
let _ = <pallet_balances::Pallet<R>>::resolve(&staking_pot, amount).defensive();
}
}

/// Implementation of `OnUnbalanced` that deals with the fees by combining tip and fee and passing
/// the result on to `ToStakingPot`.
pub struct DealWithFees<R>(PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
impl<R> OnUnbalanced<fungible::Credit<R::AccountId, pallet_balances::Pallet<R>>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,
<R as frame_system::Config>::RuntimeEvent: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
fn on_unbalanceds<B>(
mut fees_then_tips: impl Iterator<
Item = fungible::Credit<R::AccountId, pallet_balances::Pallet<R>>,
>,
) {
if let Some(mut fees) = fees_then_tips.next() {
if let Some(tips) = fees_then_tips.next() {
tips.merge_into(&mut fees);
Expand All @@ -75,10 +81,10 @@ where
R: pallet_authorship::Config + pallet_assets::Config<I>,
AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,
{
fn handle_credit(credit: Credit<AccountIdOf<R>, pallet_assets::Pallet<R, I>>) {
fn handle_credit(credit: fungibles::Credit<AccountIdOf<R>, pallet_assets::Pallet<R, I>>) {
if let Some(author) = pallet_authorship::Pallet::<R>::author() {
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
let _ = pallet_assets::Pallet::<R, I>::resolve(&author, credit);
let _ = pallet_assets::Pallet::<R, I>::resolve(&author, credit).defensive();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ parameter_types! {
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees<Runtime>>;
pallet_transaction_payment::FungibleAdapter<Balances, DealWithFees<Runtime>>;
type WeightToFee = WeightToFee;
/// Relay Chain `TransactionByteFee` / 10
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl pallet_balances::Config for Runtime {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = ();
Expand Down
2 changes: 1 addition & 1 deletion cumulus/test/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl pallet_balances::Config for Runtime {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = ();
Expand Down
22 changes: 14 additions & 8 deletions polkadot/runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,43 @@

//! Auxiliary `struct`/`enum`s for polkadot runtime.

use crate::NegativeImbalance;
use frame_support::traits::{Currency, Imbalance, OnUnbalanced};
use frame_support::traits::{
fungible::{Balanced, Credit},
Imbalance, OnUnbalanced,
};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::Balance;
use sp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug};
use xcm::VersionedMultiLocation;

/// Logic for the author to get a portion of fees.
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for ToAuthor<R>
where
R: pallet_balances::Config + pallet_authorship::Config,
<R as frame_system::Config>::AccountId: From<primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<primitives::AccountId>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
fn on_nonzero_unbalanced(
amount: Credit<<R as frame_system::Config>::AccountId, pallet_balances::Pallet<R>>,
) {
if let Some(author) = <pallet_authorship::Pallet<R>>::author() {
<pallet_balances::Pallet<R>>::resolve_creating(&author, amount);
let _ = <pallet_balances::Pallet<R>>::resolve(&author, amount);
}
}
}

pub struct DealWithFees<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_treasury::Config + pallet_authorship::Config,
pallet_treasury::Pallet<R>: OnUnbalanced<NegativeImbalance<R>>,
pallet_treasury::Pallet<R>: OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>>,
<R as frame_system::Config>::AccountId: From<primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<primitives::AccountId>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
fn on_unbalanceds<B>(
mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pallet_balances::Pallet<R>>>,
) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 80% to treasury, 20% to author
let mut split = fees.ration(80, 20);
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use sp_core::{ConstU128, OpaqueMetadata, H256};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
Expand Down Expand Up @@ -335,7 +335,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;
type OnChargeTransaction = FungibleAdapter<Balances, ToAuthor<Runtime>>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::legacy::IdentityInfo;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::{
slashing, vstaging::NodeFeatures, AccountId, AccountIndex, Balance, BlockNumber,
Expand Down Expand Up @@ -398,7 +398,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;
type OnChargeTransaction = FungibleAdapter<Balances, ToAuthor<Runtime>>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
Expand Down
33 changes: 18 additions & 15 deletions polkadot/xcm/xcm-builder/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

use frame_support::{
dispatch::GetDispatchInfo,
traits::{tokens::currency::Currency as CurrencyT, Get, OnUnbalanced as OnUnbalancedT},
traits::{
fungible::{Balanced, Credit, Inspect},
Get, OnUnbalanced as OnUnbalancedT,
},
weights::{
constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND},
WeightToFee as WeightToFeeT,
Expand Down Expand Up @@ -193,23 +196,23 @@ impl<T: Get<(AssetId, u128, u128)>, R: TakeRevenue> Drop for FixedRateOfFungible
/// Weight trader which uses the configured `WeightToFee` to set the right price for weight and then
/// places any weight bought into the right account.
pub struct UsingComponents<
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
WeightToFee: WeightToFeeT<Balance = <Fungible as Inspect<AccountId>>::Balance>,
AssetId: Get<MultiLocation>,
AccountId,
Currency: CurrencyT<AccountId>,
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
Fungible: Balanced<AccountId> + Inspect<AccountId>,
OnUnbalanced: OnUnbalancedT<Credit<AccountId, Fungible>>,
>(
Weight,
Currency::Balance,
PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced)>,
Fungible::Balance,
PhantomData<(WeightToFee, AssetId, AccountId, Fungible, OnUnbalanced)>,
);
impl<
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
WeightToFee: WeightToFeeT<Balance = <Fungible as Inspect<AccountId>>::Balance>,
AssetId: Get<MultiLocation>,
AccountId,
Currency: CurrencyT<AccountId>,
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
> WeightTrader for UsingComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
Fungible: Balanced<AccountId> + Inspect<AccountId>,
OnUnbalanced: OnUnbalancedT<Credit<AccountId, Fungible>>,
> WeightTrader for UsingComponents<WeightToFee, AssetId, AccountId, Fungible, OnUnbalanced>
{
fn new() -> Self {
Self(Weight::zero(), Zero::zero(), PhantomData)
Expand Down Expand Up @@ -246,14 +249,14 @@ impl<
}
}
impl<
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
WeightToFee: WeightToFeeT<Balance = <Fungible as Inspect<AccountId>>::Balance>,
AssetId: Get<MultiLocation>,
AccountId,
Currency: CurrencyT<AccountId>,
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
> Drop for UsingComponents<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced>
Fungible: Balanced<AccountId> + Inspect<AccountId>,
OnUnbalanced: OnUnbalancedT<Credit<AccountId, Fungible>>,
> Drop for UsingComponents<WeightToFee, AssetId, AccountId, Fungible, OnUnbalanced>
{
fn drop(&mut self) {
OnUnbalanced::on_unbalanced(Currency::issue(self.1));
OnUnbalanced::on_unbalanced(Fungible::issue(self.1));
}
}
2 changes: 1 addition & 1 deletion substrate/bin/minimal/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl pallet_timestamp::Config for Runtime {}

#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig as pallet_transaction_payment::DefaultConfig)]
impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter<Balances, ()>;
type WeightToFee = NoFee<<Self as pallet_balances::Config>::Balance>;
type LengthToFee = FixedFee<1, <Self as pallet_balances::Config>::Balance>;
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub use frame_support::{
pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::{ConstFeeMultiplier, CurrencyAdapter, Multiplier};
use pallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter, Multiplier};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};
Expand Down Expand Up @@ -261,7 +261,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = FungibleAdapter<Balances, ()>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = IdentityFee<Balance>;
Expand Down
6 changes: 6 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_nfts::PalletFeatures;
use pallet_nis::WithMaximumOf;
use pallet_session::historical as pallet_session_historical;
// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
// <https://github.com/paritytech/polkadot-sdk/issues/226>
#[allow(deprecated)]
pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_tx_pause::RuntimeCallNameOf;
Expand Down Expand Up @@ -538,6 +541,9 @@ parameter_types! {
pub MaximumMultiplier: Multiplier = Bounded::max_value();
}

// Can't use `FungibleAdapter` here until Treasury pallet migrates to fungibles
// <https://github.com/paritytech/polkadot-sdk/issues/226>
#[allow(deprecated)]
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
Expand Down
Loading