contracts_parachain_runtime/
contracts_config.rs1use crate::{
2 Balance, Balances, BalancesCall, Perbill, RandomnessCollectiveFlip, Runtime, RuntimeCall,
3 RuntimeEvent, RuntimeHoldReason, Timestamp,
4};
5use frame_support::{
6 parameter_types,
7 traits::{ConstBool, ConstU32},
8};
9use frame_system::EnsureSigned;
10
11pub enum AllowBalancesCall {}
12
13impl frame_support::traits::Contains<RuntimeCall> for AllowBalancesCall {
14 fn contains(call: &RuntimeCall) -> bool {
15 matches!(call, RuntimeCall::Balances(BalancesCall::transfer_allow_death { .. }))
16 }
17}
18
19const UNIT: Balance = 1_000_000_000_000;
21const MILLIUNIT: Balance = 1_000_000_000;
22
23const fn deposit(items: u32, bytes: u32) -> Balance {
24 (items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10
25}
26
27fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {
28 pallet_contracts::Schedule {
29 limits: pallet_contracts::Limits {
30 runtime_memory: 1024 * 1024 * 1024,
31 validator_runtime_memory: 1024 * 1024 * 1024 * 2,
32 ..Default::default()
33 },
34 ..Default::default()
35 }
36}
37
38parameter_types! {
39 pub const DepositPerItem: Balance = deposit(1, 0);
40 pub const DepositPerByte: Balance = deposit(0, 1);
41 pub Schedule: pallet_contracts::Schedule<Runtime> = schedule::<Runtime>();
42 pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
43 pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
44 pub const MaxDelegateDependencies: u32 = 32;
45}
46
47impl pallet_contracts::Config for Runtime {
48 type Time = Timestamp;
49 type Randomness = RandomnessCollectiveFlip;
50 type Currency = Balances;
51 type RuntimeEvent = RuntimeEvent;
52 type RuntimeCall = RuntimeCall;
53
54 type CallFilter = AllowBalancesCall;
61 type DepositPerItem = DepositPerItem;
62 type DepositPerByte = DepositPerByte;
63 type CallStack = [pallet_contracts::Frame<Self>; 23];
64 type WeightPrice = pallet_transaction_payment::Pallet<Self>;
65 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
66 type ChainExtension = ();
67 type Schedule = Schedule;
68 type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
69 type MaxCodeLen = ConstU32<{ 256 * 1024 }>;
78 type DefaultDepositLimit = DefaultDepositLimit;
79 type MaxStorageKeyLen = ConstU32<128>;
80 type MaxTransientStorageSize = ConstU32<{ 1024 * 1024 }>;
81 type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
82 type UnsafeUnstableInterface = ConstBool<true>;
83 type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
84 type MaxDelegateDependencies = MaxDelegateDependencies;
85 type RuntimeHoldReason = RuntimeHoldReason;
86
87 type Environment = ();
88 type Debug = ();
89 type ApiVersion = ();
90 type Migrations = ();
91 #[cfg(feature = "parachain")]
92 type Xcm = pallet_xcm::Pallet<Self>;
93 #[cfg(not(feature = "parachain"))]
94 type Xcm = ();
95
96 type UploadOrigin = EnsureSigned<Self::AccountId>;
97 type InstantiateOrigin = EnsureSigned<Self::AccountId>;
98}