Skip to content

Commit

Permalink
Filter out credit purchase call (#312)
Browse files Browse the repository at this point in the history
This PR aims to filter out credit purchase calls until the credit system
is implemented. Otherwise, users may have a chance of locking their
funds forever on purchased credits they cannot use.

Closes paritytech/polkadot-sdk#4454

---------

Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
s0me0ne-unkn0wn and bkchr authored May 22, 2024
1 parent c401ada commit dd8cb5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Kusama chains: allow arbitrary XCM execution ([polkadot-fellows/runtimes#261](https://github.com/polkadot-fellows/runtimes/pull/261))
- Allow everything through XCM SafeCallFilter ([polkadot-fellows/runtimes#285](https://github.com/polkadot-fellows/runtimes/pull/285))
- Disable Coretime credit purchasing until we have the credit system implemented ([polkadot-fellows/runtimes#312](https://github.com/polkadot-fellows/runtimes/pull/312))

### Added

Expand Down
13 changes: 12 additions & 1 deletion system-parachains/coretime/coretime-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ use frame_support::{
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{
ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, InstanceFilter, TransformOrigin,
ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, EverythingBut,
InstanceFilter, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
Expand Down Expand Up @@ -170,9 +171,19 @@ parameter_types! {
pub const SS58Prefix: u8 = 2;
}

/// Filter out credit purchase calls until the credit system is implemented. Otherwise, users
/// may have chance of locking their funds forever on purchased credits they cannot use.
pub struct IsBrokerCreditPurchaseCall;
impl Contains<RuntimeCall> for IsBrokerCreditPurchaseCall {
fn contains(c: &RuntimeCall) -> bool {
matches!(c, RuntimeCall::Broker(pallet_broker::Call::purchase_credit { .. }))
}
}

// Configure FRAME pallets to include in runtime.
#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
type BaseCallFilter = EverythingBut<IsBrokerCreditPurchaseCall>;
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The nonce type for storing how many extrinsics an account has signed.
Expand Down

0 comments on commit dd8cb5d

Please sign in to comment.