referrerpolicy=no-referrer-when-downgrade

pallet_staking_async_preset_store/
lib.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Simple pallet that stores the preset that was used to generate the genesis state in the state.
19
20#![cfg_attr(not(feature = "std"), no_std)]
21
22pub use pallet::*;
23
24#[frame::pallet]
25pub mod pallet {
26	extern crate alloc;
27	use frame::prelude::*;
28
29	#[pallet::storage]
30	#[pallet::getter(fn preset)]
31	#[pallet::unbounded]
32	pub type Preset<T: Config> = StorageValue<_, alloc::string::String, OptionQuery>;
33
34	#[pallet::genesis_config]
35	#[derive(DefaultNoBound, DebugNoBound, CloneNoBound, PartialEqNoBound, EqNoBound)]
36	pub struct GenesisConfig<T: Config> {
37		pub preset: alloc::string::String,
38		pub _marker: core::marker::PhantomData<T>,
39	}
40
41	#[pallet::genesis_build]
42	impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
43		fn build(&self) {
44			Preset::<T>::put(self.preset.clone());
45		}
46	}
47
48	#[pallet::config]
49	pub trait Config: frame_system::Config {}
50
51	#[pallet::pallet]
52	pub struct Pallet<T>(_);
53}