Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add emission pallet skeleton #3

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pallets/emission0/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
60 changes: 60 additions & 0 deletions pallets/emission0/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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(dev_mode)]
pub mod pallet {
use frame::traits::ConstU64;

use super::*;

#[pallet::storage]
pub type Weights<T> =
StorageMap<_, Identity, u16, BoundedVec<(u16, u16), ConstU32<{ u32::MAX }>>>;

#[pallet::storage]
pub type PendingEmission<T> = StorageMap<_, Identity, u16, u64>;

#[pallet::storage]
pub type UnitEmission<T> = StorageValue<_, u64, ValueQuery, ConstU64<23148148148>>;
devwckd marked this conversation as resolved.
Show resolved Hide resolved

#[pallet::config]
pub trait Config: polkadot_sdk::frame_system::Config {}

#[pallet::pallet]
pub struct Pallet<T>(_);

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::call_index(0)]
#[pallet::weight(0)]
pub fn set_weights_extrinsic(
origin: OriginFor<T>,
uids: Vec<u16>,
weights: Vec<u16>,
) -> DispatchResult {
weights::set_weights::<T>(origin, uids, weights)
}

#[pallet::call_index(2)]
#[pallet::weight(0)]
pub fn delegate_weight_control_extrinsic(
origin: OriginFor<T>,
target: T::AccountId,
) -> DispatchResult {
weights::delegate_weight_control::<T>(origin, target)
}

#[pallet::call_index(3)]
#[pallet::weight(0)]
pub fn regain_weight_control_extrinsic(origin: OriginFor<T>) -> DispatchResult {
weights::regain_weight_control::<T>(origin)
}
}
}
22 changes: 22 additions & 0 deletions pallets/emission0/src/weights.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use polkadot_sdk::{
frame_support::dispatch::DispatchResult, polkadot_sdk_frame::prelude::OriginFor,
};

pub fn set_weights<T: crate::Config>(
_origin: OriginFor<T>,
_uids: Vec<u16>,
_weights: Vec<u16>,
) -> DispatchResult {
todo!()
}

pub fn delegate_weight_control<T: crate::Config>(
_origin: OriginFor<T>,
_target: T::AccountId,
) -> DispatchResult {
todo!()
}

pub fn regain_weight_control<T: crate::Config>(_origin: OriginFor<T>) -> DispatchResult {
todo!()
}