mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +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:
@@ -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,
|
||||
@@ -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>,
|
||||
AssetIdValue: Get<Location>,
|
||||
AccountId,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
|
||||
Fungible: Balanced<AccountId> + Inspect<AccountId>,
|
||||
OnUnbalanced: OnUnbalancedT<Credit<AccountId, Fungible>>,
|
||||
>(
|
||||
Weight,
|
||||
Currency::Balance,
|
||||
PhantomData<(WeightToFee, AssetIdValue, AccountId, Currency, OnUnbalanced)>,
|
||||
Fungible::Balance,
|
||||
PhantomData<(WeightToFee, AssetIdValue, AccountId, Fungible, OnUnbalanced)>,
|
||||
);
|
||||
impl<
|
||||
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
|
||||
WeightToFee: WeightToFeeT<Balance = <Fungible as Inspect<AccountId>>::Balance>,
|
||||
AssetIdValue: Get<Location>,
|
||||
AccountId,
|
||||
Currency: CurrencyT<AccountId>,
|
||||
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
|
||||
> WeightTrader for UsingComponents<WeightToFee, AssetIdValue, AccountId, Currency, OnUnbalanced>
|
||||
Fungible: Balanced<AccountId> + Inspect<AccountId>,
|
||||
OnUnbalanced: OnUnbalancedT<Credit<AccountId, Fungible>>,
|
||||
> WeightTrader for UsingComponents<WeightToFee, AssetIdValue, AccountId, Fungible, OnUnbalanced>
|
||||
{
|
||||
fn new() -> Self {
|
||||
Self(Weight::zero(), Zero::zero(), PhantomData)
|
||||
@@ -247,14 +250,14 @@ impl<
|
||||
}
|
||||
}
|
||||
impl<
|
||||
WeightToFee: WeightToFeeT<Balance = Currency::Balance>,
|
||||
WeightToFee: WeightToFeeT<Balance = <Fungible as Inspect<AccountId>>::Balance>,
|
||||
AssetId: Get<Location>,
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user