Преглед изворни кода

Main lib builds, only tests missing some trait impls

Bedeho Mender пре 5 година
родитељ
комит
f638ed3af5

+ 1 - 1
Cargo.toml

@@ -289,4 +289,4 @@ rev = '21efbf1b9535c5c18dc36e9e42e192f3c9c7515b'
 default_features = false
 git = 'https://github.com/mnaamani/substrate-versioned-store-permissions-module'
 package = 'substrate-versioned-store-permissions-module'
-rev = '694a50420b9ffd37a396489ca82f700b54009363'
+rev = 'a6f60058ce8cc1123e90172807abb22459916727'

+ 436 - 30
src/content_working_group/lib.rs

@@ -1,24 +1,424 @@
 // Ensure we're `no_std` when compiling for Wasm.
 #![cfg_attr(not(feature = "std"), no_std)]
 
+#[cfg(feature = "std")]
+use serde::{Deserialize, Serialize};
+
+use codec::{Codec, Decode, Encode};
+//use rstd::collections::btree_map::BTreeMap;
+use rstd::collections::btree_set::BTreeSet;
 use rstd::prelude::*;
+use srml_support::traits::Currency;
 use srml_support::{
-    decl_module, decl_storage, ensure, StorageMap, StorageValue,
+    decl_module, decl_storage, decl_event, ensure, StorageMap, StorageValue, Parameter
 };
-//use rstd::collections::btree_map::BTreeMap;
-use rstd::collections::btree_set::BTreeSet;
-
+use runtime_primitives::traits::{Member, One, SimpleArithmetic, MaybeSerialize};
+use minting;
+use recurringrewards;
+use stake;
+use hiring;
 use versioned_store_permissions;
+use super::super::membership::members as membership;
+
+/// Module configuration trait for this Substrate module.
+pub trait Trait: system::Trait + minting::Trait + recurringrewards::Trait + stake::Trait + hiring::Trait + versioned_store_permissions::Trait + membership::Trait + Sized {
+
+    /// The event type.
+    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+
+    /// Type for identifier for lead.
+    type LeadId: Parameter
+        + Member
+        + SimpleArithmetic
+        + Codec
+        + Default
+        + Copy
+        + MaybeSerialize
+        + PartialEq;
+
+    /// Type for identifier for curators.
+    type CuratorId: Parameter
+        + Member
+        + SimpleArithmetic
+        + Codec
+        + Default
+        + Copy
+        + MaybeSerialize
+        + PartialEq
+        + Ord;
+
+    /// Type for identifier for channels.
+    type ChannelId: Parameter
+        + Member
+        + SimpleArithmetic
+        + Codec
+        + Default
+        + Copy
+        + MaybeSerialize
+        + PartialEq;
+}
+
+/// Type for identifier for dynamic version store credential.
+pub type DynamicCredentialId<T: Trait> = T::PrincipalId;
+
+/// Balance type of runtime
+pub type BalanceOf<T> =
+    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
+
+/// Negative imbalance of runtime.
+pub type NegativeImbalance<T> =
+    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
+
+/// The exit stage of a lead involvement in the working group.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct ExitedLeadRole<BlockNumber> {
+
+    /// When exit was initiated.
+    pub initiated_at_block_number: BlockNumber
+}
+
+/// The stage of the involvement of a lead in the working group.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum LeadRoleState<BlockNumber> {
+
+    /// Currently active.
+    Active,
+
+    /// No longer active, for some reason
+    Exited(ExitedLeadRole<BlockNumber>)
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl<BlockNumber> Default for LeadRoleState<BlockNumber> {
+
+    fn default() -> Self {
+        LeadRoleState::Active
+    }
+}
+
+/// Working group lead: curator lead
+/// For now this role is not staked or inducted through an structured process, like the hiring module,
+/// hence information about this is missing. Recurring rewards is included, somewhat arbitrarily!
+#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct Lead<AccountId, RewardRelationshipId, BlockNumber> {
+
+    /// Account used to authenticate in this role,
+    pub role_account: AccountId,
+
+    /// Whether the role has recurring reward, and if so an identifier for this.
+    pub reward_relationship: Option<RewardRelationshipId>,
+
+    /// When was inducted
+    /// TODO: Add richer information about circumstances of induction, like referencing a council proposal?
+    pub inducted: BlockNumber,
+
+    /// The stage of the involvement of this lead in the working group.
+    pub stage: LeadRoleState<BlockNumber>
+}
+
+/// Origin of exit initiation on behalf of a curator.'
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum CuratorExitInitiationOrigin {
+
+    /// Lead is origin.
+    Lead,
+
+    /// The curator exiting is the origin.
+    Curator
+}
+
+/// The exit stage of a curators involvement in the working group.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct ExitedCuratorRoleStage<BlockNumber> {
+
+    /// Origin for exit.
+    pub origin: CuratorExitInitiationOrigin,
+
+    /// When exit was initiated.
+    pub initiated_at_block_number: BlockNumber,
+
+    /// Explainer for why exit was initited.
+    pub rationale_text: Vec<u8>
+}
 
-pub use super::types::{*};
+/// The stage of the involvement of a curator in the working group.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum CuratorRoleStage<BlockNumber> {
 
-use system;
+    /// Currently active.
+    Active,
+
+    /// No longer active, for some reason
+    Exited(ExitedCuratorRoleStage<BlockNumber>)
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl<BlockNumber> Default for CuratorRoleStage<BlockNumber> {
+
+    fn default() -> Self {
+        CuratorRoleStage::Active
+    }
+}
+
+/// The induction of a curator in the working group.
+#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct CuratorInduction<LeadId, ApplicationId, BlockNumber> {
+
+    /// Lead responsible
+    pub lead: LeadId,
+
+    /// Application through which curator was inducted
+    pub application: ApplicationId,
+
+    /// When induction occurred
+    pub at_block: BlockNumber
+}
+
+/// Working group participant: curator
+/// This role can be staked, have reward and be inducted through the hiring module.
+#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct Curator<AccountId, RewardRelationshipId, StakeId, BlockNumber, LeadId, ApplicationId> {
+
+    /// Account used to authenticate in this role,
+    pub role_account: AccountId,
+
+    /// Whether the role has recurring reward, and if so an identifier for this.
+    pub reward_relationship: Option<RewardRelationshipId>,
+
+    /// Whether participant is staked, and if so, the identifier for this staking in the staking module.
+    pub stake: Option<StakeId>,
+
+    /// The stage of this curator in the working group.
+    pub stage: CuratorRoleStage<BlockNumber>,
+
+    /// How the curator was inducted into the working group.
+    pub induction: CuratorInduction<LeadId, ApplicationId, BlockNumber>,
+
+    /// Whether this curator can unilaterally alter the curation status of a channel.
+    pub can_update_channel_curation_status: bool
+}
+
+/// Type of channel content.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum ChannelContentType {
+    Video,
+    Music,
+    Ebook
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl Default for ChannelContentType {
+
+    fn default() -> Self {
+        ChannelContentType::Video
+    }
+}
+
+/// Status of channel, as set by the owner.
+/// Is only meant to affect visibility, mutation of channel and child content
+/// is unaffected on runtime.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum ChannelPublishingStatus {
+
+    /// Compliant UIs should render.
+    Published,
+    
+    /// Compliant UIs should not render it or any child content.
+    NotPublished
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl Default for ChannelPublishingStatus {
+
+    fn default() -> Self {
+        ChannelPublishingStatus::Published
+    }
+}
+
+/// Status of channel, as set by curators.
+/// Is only meant to affect visibility currently, but in the future
+/// it will also gate publication of new child content,
+/// editing properties, revenue flows, etc. 
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum ChannelCurationStatus {
+    Normal,
+    Censored
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl Default for ChannelCurationStatus {
+
+    fn default() -> Self {
+        ChannelCurationStatus::Normal
+    }
+}
+
+/// A channel for publishing content.
+#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct Channel<MemberId, AccountId, BlockNumber> {
+
+    /// Unique human readble channel handle.
+    pub handle: Vec<u8>, 
+
+    /// Whether channel has been verified, in the normal Web2.0 platform sense of being authenticated.
+    pub verified: bool,
+
+    /// Human readable description of channel purpose and scope.
+    pub description: Vec<u8>,
+
+    /// The type of channel.
+    pub content: ChannelContentType,
+
+    /// Member who owns channel.
+    pub owner: MemberId,
+
+    /// Account used to authenticate as owner.
+    /// Can be updated through membership role key.
+    pub role_account: AccountId,
+
+    /// Publication status of channel.
+    pub publishing_status: ChannelPublishingStatus,
+
+    /// Curation status of channel.
+    pub curation_status: ChannelCurationStatus,
+
+    /// When channel was established.
+    pub created: BlockNumber
+
+}
+
+/// The types of built in credential holders.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum BuiltInCredentialHolder {
+
+    /// Cyrrent working group lead.
+    Lead,
+    
+    /// Any active urator in the working group.
+    AnyCurator,
+
+    /// Any active member in the membership registry.
+    AnyMember
+}
+
+/// Holder of dynamic credential.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum DynamicCredentialHolder<CuratorId: Ord, ChannelId> {
+
+    /// Sets of curators.
+    Curators(BTreeSet<CuratorId>),
+
+    /// Owner of a channel.
+    ChannelOwner(ChannelId),
+}
+
+/// Must be default constructible because it indirectly is a value in a storage map.
+/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
+impl<CuratorId: Ord, ChannelId> Default for DynamicCredentialHolder<CuratorId, ChannelId> {
+
+    fn default() -> Self {
+        DynamicCredentialHolder::Curators(BTreeSet::new())
+    }
+}
+
+/// Represents credential for authenticating as "the current lead".
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd, Default)]
+pub struct LeadCredential {
+
+    /// Whether it is currently possible to authenticate with this credential.
+    pub is_active: bool
+}
+
+/// Represents credential for authenticating as "any curator".
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd, Default)]
+pub struct AnyCuratorCredential {
+
+    /// Whether it is currently possible to authenticate with this credential.
+    pub is_active: bool
+}
+
+/// Represents credential for authenticating as "any member".
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd, Default)]
+pub struct AnyMemberCredential {
+
+    /// Whether it is currently possible to authenticate with this credential.
+    pub is_active: bool
+}
+
+/// Represents credential to be referenced from the version store.
+/// It is dynamic in the sense that these can be created on the fly.
+#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct DynamicCredential<CuratorId: Ord, ChannelId, BlockNumber> {
+
+    /// Who holds this credential, meaning they can successfully authenticate with this credential.
+    pub holder: DynamicCredentialHolder<CuratorId, ChannelId>,
+
+    /// Whether it is currently possible to authenticate with this credential.
+    pub is_active: bool,
+
+    /// When it was created.
+    pub created: BlockNumber,
+
+    /// Human readable description of credential.
+    pub description: Vec<u8>
+}
+
+/// Policy governing any curator opening which can be made by lead.
+/// Be aware that all limits are forward looking in constrainign future extrinsics or method calls.
+/// Updating them has no side-effects beyond changing the limit.
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub struct OpeningPolicy<BlockNumber, StakingPolicy> {
+
+    /// Limits the total number of curators which can be active, or possibly active through an active opening. 
+    /// The contribution of an active opening is counted by looking at the rationing policy of the opening.
+    /// A limit of N is counted as there being N actual active curators, as a worst case bound.
+    /// The absence of a limit is counted as "infinity", thus blocking any further openings from being created,
+    /// and is is not possible to actually hire a number of curators that would bring the number above this parameter `curator_limit`.
+    pub curator_limit: Option<u16>,
+
+    /// Maximum length of review period of applications
+    pub max_review_period_length: BlockNumber,
+
+    /// Staking policy for application
+    pub application_staking_policy: Option<StakingPolicy>,
+
+    /// Staking policy for role itself
+    pub role_staking_policy: Option<StakingPolicy>
+}
+
+/// Represents 
+#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
+pub enum WorkingGroupActor<T: Trait> {
+
+    ///
+    Lead(T::LeadId),
+
+    ///
+    Curator(T::CuratorId),
+}
+
+pub enum ChannelActor<T: Trait> {
+
+    ///
+    WorkingGroupActor(WorkingGroupActor<T>),
+
+    ///
+    Owner
+}
 
 decl_storage! {
     trait Store for Module<T: Trait> as ContentWorkingGroup {
 
         /// The mint currently funding the rewards for this module.
-        pub Mint get(mint) config(): T::TokenMintId; 
+        pub Mint get(mint) config(): <T as minting::Trait>::MintId; 
 
         /// The current lead.
         pub CurrentLeadId get(current_lead_id) config(): Option<T::LeadId>;
@@ -52,22 +452,22 @@ decl_storage! {
 
         /// The constraints lead must respect when creating a new curator opening.
         /// Lack of policy is interpreted as blocking any new openings at all.
-        pub OpeningPolicy get(opening_policy) config(): Option<OpeningPolicy<T::BlockNumber, hiring::StakingPolicy<BalanceOf<T>, T::BlockNumber>>>;
+        pub OptOpeningPolicy get(opening_policy) config(): Option<OpeningPolicy<T::BlockNumber, hiring::StakingPolicy<BalanceOf<T>, T::BlockNumber>>>;
 
         /// Credentials for built in roles.
-        pub LeadCredential get(lead_credential) config(): LeadCredential;
+        pub CredentialOfLead get(credential_of_lead) config(): LeadCredential;
 
         /// The "any curator" credential.
-        pub AnyCuratorCredential get(any_curator_credential) config(): AnyCuratorCredential;
+        pub CredentialOfAnyCurator get(credential_of_anycurator) config(): AnyCuratorCredential;
 
         /// The "any member" credential.
-        pub AnyMemberCredential get(any_member_credential) config(): AnyMemberCredential;
+        pub CredentialOfAnyMember get(credential_of_anymember) config(): AnyMemberCredential;
 
         /// Maps dynamic credential by
-        pub DynamicCredentialById get(dynamic_credential_by_id) config(): linked_map DynamicCredentialId => DynamicCredential<T::CuratorId, T::ChannelId, T::BlockNumber>;
+        pub DynamicCredentialById get(dynamic_credential_by_id) config(): linked_map DynamicCredentialId<T> => DynamicCredential<T::CuratorId, T::ChannelId, T::BlockNumber>;
 
         /// ...
-        pub NextDynamicCredentialId get(next_dynamic_credential_id) config(): T::DynamicCredentialId;
+        pub NextDynamicCredentialId get(next_dynamic_credential_id) config(): DynamicCredentialId<T>;
 
         /// Whether it is currently possible to create a channel via `create_channel` extrinsic.
         pub ChannelCreationEnabled get(channel_creation_enabled) config(): bool;
@@ -85,7 +485,8 @@ decl_storage! {
 
     }
 }
-        /*
+
+/*
 /// Substrate module events.
 decl_event! {
     pub enum Event<T> where
@@ -118,6 +519,15 @@ decl_event! {
 }
 */
 
+decl_event!(
+    pub enum Event<T>
+    where
+        <T as system::Trait>::AccountId,
+    {
+        MyOtherEvent(AccountId),
+    }
+);
+
 decl_module! {
     pub struct Module<T: Trait> for enum Call where origin: T::Origin {
 
@@ -197,9 +607,9 @@ decl_module! {
         /// Update channel curation status of a channel.
         /// 
         /// Can 
-        pub fn update_channel_curation_status(origin, WorkingGroupActor) {
-
+        pub fn update_channel_curation_status(origin) {
 
+            // WorkingGroupActor
 
         }
 
@@ -209,25 +619,21 @@ decl_module! {
          * Lead credential is managed as non-dispatchable.
          */
 
-        pub fn update_any_member_credential() {
+        pub fn update_any_member_credential(origin) {
             
         }
 
-        pub fn update_any_curator_credential() {
+        pub fn update_any_curator_credential(origin) {
             
         }
 
-        pub fn create_dynamic_credential() {
-
-        }
+        pub fn create_dynamic_credential(origin) {
 
-        pub fn update_dynamic_credential() {
-            
         }
 
+        pub fn update_dynamic_credential(origin) {
 
-
-
+        }
 
         /// ...
         pub fn update_channel_as_owner(origin) {
@@ -347,7 +753,7 @@ impl<T: Trait> Module<T> {
  */
 
 /// ...
-enum Credential<CuratorId, ChannelId, BlockNumber> {
+enum Credential<CuratorId: Ord, ChannelId, BlockNumber> {
     Lead(LeadCredential),
     AnyCurator(AnyCuratorCredential),
     AnyMember(AnyMemberCredential),
@@ -388,10 +794,10 @@ impl<T: Trait> Module<T> {
 
         match credential_id {
 
-            LEAD_CREDENTIAL_ID => CredentialHolder(BuiltInCredentialHolder(BuiltInCredentialHolder::Lead)),
-            ANY_CURATOR_CREDENTIAL_ID => CredentialHolder(BuiltInCredentialHolder(BuiltInCredentialHolder::AnyCurator)),
-            ANY_MEMBER_CREDENTIAL_ID => CredentialHolder(BuiltInCredentialHolder(BuiltInCredentialHolder::AnyMember)),
-            _ => CredentialHolder(CandidateDynamicCredentialId(credential_id - 3)) // will map first dynamic id to 0
+            LEAD_CREDENTIAL_ID => CredentialHolder::BuiltInCredentialHolder(BuiltInCredentialHolder::Lead),
+            ANY_CURATOR_CREDENTIAL_ID => CredentialHolder::BuiltInCredentialHolder(BuiltInCredentialHolder::AnyCurator),
+            ANY_MEMBER_CREDENTIAL_ID => CredentialHolder::BuiltInCredentialHolder(BuiltInCredentialHolder::AnyMember),
+            _ => CredentialHolder::CandidateDynamicCredentialId(credential_id - T::PrincipalId::from(3)) // will map first dynamic id to 0
 
             /*
             Add new built in credentials here below

+ 26 - 24
src/content_working_group/mock.rs

@@ -1,16 +1,17 @@
 #![cfg(test)]
 
-use crate::*;
-
-use primitives::{Blake2Hasher, H256};
-
-use crate::{Module, Trait};
-use balances;
-use runtime_primitives::{
-    testing::Header,
-    traits::{BlakeTwo256, IdentityLookup},
-    Perbill,
+pub use super::lib::{self, Module, Trait};
+pub use srml_support::traits::Currency;
+pub use system;
+
+pub use primitives::{Blake2Hasher, H256};
+pub use runtime_primitives::{
+    testing::{Digest, DigestItem, Header, UintAuthorityId},
+    traits::{BlakeTwo256, Convert, IdentityLookup, OnFinalize},
+    weights::Weight,
+    BuildStorage, Perbill,
 };
+
 use srml_support::{impl_outer_origin, parameter_types};
 
 use stake;
@@ -40,7 +41,6 @@ impl system::Trait for Test {
     type AccountId = u64;
     type Lookup = IdentityLookup<Self::AccountId>;
     type Header = Header;
-    type WeightMultiplierUpdate = ();
     type Event = ();
     type BlockHashCount = BlockHashCount;
     type MaximumBlockWeight = MaximumBlockWeight;
@@ -59,6 +59,15 @@ parameter_types! {
     pub const StakePoolId: [u8; 8] = *b"joystake";
 }
 
+// system::Trait + 
+// minting::Trait +
+// recurringrewards::Trait +
+// stake::Trait +
+// hiring::Trait +
+// versioned_store_permissions::Trait +
+// membership::Trait +
+// Sized
+
 impl balances::Trait for Test {
     /// The type for recording an account's balance.
     type Balance = u64;
@@ -69,25 +78,18 @@ impl balances::Trait for Test {
     /// The ubiquitous event type.
     type Event = ();
 
-    type TransactionPayment = ();
     type DustRemoval = ();
     type TransferPayment = ();
     type ExistentialDeposit = ExistentialDeposit;
     type TransferFee = TransferFee;
     type CreationFee = CreationFee;
-    type TransactionBaseFee = TransactionBaseFee;
-    type TransactionByteFee = TransactionByteFee;
-    type WeightToFee = ();
 }
 
 impl Trait for Test {
-    //type Event = ();
-
-    type OpeningId = u64;
-
-    type ApplicationId = u64;
-
-    
+    type Event = ();
+    type LeadId = u64;
+    type CuratorId = u64;
+    type ChannelId = u64;   
 }
 
 impl stake::Trait for Test {
@@ -98,7 +100,7 @@ impl stake::Trait for Test {
     type SlashId = u64;
 }
 
-pub fn build_test_externalities() -> runtime_io::TestExternalities<Blake2Hasher> {
+pub fn build_test_externalities() -> runtime_io::TestExternalities {
     let t = system::GenesisConfig::default()
         .build_storage::<Test>()
         .unwrap();
@@ -108,4 +110,4 @@ pub fn build_test_externalities() -> runtime_io::TestExternalities<Blake2Hasher>
 
 //pub type System = system::Module<Test>;
 pub type Balances = balances::Module<Test>;
-pub type Hiring = Module<Test>;
+pub type ContentWorkingGroup = Module<Test>;

+ 1 - 1
src/content_working_group/mod.rs

@@ -1,5 +1,5 @@
 pub mod lib;
-pub mod types;
+//pub mod types;
 
 mod mock;
 mod tests;

+ 0 - 407
src/content_working_group/types.rs

@@ -1,407 +0,0 @@
-use codec::{Codec, Decode, Encode};
-//use rstd::collections::btree_map::BTreeMap;
-use rstd::collections::btree_set::BTreeSet;
-use rstd::prelude::*;
-use srml_support::traits::Currency;
-use srml_support::{
-    decl_module, decl_storage, ensure, Parameter, StorageMap, StorageValue,
-};
-use runtime_primitives::traits::{Member, One, SimpleArithmetic, MaybeSerialize};
-
-use minting;
-use recurringrewards;
-use stake;
-use hiring;
-use versioned_store_permissions;
-
-use super::super::membership::members as membership;
-
-/// Module configuration trait for this Substrate module.
-pub trait Trait: system::Trait + minting::Trait + recurringrewards::Trait + stake::Trait + hiring::Trait + versioned_store_permissions::Trait + membership::Trait + Sized {
-
-    /// The event type.
-    type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
-
-    /// Type for identifier for lead.
-    type LeadId: Parameter
-        + Member
-        + SimpleArithmetic
-        + Codec
-        + Default
-        + Copy
-        + MaybeSerialize
-        + PartialEq;
-
-    /// Type for identifier for curators.
-    type CuratorId: Parameter
-        + Member
-        + SimpleArithmetic
-        + Codec
-        + Default
-        + Copy
-        + MaybeSerialize
-        + PartialEq;
-
-    /// Type for identifier for channels.
-    type ChannelId: Parameter
-        + Member
-        + SimpleArithmetic
-        + Codec
-        + Default
-        + Copy
-        + MaybeSerialize
-        + PartialEq;
-}
-
-/// Type for identifier for dynamic version store credential.
-pub type DynamicCredentialId<T: Trait> = T::PrincipalId;
-
-/// Balance type of runtime
-pub type BalanceOf<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
-
-/// Negative imbalance of runtime.
-pub type NegativeImbalance<T> =
-    <<T as stake::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
-
-/// The exit stage of a lead involvement in the working group.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct ExitedLeadRole<BlockNumber> {
-
-    /// When exit was initiated.
-    pub initiated_at_block_number: BlockNumber
-}
-
-/// The stage of the involvement of a lead in the working group.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum LeadRoleState<BlockNumber> {
-
-    /// Currently active.
-    Active,
-
-    /// No longer active, for some reason
-    Exited(ExitedLeadRole<BlockNumber>)
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl<BlockNumber> Default for LeadRoleState<BlockNumber> {
-
-    fn default() -> Self {
-        LeadRoleState::Active
-    }
-}
-
-/// Working group lead: curator lead
-/// For now this role is not staked or inducted through an structured process, like the hiring module,
-/// hence information about this is missing. Recurring rewards is included, somewhat arbitrarily!
-#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct Lead<AccountId, RewardRelationshipId, BlockNumber> {
-
-    /// Account used to authenticate in this role,
-    pub role_account: AccountId,
-
-    /// Whether the role has recurring reward, and if so an identifier for this.
-    pub reward_relationship: Option<RewardRelationshipId>,
-
-    /// When was inducted
-    /// TODO: Add richer information about circumstances of induction, like referencing a council proposal?
-    pub inducted: BlockNumber,
-
-    /// The stage of the involvement of this lead in the working group.
-    pub stage: LeadRoleState<BlockNumber>
-}
-
-/// Origin of exit initiation on behalf of a curator.'
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum CuratorExitInitiationOrigin {
-
-    /// Lead is origin.
-    Lead,
-
-    /// The curator exiting is the origin.
-    Curator
-}
-
-/// The exit stage of a curators involvement in the working group.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct ExitedCuratorRoleStage<BlockNumber> {
-
-    /// Origin for exit.
-    pub origin: CuratorExitInitiationOrigin,
-
-    /// When exit was initiated.
-    pub initiated_at_block_number: BlockNumber,
-
-    /// Explainer for why exit was initited.
-    pub rationale_text: Vec<u8>
-}
-
-/// The stage of the involvement of a curator in the working group.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum CuratorRoleStage<BlockNumber> {
-
-    /// Currently active.
-    Active,
-
-    /// No longer active, for some reason
-    Exited(ExitedCuratorRoleStage<BlockNumber>)
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl<BlockNumber> Default for CuratorRoleStage<BlockNumber> {
-
-    fn default() -> Self {
-        CuratorRoleStage::Active
-    }
-}
-
-/// The induction of a curator in the working group.
-#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct CuratorInduction<LeadId, ApplicationId, BlockNumber> {
-
-    /// Lead responsible
-    pub lead: LeadId,
-
-    /// Application through which curator was inducted
-    pub application: ApplicationId,
-
-    /// When induction occurred
-    pub at_block: BlockNumber // wasn't there some composte type here?
-}
-
-/// Working group participant: curator
-/// This role can be staked, have reward and be inducted through the hiring module.
-#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct Curator<AccountId, RewardRelationshipId, StakeId, BlockNumber, LeadId, ApplicationId> {
-
-    /// Account used to authenticate in this role,
-    pub role_account: AccountId,
-
-    /// Whether the role has recurring reward, and if so an identifier for this.
-    pub reward_relationship: Option<RewardRelationshipId>,
-
-    /// Whether participant is staked, and if so, the identifier for this staking in the staking module.
-    pub stake: Option<StakeId>,
-
-    /// The stage of this curator in the working group.
-    pub stage: CuratorRoleStage<BlockNumber>,
-
-    /// How the curator was inducted into the working group.
-    pub induction: CuratorInduction<LeadId, ApplicationId, BlockNumber>
-
-    /// Whether this curator can unilaterally alter the curation status of a  channel.
-    pub can_update_channel_curation_status: bool
-}
-
-/// Type of channel content.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum ChannelContentType {
-    Video,
-    Music,
-    Ebook
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl Default for ChannelContentType {
-
-    fn default() -> Self {
-        ChannelContentType::Video
-    }
-}
-
-/// Status of channel, as set by the owner.
-/// Is only meant to affect visibility, mutation of channel and child content
-/// is unaffected on runtime.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum ChannelPublishingStatus {
-
-    /// Compliant UIs should render.
-    Published,
-    
-    /// Compliant UIs should not render it or any child content.
-    NotPublished
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl Default for ChannelPublishingStatus {
-
-    fn default() -> Self {
-        ChannelPublishingStatus::Published
-    }
-}
-
-/// Status of channel, as set by curators.
-/// Is only meant to affect visibility currently, but in the future
-/// it will also gate publication of new child content,
-/// editing properties, revenue flows, etc. 
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum ChannelCurationStatus {
-    Normal,
-    Censored
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl Default for ChannelCurationStatus {
-
-    fn default() -> Self {
-        ChannelCurationStatus::Normal
-    }
-}
-
-/// A channel for publishing content.
-#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct Channel<MemberId, AccountId, BlockNumber> {
-
-    /// Unique human readble channel handle.
-    pub handle: Vec<u8>, 
-
-    /// Whether channel has been verified, in the normal Web2.0 platform sense of being authenticated.
-    pub verified: bool,
-
-    /// Human readable description of channel purpose and scope.
-    pub description: Vec<u8>,
-
-    /// The type of channel.
-    pub content: ChannelContentType,
-
-    /// Member who owns channel.
-    pub owner: MemberId,
-
-    /// Account used to authenticate as owner.
-    /// Can be updated through membership role key.
-    pub role_account: AccountId,
-
-    /// Publication status of channel.
-    pub publishing_status: ChannelPublishingStatus,
-
-    /// Curation status of channel.
-    pub curation_status: ChannelCurationStatus,
-
-    /// When channel was established.
-    pub created: BlockNumber
-
-}
-
-/// The types of built in credential holders.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum BuiltInCredentialHolder {
-
-    /// Cyrrent working group lead.
-    Lead,
-    
-    /// Any active urator in the working group.
-    AnyCurator,
-
-    /// Any active member in the membership registry.
-    AnyMember
-}
-
-/// Holder of dynamic credential.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum DynamicCredentialHolder<CuratorId, ChannelId> {
-
-    /// Sets of curators.
-    Curators(BTreeSet<CuratorId>),
-
-    /// Owner of a channel.
-    ChannelOwner(ChannelId),
-}
-
-/// Must be default constructible because it indirectly is a value in a storage map.
-/// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl<CuratorId, ChannelId> Default for DynamicCredentialHolder<CuratorId, ChannelId> {
-
-    fn default() -> Self {
-        DynamicCredentialHolder::Curators(BTreeSet::new())
-    }
-}
-
-/// Represents credential for authenticating as "the current lead".
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct LeadCredential {
-
-    /// Whether it is currently possible to authenticate with this credential.
-    pub is_active: bool
-}
-
-/// Represents credential for authenticating as "any curator".
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct AnyCuratorCredential {
-
-    /// Whether it is currently possible to authenticate with this credential.
-    pub is_active: bool
-}
-
-/// Represents credential for authenticating as "any member".
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct AnyMemberCredential {
-
-    /// Whether it is currently possible to authenticate with this credential.
-    pub is_active: bool
-}
-
-/// Represents credential to be referenced from the version store.
-/// It is dynamic in the sense that these can be created on the fly.
-#[derive(Encode, Decode, Default, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct DynamicCredential<CuratorId, ChannelId, BlockNumber> {
-
-    /// Who holds this credential, meaning they can successfully authenticate with this credential.
-    pub holder: DynamicCredentialHolder<CuratorId, ChannelId>,
-
-    /// Whether it is currently possible to authenticate with this credential.
-    pub is_active: bool,
-
-    /// When it was created.
-    pub created: BlockNumber,
-
-    /// Human readable description of credential.
-    pub description: Vec<u8>
-}
-
-/// Policy governing any curator opening which can be made by lead.
-/// Be aware that all limits are forward looking in constrainign future extrinsics or method calls.
-/// Updating them has no side-effects beyond changing the limit.
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub struct OpeningPolicy<BlockNumber, StakingPolicy> {
-
-    /// Limits the total number of curators which can be active, or possibly active through an active opening. 
-    /// The contribution of an active opening is counted by looking at the rationing policy of the opening.
-    /// A limit of N is counted as there being N actual active curators, as a worst case bound.
-    /// The absence of a limit is counted as "infinity", thus blocking any further openings from being created,
-    /// and is is not possible to actually hire a number of curators that would bring the number above this parameter `curator_limit`.
-    pub curator_limit: Option<u16>,
-
-    /// Maximum length of review period of applications
-    pub max_review_period_length: BlockNumber,
-
-    /// Staking policy for application
-    pub application_staking_policy: Option<StakingPolicy>,
-
-    /// Staking policy for role itself
-    pub role_staking_policy: Option<StakingPolicy>
-}
-
-/// Represents 
-#[derive(Encode, Decode, Debug, Eq, PartialEq, Clone, PartialOrd)]
-pub enum WorkingGroupActor<T: Trait> {
-
-    ///
-    Lead(T::LeadId),
-
-    ///
-    Curator(T::CuratorId),
-}
-
-pub enum ChannelActor<T: Trait> {
-
-    ///
-    WorkingGroupActor(WorkingGroupActor<T>),
-
-    ///
-    Owner
-}