Skip to content

Commit

Permalink
runtimes, format and clippy issues
Browse files Browse the repository at this point in the history
Signed-off-by: muraca <mmuraca247@gmail.com>
  • Loading branch information
muraca committed Sep 9, 2023
1 parent e9f67a5 commit 6d401ff
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
use crate::OriginCaller;
use frame_support::{
dispatch::DispatchResultWithPostInfo,
traits::{Currency, Get, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp},
traits::{
Currency, Get, Hash as PreimageHash, Imbalance, OnUnbalanced, OriginTrait, PrivilegeCmp,
},
weights::Weight,
};

use log;
use pallet_alliance::{ProposalIndex, ProposalProvider};
use parachains_common::impls::NegativeImbalance;
Expand All @@ -30,8 +33,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 @@ -85,7 +86,7 @@ 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>>
impl<T, I> ProposalProvider<AccountIdOf<T>, PreimageHash, ProposalOf<T, I>>
for AllianceProposalProvider<T, I>
where
T: pallet_collective::Config<I> + frame_system::Config,
Expand All @@ -107,15 +108,15 @@ where

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

fn close_proposal(
proposal_hash: HashOf<T>,
proposal_hash: PreimageHash,
proposal_index: ProposalIndex,
proposal_weight_bound: Weight,
length_bound: u32,
Expand All @@ -128,8 +129,8 @@ where
)
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,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
2 changes: 2 additions & 0 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
type Preimages = Preimage;
}

parameter_types! {
Expand Down Expand Up @@ -514,6 +515,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type SetMembersOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
type Preimages = Preimage;
}

type MoreThanHalfCouncil = EitherOfDiverse<
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ProposalProvider<AccountId, Hash, RuntimeCall> for AllianceProposalProvider
}

fn proposal_of(proposal_hash: Hash) -> Option<RuntimeCall> {
AllianceMotion::proposal_of(proposal_hash)
AllianceMotion::proposal_of(&proposal_hash)
}
}

Expand Down
3 changes: 3 additions & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

parameter_types! {
Expand Down Expand Up @@ -1145,6 +1146,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

type EnsureRootOrHalfCouncil = EitherOfDiverse<
Expand Down Expand Up @@ -1869,6 +1871,7 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
type Preimages = Preimage;
}

parameter_types! {
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/collective/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ std = [
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-preimage/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"pallet-preimage/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"pallet-preimage/try-runtime",
"sp-runtime/try-runtime",
]
3 changes: 1 addition & 2 deletions substrate/frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
false => None,
true => T::Preimages::fetch(&proposal_hash, None)
.ok()
.map(|x| <T as Config<I>>::Proposal::decode(&mut &x[..]).ok())
.flatten(),
.and_then(|x| <T as Config<I>>::Proposal::decode(&mut &x[..]).ok()),
}
}

Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/utility/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ sp-std = { path = "../../primitives/std", default-features = false}

[dev-dependencies]
pallet-balances = { path = "../balances" }
pallet-root-testing = { path = "../root-testing" }
pallet-collective = { path = "../collective" }
pallet-preimage = { path = "../preimage" }
pallet-root-testing = { path = "../root-testing" }
pallet-timestamp = { path = "../timestamp" }
sp-core = { path = "../../primitives/core" }

Expand All @@ -40,8 +40,8 @@ std = [
"frame-system/std",
"pallet-balances/std",
"pallet-collective/std",
"pallet-root-testing/std",
"pallet-preimage/std",
"pallet-root-testing/std",
"pallet-timestamp/std",
"scale-info/std",
"sp-core/std",
Expand All @@ -64,8 +64,8 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-preimage/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-timestamp/try-runtime",
"sp-runtime/try-runtime",
]

0 comments on commit 6d401ff

Please sign in to comment.