Skip to content

Commit

Permalink
pallet-referenda: make the pallet instanceable (#11089)
Browse files Browse the repository at this point in the history
Signed-off-by: koushiro <[email protected]>
  • Loading branch information
koushiro authored Mar 24, 2022
1 parent dfb2a8c commit 666f39b
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 141 deletions.
14 changes: 8 additions & 6 deletions frame/referenda/src/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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())
Expand All @@ -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(),
Expand All @@ -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())
Expand Down Expand Up @@ -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(),
Expand All @@ -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())
Expand Down
Loading

0 comments on commit 666f39b

Please sign in to comment.