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

Commit

Permalink
update trait ProposalProvider to use Bounded<Call> instead of Hash
Browse files Browse the repository at this point in the history
Signed-off-by: muraca <[email protected]>
  • Loading branch information
muraca committed Jul 4, 2023
1 parent 21919c8 commit e92ab62
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
29 changes: 17 additions & 12 deletions parachains/runtimes/collectives/collectives-polkadot/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use crate::OriginCaller;
use frame_support::{
dispatch::{DispatchError, DispatchResultWithPostInfo},
log,
traits::{Currency, Get, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp},
traits::{
Bounded, Currency, Get, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp, StorePreimage,
},
weights::Weight,
};
use pallet_alliance::{ProposalIndex, ProposalProvider};
Expand All @@ -29,8 +31,6 @@ type AccountIdOf<T> = <T as frame_system::Config>::AccountId;

type ProposalOf<T, I> = <T as pallet_collective::Config<I>>::Proposal;

type HashOf<T> = <T as frame_system::Config>::Hash;

/// Type alias to conveniently refer to the `Currency::Balance` associated type.
pub type BalanceOf<T> =
<pallet_balances::Pallet<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
Expand Down Expand Up @@ -83,10 +83,9 @@ where
/// Adapter from collective pallet to alliance proposal provider trait.
pub struct AllianceProposalProvider<T, I = ()>(PhantomData<(T, I)>);

impl<T, I> ProposalProvider<AccountIdOf<T>, HashOf<T>, ProposalOf<T, I>>
for AllianceProposalProvider<T, I>
impl<T, I> ProposalProvider<AccountIdOf<T>, ProposalOf<T, I>> for AllianceProposalProvider<T, I>
where
T: pallet_collective::Config<I> + frame_system::Config,
T: pallet_collective::Config<I> + frame_system::Config + pallet_preimage::Config,
I: 'static,
{
fn propose_proposal(
Expand All @@ -105,29 +104,35 @@ where

fn vote_proposal(
who: AccountIdOf<T>,
proposal: HashOf<T>,
proposal_bounded: Bounded<ProposalOf<T, I>>,
index: ProposalIndex,
approve: bool,
) -> Result<bool, DispatchError> {
pallet_collective::Pallet::<T, I>::do_vote(who, proposal, index, approve)
pallet_collective::Pallet::<T, I>::do_vote(who, proposal_bounded, index, approve)
}

fn close_proposal(
proposal_hash: HashOf<T>,
proposal_bounded: Bounded<ProposalOf<T, I>>,
proposal_index: ProposalIndex,
proposal_weight_bound: Weight,
length_bound: u32,
) -> DispatchResultWithPostInfo {
pallet_collective::Pallet::<T, I>::do_close(
proposal_hash,
proposal_bounded,
proposal_index,
proposal_weight_bound,
length_bound,
)
}

fn proposal_of(proposal_hash: HashOf<T>) -> Option<ProposalOf<T, I>> {
pallet_collective::Pallet::<T, I>::proposal_of(proposal_hash)
fn proposal_of(proposal_bounded: Bounded<ProposalOf<T, I>>) -> Option<ProposalOf<T, I>> {
pallet_collective::Pallet::<T, I>::proposal_of(proposal_bounded)
}

fn bound_proposal(
proposal: ProposalOf<T, I>,
) -> Result<Bounded<ProposalOf<T, I>>, DispatchError> {
pallet_preimage::Pallet::<T>::bound(proposal)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
type Preimages = Preimage;
}

pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS;
Expand Down

0 comments on commit e92ab62

Please sign in to comment.