Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Introduce SubmitOrigin to Referenda pallet config #11567

Merged
merged 2 commits into from
Jun 1, 2022
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
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