// Copyright Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see .
use super::{Balances, Runtime, RuntimeCall, RuntimeEvent};
use crate::{
parachain,
parachain::RuntimeHoldReason,
primitives::{Balance, CENTS},
};
use frame_support::{
parameter_types,
traits::{ConstBool, ConstU32, Contains, Randomness},
weights::Weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_xcm::BalanceOf;
use sp_runtime::{traits::Convert, Perbill};
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 1 * CENTS + (bytes as Balance) * 1 * CENTS
}
parameter_types! {
pub const DepositPerItem: Balance = deposit(1, 0);
pub const DepositPerByte: Balance = deposit(0, 1);
pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024);
pub Schedule: pallet_contracts::Schedule = Default::default();
pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0);
pub const MaxDelegateDependencies: u32 = 32;
}
pub struct DummyRandomness(sp_std::marker::PhantomData);
impl Randomness> for DummyRandomness {
fn random(_subject: &[u8]) -> (T::Hash, BlockNumberFor) {
(Default::default(), Default::default())
}
}
impl Convert> for Runtime {
fn convert(w: Weight) -> BalanceOf {
w.ref_time().into()
}
}
#[derive(Clone, Default)]
pub struct Filters;
impl Contains for Filters {
fn contains(call: &RuntimeCall) -> bool {
match call {
parachain::RuntimeCall::Contracts(_) => true,
_ => false,
}
}
}
impl pallet_contracts::Config for Runtime {
type AddressGenerator = pallet_contracts::DefaultAddressGenerator;
type CallFilter = Filters;
type CallStack = [pallet_contracts::Frame; 5];
type ChainExtension = ();
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type Currency = Balances;
type DefaultDepositLimit = DefaultDepositLimit;
type DepositPerByte = DepositPerByte;
type DepositPerItem = DepositPerItem;
type MaxCodeLen = ConstU32<{ 123 * 1024 }>;
type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>;
type MaxDelegateDependencies = MaxDelegateDependencies;
type MaxStorageKeyLen = ConstU32<128>;
type Migrations = ();
type Randomness = DummyRandomness;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = RuntimeHoldReason;
type Schedule = Schedule;
type Time = super::Timestamp;
type UnsafeUnstableInterface = ConstBool;
type WeightInfo = ();
type WeightPrice = Self;
type Debug = ();
type Environment = ();
type Xcm = pallet_xcm::Pallet;
}