1use crate::{Config, DebugSettingsOf};
19use codec::{Decode, Encode, MaxEncodedLen};
20use scale_info::TypeInfo;
21use serde::{Deserialize, Serialize};
22use sp_core::Get;
23use sp_runtime::RuntimeDebug;
24
25#[derive(
27 Encode,
28 Decode,
29 Default,
30 Clone,
31 PartialEq,
32 RuntimeDebug,
33 TypeInfo,
34 MaxEncodedLen,
35 Serialize,
36 Deserialize,
37)]
38pub struct DebugSettings {
39 allow_unlimited_contract_size: bool,
41}
42
43impl DebugSettings {
44 pub fn new(allow_unlimited_contract_size: bool) -> Self {
45 Self { allow_unlimited_contract_size }
46 }
47
48 pub fn is_unlimited_contract_size_allowed<T: Config>() -> bool {
50 T::DebugEnabled::get() && DebugSettingsOf::<T>::get().allow_unlimited_contract_size
51 }
52
53 pub fn write_to_storage<T: Config>(&self) {
55 DebugSettingsOf::<T>::put(self);
56 if !T::DebugEnabled::get() {
57 log::warn!(
58 target: crate::LOG_TARGET,
59 "Debug settings changed, but debug features are disabled in the runtime configuration."
60 );
61 }
62 }
63}