use crate::prod_or_testnet_or_local;
use common_primitives::node::{Balance, BlockNumber};
use parity_scale_codec::{Encode, MaxEncodedLen};
use frame_support::{
parameter_types,
sp_runtime::{Perbill, Permill},
traits::{ConstU128, ConstU16, ConstU32, ConstU64, ConstU8},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
PalletId,
};
pub const FREQUENCY_TESTNET_TOKEN: &str = "XRQCY";
pub const FREQUENCY_LOCAL_TOKEN: &str = "UNIT";
pub const FREQUENCY_TOKEN: &str = "FRQCY";
pub const TOKEN_DECIMALS: u8 = 8;
pub type MaxSchemaGrants = ConstU32<30>;
pub const MILLISECS_PER_BLOCK: u64 = 6_000;
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub mod currency {
use common_primitives::node::Balance;
pub const EXISTENTIAL_DEPOSIT: Balance = CENTS;
pub const UNITS: Balance = 10u128.saturating_pow(super::TOKEN_DECIMALS as u32);
pub const DOLLARS: Balance = UNITS; pub const CENTS: Balance = DOLLARS / 100; pub const MILLICENTS: Balance = CENTS / 1_000; pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS
}
}
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
);
pub type ZERO = ConstU32<0>;
pub type TWO = ConstU32<2>;
pub type FIFTY = ConstU32<50>;
pub type HUNDRED = ConstU32<100>;
pub type FrameSystemMaxConsumers = ConstU32<16>;
pub type MsaMaxPublicKeysPerMsa = ConstU8<25>;
pub type MsaMaxProviderNameSize = ConstU32<16>;
pub type MSAMortalityWindowSize = ConstU32<{ 20 * MINUTES }>;
pub type MSAMaxSignaturesStored = ConstU32<50_000>;
parameter_types! {
pub const SchemasMaxBytesBoundedVecLimit :u32 = 65_500;
}
pub type SchemasMaxRegistrations = ConstU16<65_000>;
pub type SchemasMinModelSizeBytes = ConstU32<8>;
pub type MaxSchemaSettingsPerSchema = ConstU32<2>;
impl Encode for SchemasMaxBytesBoundedVecLimit {}
impl MaxEncodedLen for SchemasMaxBytesBoundedVecLimit {
fn max_encoded_len() -> usize {
u32::max_encoded_len()
}
}
pub type HandleSuffixMin = ConstU16<10>;
pub type HandleSuffixMax = ConstU16<99>;
pub type MinReleaseTransfer = ConstU128<0>;
pub const MAX_RELEASE_SCHEDULES: u32 = 50;
pub type MinimumPeriod = ConstU64<0>;
pub type AuthorshipUncleGenerations = ZERO;
pub type BalancesMaxLocks = FIFTY;
pub type BalancesMaxReserves = FIFTY;
pub type BalancesMaxFreezes = TWO; pub type SchedulerMaxScheduledPerBlock = FIFTY;
pub type PreimageMaxSize = ConstU32<{ 4096 * 1024 }>;
pub type PreimageBaseDeposit = ConstU128<{ currency::deposit(10, 64) }>;
pub type PreimageByteDeposit = ConstU128<{ currency::deposit(0, 1) }>;
pub type CouncilMaxProposals = ConstU32<25>;
pub type CouncilMaxMembers = ConstU32<10>;
pub type CouncilMotionDuration = ConstU32<{ 5 * DAYS }>;
pub type TCMaxProposals = ConstU32<25>;
pub type TCMaxMembers = ConstU32<10>;
pub type TCMotionDuration = ConstU32<{ 5 * DAYS }>;
pub type LaunchPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
pub type VotingPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
pub type FastTrackVotingPeriod =
ConstU32<{ prod_or_testnet_or_local!(3 * HOURS, 30 * MINUTES, 5 * MINUTES) }>;
pub type EnactmentPeriod =
ConstU32<{ prod_or_testnet_or_local!(8 * DAYS, 30 * HOURS, 10 * MINUTES) }>;
pub type CooloffPeriod = ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 1 * DAYS, 5 * MINUTES) }>;
pub type MinimumDeposit = ConstU128<
{
prod_or_testnet_or_local!(
currency::deposit(5, 0),
100 * currency::deposit(5, 0),
100 * currency::deposit(5, 0)
)
},
>;
pub type SpendPeriod =
ConstU32<{ prod_or_testnet_or_local!(7 * DAYS, 10 * MINUTES, 10 * MINUTES) }>;
pub type DemocracyMaxVotes = ConstU32<100>;
pub type DemocracyMaxProposals = HUNDRED;
pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
parameter_types! {
pub const TreasuryPalletId: PalletId = TREASURY_PALLET_ID;
pub const ProposalBondPercent: Permill = Permill::from_percent(5);
pub const Burn: Permill = Permill::zero();
}
pub type MaxApprovals = ConstU32<64>;
pub type ProposalBondMinimum = ConstU128<{ 100 * currency::DOLLARS }>;
pub type ProposalBondMaximum = ConstU128<{ 1_000 * currency::DOLLARS }>;
pub type TransactionPaymentOperationalFeeMultiplier = ConstU8<5>;
pub type TransactionByteFee = ConstU128<{ 10 * currency::MILLICENTS }>;
pub type MaximumCapacityBatchLength = ConstU8<10>;
pub type SessionPeriod = ConstU32<{ 6 * HOURS }>;
pub type SessionOffset = ZERO;
pub type AuraMaxAuthorities = ConstU32<100_000>;
pub type CollatorMaxCandidates = ConstU32<50>;
pub type CollatorMinCandidates = ConstU32<{ prod_or_testnet_or_local!(1, 0, 0) }>;
pub type CollatorMaxInvulnerables = ConstU32<{ prod_or_testnet_or_local!(16, 5, 5) }>;
pub type CollatorKickThreshold =
ConstU32<{ prod_or_testnet_or_local!(6 * HOURS, 6 * HOURS, 6 * HOURS) }>;
parameter_types! {
pub const NeverDepositIntoId: PalletId = PalletId(*b"NeverDep");
pub const MessagesMaxPayloadSizeBytes: u32 = 1024 * 3; }
parameter_types! {
pub const ProxyDepositBase: Balance = currency::deposit(1, 8);
pub const ProxyDepositFactor: Balance = currency::deposit(0, 33);
pub const MaxProxies: u16 = 32;
pub const AnnouncementDepositBase: Balance = currency::deposit(1, 8);
pub const AnnouncementDepositFactor: Balance = currency::deposit(0, 66);
pub const MaxPending: u16 = 32;
}
impl Clone for MessagesMaxPayloadSizeBytes {
fn clone(&self) -> Self {
MessagesMaxPayloadSizeBytes {}
}
}
impl sp_std::fmt::Debug for MessagesMaxPayloadSizeBytes {
#[cfg(feature = "std")]
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
write!(f, "MessagesMaxPayloadSizeBytes<{:?}>", Self::get())
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Ok(())
}
}
impl Encode for MessagesMaxPayloadSizeBytes {}
impl MaxEncodedLen for MessagesMaxPayloadSizeBytes {
fn max_encoded_len() -> usize {
u32::max_encoded_len()
}
}
parameter_types! {
pub const Ss58Prefix: u16 = prod_or_testnet_or_local!(90, 42, 42);
}
parameter_types! {
pub const MaxItemizedBlobSizeBytes: u32 = 1024;
pub const MaxItemizedPageSizeBytes: u32 = 10 * (1024 + 2);
pub const MaxPaginatedPageSizeBytes: u32 = 1 * 1024;
}
pub type MaxPaginatedPageId = ConstU16<32>;
pub type MaxItemizedActionsCount = ConstU32<5>;
pub type StatefulMortalityWindowSize = ConstU32<{ 2 * DAYS }>;
impl Default for MaxItemizedPageSizeBytes {
fn default() -> Self {
Self
}
}
impl Default for MaxPaginatedPageSizeBytes {
fn default() -> Self {
Self
}
}
impl Clone for MaxItemizedBlobSizeBytes {
fn clone(&self) -> Self {
MaxItemizedBlobSizeBytes {}
}
}
impl Eq for MaxItemizedBlobSizeBytes {
fn assert_receiver_is_total_eq(&self) {}
}
impl PartialEq for MaxItemizedBlobSizeBytes {
fn eq(&self, other: &Self) -> bool {
self == other
}
}
impl sp_std::fmt::Debug for MaxItemizedBlobSizeBytes {
#[cfg(feature = "std")]
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Ok(())
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
Ok(())
}
}
pub type CapacityMinimumStakingAmount = ConstU128<{ currency::EXISTENTIAL_DEPOSIT }>;
pub type CapacityMinimumTokenBalance = ConstU128<{ currency::DOLLARS }>;
pub type CapacityMaxUnlockingChunks = ConstU32<4>;
pub type CapacityMaxEpochLength = ConstU32<{ 2 * DAYS }>; #[cfg(not(any(feature = "frequency-local", feature = "frequency-no-relay")))]
pub type CapacityUnstakingThawPeriod = ConstU16<30>; #[cfg(any(feature = "frequency-local", feature = "frequency-no-relay"))]
pub type CapacityUnstakingThawPeriod = ConstU16<2>; parameter_types! {
pub const CapacityPerToken: Perbill = Perbill::from_percent(2);
pub const CapacityRewardCap: Permill = Permill::from_parts(5_750); }
pub type CapacityRewardEraLength =
ConstU32<{ prod_or_testnet_or_local!(14 * DAYS, 1 * HOURS, 50) }>;