Skip to content

Commit

Permalink
feat: add emission pallet skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
devwckd committed Dec 7, 2024
1 parent fce0186 commit 5865221
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
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]
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, ValueQuery>;

#[pallet::storage]
pub type UnitEmission<T> = StorageValue<_, u64, ValueQuery, ConstU64<23148148148>>;

#[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)]

Check failure on line 36 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this let-binding has unit value

error: this let-binding has unit value --> pallets/emission0/src/lib.rs:36:26 | 36 | #[pallet::weight(0)] | ^ help: omit the `let` binding: `0;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value = note: `-D clippy::let-unit-value` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]`

Check failure on line 36 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated constant `pallet::warnings::ConstantWeight_0::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798>

error: use of deprecated constant `pallet::warnings::ConstantWeight_0::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798> --> pallets/emission0/src/lib.rs:36:26 | 36 | #[pallet::weight(0)] | ^ | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]`
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)]

Check failure on line 46 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this let-binding has unit value

error: this let-binding has unit value --> pallets/emission0/src/lib.rs:46:26 | 46 | #[pallet::weight(0)] | ^ help: omit the `let` binding: `0;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value

Check failure on line 46 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated constant `pallet::warnings::ConstantWeight_1::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798>

error: use of deprecated constant `pallet::warnings::ConstantWeight_1::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798> --> pallets/emission0/src/lib.rs:46:26 | 46 | #[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)]

Check failure on line 55 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this let-binding has unit value

error: this let-binding has unit value --> pallets/emission0/src/lib.rs:55:26 | 55 | #[pallet::weight(0)] | ^ help: omit the `let` binding: `0;` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value

Check failure on line 55 in pallets/emission0/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated constant `pallet::warnings::ConstantWeight_2::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798>

error: use of deprecated constant `pallet::warnings::ConstantWeight_2::_w`: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet into `dev` mode. For more info see: <https://github.com/paritytech/substrate/pull/13798> --> pallets/emission0/src/lib.rs:55:26 | 55 | #[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!()
}

0 comments on commit 5865221

Please sign in to comment.