forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(referenda-tracks): define pallet calls fix(pallet-referenda): impl Debug + PartialEq on TrackInfo chore(impl_tracks_info): split codebase chore(referenda-tracks): add test suite * fix(referenda-tracks): implement requested changes
- Loading branch information
Showing
7 changed files
with
491 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
# Remark Storage Pallet | ||
# Referenda Tracks Pallet | ||
|
||
Allows storing arbitrary data off chain. | ||
- [`Config`][Config] | ||
- [`Call`][Call] | ||
|
||
## Overview | ||
|
||
Manage referenda voting tracks. | ||
|
||
## Interface | ||
|
||
### Dispatchable Functions | ||
|
||
- `insert` - Insert a new referenda Track. | ||
- `update` - Update the configuration of an existing referenda Track. | ||
- `remove` - Remove an existing track | ||
|
||
License: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use super::*; | ||
|
||
impl<T: Config<I>, I> pallet_referenda::TracksInfo<BalanceOf<T, I>, BlockNumberFor<T>> | ||
for Pallet<T, I> | ||
{ | ||
type Id = T::TrackId; | ||
type RuntimeOrigin = <T::RuntimeOrigin as OriginTrait>::PalletsOrigin; | ||
type TracksIter = TracksIter<T, I>; | ||
|
||
fn tracks() -> Self::TracksIter { | ||
Tracks::<T, I>::iter().map(|(id, info)| Cow::Owned(Track { id, info })) | ||
} | ||
fn track_for(origin: &Self::RuntimeOrigin) -> Result<Self::Id, ()> { | ||
OriginToTrackId::<T, I>::get(origin).ok_or(()) | ||
} | ||
fn tracks_ids() -> Vec<Self::Id> { | ||
TracksIds::<T, I>::get().into_inner() | ||
} | ||
fn info(id: Self::Id) -> Option<Cow<'static, TrackInfoOf<T, I>>> { | ||
Tracks::<T, I>::get(id).map(Cow::Owned) | ||
} | ||
} | ||
|
||
impl<T: Config<I>, I: 'static> Get<Vec<TrackOf<T, I>>> for crate::Pallet<T, I> { | ||
fn get() -> Vec<TrackOf<T, I>> { | ||
// expensive but it doesn't seem to be used anywhere | ||
<Pallet<T, I> as pallet_referenda::TracksInfo<BalanceOf<T, I>, BlockNumberFor<T>>>::tracks() | ||
.map(|t| t.into_owned()) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.