-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into p-1240-implement-access-control-for-accountst…
…ore-members-in-the
- Loading branch information
Showing
31 changed files
with
1,295 additions
and
44 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//! # Gov2 config | ||
//! Includes runtime configs for these substrate pallets: | ||
//! 1. pallet-conviction-voting | ||
//! 2. pallet-whitelist | ||
//! 3. pallet-referenda | ||
use super::*; | ||
use frame_support::traits::EitherOf; | ||
|
||
mod origins; | ||
pub use origins::{ | ||
pallet_custom_origins, ReferendumCanceller, ReferendumKiller, WhitelistedCaller, | ||
}; | ||
|
||
mod tracks; | ||
pub use tracks::TracksInfo; | ||
|
||
parameter_types! { | ||
pub const VoteLockingPeriod: BlockNumber = 1 * DAYS; | ||
} | ||
|
||
impl pallet_conviction_voting::Config for Runtime { | ||
type WeightInfo = weights::pallet_conviction_voting::WeightInfo<Runtime>; | ||
type RuntimeEvent = RuntimeEvent; | ||
type Currency = Balances; | ||
type Polls = Referenda; | ||
type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>; | ||
// Maximum number of concurrent votes an account may have | ||
type MaxVotes = ConstU32<20>; | ||
// Minimum period of vote locking | ||
type VoteLockingPeriod = VoteLockingPeriod; | ||
} | ||
|
||
parameter_types! { | ||
pub const AlarmInterval: BlockNumber = 1; | ||
pub const SubmissionDeposit: Balance = 100 * DOLLARS; | ||
pub const UndecidingTimeout: BlockNumber = 21 * DAYS; | ||
} | ||
|
||
impl pallet_custom_origins::Config for Runtime {} | ||
|
||
// The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch | ||
// origin corresponds to the Gov2 Whitelist track. | ||
impl pallet_whitelist::Config for Runtime { | ||
type WeightInfo = weights::pallet_whitelist::WeightInfo<Runtime>; | ||
type RuntimeEvent = RuntimeEvent; | ||
type RuntimeCall = RuntimeCall; | ||
type WhitelistOrigin = EnsureRootOrTwoThirdsCouncil; | ||
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>; | ||
type Preimages = Preimage; | ||
} | ||
|
||
pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); | ||
|
||
impl pallet_referenda::Config for Runtime { | ||
type WeightInfo = weights::pallet_referenda::WeightInfo<Runtime>; | ||
type RuntimeCall = RuntimeCall; | ||
type RuntimeEvent = RuntimeEvent; | ||
type Scheduler = Scheduler; | ||
type Currency = Balances; | ||
type SubmitOrigin = frame_system::EnsureSigned<AccountId>; | ||
type CancelOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumCanceller>; | ||
type KillOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumKiller>; | ||
type Slash = Treasury; | ||
type Votes = pallet_conviction_voting::VotesOf<Runtime>; | ||
type Tally = pallet_conviction_voting::TallyOf<Runtime>; | ||
type SubmissionDeposit = SubmissionDeposit; | ||
type MaxQueued = ConstU32<100>; | ||
type UndecidingTimeout = UndecidingTimeout; | ||
type AlarmInterval = AlarmInterval; | ||
type Tracks = TracksInfo; | ||
type Preimages = Preimage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
//! Custom origins for governance interventions. | ||
pub use pallet_custom_origins::*; | ||
|
||
#[frame_support::pallet] | ||
pub mod pallet_custom_origins { | ||
use frame_support::pallet_prelude::*; | ||
|
||
#[pallet::config] | ||
pub trait Config: frame_system::Config {} | ||
|
||
#[pallet::pallet] | ||
pub struct Pallet<T>(_); | ||
|
||
#[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)] | ||
#[pallet::origin] | ||
pub enum Origin { | ||
/// Origin able to cancel referenda. | ||
ReferendumCanceller, | ||
/// Origin able to kill referenda. | ||
ReferendumKiller, | ||
/// Origin able to dispatch a whitelisted call. | ||
WhitelistedCaller, | ||
} | ||
|
||
macro_rules! decl_unit_ensures { | ||
( $name:ident: $success_type:ty = $success:expr ) => { | ||
pub struct $name; | ||
impl<O: Into<Result<Origin, O>> + From<Origin>> | ||
EnsureOrigin<O> for $name | ||
{ | ||
type Success = $success_type; | ||
fn try_origin(o: O) -> Result<Self::Success, O> { | ||
o.into().and_then(|o| match o { | ||
Origin::$name => Ok($success), | ||
r => Err(O::from(r)), | ||
}) | ||
} | ||
#[cfg(feature = "runtime-benchmarks")] | ||
fn try_successful_origin() -> Result<O, ()> { | ||
Ok(O::from(Origin::$name)) | ||
} | ||
} | ||
}; | ||
( $name:ident ) => { decl_unit_ensures! { $name : () = () } }; | ||
( $name:ident: $success_type:ty = $success:expr, $( $rest:tt )* ) => { | ||
decl_unit_ensures! { $name: $success_type = $success } | ||
decl_unit_ensures! { $( $rest )* } | ||
}; | ||
( $name:ident, $( $rest:tt )* ) => { | ||
decl_unit_ensures! { $name } | ||
decl_unit_ensures! { $( $rest )* } | ||
}; | ||
() => {} | ||
} | ||
decl_unit_ensures!(ReferendumCanceller, ReferendumKiller, WhitelistedCaller,); | ||
} |
Oops, something went wrong.