Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
}
}
}
pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);

impl pallet_referenda::Config for Runtime {
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
Expand Down
42 changes: 36 additions & 6 deletions frame/referenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use frame_support::{
v2::{Anon as ScheduleAnon, Named as ScheduleNamed},
DispatchTime, MaybeHashed,
},
Currency, Get, LockIdentifier, OnUnbalanced, OriginTrait, PollStatus, Polling,
Currency, LockIdentifier, OnUnbalanced, OriginTrait, PollStatus, Polling,
ReservableCurrency, VoteTally,
},
BoundedVec,
Expand Down Expand Up @@ -108,6 +108,30 @@ mod tests;
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;

pub use frame_support::traits::Get;
pub use sp_std::vec::Vec;

#[macro_export]
macro_rules! impl_tracksinfo_get {
($tracksinfo:ty, $balance:ty, $blocknumber:ty) => {
impl
$crate::Get<
$crate::Vec<(
<$tracksinfo as $crate::TracksInfo<$balance, $blocknumber>>::Id,
$crate::TrackInfo<$balance, $blocknumber>,
)>,
> for $tracksinfo
{
fn get() -> $crate::Vec<(
<$tracksinfo as $crate::TracksInfo<$balance, $blocknumber>>::Id,
$crate::TrackInfo<$balance, $blocknumber>,
)> {
<$tracksinfo as $crate::TracksInfo<$balance, $blocknumber>>::tracks().to_vec()
}
}
};
}

const ASSEMBLY_ID: LockIdentifier = *b"assembly";

#[frame_support::pallet]
Expand Down Expand Up @@ -184,11 +208,17 @@ pub mod pallet {

// The other stuff.
/// Information concerning the different referendum tracks.
type Tracks: TracksInfo<
BalanceOf<Self, I>,
Self::BlockNumber,
Origin = <Self::Origin as OriginTrait>::PalletsOrigin,
>;
#[pallet::constant]
type Tracks: Get<
Vec<(
<Self::Tracks as TracksInfo<BalanceOf<Self, I>, Self::BlockNumber>>::Id,
TrackInfo<BalanceOf<Self, I>, Self::BlockNumber>,
)>,
> + TracksInfo<
BalanceOf<Self, I>,
Self::BlockNumber,
Origin = <Self::Origin as OriginTrait>::PalletsOrigin,
>;
}

/// The next free referendum index, aka the number of referenda started so far.
Expand Down
1 change: 1 addition & 0 deletions frame/referenda/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ impl TracksInfo<u64, u64> for TestTracksInfo {
}
}
}
impl_tracksinfo_get!(TestTracksInfo, u64, u64);

impl Config for Test {
type WeightInfo = ();
Expand Down