referrerpolicy=no-referrer-when-downgrade

pallet_example_frame_crate/
lib.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: MIT-0
5
6// Permission is hereby granted, free of charge, to any person obtaining a copy of
7// this software and associated documentation files (the "Software"), to deal in
8// the Software without restriction, including without limitation the rights to
9// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10// of the Software, and to permit persons to whom the Software is furnished to do
11// so, subject to the following conditions:
12
13// The above copyright notice and this permission notice shall be included in all
14// copies or substantial portions of the Software.
15
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22// SOFTWARE.
23
24use frame::prelude::*;
25
26#[frame::pallet(dev_mode)]
27pub mod pallet {
28	use super::*;
29
30	#[pallet::config]
31	pub trait Config: frame_system::Config {}
32
33	#[pallet::pallet]
34	pub struct Pallet<T>(_);
35
36	#[pallet::event]
37	pub enum Event<T: Config> {}
38
39	#[pallet::storage]
40	pub type Value<T> = StorageValue<Value = u32>;
41
42	#[pallet::call]
43	impl<T: Config> Pallet<T> {
44		pub fn some_dispatchable(_origin: OriginFor<T>) -> DispatchResult {
45			Ok(())
46		}
47	}
48}
49
50#[cfg(test)]
51mod tests {
52	use crate::pallet as my_pallet;
53	use frame::testing_prelude::*;
54
55	construct_runtime!(
56		pub enum Runtime {
57			System: frame_system,
58			MyPallet: my_pallet,
59		}
60	);
61
62	#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
63	impl frame_system::Config for Runtime {
64		type Block = MockBlock<Self>;
65	}
66
67	impl my_pallet::Config for Runtime {}
68}