Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,449 changes: 1,194 additions & 5,255 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[workspace]
members = [
"runtime",
"runtime-modules/proposals/engine",
"runtime-modules/proposals/codex",
"runtime-modules/proposals/discussion",
# "runtime",
# "runtime-modules/proposals/engine",
# "runtime-modules/proposals/codex",
# "runtime-modules/proposals/discussion",
"runtime-modules/common",
"runtime-modules/content-working-group",
"runtime-modules/forum",
"runtime-modules/governance",
# "runtime-modules/content-working-group",
# "runtime-modules/forum",
# "runtime-modules/governance",
"runtime-modules/hiring",
"runtime-modules/membership",
"runtime-modules/memo",
"runtime-modules/recurring-reward",
"runtime-modules/service-discovery",
# "runtime-modules/service-discovery",
"runtime-modules/stake",
"runtime-modules/storage",
# "runtime-modules/storage",
"runtime-modules/token-minting",
"runtime-modules/versioned-store",
"runtime-modules/versioned-store-permissions",
"runtime-modules/working-group",
"node",
"utils/chain-spec-builder/"
# "runtime-modules/working-group",
# "node",
# "utils/chain-spec-builder/"
]

[profile.release]
Expand Down
56 changes: 14 additions & 42 deletions runtime-modules/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
[package]
name = 'substrate-common-module'
version = '1.2.0'
name = 'pallet-common'
version = '3.0.0'
authors = ['Joystream contributors']
edition = '2018'

[dependencies]
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}

[features]
default = ['std']
std = [
'sr-primitives/std',
'srml-support/std',
'serde',
'codec/std',
'sp-runtime/std',
'frame-support/std',
'system/std',
'timestamp/std',
'codec/std',
'serde'
]


[dependencies.sr-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-primitives'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

[dependencies.srml-support]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-support'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

[dependencies.system]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '1.0.0'

[dependencies.serde]
features = ['derive']
optional = true
version = '1.0.101'

[dependencies.timestamp]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
4 changes: 2 additions & 2 deletions runtime-modules/common/src/currency.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sr_primitives::traits::Convert;
use srml_support::traits::{Currency, LockableCurrency, ReservableCurrency};
use frame_support::traits::{Currency, LockableCurrency, ReservableCurrency};
use sp_runtime::traits::Convert;

pub trait GovernanceCurrency: system::Trait + Sized {
type Currency: Currency<Self::AccountId>
Expand Down
62 changes: 18 additions & 44 deletions runtime-modules/hiring/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,60 +1,34 @@
[package]
name = 'substrate-hiring-module'
version = '1.0.2'
name = 'pallet-hiring'
version = '3.0.0'
authors = ['Joystream contributors']
edition = '2018'

[dependencies]
hex-literal = '0.1.0'
serde = { version = '1.0', optional = true }
serde_derive = { version = '1.0', optional = true }
rstd = { package = 'sr-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
runtime-primitives = { package = 'sr-primitives', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
srml-support = { package = 'srml-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
srml-support-procedural = { package = 'srml-support-procedural', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
system = { package = 'srml-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
balances = { package = 'srml-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
codec = { package = 'parity-scale-codec', version = '1.0.0', default-features = false, features = ['derive'] }
mockall = {version = "0.6.0", optional = true}
# https://users.rust-lang.org/t/failure-derive-compilation-error/39062
quote = '<=1.0.2'

[dependencies.stake]
default_features = false
package = 'substrate-stake-module'
path = '../stake'

[dependencies.timestamp]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'

[dependencies.runtime-io]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io'
rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = 'parity-scale-codec', version = '1.3.1', default-features = false, features = ['derive'] }
rstd = { package = 'sp-std', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
stake = { package = 'pallet-stake', default-features = false, path = '../stake'}

[dev-dependencies]
runtime-io = { package = 'sr-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
primitives = { package = 'substrate-primitives', git = 'https://github.com/paritytech/substrate.git', rev = 'c37bb08535c49a12320af7facfd555ce05cce2e8'}
mockall = "0.6.0"

mockall = "0.7.1"
sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}
balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4'}

[features]
default = ['std']
test = ['mockall']
std = [
'serde',
'serde_derive',
'codec/std',
'rstd/std',
'runtime-io/std',
'runtime-primitives/std',
'srml-support/std',
'frame-support/std',
'system/std',
'balances/std',
'timestamp/std',
'sp-arithmetic/std',
'sp-runtime/std',
'stake/std',
]
]
4 changes: 0 additions & 4 deletions runtime-modules/hiring/src/hiring/opening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ pub enum OpeningStage<BlockNumber, ApplicationId> {

/// Deactivated at any time for any cause.
deactivated_application_count: u32,
// Removed at any time.
//removed_application_count: u32
},
}

Expand Down Expand Up @@ -401,6 +399,4 @@ pub enum ActivateOpeningAt<BlockNumber> {
pub struct ApplicationRationingPolicy {
/// The maximum number of applications that can be on the list at any time.
pub max_active_applicants: u32,
// How applicants will be ranked, in order to respect the maximum simultaneous application limit
//pub applicant_ranking: ApplicationRankingPolicy
}
61 changes: 27 additions & 34 deletions runtime-modules/hiring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,25 @@
// Do not delete! Cannot be uncommented by default, because of Parity decl_module! issue.
//#![warn(missing_docs)]

// Test feature dependencies
#[cfg(all(any(test, feature = "test"), not(target_arch = "wasm32")))]
// Test dependencies
#[cfg(all(test, not(target_arch = "wasm32")))]
use mockall::predicate::*;
#[cfg(all(any(test, feature = "test"), not(target_arch = "wasm32")))]
#[cfg(all(test, not(target_arch = "wasm32")))]
use mockall::*;

use stake::{InitiateUnstakingError, Stake, StakeActionError, StakingError, Trait as StakeTrait};

use codec::Codec;

use runtime_primitives::traits::Zero;
use runtime_primitives::traits::{MaybeSerialize, Member, One, SimpleArithmetic};

use srml_support::traits::Currency;
use srml_support::{decl_module, decl_storage, ensure, Parameter};

use frame_support::storage::IterableStorageMap;
use frame_support::traits::{Currency, Imbalance};
use frame_support::{decl_module, decl_storage, ensure, Parameter};
use rstd::cell::RefCell;
use rstd::collections::btree_map::BTreeMap;
use rstd::collections::btree_set::BTreeSet;
use rstd::iter::Iterator;
use rstd::prelude::*;

use rstd::cell::RefCell;
use rstd::rc::Rc;
use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
use sp_runtime::traits::{MaybeSerialize, Member};

use crate::sr_api_hidden_includes_decl_storage::hidden_include::traits::Imbalance;
use stake::{InitiateUnstakingError, Stake, StakeActionError, StakingError, Trait as StakeTrait};

mod hiring;
#[macro_use]
Expand All @@ -57,7 +51,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized {
/// OpeningId type
type OpeningId: Parameter
+ Member
+ SimpleArithmetic
+ BaseArithmetic
+ Codec
+ Default
+ Copy
Expand All @@ -67,7 +61,7 @@ pub trait Trait: system::Trait + stake::Trait + Sized {
/// ApplicationId type
type ApplicationId: Parameter
+ Member
+ SimpleArithmetic
+ BaseArithmetic
+ Codec
+ Default
+ Copy
Expand All @@ -83,21 +77,23 @@ pub trait Trait: system::Trait + stake::Trait + Sized {

decl_storage! {
trait Store for Module<T: Trait> as Hiring {

/// Openings.
pub OpeningById get(opening_by_id): linked_map T::OpeningId => Opening<BalanceOf<T>, T::BlockNumber, T::ApplicationId>;
pub OpeningById get(fn opening_by_id): map hasher(blake2_128_concat)
T::OpeningId => Opening<BalanceOf<T>, T::BlockNumber, T::ApplicationId>;

/// Identifier for next opening to be added.
pub NextOpeningId get(next_opening_id): T::OpeningId;
pub NextOpeningId get(fn next_opening_id): T::OpeningId;

/// Applications
pub ApplicationById get(application_by_id): linked_map T::ApplicationId => Application<T::OpeningId, T::BlockNumber, T::StakeId>;
pub ApplicationById get(fn application_by_id): map hasher(blake2_128_concat)
T::ApplicationId => Application<T::OpeningId, T::BlockNumber, T::StakeId>;

/// Identifier for next application to be added.
pub NextApplicationId get(next_application_id): T::ApplicationId;
pub NextApplicationId get(fn next_application_id): T::ApplicationId;

/// Internal purpose of given stake, i.e. fro what application, and whether for the role or for the application.
pub ApplicationIdByStakingId get(stake_purpose_by_staking_id): linked_map T::StakeId => T::ApplicationId;
pub ApplicationIdByStakingId get(fn stake_purpose_by_staking_id): map hasher(blake2_128_concat)
T::StakeId => T::ApplicationId;
}
}

Expand Down Expand Up @@ -769,14 +765,14 @@ impl<T: Trait> Module<T> {
/// The stake, with the given id, was unstaked.
pub fn unstaked(stake_id: T::StakeId) -> UnstakedResult {
// Ignore unstaked
if !<ApplicationIdByStakingId<T>>::exists(stake_id) {
if !<ApplicationIdByStakingId<T>>::contains_key(stake_id) {
return UnstakedResult::StakeIdNonExistent;
}

// Get application
let application_id = <ApplicationIdByStakingId<T>>::get(stake_id);

assert!(<ApplicationById<T>>::exists(application_id));
assert!(<ApplicationById<T>>::contains_key(application_id));

let application = <ApplicationById<T>>::get(application_id);

Expand Down Expand Up @@ -1005,7 +1001,7 @@ impl<T: Trait> Module<T> {
Opening<BalanceOf<T>, T::BlockNumber, T::ApplicationId>,
),
> {
<OpeningById<T>>::enumerate().filter_map(move |(opening_id, opening)| {
<OpeningById<T>>::iter().filter_map(move |(opening_id, opening)| {
if let hiring::OpeningStage::WaitingToBegin { begins_at_block } = opening.stage {
if begins_at_block == now {
Some((opening_id, opening))
Expand All @@ -1028,7 +1024,7 @@ impl<T: Trait> Module<T> {
(BTreeSet<T::ApplicationId>, T::BlockNumber, T::BlockNumber),
),
> {
<OpeningById<T>>::enumerate().filter_map(move |(opening_id, opening)| {
<OpeningById<T>>::iter().filter_map(move |(opening_id, opening)| {
if let hiring::OpeningStage::Active {
ref stage,
ref applications_added,
Expand Down Expand Up @@ -1282,7 +1278,7 @@ impl<T: Trait> Module<T> {

// MUST never already be a key for new stake, false means code is broken.
// But should we do panic in runtime? Is there safer way?
assert!(!<ApplicationIdByStakingId<T>>::exists(new_stake_id));
assert!(!<ApplicationIdByStakingId<T>>::contains_key(new_stake_id));

<ApplicationIdByStakingId<T>>::insert(new_stake_id, application_id);

Expand Down Expand Up @@ -1476,10 +1472,7 @@ impl<T: Trait> Module<T> {
*/

/// Defines stake module interface
#[cfg_attr(
all(any(test, feature = "test"), not(target_arch = "wasm32")),
automock
)]
#[cfg_attr(all(test, not(target_arch = "wasm32")), automock)]
pub trait StakeHandler<T: StakeTrait> {
/// Adds a new Stake which is NotStaked, created at given block, into stakes map.
fn create_stake(&self) -> T::StakeId;
Expand Down Expand Up @@ -1536,7 +1529,7 @@ impl<T: Trait> StakeHandler<T> for HiringStakeHandler {
}

fn stake_exists(&self, stake_id: T::StakeId) -> bool {
<stake::Stakes<T>>::exists(stake_id)
<stake::Stakes<T>>::contains_key(stake_id)
}

fn get_stake(&self, stake_id: T::StakeId) -> Stake<T::BlockNumber, BalanceOf<T>, T::SlashId> {
Expand Down
2 changes: 1 addition & 1 deletion runtime-modules/hiring/src/macroes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! ensure_eq {
/// Ensure that a storage map, with a given name, has mapping for the given key value.
macro_rules! ensure_map_key {
($map_variable_name:ident , $runtime_trait:tt, $key:expr, $error:expr) => {{
if <$map_variable_name<$runtime_trait>>::exists($key) {
if <$map_variable_name<$runtime_trait>>::contains_key($key) {
let value = <$map_variable_name<$runtime_trait>>::get($key);

Ok(value)
Expand Down
Loading