pallet-referenda: make the pallet instanceable (#11089)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-03-25 00:36:58 +08:00
committed by GitHub
parent a4041add8a
commit 44e71d8d7e
3 changed files with 160 additions and 141 deletions
+8 -6
View File
@@ -59,7 +59,7 @@ impl From<BeginDecidingBranch> for ServiceBranch {
impl ServiceBranch {
/// Return the weight of the `nudge` function when it takes the branch denoted by `self`.
pub fn weight_of_nudge<T: Config>(self) -> frame_support::weights::Weight {
pub fn weight_of_nudge<T: Config<I>, I: 'static>(self) -> frame_support::weights::Weight {
use ServiceBranch::*;
match self {
NoDeposit => T::WeightInfo::nudge_referendum_no_deposit(),
@@ -81,7 +81,7 @@ impl ServiceBranch {
}
/// Return the maximum possible weight of the `nudge` function.
pub fn max_weight_of_nudge<T: Config>() -> frame_support::weights::Weight {
pub fn max_weight_of_nudge<T: Config<I>, I: 'static>() -> frame_support::weights::Weight {
0.max(T::WeightInfo::nudge_referendum_no_deposit())
.max(T::WeightInfo::nudge_referendum_preparing())
.max(T::WeightInfo::nudge_referendum_queued())
@@ -101,7 +101,9 @@ impl ServiceBranch {
/// Return the weight of the `place_decision_deposit` function when it takes the branch denoted
/// by `self`.
pub fn weight_of_deposit<T: Config>(self) -> Option<frame_support::weights::Weight> {
pub fn weight_of_deposit<T: Config<I>, I: 'static>(
self,
) -> Option<frame_support::weights::Weight> {
use ServiceBranch::*;
Some(match self {
Preparing => T::WeightInfo::place_decision_deposit_preparing(),
@@ -124,7 +126,7 @@ impl ServiceBranch {
}
/// Return the maximum possible weight of the `place_decision_deposit` function.
pub fn max_weight_of_deposit<T: Config>() -> frame_support::weights::Weight {
pub fn max_weight_of_deposit<T: Config<I>, I: 'static>() -> frame_support::weights::Weight {
0.max(T::WeightInfo::place_decision_deposit_preparing())
.max(T::WeightInfo::place_decision_deposit_queued())
.max(T::WeightInfo::place_decision_deposit_not_queued())
@@ -154,7 +156,7 @@ impl From<BeginDecidingBranch> for OneFewerDecidingBranch {
impl OneFewerDecidingBranch {
/// Return the weight of the `one_fewer_deciding` function when it takes the branch denoted
/// by `self`.
pub fn weight<T: Config>(self) -> frame_support::weights::Weight {
pub fn weight<T: Config<I>, I: 'static>(self) -> frame_support::weights::Weight {
use OneFewerDecidingBranch::*;
match self {
QueueEmpty => T::WeightInfo::one_fewer_deciding_queue_empty(),
@@ -164,7 +166,7 @@ impl OneFewerDecidingBranch {
}
/// Return the maximum possible weight of the `one_fewer_deciding` function.
pub fn max_weight<T: Config>() -> frame_support::weights::Weight {
pub fn max_weight<T: Config<I>, I: 'static>() -> frame_support::weights::Weight {
0.max(T::WeightInfo::one_fewer_deciding_queue_empty())
.max(T::WeightInfo::one_fewer_deciding_passing())
.max(T::WeightInfo::one_fewer_deciding_failing())