Skip to content

Commit

Permalink
Introduce SubmitOrigin to Referenda pallet config (paritytech#11567)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork authored and godcodehunter committed Jun 22, 2022
1 parent 02c7eb6 commit 62eb90f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ impl pallet_referenda::Config for Runtime {
type Event = Event;
type Scheduler = Scheduler;
type Currency = pallet_balances::Pallet<Self>;
type SubmitOrigin = EnsureSigned<AccountId>;
type CancelOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type Slash = ();
Expand All @@ -843,6 +844,7 @@ impl pallet_referenda::Config<pallet_referenda::Instance2> for Runtime {
type Event = Event;
type Scheduler = Scheduler;
type Currency = pallet_balances::Pallet<Self>;
type SubmitOrigin = EnsureSigned<AccountId>;
type CancelOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type Slash = ();
Expand Down
6 changes: 4 additions & 2 deletions frame/referenda/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ pub mod pallet {
/// Currency type for this pallet.
type Currency: ReservableCurrency<Self::AccountId>;
// Origins and unbalances.
/// Origin from which proposals may be submitted.
type SubmitOrigin: EnsureOrigin<Self::Origin, Success = Self::AccountId>;
/// Origin from which any vote may be cancelled.
type CancelOrigin: EnsureOrigin<Self::Origin>;
/// Origin from which any vote may be killed.
Expand Down Expand Up @@ -343,7 +345,7 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Propose a referendum on a privileged action.
///
/// - `origin`: must be `Signed` and the account must have `SubmissionDeposit` funds
/// - `origin`: must be `SubmitOrigin` and the account must have `SubmissionDeposit` funds
/// available.
/// - `proposal_origin`: The origin from which the proposal should be executed.
/// - `proposal_hash`: The hash of the proposal preimage.
Expand All @@ -357,7 +359,7 @@ pub mod pallet {
proposal_hash: T::Hash,
enactment_moment: DispatchTime<T::BlockNumber>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let who = T::SubmitOrigin::ensure_origin(origin)?;

let track =
T::Tracks::track_for(&proposal_origin).map_err(|_| Error::<T, I>::NoTrack)?;
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 @@ -215,6 +215,7 @@ impl Config for Test {
type Event = Event;
type Scheduler = Scheduler;
type Currency = pallet_balances::Pallet<Self>;
type SubmitOrigin = frame_system::EnsureSigned<u64>;
type CancelOrigin = EnsureSignedBy<Four, u64>;
type KillOrigin = EnsureRoot<u64>;
type Slash = ();
Expand Down
2 changes: 0 additions & 2 deletions frame/referenda/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ use frame_support::{
};
use pallet_balances::Error as BalancesError;

// TODO: Scheduler should re-use `None` items in its `Agenda`.

#[test]
fn params_should_work() {
new_test_ext().execute_with(|| {
Expand Down

0 comments on commit 62eb90f

Please sign in to comment.