Browse Source

move custom proposal config parameters out of runtime and into node pacakge

Mokhtar Naamani 4 years ago
parent
commit
2f8e54bdfb

+ 0 - 1
Cargo.lock

@@ -394,7 +394,6 @@ version = "2.1.0"
 dependencies = [
  "ansi_term 0.12.1",
  "joystream-node",
- "joystream-node-runtime",
  "rand 0.7.3",
  "structopt",
  "substrate-keystore",

+ 2 - 2
node/src/chain_spec.rs

@@ -108,7 +108,7 @@ impl Alternative {
                             get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
                             get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
                         ],
-                        node_runtime::ProposalsConfigParameters::development(),
+                        crate::proposals_config::development(),
                     )
                 },
                 vec![],
@@ -141,7 +141,7 @@ impl Alternative {
                             get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
                             get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
                         ],
-                        node_runtime::ProposalsConfigParameters::development(),
+                        crate::proposals_config::development(),
                     )
                 },
                 vec![],

+ 1 - 0
node/src/lib.rs

@@ -2,4 +2,5 @@ pub mod chain_spec;
 pub mod cli;
 pub mod forum_config;
 pub mod members_config;
+pub mod proposals_config;
 pub mod service;

+ 17 - 0
node/src/proposals_config.rs

@@ -0,0 +1,17 @@
+use node_runtime::ProposalsConfigParameters;
+
+/// Development chain config. 0 grace period for all proposals, ie.
+/// proposals executed immediatly. Short voting period.
+pub fn development() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::with_grace_and_voting_periods(0, 200)
+}
+
+/// Staging chain config. Shorter grace periods and voting periods than default.
+pub fn staging() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::with_grace_and_voting_periods(200, 600)
+}
+
+/// The default configuration as defined in the runtime module
+pub fn default() -> ProposalsConfigParameters {
+    ProposalsConfigParameters::default()
+}

+ 1 - 12
runtime-modules/proposals/codex/src/proposal_types/mod.rs

@@ -351,21 +351,10 @@ impl Default for ProposalsConfigParameters {
 }
 
 impl ProposalsConfigParameters {
-    /// Development chain config. 0 grace period for all proposals, ie.
-    /// proposals executed immediatly. Short voting period.
-    pub fn development() -> Self {
-        Self::with_grace_and_voting_periods(0, 200)
-    }
-
-    /// Staging chain config. Shorter grace periods and voting periods than default.
-    pub fn testing() -> Self {
-        Self::with_grace_and_voting_periods(200, 600)
-    }
-
     /// Set same voting_period for all proposals. For proposals
     /// that by default have 0 grace period remain with 0 grace period.
     /// All remaining proposals get assigned grace_period.
-    fn with_grace_and_voting_periods(grace_period: u32, voting_period: u32) -> Self {
+    pub fn with_grace_and_voting_periods(grace_period: u32, voting_period: u32) -> Self {
         ProposalsConfigParameters {
             set_validator_count_proposal_voting_period: voting_period,
             set_validator_count_proposal_grace_period: 0,

+ 0 - 1
utils/chain-spec-builder/Cargo.toml

@@ -13,7 +13,6 @@ ansi_term = "0.12.1"
 rand = "0.7.2"
 structopt = "0.3.5"
 joystream-node = { path = "../../node" }
-joystream-runtime = { path = "../../runtime", package = "joystream-node-runtime" }
 
 [dependencies.sr-keystore]
 git = 'https://github.com/paritytech/substrate.git'

+ 5 - 2
utils/chain-spec-builder/src/main.rs

@@ -23,7 +23,10 @@ use ansi_term::Style;
 use rand::{distributions::Alphanumeric, rngs::OsRng, Rng};
 use structopt::StructOpt;
 
-use joystream_node::chain_spec::{self, chain_spec_properties, AccountId};
+use joystream_node::{
+    chain_spec::{self, chain_spec_properties, AccountId},
+    proposals_config,
+};
 use sr_keystore::Store as Keystore;
 use sr_primitives::{
     crypto::{Public, Ss58Codec},
@@ -106,7 +109,7 @@ fn genesis_constructor(
         authorities,
         sudo_account.clone(),
         endowed_accounts.to_vec(),
-        joystream_runtime::ProposalsConfigParameters::default(),
+        proposals_config::default(),
     )
 }