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/ext.rs b/pallets/emission0/src/ext.rs new file mode 100644 index 0000000..5c072c1 --- /dev/null +++ b/pallets/emission0/src/ext.rs @@ -0,0 +1,7 @@ +use polkadot_sdk::frame_support::traits::Currency; + +pub(super) type BalanceOf = <::Currency as Currency< + ::AccountId, +>>::Balance; + +pub(super) type AccountIdOf = ::AccountId; diff --git a/pallets/emission0/src/lib.rs b/pallets/emission0/src/lib.rs new file mode 100644 index 0000000..9e30598 --- /dev/null +++ b/pallets/emission0/src/lib.rs @@ -0,0 +1,69 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +mod ext; +mod weights; + +use crate::frame::testing_prelude::DispatchResult; +use crate::frame::testing_prelude::OriginFor; +pub(crate) use ext::*; +pub use pallet::*; +use polkadot_sdk::frame_support::pallet_prelude::{ValueQuery, *}; +use polkadot_sdk::polkadot_sdk_frame as frame; + +#[frame::pallet(dev_mode)] +pub mod pallet { + use frame::traits::{ConstU128, Currency}; + + use super::*; + + #[pallet::storage] + pub type Weights = StorageMap< + _, + Identity, + AccountIdOf, + BoundedVec<(AccountIdOf, u16), ConstU32<{ u32::MAX }>>, + >; + + #[pallet::storage] + pub type PendingEmission = StorageMap<_, Identity, AccountIdOf, BalanceOf>; + + #[pallet::storage] + pub type UnitEmission = + StorageValue<_, BalanceOf, ValueQuery, ConstU128<23148148148>>; + + #[pallet::config] + pub trait Config: polkadot_sdk::frame_system::Config { + type Currency: Currency + Send + Sync; + } + + #[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: AccountIdOf, + ) -> 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!() +}