mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin * more renaming * a bit more renaming * fix * more fixing * fix in frame_support * even more fixes * fix * small fix * ... * update .stderr * docs * update docs * update docs * docs
This commit is contained in:
@@ -42,8 +42,8 @@ fn funded_account<T: Config<I>, I: 'static>(name: &'static str, index: u32) -> T
|
||||
caller
|
||||
}
|
||||
|
||||
fn create_referendum<T: Config<I>, I: 'static>() -> (T::Origin, ReferendumIndex) {
|
||||
let origin: T::Origin = T::SubmitOrigin::successful_origin();
|
||||
fn create_referendum<T: Config<I>, I: 'static>() -> (T::RuntimeOrigin, ReferendumIndex) {
|
||||
let origin: T::RuntimeOrigin = T::SubmitOrigin::successful_origin();
|
||||
if let Ok(caller) = frame_system::ensure_signed(origin.clone()) {
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T, I>::max_value());
|
||||
whitelist_account!(caller);
|
||||
@@ -188,12 +188,12 @@ fn is_not_confirming<T: Config<I>, I: 'static>(index: ReferendumIndex) -> bool {
|
||||
|
||||
benchmarks_instance_pallet! {
|
||||
submit {
|
||||
let origin: T::Origin = T::SubmitOrigin::successful_origin();
|
||||
let origin: T::RuntimeOrigin = T::SubmitOrigin::successful_origin();
|
||||
if let Ok(caller) = frame_system::ensure_signed(origin.clone()) {
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T, I>::max_value());
|
||||
whitelist_account!(caller);
|
||||
}
|
||||
}: _<T::Origin>(
|
||||
}: _<T::RuntimeOrigin>(
|
||||
origin,
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
T::Hashing::hash_of(&0),
|
||||
@@ -205,7 +205,7 @@ benchmarks_instance_pallet! {
|
||||
|
||||
place_decision_deposit_preparing {
|
||||
let (origin, index) = create_referendum::<T, I>();
|
||||
}: place_decision_deposit<T::Origin>(origin, index)
|
||||
}: place_decision_deposit<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
assert!(Referenda::<T, I>::ensure_ongoing(index).unwrap().decision_deposit.is_some());
|
||||
}
|
||||
@@ -213,7 +213,7 @@ benchmarks_instance_pallet! {
|
||||
place_decision_deposit_queued {
|
||||
let (origin, index) = create_referendum::<T, I>();
|
||||
fill_queue::<T, I>(index, 1, 90);
|
||||
}: place_decision_deposit<T::Origin>(origin, index)
|
||||
}: place_decision_deposit<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
let track = Referenda::<T, I>::ensure_ongoing(index).unwrap().track;
|
||||
assert_eq!(TrackQueue::<T, I>::get(&track).len() as u32, T::MaxQueued::get());
|
||||
@@ -226,7 +226,7 @@ benchmarks_instance_pallet! {
|
||||
let track = Referenda::<T, I>::ensure_ongoing(index).unwrap().track;
|
||||
assert_eq!(TrackQueue::<T, I>::get(&track).len() as u32, T::MaxQueued::get());
|
||||
assert!(TrackQueue::<T, I>::get(&track).into_iter().all(|(i, _)| i != index));
|
||||
}: place_decision_deposit<T::Origin>(origin, index)
|
||||
}: place_decision_deposit<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
assert_eq!(TrackQueue::<T, I>::get(&track).len() as u32, T::MaxQueued::get());
|
||||
assert!(TrackQueue::<T, I>::get(&track).into_iter().all(|(i, _)| i != index));
|
||||
@@ -236,7 +236,7 @@ benchmarks_instance_pallet! {
|
||||
let (origin, index) = create_referendum::<T, I>();
|
||||
skip_prepare_period::<T, I>(index);
|
||||
make_passing::<T, I>(index);
|
||||
}: place_decision_deposit<T::Origin>(origin, index)
|
||||
}: place_decision_deposit<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
assert!(is_confirming::<T, I>(index));
|
||||
}
|
||||
@@ -244,7 +244,7 @@ benchmarks_instance_pallet! {
|
||||
place_decision_deposit_failing {
|
||||
let (origin, index) = create_referendum::<T, I>();
|
||||
skip_prepare_period::<T, I>(index);
|
||||
}: place_decision_deposit<T::Origin>(origin, index)
|
||||
}: place_decision_deposit<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
assert!(is_not_confirming::<T, I>(index));
|
||||
}
|
||||
@@ -253,7 +253,7 @@ benchmarks_instance_pallet! {
|
||||
let (origin, index) = create_referendum::<T, I>();
|
||||
place_deposit::<T, I>(index);
|
||||
assert_ok!(Referenda::<T, I>::cancel(T::CancelOrigin::successful_origin(), index));
|
||||
}: _<T::Origin>(origin, index)
|
||||
}: _<T::RuntimeOrigin>(origin, index)
|
||||
verify {
|
||||
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Cancelled(_, _, None)));
|
||||
}
|
||||
@@ -261,7 +261,7 @@ benchmarks_instance_pallet! {
|
||||
cancel {
|
||||
let (_origin, index) = create_referendum::<T, I>();
|
||||
place_deposit::<T, I>(index);
|
||||
}: _<T::Origin>(T::CancelOrigin::successful_origin(), index)
|
||||
}: _<T::RuntimeOrigin>(T::CancelOrigin::successful_origin(), index)
|
||||
verify {
|
||||
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Cancelled(..)));
|
||||
}
|
||||
@@ -269,7 +269,7 @@ benchmarks_instance_pallet! {
|
||||
kill {
|
||||
let (_origin, index) = create_referendum::<T, I>();
|
||||
place_deposit::<T, I>(index);
|
||||
}: _<T::Origin>(T::KillOrigin::successful_origin(), index)
|
||||
}: _<T::RuntimeOrigin>(T::KillOrigin::successful_origin(), index)
|
||||
verify {
|
||||
assert_matches!(ReferendumInfoFor::<T, I>::get(index), Some(ReferendumInfo::Killed(..)));
|
||||
}
|
||||
|
||||
@@ -147,7 +147,9 @@ pub mod pallet {
|
||||
#[pallet::config]
|
||||
pub trait Config<I: 'static = ()>: frame_system::Config + Sized {
|
||||
// System level stuff.
|
||||
type RuntimeCall: Parameter + Dispatchable<Origin = Self::Origin> + From<Call<Self, I>>;
|
||||
type RuntimeCall: Parameter
|
||||
+ Dispatchable<RuntimeOrigin = Self::RuntimeOrigin>
|
||||
+ From<Call<Self, I>>;
|
||||
type RuntimeEvent: From<Event<Self, I>>
|
||||
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
@@ -168,11 +170,11 @@ pub mod pallet {
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
// Origins and unbalances.
|
||||
/// Origin from which proposals may be submitted.
|
||||
type SubmitOrigin: EnsureOrigin<Self::Origin, Success = Self::AccountId>;
|
||||
type SubmitOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
|
||||
/// Origin from which any vote may be cancelled.
|
||||
type CancelOrigin: EnsureOrigin<Self::Origin>;
|
||||
type CancelOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
/// Origin from which any vote may be killed.
|
||||
type KillOrigin: EnsureOrigin<Self::Origin>;
|
||||
type KillOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
/// Handler for the unbalanced reduction when slashing a preimage deposit.
|
||||
type Slash: OnUnbalanced<NegativeImbalanceOf<Self, I>>;
|
||||
/// The counting type for votes. Usually just balance.
|
||||
@@ -217,7 +219,7 @@ pub mod pallet {
|
||||
> + TracksInfo<
|
||||
BalanceOf<Self, I>,
|
||||
Self::BlockNumber,
|
||||
Origin = <Self::Origin as OriginTrait>::PalletsOrigin,
|
||||
RuntimeOrigin = <Self::RuntimeOrigin as OriginTrait>::PalletsOrigin,
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ impl frame_system::Config for Test {
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
@@ -103,7 +103,7 @@ impl pallet_preimage::Config for Test {
|
||||
}
|
||||
impl pallet_scheduler::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type PalletsOrigin = OriginCaller;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type MaximumWeight = MaxWeight;
|
||||
@@ -148,7 +148,7 @@ impl SortedMembers<u64> for OneToFive {
|
||||
pub struct TestTracksInfo;
|
||||
impl TracksInfo<u64, u64> for TestTracksInfo {
|
||||
type Id = u8;
|
||||
type Origin = <Origin as OriginTrait>::PalletsOrigin;
|
||||
type RuntimeOrigin = <RuntimeOrigin as OriginTrait>::PalletsOrigin;
|
||||
fn tracks() -> &'static [(Self::Id, TrackInfo<u64, u64>)] {
|
||||
static DATA: [(u8, TrackInfo<u64, u64>); 2] = [
|
||||
(
|
||||
@@ -198,7 +198,7 @@ impl TracksInfo<u64, u64> for TestTracksInfo {
|
||||
];
|
||||
&DATA[..]
|
||||
}
|
||||
fn track_for(id: &Self::Origin) -> Result<Self::Id, ()> {
|
||||
fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
|
||||
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) {
|
||||
match system_origin {
|
||||
frame_system::RawOrigin::Root => Ok(0),
|
||||
@@ -319,7 +319,7 @@ pub fn set_balance_proposal_hash(value: u64) -> H256 {
|
||||
#[allow(dead_code)]
|
||||
pub fn propose_set_balance(who: u64, value: u64, delay: u64) -> DispatchResult {
|
||||
Referenda::submit(
|
||||
Origin::signed(who),
|
||||
RuntimeOrigin::signed(who),
|
||||
Box::new(frame_system::RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(value),
|
||||
DispatchTime::After(delay),
|
||||
@@ -447,12 +447,12 @@ pub enum RefState {
|
||||
impl RefState {
|
||||
pub fn create(self) -> ReferendumIndex {
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(frame_support::dispatch::RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(1),
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
if matches!(self, RefState::Confirming { immediate: true }) {
|
||||
set_tally(0, 100, 0);
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ fn basic_happy_path_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// #1: submit
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(1),
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_eq!(Balances::reserved_balance(&1), 2);
|
||||
assert_eq!(ReferendumCount::<Test>::get(), 1);
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
run_to(4);
|
||||
assert_eq!(DecidingCount::<Test>::get(0), 0);
|
||||
run_to(5);
|
||||
@@ -63,7 +63,7 @@ fn basic_happy_path_works() {
|
||||
run_to(9);
|
||||
// #8: Should be confirmed & ended.
|
||||
assert_eq!(approved_since(0), 9);
|
||||
assert_ok!(Referenda::refund_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
run_to(12);
|
||||
// #9: Should not yet be enacted.
|
||||
assert_eq!(Balances::free_balance(&42), 0);
|
||||
@@ -78,7 +78,7 @@ fn insta_confirm_then_kill_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let r = Confirming { immediate: true }.create();
|
||||
run_to(6);
|
||||
assert_ok!(Referenda::kill(Origin::root(), r));
|
||||
assert_ok!(Referenda::kill(RuntimeOrigin::root(), r));
|
||||
assert_eq!(killed_since(r), 6);
|
||||
});
|
||||
}
|
||||
@@ -173,24 +173,24 @@ fn queueing_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Submit a proposal into a track with a queue len of 1.
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(5),
|
||||
RuntimeOrigin::signed(5),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(0),
|
||||
DispatchTime::After(0),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(5), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(5), 0));
|
||||
|
||||
run_to(2);
|
||||
|
||||
// Submit 3 more proposals into the same queue.
|
||||
for i in 1..=4 {
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(i),
|
||||
RuntimeOrigin::signed(i),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(i),
|
||||
DispatchTime::After(0),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(i), i as u32));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(i), i as u32));
|
||||
// TODO: decision deposit after some initial votes with a non-highest voted coming
|
||||
// first.
|
||||
}
|
||||
@@ -214,7 +214,7 @@ fn queueing_works() {
|
||||
println!("{:?}", Vec::<_>::from(TrackQueue::<Test>::get(0)));
|
||||
|
||||
// Cancel the first.
|
||||
assert_ok!(Referenda::cancel(Origin::signed(4), 0));
|
||||
assert_ok!(Referenda::cancel(RuntimeOrigin::signed(4), 0));
|
||||
assert_eq!(cancelled_since(0), 6);
|
||||
|
||||
// The other with the most approvals (#4) should be being decided.
|
||||
@@ -270,7 +270,7 @@ fn auto_timeout_should_happen_with_nothing_but_submit() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// #1: submit
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(1),
|
||||
DispatchTime::At(20),
|
||||
@@ -290,20 +290,20 @@ fn auto_timeout_should_happen_with_nothing_but_submit() {
|
||||
fn tracks_are_distinguished() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
set_balance_proposal_hash(1),
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
Box::new(RawOrigin::None.into()),
|
||||
set_balance_proposal_hash(2),
|
||||
DispatchTime::At(20),
|
||||
));
|
||||
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(3), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(4), 1));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(3), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(4), 1));
|
||||
|
||||
let mut i = ReferendumInfoFor::<Test>::iter().collect::<Vec<_>>();
|
||||
i.sort_by_key(|x| x.0);
|
||||
@@ -354,7 +354,7 @@ fn submit_errors_work() {
|
||||
// No track for Signed origins.
|
||||
assert_noop!(
|
||||
Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Signed(2).into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
@@ -365,7 +365,7 @@ fn submit_errors_work() {
|
||||
// No funds for deposit
|
||||
assert_noop!(
|
||||
Referenda::submit(
|
||||
Origin::signed(10),
|
||||
RuntimeOrigin::signed(10),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
@@ -379,21 +379,21 @@ fn submit_errors_work() {
|
||||
fn decision_deposit_errors_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let e = Error::<Test>::NotOngoing;
|
||||
assert_noop!(Referenda::place_decision_deposit(Origin::signed(2), 0), e);
|
||||
assert_noop!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0), e);
|
||||
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
let e = BalancesError::<Test>::InsufficientBalance;
|
||||
assert_noop!(Referenda::place_decision_deposit(Origin::signed(10), 0), e);
|
||||
assert_noop!(Referenda::place_decision_deposit(RuntimeOrigin::signed(10), 0), e);
|
||||
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
let e = Error::<Test>::HasDeposit;
|
||||
assert_noop!(Referenda::place_decision_deposit(Origin::signed(2), 0), e);
|
||||
assert_noop!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0), e);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -401,24 +401,24 @@ fn decision_deposit_errors_work() {
|
||||
fn refund_deposit_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let e = Error::<Test>::BadReferendum;
|
||||
assert_noop!(Referenda::refund_decision_deposit(Origin::signed(1), 0), e);
|
||||
assert_noop!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(1), 0), e);
|
||||
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
let e = Error::<Test>::NoDeposit;
|
||||
assert_noop!(Referenda::refund_decision_deposit(Origin::signed(2), 0), e);
|
||||
assert_noop!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(2), 0), e);
|
||||
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
let e = Error::<Test>::Unfinished;
|
||||
assert_noop!(Referenda::refund_decision_deposit(Origin::signed(3), 0), e);
|
||||
assert_noop!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(3), 0), e);
|
||||
|
||||
run_to(11);
|
||||
assert_ok!(Referenda::refund_decision_deposit(Origin::signed(3), 0));
|
||||
assert_ok!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(3), 0));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -427,16 +427,16 @@ fn cancel_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
|
||||
run_to(8);
|
||||
assert_ok!(Referenda::cancel(Origin::signed(4), 0));
|
||||
assert_ok!(Referenda::refund_decision_deposit(Origin::signed(3), 0));
|
||||
assert_ok!(Referenda::cancel(RuntimeOrigin::signed(4), 0));
|
||||
assert_ok!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(3), 0));
|
||||
assert_eq!(cancelled_since(0), 8);
|
||||
});
|
||||
}
|
||||
@@ -446,16 +446,16 @@ fn cancel_errors_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_noop!(Referenda::cancel(Origin::signed(1), 0), BadOrigin);
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
assert_noop!(Referenda::cancel(RuntimeOrigin::signed(1), 0), BadOrigin);
|
||||
|
||||
run_to(11);
|
||||
assert_noop!(Referenda::cancel(Origin::signed(4), 0), Error::<Test>::NotOngoing);
|
||||
assert_noop!(Referenda::cancel(RuntimeOrigin::signed(4), 0), Error::<Test>::NotOngoing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -464,17 +464,17 @@ fn kill_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
|
||||
run_to(8);
|
||||
assert_ok!(Referenda::kill(Origin::root(), 0));
|
||||
assert_ok!(Referenda::kill(RuntimeOrigin::root(), 0));
|
||||
let e = Error::<Test>::NoDeposit;
|
||||
assert_noop!(Referenda::refund_decision_deposit(Origin::signed(3), 0), e);
|
||||
assert_noop!(Referenda::refund_decision_deposit(RuntimeOrigin::signed(3), 0), e);
|
||||
assert_eq!(killed_since(0), 8);
|
||||
});
|
||||
}
|
||||
@@ -484,16 +484,16 @@ fn kill_errors_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let h = set_balance_proposal_hash(1);
|
||||
assert_ok!(Referenda::submit(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
Box::new(RawOrigin::Root.into()),
|
||||
h,
|
||||
DispatchTime::At(10),
|
||||
));
|
||||
assert_ok!(Referenda::place_decision_deposit(Origin::signed(2), 0));
|
||||
assert_noop!(Referenda::kill(Origin::signed(4), 0), BadOrigin);
|
||||
assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(2), 0));
|
||||
assert_noop!(Referenda::kill(RuntimeOrigin::signed(4), 0), BadOrigin);
|
||||
|
||||
run_to(11);
|
||||
assert_noop!(Referenda::kill(Origin::root(), 0), Error::<Test>::NotOngoing);
|
||||
assert_noop!(Referenda::kill(RuntimeOrigin::root(), 0), Error::<Test>::NotOngoing);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ pub type NegativeImbalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<
|
||||
pub type CallOf<T, I> = <T as Config<I>>::RuntimeCall;
|
||||
pub type VotesOf<T, I> = <T as Config<I>>::Votes;
|
||||
pub type TallyOf<T, I> = <T as Config<I>>::Tally;
|
||||
pub type PalletsOriginOf<T> = <<T as frame_system::Config>::Origin as OriginTrait>::PalletsOrigin;
|
||||
pub type PalletsOriginOf<T> =
|
||||
<<T as frame_system::Config>::RuntimeOrigin as OriginTrait>::PalletsOrigin;
|
||||
pub type ReferendumInfoOf<T, I> = ReferendumInfo<
|
||||
TrackIdOf<T, I>,
|
||||
PalletsOriginOf<T>,
|
||||
@@ -139,13 +140,13 @@ pub trait TracksInfo<Balance, Moment> {
|
||||
type Id: Copy + Parameter + Ord + PartialOrd + Send + Sync + 'static + MaxEncodedLen;
|
||||
|
||||
/// The origin type from which a track is implied.
|
||||
type Origin;
|
||||
type RuntimeOrigin;
|
||||
|
||||
/// Return the array of known tracks and their information.
|
||||
fn tracks() -> &'static [(Self::Id, TrackInfo<Balance, Moment>)];
|
||||
|
||||
/// Determine the voting track for the given `origin`.
|
||||
fn track_for(origin: &Self::Origin) -> Result<Self::Id, ()>;
|
||||
fn track_for(origin: &Self::RuntimeOrigin) -> Result<Self::Id, ()>;
|
||||
|
||||
/// Return the track info for track `id`, by default this just looks it up in `Self::tracks()`.
|
||||
fn info(id: Self::Id) -> Option<&'static TrackInfo<Balance, Moment>> {
|
||||
@@ -157,7 +158,7 @@ pub trait TracksInfo<Balance, Moment> {
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub struct ReferendumStatus<
|
||||
TrackId: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Origin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
RuntimeOrigin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Moment: Parameter + Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone + EncodeLike,
|
||||
Hash: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Balance: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
@@ -168,7 +169,7 @@ pub struct ReferendumStatus<
|
||||
/// The track of this referendum.
|
||||
pub(crate) track: TrackId,
|
||||
/// The origin for this referendum.
|
||||
pub(crate) origin: Origin,
|
||||
pub(crate) origin: RuntimeOrigin,
|
||||
/// The hash of the proposal up for referendum.
|
||||
pub(crate) proposal_hash: Hash,
|
||||
/// The time the proposal should be scheduled for enactment.
|
||||
@@ -194,7 +195,7 @@ pub struct ReferendumStatus<
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub enum ReferendumInfo<
|
||||
TrackId: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Origin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
RuntimeOrigin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Moment: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone + EncodeLike,
|
||||
Hash: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Balance: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
@@ -204,7 +205,16 @@ pub enum ReferendumInfo<
|
||||
> {
|
||||
/// Referendum has been submitted and is being voted on.
|
||||
Ongoing(
|
||||
ReferendumStatus<TrackId, Origin, Moment, Hash, Balance, Tally, AccountId, ScheduleAddress>,
|
||||
ReferendumStatus<
|
||||
TrackId,
|
||||
RuntimeOrigin,
|
||||
Moment,
|
||||
Hash,
|
||||
Balance,
|
||||
Tally,
|
||||
AccountId,
|
||||
ScheduleAddress,
|
||||
>,
|
||||
),
|
||||
/// Referendum finished with approval. Submission deposit is held.
|
||||
Approved(Moment, Deposit<AccountId, Balance>, Option<Deposit<AccountId, Balance>>),
|
||||
@@ -220,14 +230,14 @@ pub enum ReferendumInfo<
|
||||
|
||||
impl<
|
||||
TrackId: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Origin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
RuntimeOrigin: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Moment: Parameter + Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone + EncodeLike,
|
||||
Hash: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Balance: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
Tally: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
AccountId: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
ScheduleAddress: Eq + PartialEq + Debug + Encode + Decode + TypeInfo + Clone,
|
||||
> ReferendumInfo<TrackId, Origin, Moment, Hash, Balance, Tally, AccountId, ScheduleAddress>
|
||||
> ReferendumInfo<TrackId, RuntimeOrigin, Moment, Hash, Balance, Tally, AccountId, ScheduleAddress>
|
||||
{
|
||||
/// Take the Decision Deposit from `self`, if there is one. Returns an `Err` if `self` is not
|
||||
/// in a valid state for the Decision Deposit to be refunded.
|
||||
|
||||
Reference in New Issue
Block a user