mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 03:17:56 +00:00
Migrate fee payment from Currency to fungible (#2292)
Part of https://github.com/paritytech/polkadot-sdk/issues/226 Related https://github.com/paritytech/polkadot-sdk/issues/1833 - Deprecate `CurrencyAdapter` and introduce `FungibleAdapter` - Deprecate `ToStakingPot` and replace usage with `ResolveTo` - Required creating a new `StakingPotAccountId` struct that implements `TypedGet` for the staking pot account ID - Update parachain common utils `DealWithFees`, `ToAuthor` and `AssetsToBlockAuthor` implementations to use `fungible` - Update runtime XCM Weight Traders to use `ResolveTo` instead of `ToStakingPot` - Update runtime Transaction Payment pallets to use `FungibleAdapter` instead of `CurrencyAdapter` - [x] Blocked by https://github.com/paritytech/polkadot-sdk/pull/1296, needs the `Unbalanced::decrease_balance` fix
This commit is contained in:
@@ -24,6 +24,7 @@ use frame_support::{
|
||||
pallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{
|
||||
fungible,
|
||||
tokens::{
|
||||
fungible::{NativeFromLeft, NativeOrWithId, UnionOf},
|
||||
imbalance::ResolveAssetTo,
|
||||
@@ -36,7 +37,7 @@ use frame_support::{
|
||||
use frame_system as system;
|
||||
use frame_system::{EnsureRoot, EnsureSignedBy};
|
||||
use pallet_asset_conversion::{Ascending, Chain, WithFirstAsset};
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
use pallet_transaction_payment::FungibleAdapter;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion},
|
||||
@@ -155,9 +156,13 @@ parameter_types! {
|
||||
}
|
||||
|
||||
pub struct DealWithFees;
|
||||
impl OnUnbalanced<pallet_balances::NegativeImbalance<Runtime>> for DealWithFees {
|
||||
impl OnUnbalanced<fungible::Credit<<Runtime as frame_system::Config>::AccountId, Balances>>
|
||||
for DealWithFees
|
||||
{
|
||||
fn on_unbalanceds<B>(
|
||||
mut fees_then_tips: impl Iterator<Item = pallet_balances::NegativeImbalance<Runtime>>,
|
||||
mut fees_then_tips: impl Iterator<
|
||||
Item = fungible::Credit<<Runtime as frame_system::Config>::AccountId, Balances>,
|
||||
>,
|
||||
) {
|
||||
if let Some(fees) = fees_then_tips.next() {
|
||||
FeeUnbalancedAmount::mutate(|a| *a += fees.peek());
|
||||
@@ -171,7 +176,7 @@ impl OnUnbalanced<pallet_balances::NegativeImbalance<Runtime>> for DealWithFees
|
||||
#[derive_impl(pallet_transaction_payment::config_preludes::TestDefaultConfig)]
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
|
||||
type OnChargeTransaction = FungibleAdapter<Balances, DealWithFees>;
|
||||
type WeightToFee = WeightToFee;
|
||||
type LengthToFee = TransactionByteFee;
|
||||
type FeeMultiplierUpdate = ();
|
||||
|
||||
Reference in New Issue
Block a user