Bladeren bron

Add proposals modules to the runtime

Shamil Gadelshin 5 jaren geleden
bovenliggende
commit
9b980fb793
2 gewijzigde bestanden met toevoegingen van 78 en 0 verwijderingen
  1. 18 0
      runtime/Cargo.toml
  2. 60 0
      runtime/src/lib.rs

+ 18 - 0
runtime/Cargo.toml

@@ -353,3 +353,21 @@ default_features = false
 package = 'substrate-storage-module'
 path = '../runtime-modules/storage'
 version = '1.0.0'
+
+[dependencies.proposals_engine]
+default_features = false
+package = 'substrate-proposals-engine-module'
+path = '../runtime-modules/proposals/engine'
+version = '2.0.0'
+
+[dependencies.proposals_discussion]
+default_features = false
+package = 'substrate-proposals-discussion-module'
+path = '../runtime-modules/proposals/discussion'
+version = '2.0.0'
+
+[dependencies.proposals_codex]
+default_features = false
+package = 'substrate-proposals-codex-module'
+path = '../runtime-modules/proposals/codex'
+version = '2.0.0'

+ 60 - 0
runtime/src/lib.rs

@@ -54,6 +54,8 @@ pub use srml_support::{
 pub use staking::StakerStatus;
 pub use timestamp::Call as TimestampCall;
 
+use membership::origin_validator::MembershipOriginValidator;
+
 /// An index to a block.
 pub type BlockNumber = u32;
 
@@ -800,6 +802,59 @@ impl discovery::Trait for Runtime {
     type Roles = LookupRoles;
 }
 
+parameter_types! {
+    pub const ProposalCancellationFee: u64 = 5;
+    pub const ProposalRejectionFee: u64 = 3;
+    pub const ProposalTitleMaxLength: u32 = 100;
+    pub const ProposalDescriptionMaxLength: u32 = 10000;
+    pub const ProposalMaxActiveProposalLimit: u32 = 100;
+}
+
+impl proposals_engine::Trait for Runtime {
+    type Event = Event;
+    type ProposerOriginValidator = MembershipOriginValidator<Self>;
+    type VoterOriginValidator = proposals_engine::CouncilManager<Self>;
+    type TotalVotersCounter = proposals_engine::CouncilManager<Self>;
+    type ProposalCodeDecoder = proposals_codex::ProposalType;
+    type ProposalId = u32;
+    type StakeHandlerProvider = proposals_engine::DefaultStakeHandlerProvider;
+    type CancellationFee = ProposalCancellationFee;
+    type RejectionFee = ProposalRejectionFee;
+    type TitleMaxLength = ProposalTitleMaxLength;
+    type DescriptionMaxLength = ProposalDescriptionMaxLength;
+    type MaxActiveProposalLimit = ProposalMaxActiveProposalLimit;
+}
+
+parameter_types! {
+    pub const ProposalMaxPostEditionNumber: u32 = 5;
+    pub const ProposalMaxThreadInARowNumber: u32 = 3;
+    pub const ProposalThreadTitleLengthLimit: u32 = 200;
+    pub const ProposalPostLengthLimit: u32 = 2000;
+}
+
+impl proposals_discussion::Trait for Runtime {
+    type Event = Event;
+    type ThreadAuthorOriginValidator = MembershipOriginValidator<Self>;
+    type PostAuthorOriginValidator = MembershipOriginValidator<Self>;
+    type ThreadId = u32;
+    type PostId = u32;
+    type MaxPostEditionNumber = ProposalMaxPostEditionNumber;
+    type ThreadTitleLengthLimit = ProposalThreadTitleLengthLimit;
+    type PostLengthLimit = ProposalPostLengthLimit;
+    type MaxThreadInARowNumber = ProposalMaxThreadInARowNumber;
+}
+
+parameter_types! {
+    pub const TextProposalMaxLength: u32 = 60_000;
+    pub const RuntimeUpgradeWasmProposalMaxLength: u32 = 2_000_000;
+}
+
+
+impl proposals_codex::Trait for Runtime {
+    type TextProposalMaxLength = TextProposalMaxLength;
+    type RuntimeUpgradeWasmProposalMaxLength = RuntimeUpgradeWasmProposalMaxLength;
+}
+
 construct_runtime!(
 	pub enum Runtime where
 		Block = Block,
@@ -842,6 +897,11 @@ construct_runtime!(
         RecurringRewards: recurringrewards::{Module, Call, Storage},
         Hiring: hiring::{Module, Call, Storage},
         ContentWorkingGroup: content_wg::{Module, Call, Storage, Event<T>, Config<T>},
+        // --- Proposals
+        ProposalsEngine: proposals_engine::{Module, Call, Storage, Event<T>},
+        ProposalsDiscussion: proposals_discussion::{Module, Call, Storage, Event<T>},
+        ProposalsCodex: proposals_codex::{Module, Call, Storage, Error},
+        // ---
 	}
 );