Skip to content

Commit

Permalink
Added call_runtime filter for pallet_assets
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreOssun committed Aug 15, 2023
1 parent a1d9bd6 commit a41c500
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
17 changes: 14 additions & 3 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use frame_support::{
construct_runtime, parameter_types,
traits::{
AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Currency, EitherOfDiverse,
EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, Nothing, OnFinalize, WithdrawReasons,
AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Contains, Currency, EitherOfDiverse,
EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, OnFinalize, WithdrawReasons,
},
weights::{
constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND},
Expand Down Expand Up @@ -799,6 +799,17 @@ impl pallet_vesting::Config for Runtime {
const MAX_VESTING_SCHEDULES: u32 = 28;
}

pub struct CallRuntimeFilter;
impl Contains<RuntimeCall> for CallRuntimeFilter {
fn contains(c: &RuntimeCall) -> bool {
match *c {
RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true,
RuntimeCall::Assets(pallet_assets::Call::transfer_approved { .. }) => true,
_ => false,
}
}
}

parameter_types! {
pub const DepositPerItem: Balance = deposit(1, 0);
pub const DepositPerByte: Balance = deposit(0, 1);
Expand All @@ -819,7 +830,7 @@ impl pallet_contracts::Config for Runtime {
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to
/// change because that would break already deployed contracts. The `Call` structure itself
/// is not allowed to change the indices of existing pallets, too.
type CallFilter = Nothing;
type CallFilter = CallRuntimeFilter;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type DefaultDepositLimit = DefaultDepositLimit;
Expand Down
18 changes: 14 additions & 4 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ use frame_support::{
parameter_types,
traits::{
AsEnsureOriginWithArg, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly,
FindAuthor, Get, Imbalance, InstanceFilter, Nothing, OnFinalize, OnUnbalanced,
WithdrawReasons,
FindAuthor, Get, Imbalance, InstanceFilter, OnFinalize, OnUnbalanced, WithdrawReasons,
},
weights::{
constants::{
Expand Down Expand Up @@ -656,6 +655,17 @@ impl pallet_vesting::Config for Runtime {
const MAX_VESTING_SCHEDULES: u32 = 28;
}

pub struct CallRuntimeFilter;
impl Contains<RuntimeCall> for CallRuntimeFilter {
fn contains(c: &RuntimeCall) -> bool {
match *c {
RuntimeCall::Assets(pallet_assets::Call::transfer { .. }) => true,
RuntimeCall::Assets(pallet_assets::Call::transfer_approved { .. }) => true,
_ => false,
}
}
}

// TODO: changing depost per item and per byte to `deposit` function will require storage migration it seems
parameter_types! {
pub const DepositPerItem: Balance = MILLISBY / 1_000_000;
Expand All @@ -677,7 +687,7 @@ impl pallet_contracts::Config for Runtime {
/// and make sure they are stable. Dispatchables exposed to contracts are not allowed to
/// change because that would break already deployed contracts. The `Call` structure itself
/// is not allowed to change the indices of existing pallets, too.
type CallFilter = Nothing;
type CallFilter = CallRuntimeFilter;
type DepositPerItem = DepositPerItem;
type DepositPerByte = DepositPerByte;
type DefaultDepositLimit = DefaultDepositLimit;
Expand All @@ -693,7 +703,7 @@ impl pallet_contracts::Config for Runtime {
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>;
type UnsafeUnstableInterface = ConstBool<true>;
type UnsafeUnstableInterface = ConstBool<false>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
}

Expand Down

0 comments on commit a41c500

Please sign in to comment.