From 58652214ac04fe5e019f2aa67550df1848237d68 Mon Sep 17 00:00:00 2001 From: devwckd Date: Sat, 7 Dec 2024 18:49:08 -0300 Subject: [PATCH] feat: add emission pallet skeleton --- Cargo.lock | 9 +++++ pallets/emission0/Cargo.toml | 16 +++++++++ pallets/emission0/src/lib.rs | 60 ++++++++++++++++++++++++++++++++ pallets/emission0/src/weights.rs | 22 ++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 pallets/emission0/Cargo.toml create mode 100644 pallets/emission0/src/lib.rs create mode 100644 pallets/emission0/src/weights.rs diff --git a/Cargo.lock b/Cargo.lock index bbc8437..a0402f9 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -6859,6 +6859,15 @@ dependencies = [ "sp-staking", ] +[[package]] +name = "pallet-emission0" +version = "0.1.0" +dependencies = [ + "parity-scale-codec", + "polkadot-sdk", + "scale-info", +] + [[package]] name = "pallet-fast-unstake" version = "37.0.0" diff --git a/pallets/emission0/Cargo.toml b/pallets/emission0/Cargo.toml new file mode 100644 index 0000000..67a42fd --- /dev/null +++ b/pallets/emission0/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "pallet-emission0" +description = "The chain's emission pallet." +version = "0.1.0" +license = "MIT-0" +authors.workspace = true +edition.workspace = true + +[features] +default = ["std"] +std = ["codec/std", "polkadot-sdk/std", "scale-info/std"] + +[dependencies] +codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } +polkadot-sdk = { workspace = true, features = ["experimental", "runtime"] } diff --git a/pallets/emission0/src/lib.rs b/pallets/emission0/src/lib.rs new file mode 100644 index 0000000..a5a3361 --- /dev/null +++ b/pallets/emission0/src/lib.rs @@ -0,0 +1,60 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +mod weights; + +use crate::frame::testing_prelude::DispatchResult; +use crate::frame::testing_prelude::OriginFor; +pub use pallet::*; +use polkadot_sdk::frame_support::pallet_prelude::{ValueQuery, *}; +use polkadot_sdk::polkadot_sdk_frame as frame; + +#[frame::pallet] +pub mod pallet { + use frame::traits::ConstU64; + + use super::*; + + #[pallet::storage] + pub type Weights = + StorageMap<_, Identity, u16, BoundedVec<(u16, u16), ConstU32<{ u32::MAX }>>>; + + #[pallet::storage] + pub type PendingEmission = StorageMap<_, Identity, u16, u64, ValueQuery>; + + #[pallet::storage] + pub type UnitEmission = StorageValue<_, u64, ValueQuery, ConstU64<23148148148>>; + + #[pallet::config] + pub trait Config: polkadot_sdk::frame_system::Config {} + + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(0)] + pub fn set_weights_extrinsic( + origin: OriginFor, + uids: Vec, + weights: Vec, + ) -> DispatchResult { + weights::set_weights::(origin, uids, weights) + } + + #[pallet::call_index(2)] + #[pallet::weight(0)] + pub fn delegate_weight_control_extrinsic( + origin: OriginFor, + target: T::AccountId, + ) -> DispatchResult { + weights::delegate_weight_control::(origin, target) + } + + #[pallet::call_index(3)] + #[pallet::weight(0)] + pub fn regain_weight_control_extrinsic(origin: OriginFor) -> DispatchResult { + weights::regain_weight_control::(origin) + } + } +} diff --git a/pallets/emission0/src/weights.rs b/pallets/emission0/src/weights.rs new file mode 100644 index 0000000..bbc193a --- /dev/null +++ b/pallets/emission0/src/weights.rs @@ -0,0 +1,22 @@ +use polkadot_sdk::{ + frame_support::dispatch::DispatchResult, polkadot_sdk_frame::prelude::OriginFor, +}; + +pub fn set_weights( + _origin: OriginFor, + _uids: Vec, + _weights: Vec, +) -> DispatchResult { + todo!() +} + +pub fn delegate_weight_control( + _origin: OriginFor, + _target: T::AccountId, +) -> DispatchResult { + todo!() +} + +pub fn regain_weight_control(_origin: OriginFor) -> DispatchResult { + todo!() +}