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

Commit f8c9a8e

Browse files
mrshiposhakianenigma
authored andcommitted
Introduce EnsureOrigin to democracy.propose (#13410)
* feat: add submitorigin to democracy * fix: democracy tests * fix: SubmitOrigin doc comment Co-authored-by: Kian Paimani <[email protected]> --------- Co-authored-by: Kian Paimani <[email protected]>
1 parent 68a153d commit f8c9a8e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

bin/node/runtime/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ impl pallet_democracy::Config for Runtime {
948948
/// (NTB) vote.
949949
type ExternalDefaultOrigin =
950950
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
951+
type SubmitOrigin = EnsureSigned<AccountId>;
951952
/// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote
952953
/// be tabled immediately and with a shorter voting/enactment period.
953954
type FastTrackOrigin =

frame/democracy/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ pub mod pallet {
308308
/// of a negative-turnout-bias (default-carries) referendum.
309309
type ExternalDefaultOrigin: EnsureOrigin<Self::RuntimeOrigin>;
310310

311+
/// Origin from which the new proposal can be made.
312+
///
313+
/// The success variant is the account id of the depositor.
314+
type SubmitOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
315+
311316
/// Origin from which the next majority-carries (or more permissive) referendum may be
312317
/// tabled to vote according to the `FastTrackVotingPeriod` asynchronously in a similar
313318
/// manner to the emergency origin. It retains its threshold method.
@@ -590,7 +595,7 @@ pub mod pallet {
590595
proposal: BoundedCallOf<T>,
591596
#[pallet::compact] value: BalanceOf<T>,
592597
) -> DispatchResult {
593-
let who = ensure_signed(origin)?;
598+
let who = T::SubmitOrigin::ensure_origin(origin)?;
594599
ensure!(value >= T::MinimumDeposit::get(), Error::<T>::ValueLow);
595600

596601
let index = Self::public_prop_count();

frame/democracy/src/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use frame_support::{
2727
},
2828
weights::Weight,
2929
};
30-
use frame_system::{EnsureRoot, EnsureSignedBy};
30+
use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy};
3131
use pallet_balances::{BalanceLock, Error as BalancesError};
3232
use sp_core::H256;
3333
use sp_runtime::{
@@ -177,6 +177,7 @@ impl Config for Test {
177177
type MinimumDeposit = ConstU64<1>;
178178
type MaxDeposits = ConstU32<1000>;
179179
type MaxBlacklisted = ConstU32<5>;
180+
type SubmitOrigin = EnsureSigned<Self::AccountId>;
180181
type ExternalOrigin = EnsureSignedBy<Two, u64>;
181182
type ExternalMajorityOrigin = EnsureSignedBy<Three, u64>;
182183
type ExternalDefaultOrigin = EnsureSignedBy<One, u64>;

0 commit comments

Comments
 (0)