encointer_balances_tx_payment/
lib.rs

1// Copyright (c) 2019 Alain Brenzikofer
2// This file is part of Encointer
3//
4// Encointer is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Encointer is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Encointer.  If not, see <http://www.gnu.org/licenses/>.
16
17#![cfg_attr(not(feature = "std"), no_std)]
18
19use frame_support::traits::fungibles;
20use pallet_asset_tx_payment::HandleCredit;
21use pallet_transaction_payment::OnChargeTransaction;
22
23pub mod balance_conversion;
24#[cfg(test)]
25mod tests;
26
27pub use balance_conversion::*;
28
29pub type OnChargeTransactionOf<T> = <T as pallet_transaction_payment::Config>::OnChargeTransaction;
30
31pub type BalanceOf<T> = <OnChargeTransactionOf<T> as OnChargeTransaction<T>>::Balance;
32
33pub type FungiblesOf<T> = <T as pallet_asset_tx_payment::Config>::Fungibles;
34
35pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
36
37pub type AssetBalanceOf<T> = <FungiblesOf<T> as fungibles::Inspect<AccountIdOf<T>>>::Balance;
38
39pub type AssetIdOf<T> = <FungiblesOf<T> as fungibles::Inspect<AccountIdOf<T>>>::AssetId;
40
41pub struct BurnCredit;
42impl<T> HandleCredit<<T as frame_system::Config>::AccountId, pallet_encointer_balances::Pallet<T>>
43	for BurnCredit
44where
45	T: frame_system::Config + pallet_encointer_balances::Config,
46	pallet_encointer_balances::Pallet<T>:
47		frame_support::traits::fungibles::Balanced<<T as frame_system::Config>::AccountId>,
48{
49	fn handle_credit(
50		_credit: fungibles::Credit<AccountIdOf<T>, pallet_encointer_balances::Pallet<T>>,
51	) {
52		// just doing nothing with the credit, will use the default implementation
53		// of fungibles an decrease total issuance.
54	}
55}