From e92ab62a888754b9ff4254ba6bdaab19f2224e53 Mon Sep 17 00:00:00 2001 From: muraca Date: Tue, 20 Jun 2023 09:55:01 +0200 Subject: [PATCH] update trait ProposalProvider to use Bounded instead of Hash Signed-off-by: muraca --- .../collectives-polkadot/src/impls.rs | 29 +++++++++++-------- .../collectives-polkadot/src/lib.rs | 1 + 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs index 784f6149b810..558b795b7ca2 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs @@ -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}; @@ -29,8 +31,6 @@ type AccountIdOf = ::AccountId; type ProposalOf = >::Proposal; -type HashOf = ::Hash; - /// Type alias to conveniently refer to the `Currency::Balance` associated type. pub type BalanceOf = as Currency<::AccountId>>::Balance; @@ -83,10 +83,9 @@ where /// Adapter from collective pallet to alliance proposal provider trait. pub struct AllianceProposalProvider(PhantomData<(T, I)>); -impl ProposalProvider, HashOf, ProposalOf> - for AllianceProposalProvider +impl ProposalProvider, ProposalOf> for AllianceProposalProvider where - T: pallet_collective::Config + frame_system::Config, + T: pallet_collective::Config + frame_system::Config + pallet_preimage::Config, I: 'static, { fn propose_proposal( @@ -105,29 +104,35 @@ where fn vote_proposal( who: AccountIdOf, - proposal: HashOf, + proposal_bounded: Bounded>, index: ProposalIndex, approve: bool, ) -> Result { - pallet_collective::Pallet::::do_vote(who, proposal, index, approve) + pallet_collective::Pallet::::do_vote(who, proposal_bounded, index, approve) } fn close_proposal( - proposal_hash: HashOf, + proposal_bounded: Bounded>, proposal_index: ProposalIndex, proposal_weight_bound: Weight, length_bound: u32, ) -> DispatchResultWithPostInfo { pallet_collective::Pallet::::do_close( - proposal_hash, + proposal_bounded, proposal_index, proposal_weight_bound, length_bound, ) } - fn proposal_of(proposal_hash: HashOf) -> Option> { - pallet_collective::Pallet::::proposal_of(proposal_hash) + fn proposal_of(proposal_bounded: Bounded>) -> Option> { + pallet_collective::Pallet::::proposal_of(proposal_bounded) + } + + fn bound_proposal( + proposal: ProposalOf, + ) -> Result>, DispatchError> { + pallet_preimage::Pallet::::bound(proposal) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index 5ca00d8c79d6..78ffe02fb442 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -468,6 +468,7 @@ impl pallet_collective::Config for Runtime { type SetMembersOrigin = EnsureRoot; type WeightInfo = weights::pallet_collective::WeightInfo; type MaxProposalWeight = MaxProposalWeight; + type Preimages = Preimage; } pub const MAX_FELLOWS: u32 = ALLIANCE_MAX_MEMBERS;