Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ kvdb-memorydb = { version = "0.13.0" }
kvdb-rocksdb = { version = "0.19.0" }
kvdb-shared-tests = { version = "0.11.0" }
landlock = { version = "0.3.0" }
lazy_static = { version = "1.5.0", default-features = false, features = ["spin_no_std"] }
libc = { version = "0.2.155" }
libfuzzer-sys = { version = "0.4" }
libp2p = { version = "0.54.1" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ workspace = true
[dependencies]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
hex-literal = { workspace = true, default-features = true }
lazy_static = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde_json = { features = ["alloc"], workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use super::Origin;
use crate::{Balance, BlockNumber, RuntimeOrigin, DAYS, DOLLARS, HOURS};
use sp_runtime::{str_array as s, Perbill};
use sp_runtime::{BoundedVec, Perbill};
use sp_std::borrow::Cow;

/// Referendum `TrackId` type.
Expand All @@ -38,24 +38,12 @@ pub mod constants {
pub const MASTER_AMBASSADOR_TIER_9: TrackId = 9;
}

/// The type implementing the [`pallet_referenda::TracksInfo`] trait for referenda pallet.
pub struct TracksInfo;

/// Information on the voting tracks.
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = TrackId;

type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;

/// Return the list of available tracks and their information.
fn tracks(
) -> impl Iterator<Item = Cow<'static, pallet_referenda::Track<Self::Id, Balance, BlockNumber>>>
{
static DATA: [pallet_referenda::Track<TrackId, Balance, BlockNumber>; 9] = [
lazy_static::lazy_static! {
pub static ref DATA: [pallet_referenda::Track<TrackId, Balance, BlockNumber>; 9] = [
pallet_referenda::Track {
id: constants::AMBASSADOR_TIER_1,
info: pallet_referenda::TrackInfo {
name: s("ambassador tier 1"),
name: BoundedVec::truncate_from(b"ambassador tier 1".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -77,7 +65,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::AMBASSADOR_TIER_2,
info: pallet_referenda::TrackInfo {
name: s("ambassador tier 2"),
name: BoundedVec::truncate_from(b"ambassador tier 2".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -99,7 +87,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::SENIOR_AMBASSADOR_TIER_3,
info: pallet_referenda::TrackInfo {
name: s("senior ambassador tier 3"),
name: BoundedVec::truncate_from(b"ambassador tier 3".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -121,7 +109,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::SENIOR_AMBASSADOR_TIER_4,
info: pallet_referenda::TrackInfo {
name: s("senior ambassador tier 4"),
name: BoundedVec::truncate_from(b"ambassador tier 4".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -143,7 +131,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::HEAD_AMBASSADOR_TIER_5,
info: pallet_referenda::TrackInfo {
name: s("head ambassador tier 5"),
name: BoundedVec::truncate_from(b"ambassador tier 5".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -165,7 +153,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::HEAD_AMBASSADOR_TIER_6,
info: pallet_referenda::TrackInfo {
name: s("head ambassador tier 6"),
name: BoundedVec::truncate_from(b"ambassador tier 6".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -187,7 +175,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::HEAD_AMBASSADOR_TIER_7,
info: pallet_referenda::TrackInfo {
name: s("head ambassador tier 7"),
name: BoundedVec::truncate_from(b"ambassador tier 7".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -209,7 +197,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::MASTER_AMBASSADOR_TIER_8,
info: pallet_referenda::TrackInfo {
name: s("master ambassador tier 8"),
name: BoundedVec::truncate_from(b"ambassador tier 8".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -231,7 +219,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
pallet_referenda::Track {
id: constants::MASTER_AMBASSADOR_TIER_9,
info: pallet_referenda::TrackInfo {
name: s("master ambassador tier 9"),
name: BoundedVec::truncate_from(b"ambassador tier 9".to_vec()),
max_deciding: 10,
decision_deposit: 5 * DOLLARS,
prepare_period: 24 * HOURS,
Expand All @@ -251,6 +239,21 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
},
},
];
}

/// The type implementing the [`pallet_referenda::TracksInfo`] trait for referenda pallet.
pub struct TracksInfo;

/// Information on the voting tracks.
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = TrackId;

type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;

/// Return the list of available tracks and their information.
fn tracks(
) -> impl Iterator<Item = Cow<'static, pallet_referenda::Track<Self::Id, Balance, BlockNumber>>>
{
DATA.iter().map(Cow::Borrowed)
}

Expand Down
Loading