parent
d6f219c653
commit
8407ca1c0a
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/// Edit this file to define custom logic or remove it if it is not needed.
|
/// Edit this file to define custom logic or remove it if it is not needed.
|
||||||
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
|
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
|
||||||
/// <https://docs.substrate.io/v3/runtime/frame>
|
/// <https://docs.substrate.io/reference/frame-pallets/>
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -19,6 +19,10 @@ pub mod pallet {
|
||||||
use frame_support::pallet_prelude::*;
|
use frame_support::pallet_prelude::*;
|
||||||
use frame_system::pallet_prelude::*;
|
use frame_system::pallet_prelude::*;
|
||||||
|
|
||||||
|
#[pallet::pallet]
|
||||||
|
#[pallet::generate_store(pub(super) trait Store)]
|
||||||
|
pub struct Pallet<T>(_);
|
||||||
|
|
||||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||||
#[pallet::config]
|
#[pallet::config]
|
||||||
pub trait Config: frame_system::Config {
|
pub trait Config: frame_system::Config {
|
||||||
|
@ -26,20 +30,16 @@ pub mod pallet {
|
||||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pallet::pallet]
|
|
||||||
#[pallet::generate_store(pub(super) trait Store)]
|
|
||||||
pub struct Pallet<T>(_);
|
|
||||||
|
|
||||||
// The pallet's runtime storage items.
|
// The pallet's runtime storage items.
|
||||||
// https://docs.substrate.io/v3/runtime/storage
|
// https://docs.substrate.io/main-docs/build/runtime-storage/
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn something)]
|
#[pallet::getter(fn something)]
|
||||||
// Learn more about declaring storage items:
|
// Learn more about declaring storage items:
|
||||||
// https://docs.substrate.io/v3/runtime/storage#declaring-storage-items
|
// https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
|
||||||
pub type Something<T> = StorageValue<_, u32>;
|
pub type Something<T> = StorageValue<_, u32>;
|
||||||
|
|
||||||
// Pallets use events to inform users when important changes are made.
|
// Pallets use events to inform users when important changes are made.
|
||||||
// https://docs.substrate.io/v3/runtime/events-and-errors
|
// https://docs.substrate.io/main-docs/build/events-errors/
|
||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
|
@ -68,7 +68,7 @@ pub mod pallet {
|
||||||
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
pub fn do_something(origin: OriginFor<T>, something: u32) -> DispatchResult {
|
||||||
// Check that the extrinsic was signed and get the signer.
|
// Check that the extrinsic was signed and get the signer.
|
||||||
// This function will return an error if the extrinsic is not signed.
|
// This function will return an error if the extrinsic is not signed.
|
||||||
// https://docs.substrate.io/v3/runtime/origins
|
// https://docs.substrate.io/main-docs/build/origins/
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
// Update storage.
|
// Update storage.
|
||||||
|
|
Loading…
Reference in New Issue