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

Commit

Permalink
Introduce EnsureOrigin to democracy.propose (#13410)
Browse files Browse the repository at this point in the history
* feat: add submitorigin to democracy

* fix: democracy tests

* fix: SubmitOrigin doc comment

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

---------

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
  • Loading branch information
mrshiposha and kianenigma committed Feb 21, 2023
1 parent ea18266 commit b77175d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ impl pallet_democracy::Config for Runtime {
/// (NTB) vote.
type ExternalDefaultOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
type SubmitOrigin = EnsureSigned<AccountId>;
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin =
Expand Down
7 changes: 6 additions & 1 deletion frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ pub mod pallet {
/// of a negative-turnout-bias (default-carries) referendum.
type ExternalDefaultOrigin: EnsureOrigin<Self::RuntimeOrigin>;

/// Origin from which the new proposal can be made.
///
/// The success variant is the account id of the depositor.
type SubmitOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;

/// Origin from which the next majority-carries (or more permissive) referendum may be
/// tabled to vote according to the `FastTrackVotingPeriod` asynchronously in a similar
/// manner to the emergency origin. It retains its threshold method.
Expand Down Expand Up @@ -590,7 +595,7 @@ pub mod pallet {
proposal: BoundedCallOf<T>,
#[pallet::compact] value: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let who = T::SubmitOrigin::ensure_origin(origin)?;
ensure!(value >= T::MinimumDeposit::get(), Error::<T>::ValueLow);

let index = Self::public_prop_count();
Expand Down
3 changes: 2 additions & 1 deletion frame/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_support::{
},
weights::Weight,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy};
use pallet_balances::{BalanceLock, Error as BalancesError};
use sp_core::H256;
use sp_runtime::{
Expand Down Expand Up @@ -177,6 +177,7 @@ impl Config for Test {
type MinimumDeposit = ConstU64<1>;
type MaxDeposits = ConstU32<1000>;
type MaxBlacklisted = ConstU32<5>;
type SubmitOrigin = EnsureSigned<Self::AccountId>;
type ExternalOrigin = EnsureSignedBy<Two, u64>;
type ExternalMajorityOrigin = EnsureSignedBy<Three, u64>;
type ExternalDefaultOrigin = EnsureSignedBy<One, u64>;
Expand Down

0 comments on commit b77175d

Please sign in to comment.