Frame: Give Referendum SubmitOrigin argument (#14326)

* Referedum's SubmitOrigin should have an arg

* Fixes

* Nits and two extra utils

* Fixes

* Fixes
This commit is contained in:
Gavin Wood
2023-06-12 09:10:19 +01:00
committed by GitHub
parent 62f37e105c
commit 9716c8a1cb
14 changed files with 462 additions and 88 deletions
+27 -2
View File
@@ -53,9 +53,10 @@ use frame_support::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
Pays, PostDispatchInfo,
},
ensure,
ensure, impl_ensure_origin_with_arg_ignoring_arg,
traits::{
Backing, ChangeMembers, EnsureOrigin, Get, GetBacking, InitializeMembers, StorageVersion,
Backing, ChangeMembers, EnsureOrigin, EnsureOriginWithArg, Get, GetBacking,
InitializeMembers, StorageVersion,
},
weights::Weight,
};
@@ -1154,6 +1155,12 @@ impl<
}
}
impl_ensure_origin_with_arg_ignoring_arg! {
impl< { O: .., I: 'static, AccountId: Decode, T } >
EnsureOriginWithArg<O, T> for EnsureMember<AccountId, I>
{}
}
pub struct EnsureMembers<AccountId, I: 'static, const N: u32>(PhantomData<(AccountId, I)>);
impl<
O: Into<Result<RawOrigin<AccountId, I>, O>> + From<RawOrigin<AccountId, I>>,
@@ -1176,6 +1183,12 @@ impl<
}
}
impl_ensure_origin_with_arg_ignoring_arg! {
impl< { O: .., I: 'static, const N: u32, AccountId, T } >
EnsureOriginWithArg<O, T> for EnsureMembers<AccountId, I, N>
{}
}
pub struct EnsureProportionMoreThan<AccountId, I: 'static, const N: u32, const D: u32>(
PhantomData<(AccountId, I)>,
);
@@ -1201,6 +1214,12 @@ impl<
}
}
impl_ensure_origin_with_arg_ignoring_arg! {
impl< { O: .., I: 'static, const N: u32, const D: u32, AccountId, T } >
EnsureOriginWithArg<O, T> for EnsureProportionMoreThan<AccountId, I, N, D>
{}
}
pub struct EnsureProportionAtLeast<AccountId, I: 'static, const N: u32, const D: u32>(
PhantomData<(AccountId, I)>,
);
@@ -1225,3 +1244,9 @@ impl<
Ok(O::from(RawOrigin::Members(0u32, 0u32)))
}
}
impl_ensure_origin_with_arg_ignoring_arg! {
impl< { O: .., I: 'static, const N: u32, const D: u32, AccountId, T } >
EnsureOriginWithArg<O, T> for EnsureProportionAtLeast<AccountId, I, N, D>
{}
}