diff --git a/substrate/frame/referenda-tracks/src/impl_tracks_info.rs b/substrate/frame/referenda-tracks/src/impl_tracks_info.rs new file mode 100644 index 0000000000000..2c637a7f2ddec --- /dev/null +++ b/substrate/frame/referenda-tracks/src/impl_tracks_info.rs @@ -0,0 +1,31 @@ +use super::*; + +impl, I> pallet_referenda::TracksInfo, BlockNumberFor> + for Pallet +{ + type Id = T::TrackId; + type RuntimeOrigin = ::PalletsOrigin; + type TracksIter = TracksIter; + + fn tracks() -> Self::TracksIter { + Tracks::::iter().map(|(id, info)| Cow::Owned(Track { id, info })) + } + fn track_for(origin: &Self::RuntimeOrigin) -> Result { + OriginToTrackId::::get(origin).ok_or(()) + } + fn tracks_ids() -> Vec { + TracksIds::::get().into_inner() + } + fn info(id: Self::Id) -> Option>> { + Tracks::::get(id).map(Cow::Owned) + } +} + +impl, I: 'static> Get>> for crate::Pallet { + fn get() -> Vec> { + // expensive but it doesn't seem to be used anywhere + as pallet_referenda::TracksInfo, BlockNumberFor>>::tracks() + .map(|t| t.into_owned()) + .collect() + } +}