Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ impl pallet_transaction_payment::Config for Runtime {
}

impl pallet_asset_tx_payment::Config for Runtime {
type Event = Event;
type Fungibles = Assets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
Expand Down
11 changes: 11 additions & 0 deletions frame/transaction-payment/asset-tx-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub mod pallet {

#[pallet::config]
pub trait Config: frame_system::Config + pallet_transaction_payment::Config {
/// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
/// The fungibles instance used to pay for transactions in assets.
type Fungibles: Balanced<Self::AccountId>;
/// The actual transaction charging logic that charges the fees.
Expand All @@ -122,6 +124,14 @@ pub mod pallet {
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
/// has been paid by `who`.
TransactionFeePaid { who: T::AccountId, actual_fee: BalanceOf<T>, tip: BalanceOf<T> },
Comment thread
hzy1919 marked this conversation as resolved.
Outdated
}
}

/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
Expand Down Expand Up @@ -273,6 +283,7 @@ where
tip.into(),
already_withdrawn.into(),
)?;
Pallet::<T>::deposit_event(Event::<T>::TransactionFeePaid { who, actual_fee, tip });
},
InitialPayment::Nothing => {
// `actual_fee` should be zero here for any signed extrinsic. It would be
Expand Down
3 changes: 2 additions & 1 deletion frame/transaction-payment/asset-tx-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ frame_support::construct_runtime!(
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Authorship: pallet_authorship::{Pallet, Call, Storage},
AssetTxPayment: pallet_asset_tx_payment::{Pallet},
AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event<T>},
}
);

Expand Down Expand Up @@ -198,6 +198,7 @@ impl HandleCredit<AccountId, Assets> for CreditToBlockAuthor {
}

impl Config for Runtime {
type Event = Event;
type Fungibles = Assets;
type OnChargeAssetTransaction = FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
Expand Down