Skip to content

Commit

Permalink
feeless glutton
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
  • Loading branch information
sandreim committed May 2, 2024
1 parent d1270c3 commit fe5a894
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sp-std = { path = "../../../../../substrate/primitives/std", default-features =
sp-storage = { path = "../../../../../substrate/primitives/storage", default-features = false }
sp-transaction-pool = { path = "../../../../../substrate/primitives/transaction-pool", default-features = false }
sp-version = { path = "../../../../../substrate/primitives/version", default-features = false }
pallet-transaction-payment = { path = "../../../../../substrate/frame/transaction-payment", default-features = false }

# Polkadot
xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false }
Expand Down
45 changes: 45 additions & 0 deletions cumulus/parachains/runtimes/glutton/glutton-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub mod weights;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use frame_support::weights::NoFee;
use pallet_transaction_payment::OnChargeTransaction;
use sp_api::impl_runtime_apis;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand Down Expand Up @@ -246,6 +248,48 @@ impl pallet_sudo::Config for Runtime {
type WeightInfo = ();
}

/// Balance of an account.
pub type Balance = u128;

pub struct NoCharge;

impl<T> OnChargeTransaction<T> for NoCharge
where
T: pallet_transaction_payment::Config,
{
type Balance = Balance;
type LiquidityInfo = ();

fn correct_and_deposit_fee(
_who: &T::AccountId,
_dispatch_info: &sp_runtime::traits::DispatchInfoOf<T::RuntimeCall>,
_post_info: &sp_runtime::traits::PostDispatchInfoOf<T::RuntimeCall>,
_corrected_fee: Self::Balance,
_tip: Self::Balance,
_already_withdrawn: Self::LiquidityInfo,
) -> Result<(), frame_support::pallet_prelude::TransactionValidityError> {
Ok(())
}
fn withdraw_fee(
_who: &T::AccountId,
_call: &T::RuntimeCall,
_dispatch_info: &sp_runtime::traits::DispatchInfoOf<T::RuntimeCall>,
_fee: Self::Balance,
_tip: Self::Balance,
) -> Result<Self::LiquidityInfo, frame_support::pallet_prelude::TransactionValidityError> {
Ok(())
}
}

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = NoCharge;
type WeightToFee = NoFee<Balance>;
type LengthToFee = NoFee<Balance>;
type FeeMultiplierUpdate = ();
type OperationalFeeMultiplier = ConstU8<0>;
}

construct_runtime! {
pub enum Runtime
{
Expand All @@ -265,6 +309,7 @@ construct_runtime! {
Aura: pallet_aura = 30,
AuraExt: cumulus_pallet_aura_ext = 31,

TransactionPayment: pallet_transaction_payment,
// Sudo.
Sudo: pallet_sudo = 255,
}
Expand Down

0 comments on commit fe5a894

Please sign in to comment.