pop_chains/new_pallet/
new_pallet_options.rs1use clap::ValueEnum;
2use serde::Serialize;
3use std::{fmt, fmt::Formatter};
4use strum::EnumMessage as _;
5use strum_macros::{EnumIter, EnumMessage};
6
7#[derive(Debug, Copy, Clone, PartialEq, EnumIter, EnumMessage, ValueEnum, Serialize)]
10pub enum TemplatePalletConfigCommonTypes {
11 #[strum(
13 message = "RuntimeEvent",
14 detailed_message = "This type will enable your pallet to emit events."
15 )]
16 RuntimeEvent,
17 #[strum(
21 message = "RuntimeOrigin",
22 detailed_message = "This type will be helpful if your pallet needs to deal with the outer RuntimeOrigin enum, or if your pallet needs to use custom origins. Note: If you have run the command using -o, this type will be added anyway."
23 )]
24 RuntimeOrigin,
25 #[strum(
27 message = "Currency",
28 detailed_message = "This type will allow your pallet to interact with the native currency of the blockchain."
29 )]
30 Currency,
31}
32
33impl fmt::Display for TemplatePalletConfigCommonTypes {
34 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
35 write!(f, "{}", self.get_message().unwrap_or("Unknown"))
36 }
37}
38
39#[derive(Debug, Copy, Clone, PartialEq, EnumIter, EnumMessage, ValueEnum, Serialize)]
41pub enum TemplatePalletStorageTypes {
42 #[strum(
44 message = "StorageValue",
45 detailed_message = "A storage value is a single value of a given type stored on-chain."
46 )]
47 StorageValue,
48 #[strum(
50 message = "StorageMap",
51 detailed_message = "A storage map is a mapping of keys to values of a given type stored on-chain."
52 )]
53 StorageMap,
54 #[strum(
57 message = "CountedStorageMap",
58 detailed_message = "A wrapper around a StorageMap and a StorageValue (with the value being u32) to keep track of how many items are in a map."
59 )]
60 CountedStorageMap,
61 #[strum(
63 message = "StorageDoubleMap",
64 detailed_message = "This structure associates a pair of keys with a value of a specified type stored on-chain."
65 )]
66 StorageDoubleMap,
67 #[strum(
70 message = "StorageNMap",
71 detailed_message = "This structure associates an arbitrary number of keys with a value of a specified type stored on-chain."
72 )]
73 StorageNMap,
74 #[strum(
77 message = "CountedStorageNMap",
78 detailed_message = "A wrapper around a StorageNMap and a StorageValue (with the value being u32) to keep track of how many items are in a map."
79 )]
80 CountedStorageNMap,
81}
82
83impl fmt::Display for TemplatePalletStorageTypes {
84 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
85 write!(f, "{}", self.get_message().unwrap_or("Unknown"))
86 }
87}
88
89#[derive(Debug, Copy, Clone, PartialEq, EnumIter, EnumMessage)]
92pub enum TemplatePalletOptions {
93 #[strum(
95 message = "DefaultConfig",
96 detailed_message = "Use a default configuration for your config trait."
97 )]
98 DefaultConfig,
99 #[strum(message = "GenesisConfig", detailed_message = "Add a genesis config to your pallet.")]
101 GenesisConfig,
102 #[strum(message = "Custom Origin", detailed_message = "Add a custom origin to your pallet.")]
104 CustomOrigin,
105}