walto/repuchain-node/pallets/reputation/src/lib.rs

68 lines
1.6 KiB
Rust

#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
pub mod weights;
pub use weights::*;
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type WeightInfo: WeightInfo;
}
#[pallet::storage]
#[pallet::getter(fn something)]
pub type Reputation<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, u32, ValueQuery>;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
//SomethingStored { something: u32, who: T::AccountId },
}
// Errors inform users that something went wrong.
#[pallet::error]
pub enum Error<T> {
NoneValue,
StorageOverflow,
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
pub fn set_rep(origin: OriginFor<T>, account: T::AccountId, rep: u32) -> DispatchResult{
let who = ensure_signed(origin)?;
Reputation::<T>::set(account, rep);
Ok(())
}
//#[pallet::call_index(1)]
//#[pallet::weight(T::WeightInfo::do_something())]
//pub fn set_rep(origin: OriginFor<T>, data: Vec<_>) -> DispatchResult {
// let who = ensure_signed(origin)?;
// let score = "lots of calculation from `data`";
// Reputation::<T>::set(account, score);
// Ok(())
//}
}
}