diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 2b8c9502a8..66fd41e640 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3149,6 +3149,7 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -3164,11 +3165,9 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", - "sr-std 0.1.0", "srml-balances 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", @@ -3197,7 +3196,6 @@ dependencies = [ name = "srml-grandpa" version = "0.1.0" dependencies = [ - "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3360,6 +3358,7 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 8e2be26970..5a4170542a 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/node-template/runtime/wasm/Cargo.lock b/substrate/node-template/runtime/wasm/Cargo.lock index 2e168f226f..f064925d6e 100644 --- a/substrate/node-template/runtime/wasm/Cargo.lock +++ b/substrate/node-template/runtime/wasm/Cargo.lock @@ -1177,9 +1177,7 @@ dependencies = [ name = "srml-executive" version = "0.1.0" dependencies = [ - "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -1227,14 +1225,12 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-consensus 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "srml-timestamp 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1246,17 +1242,13 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-balances 0.1.0", "srml-consensus 0.1.0", "srml-session 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", - "srml-timestamp 0.1.0", "substrate-keyring 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1267,13 +1259,11 @@ dependencies = [ "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-support 0.1.0", "srml-support-procedural 0.1.0", "srml-system 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1334,6 +1324,7 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1349,14 +1340,12 @@ dependencies = [ "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-consensus 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-inherents 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] diff --git a/substrate/node/runtime/wasm/Cargo.lock b/substrate/node/runtime/wasm/Cargo.lock index 91ec5f1cf4..5c28c30a16 100644 --- a/substrate/node/runtime/wasm/Cargo.lock +++ b/substrate/node/runtime/wasm/Cargo.lock @@ -1212,7 +1212,6 @@ dependencies = [ name = "srml-council" version = "0.1.0" dependencies = [ - "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1220,7 +1219,6 @@ dependencies = [ "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-balances 0.1.0", "srml-democracy 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", @@ -1236,22 +1234,19 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-balances 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] name = "srml-executive" version = "0.1.0" dependencies = [ - "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -1264,12 +1259,10 @@ dependencies = [ name = "srml-grandpa" version = "0.1.0" dependencies = [ - "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-session 0.1.0", @@ -1318,14 +1311,12 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-consensus 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "srml-timestamp 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1337,17 +1328,13 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", - "srml-balances 0.1.0", "srml-consensus 0.1.0", "srml-session 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", - "srml-timestamp 0.1.0", "substrate-keyring 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1358,13 +1345,11 @@ dependencies = [ "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-support 0.1.0", "srml-support-procedural 0.1.0", "srml-system 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] @@ -1425,6 +1410,7 @@ dependencies = [ "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1440,14 +1426,12 @@ dependencies = [ "parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", "srml-consensus 0.1.0", "srml-support 0.1.0", "srml-system 0.1.0", "substrate-inherents 0.1.0", - "substrate-primitives 0.1.0", ] [[package]] diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index ba214caed2..227e944b3d 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/substrate/srml/council/Cargo.toml b/substrate/srml/council/Cargo.toml index df2f66bbe9..6f4b1df15d 100644 --- a/substrate/srml/council/Cargo.toml +++ b/substrate/srml/council/Cargo.toml @@ -2,35 +2,36 @@ name = "srml-council" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] -hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } safe-mix = { version = "1.0", default-features = false} parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-balances = { path = "../balances", default-features = false } -srml-democracy = { path = "../democracy", default-features = false } -srml-system = { path = "../system", default-features = false } +democracy = { package = "srml-democracy", path = "../democracy", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } + +[dev-dependencies] +hex-literal = "0.1.0" +balances = { package = "srml-balances", path = "../balances", default-features = false } [features] default = ["std"] std = [ - "serde/std", "safe-mix/std", "parity-codec/std", "parity-codec-derive/std", "substrate-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", + "runtime_io/std", "srml-support/std", - "sr-primitives/std", - "srml-balances/std", - "srml-democracy/std", - "srml-system/std", + "primitives/std", + "democracy/std", + "system/std", ] diff --git a/substrate/srml/council/src/lib.rs b/substrate/srml/council/src/lib.rs index 5439336ef9..d92b0d7178 100644 --- a/substrate/srml/council/src/lib.rs +++ b/substrate/srml/council/src/lib.rs @@ -18,36 +18,18 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature = "std")] -extern crate serde; - -#[cfg(test)] -#[macro_use] -extern crate hex_literal; -#[cfg(test)] -extern crate srml_balances as balances; - -extern crate parity_codec as codec; -extern crate parity_codec_derive; -extern crate substrate_primitives; -extern crate sr_std as rstd; -extern crate sr_io as runtime_io; -#[macro_use] extern crate srml_support; -extern crate sr_primitives as primitives; -extern crate srml_democracy as democracy; -extern crate srml_system as system; - pub mod voting; pub mod motions; pub mod seats; -pub use seats::{Trait, Module, RawEvent, Event, VoteIndex}; +pub use crate::seats::{Trait, Module, RawEvent, Event, VoteIndex}; #[cfg(test)] mod tests { // These re-exports are here for a reason, edit with care pub use super::*; pub use runtime_io::with_externalities; + use srml_support::{impl_outer_origin, impl_outer_event, impl_outer_dispatch}; pub use substrate_primitives::H256; pub use primitives::BuildStorage; pub use primitives::traits::{BlakeTwo256, IdentityLookup}; diff --git a/substrate/srml/council/src/motions.rs b/substrate/srml/council/src/motions.rs index 9cf5e171a5..a2636c728a 100644 --- a/substrate/srml/council/src/motions.rs +++ b/substrate/srml/council/src/motions.rs @@ -21,7 +21,7 @@ use rstd::result; use substrate_primitives::u32_trait::Value as U32; use primitives::traits::{Hash, EnsureOrigin}; use srml_support::dispatch::{Dispatchable, Parameter}; -use srml_support::{StorageValue, StorageMap}; +use srml_support::{StorageValue, StorageMap, decl_module, decl_event, decl_storage, ensure}; use super::{Trait as CouncilTrait, Module as Council}; use system::{self, ensure_signed}; @@ -202,10 +202,11 @@ impl EnsureOrigin for EnsureMembers mod tests { use super::*; use super::RawEvent; - use ::tests::*; - use ::tests::{Call, Origin, Event as OuterEvent}; - use srml_support::Hashable; + use crate::tests::*; + use crate::tests::{Call, Origin, Event as OuterEvent}; + use srml_support::{Hashable, assert_ok, assert_noop}; use system::{EventRecord, Phase}; + use hex_literal::{hex, hex_impl}; #[test] fn motions_basic_environment_works() { diff --git a/substrate/srml/council/src/seats.rs b/substrate/srml/council/src/seats.rs index 2f6716d70d..6fd4f1cfec 100644 --- a/substrate/srml/council/src/seats.rs +++ b/substrate/srml/council/src/seats.rs @@ -19,7 +19,7 @@ use rstd::prelude::*; use primitives::traits::{Zero, One, As, StaticLookup}; use runtime_io::print; -use srml_support::{StorageValue, StorageMap, dispatch::Result, traits::Currency}; +use srml_support::{StorageValue, StorageMap, dispatch::Result, traits::Currency, decl_storage, decl_event, ensure}; use democracy; use system::{self, ensure_signed}; @@ -77,6 +77,8 @@ use system::{self, ensure_signed}; // after each vote as all but K entries are cleared. newly registering candidates must use cleared // entries before they increase the capacity. +use srml_support::decl_module; + pub type VoteIndex = u32; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -547,7 +549,8 @@ impl Module { #[cfg(test)] mod tests { use super::*; - use ::tests::*; + use crate::tests::*; + use srml_support::{assert_ok, assert_noop, assert_err}; #[test] fn params_should_work() { diff --git a/substrate/srml/council/src/voting.rs b/substrate/srml/council/src/voting.rs index b1a57b90ad..17ab4adc7f 100644 --- a/substrate/srml/council/src/voting.rs +++ b/substrate/srml/council/src/voting.rs @@ -21,7 +21,7 @@ use rstd::borrow::Borrow; use primitives::traits::{Hash, As, Zero}; use runtime_io::print; use srml_support::dispatch::Result; -use srml_support::{StorageValue, StorageMap, IsSubType}; +use srml_support::{StorageValue, StorageMap, IsSubType, decl_module, decl_storage, decl_event, ensure}; use {system, democracy}; use super::{Trait as CouncilTrait, Module as Council}; use system::ensure_signed; @@ -232,9 +232,9 @@ impl Module { #[cfg(test)] mod tests { use super::*; - use ::tests::*; - use ::tests::{Call, Origin}; - use srml_support::Hashable; + use crate::tests::*; + use crate::tests::{Call, Origin}; + use srml_support::{Hashable, assert_ok, assert_noop}; use democracy::{ReferendumInfo, VoteThreshold}; #[test] diff --git a/substrate/srml/democracy/Cargo.toml b/substrate/srml/democracy/Cargo.toml index 042a937ebf..aa88602ffa 100644 --- a/substrate/srml/democracy/Cargo.toml +++ b/substrate/srml/democracy/Cargo.toml @@ -2,32 +2,35 @@ name = "srml-democracy" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } +serde_derive = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } -substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-balances = { path = "../balances", default-features = false } -srml-system = { path = "../system", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } + +[dev-dependencies] +substrate-primitives = { path = "../../core/primitives", default-features = false } +balances = { package = "srml-balances", path = "../balances", default-features = false } [features] default = ["std"] std = [ "serde/std", + "serde_derive", "safe-mix/std", "parity-codec/std", - "substrate-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", + "runtime_io/std", "srml-support/std", - "sr-primitives/std", - "srml-balances/std", - "srml-system/std", + "primitives/std", + "system/std", ] diff --git a/substrate/srml/democracy/src/lib.rs b/substrate/srml/democracy/src/lib.rs index a246e98146..9e9c843d9a 100644 --- a/substrate/srml/democracy/src/lib.rs +++ b/substrate/srml/democracy/src/lib.rs @@ -18,26 +18,12 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(test)] -extern crate substrate_primitives; -#[cfg(test)] -extern crate srml_balances as balances; - -#[macro_use] -extern crate parity_codec_derive; -extern crate sr_std as rstd; -#[macro_use] -extern crate srml_support; - -extern crate parity_codec as codec; -extern crate sr_io as runtime_io; -extern crate sr_primitives as primitives; -extern crate srml_system as system; - use rstd::prelude::*; use rstd::result; use primitives::traits::{Zero, As}; +use parity_codec_derive::{Encode, Decode}; use srml_support::{StorageValue, StorageMap, Parameter, Dispatchable, IsSubType}; +use srml_support::{decl_module, decl_storage, decl_event, ensure}; use srml_support::traits::{Currency, OnFreeBalanceZero, EnsureAccountLiquid}; use srml_support::dispatch::Result; use system::ensure_signed; @@ -440,6 +426,7 @@ impl EnsureAccountLiquid for Module { mod tests { use super::*; use runtime_io::with_externalities; + use srml_support::{impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok}; use substrate_primitives::{H256, Blake2Hasher}; use primitives::BuildStorage; use primitives::traits::{BlakeTwo256, IdentityLookup}; diff --git a/substrate/srml/democracy/src/vote_threshold.rs b/substrate/srml/democracy/src/vote_threshold.rs index ab5e1ddee7..9a730fc52a 100644 --- a/substrate/srml/democracy/src/vote_threshold.rs +++ b/substrate/srml/democracy/src/vote_threshold.rs @@ -16,6 +16,9 @@ //! Voting thresholds. +#[cfg(feature = "std")] +use serde_derive::{Serialize, Deserialize}; +use parity_codec_derive::{Encode, Decode}; use primitives::traits::{Zero, IntegerSquareRoot}; use rstd::ops::{Add, Mul, Div, Rem}; diff --git a/substrate/srml/example/Cargo.toml b/substrate/srml/example/Cargo.toml index cf900f00f3..875b760f1b 100644 --- a/substrate/srml/example/Cargo.toml +++ b/substrate/srml/example/Cargo.toml @@ -2,31 +2,28 @@ name = "srml-example" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } parity-codec = { version = "3.0", default-features = false } -parity-codec-derive = { version = "3.0", default-features = false } -substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-system = { path = "../system", default-features = false } -srml-balances = { path = "../balances", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } +balances = { package = "srml-balances", path = "../balances", default-features = false } + +[dev-dependencies] +sr-io = { path = "../../core/sr-io", default-features = false } +substrate-primitives = { path = "../../core/primitives", default-features = false } +sr-primitives = { path = "../../core/sr-primitives", default-features = false } [features] default = ["std"] std = [ "serde/std", "parity-codec/std", - "parity-codec-derive/std", - "sr-std/std", - "sr-io/std", "sr-primitives/std", - "substrate-primitives/std", "srml-support/std", - "srml-system/std", - "srml-balances/std", + "system/std", + "balances/std", ] diff --git a/substrate/srml/example/src/lib.rs b/substrate/srml/example/src/lib.rs index 3dae6d729b..fbd4031869 100644 --- a/substrate/srml/example/src/lib.rs +++ b/substrate/srml/example/src/lib.rs @@ -20,37 +20,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -// Assert macros used in tests. -extern crate sr_std; - -// Needed for tests (`with_externalities`). -#[cfg(test)] -extern crate sr_io; - -// Needed for the set of mock primitives used in our tests. -#[cfg(test)] -extern crate substrate_primitives; - -// Needed for various traits. In our case, `OnInitialise` and `OnFinalise` in our -// tests. -extern crate sr_primitives; - -// Needed for deriving `Encode` and `Decode` for `RawEvent`. -extern crate parity_codec_derive; -extern crate parity_codec as codec; - -// Needed for type-safe access to storage DB. -#[macro_use] -extern crate srml_support as support; -// `system` module provides us with all sorts of useful stuff and macros -// depend on it being around. -extern crate srml_system as system; -// `balances` module is needed for our little example. It's not required in -// general (though if you want your module to be able to work with tokens, then you -// might find it useful). -extern crate srml_balances as balances; - -use support::{StorageValue, dispatch::Result}; +use srml_support::{StorageValue, dispatch::Result, decl_module, decl_storage, decl_event}; use system::ensure_signed; /// Our module's configuration trait. All our types and consts go in here. If the @@ -270,6 +240,7 @@ impl Module { mod tests { use super::*; + use srml_support::{impl_outer_origin, assert_ok}; use sr_io::with_externalities; use substrate_primitives::{H256, Blake2Hasher}; // The testing primitives are very useful for avoiding having to work with signatures diff --git a/substrate/srml/executive/Cargo.toml b/substrate/srml/executive/Cargo.toml index f3b38c276f..bc7e8616fb 100644 --- a/substrate/srml/executive/Cargo.toml +++ b/substrate/srml/executive/Cargo.toml @@ -2,32 +2,32 @@ name = "srml-executive" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] -hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } parity-codec = { version = "3.0", default-features = false } -parity-codec-derive = { version = "3.0", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-system = { path = "../system", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } [dev-dependencies] +hex-literal = "0.1.0" substrate-primitives = { path = "../../core/primitives" } srml-indices = { path = "../indices" } -srml-balances = { path = "../balances" } +balances = { package = "srml-balances", path = "../balances" } +parity-codec-derive = { version = "3.0", default-features = false } [features] default = ["std"] std = [ - "sr-std/std", + "rstd/std", "srml-support/std", "serde/std", "parity-codec/std", - "parity-codec-derive/std", - "sr-primitives/std", - "sr-io/std", - "srml-system/std", + "primitives/std", + "runtime_io/std", + "system/std", ] diff --git a/substrate/srml/executive/src/lib.rs b/substrate/srml/executive/src/lib.rs index c4e59dbbbd..04c44a53d3 100644 --- a/substrate/srml/executive/src/lib.rs +++ b/substrate/srml/executive/src/lib.rs @@ -18,35 +18,13 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(test)] -extern crate parity_codec_derive; - -#[cfg_attr(test, macro_use)] -extern crate srml_support as runtime_support; - -extern crate sr_std as rstd; -extern crate sr_io as runtime_io; -extern crate parity_codec as codec; -extern crate sr_primitives as primitives; -extern crate srml_system as system; - -#[cfg(test)] -#[macro_use] -extern crate hex_literal; - -#[cfg(test)] -extern crate substrate_primitives; - -#[cfg(test)] -extern crate srml_balances as balances; - use rstd::prelude::*; use rstd::marker::PhantomData; use rstd::result; use primitives::traits::{self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalise, OnInitialise, MakePayment, Hash, As, Digest}; -use runtime_support::Dispatchable; -use codec::{Codec, Encode}; +use srml_support::Dispatchable; +use parity_codec::{Codec, Encode}; use system::extrinsics_root; use primitives::{ApplyOutcome, ApplyError}; use primitives::transaction_validity::{TransactionValidity, TransactionPriority, TransactionLongevity}; @@ -304,8 +282,9 @@ mod tests { use primitives::BuildStorage; use primitives::traits::{Header as HeaderT, BlakeTwo256, IdentityLookup}; use primitives::testing::{Digest, DigestItem, Header, Block}; - use runtime_support::traits::Currency; + use srml_support::{traits::Currency, impl_outer_origin, impl_outer_event}; use system; + use hex_literal::{hex, hex_impl}; impl_outer_origin! { pub enum Origin for Runtime { diff --git a/substrate/srml/grandpa/Cargo.toml b/substrate/srml/grandpa/Cargo.toml index 474d65cd09..8313d0fb7d 100644 --- a/substrate/srml/grandpa/Cargo.toml +++ b/substrate/srml/grandpa/Cargo.toml @@ -2,21 +2,24 @@ name = "srml-grandpa" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] -hex-literal = "0.1.0" +#hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } serde_derive = { version = "1.0", optional = true } parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-system = { path = "../system", default-features = false } -srml-session = { path = "../session", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } +session = { package = "srml-session", path = "../session", default-features = false } + +[dev-dependencies] +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } [features] default = ["std"] @@ -26,10 +29,9 @@ std = [ "parity-codec/std", "substrate-primitives/std", "substrate-finality-grandpa-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", "srml-support/std", - "sr-primitives/std", - "srml-system/std", - "srml-session/std", + "primitives/std", + "system/std", + "session/std", ] diff --git a/substrate/srml/grandpa/src/lib.rs b/substrate/srml/grandpa/src/lib.rs index 54e78e9474..393b9bd4f9 100644 --- a/substrate/srml/grandpa/src/lib.rs +++ b/substrate/srml/grandpa/src/lib.rs @@ -27,39 +27,19 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[allow(unused_imports)] -#[macro_use] -extern crate sr_std as rstd; - -#[macro_use] -extern crate srml_support as runtime_support; +// re-export since this is necessary for `impl_apis` in runtime. +pub use substrate_finality_grandpa_primitives as fg_primitives; #[cfg(feature = "std")] -#[macro_use] -extern crate serde_derive; - -extern crate parity_codec; -#[macro_use] -extern crate parity_codec_derive; - -extern crate sr_primitives as primitives; -extern crate parity_codec as codec; -extern crate srml_system as system; -extern crate srml_session as session; -extern crate substrate_primitives; - -#[cfg(test)] -extern crate sr_io as runtime_io; - -// re-export since this is necessary for `impl_apis` in runtime. -pub extern crate substrate_finality_grandpa_primitives as fg_primitives; - +use serde_derive::Serialize; use rstd::prelude::*; +use parity_codec as codec; +use parity_codec_derive::{Encode, Decode}; use fg_primitives::ScheduledChange; -use runtime_support::Parameter; -use runtime_support::dispatch::Result; -use runtime_support::storage::StorageValue; -use runtime_support::storage::unhashed::StorageVec; +use srml_support::{Parameter, decl_event, decl_storage, decl_module}; +use srml_support::dispatch::Result; +use srml_support::storage::StorageValue; +use srml_support::storage::unhashed::StorageVec; use primitives::traits::{CurrentHeight, Convert}; use substrate_primitives::Ed25519AuthorityId; use system::ensure_signed; @@ -71,7 +51,7 @@ mod tests; struct AuthorityStorageVec(rstd::marker::PhantomData); impl StorageVec for AuthorityStorageVec { type Item = (S, u64); - const PREFIX: &'static [u8] = ::fg_primitives::well_known_keys::AUTHORITY_PREFIX; + const PREFIX: &'static [u8] = crate::fg_primitives::well_known_keys::AUTHORITY_PREFIX; } /// The log type of this crate, projected from module trait type. @@ -162,12 +142,12 @@ decl_storage! { let auth_count = config.authorities.len() as u32; config.authorities.iter().enumerate().for_each(|(i, v)| { storage.insert((i as u32).to_keyed_vec( - ::fg_primitives::well_known_keys::AUTHORITY_PREFIX), + crate::fg_primitives::well_known_keys::AUTHORITY_PREFIX), v.encode() ); }); storage.insert( - ::fg_primitives::well_known_keys::AUTHORITY_COUNT.to_vec(), + crate::fg_primitives::well_known_keys::AUTHORITY_COUNT.to_vec(), auth_count.encode(), ); }); diff --git a/substrate/srml/grandpa/src/mock.rs b/substrate/srml/grandpa/src/mock.rs index 380133ae80..7123e784cc 100644 --- a/substrate/srml/grandpa/src/mock.rs +++ b/substrate/srml/grandpa/src/mock.rs @@ -21,9 +21,11 @@ use primitives::{BuildStorage, traits::IdentityLookup, testing::{Digest, DigestItem, Header}}; use primitives::generic::DigestItem as GenDigestItem; use runtime_io; +use srml_support::{impl_outer_origin, impl_outer_event}; use substrate_primitives::{H256, Blake2Hasher}; use parity_codec::Encode; -use {system, GenesisConfig, Trait, Module, RawLog}; +use parity_codec_derive::{Encode, Decode}; +use crate::{GenesisConfig, Trait, Module, RawLog}; impl_outer_origin!{ pub enum Origin for Test {} @@ -58,7 +60,7 @@ impl system::Trait for Test { } mod grandpa { - pub use ::Event; + pub use crate::Event; } impl_outer_event!{ diff --git a/substrate/srml/grandpa/src/tests.rs b/substrate/srml/grandpa/src/tests.rs index 4d8694b2a5..74c998d873 100644 --- a/substrate/srml/grandpa/src/tests.rs +++ b/substrate/srml/grandpa/src/tests.rs @@ -21,9 +21,9 @@ use primitives::{testing, traits::OnFinalise}; use primitives::traits::Header; use runtime_io::with_externalities; -use mock::{Grandpa, System, new_test_ext}; +use crate::mock::{Grandpa, System, new_test_ext}; use system::{EventRecord, Phase}; -use {RawLog, RawEvent}; +use crate::{RawLog, RawEvent}; #[test] fn authorities_change_logged() { diff --git a/substrate/srml/indices/src/lib.rs b/substrate/srml/indices/src/lib.rs index 3cbc87b6dc..754d004c91 100644 --- a/substrate/srml/indices/src/lib.rs +++ b/substrate/srml/indices/src/lib.rs @@ -19,16 +19,9 @@ #![cfg_attr(not(feature = "std"), no_std)] -// We need these `extern crate` to be placed here otherwise there will be errors. -// TODO: https://github.com/paritytech/substrate/issues/1509 -#[macro_use] -extern crate srml_support as runtime_support; -extern crate parity_codec_derive; -extern crate parity_codec as codec; - use rstd::{prelude::*, result, marker::PhantomData}; -use codec::{Encode, Decode, Codec, Input, Output}; -use runtime_support::{StorageValue, StorageMap, Parameter}; +use parity_codec::{Encode, Decode, Codec, Input, Output}; +use srml_support::{StorageValue, StorageMap, Parameter, decl_module, decl_event, decl_storage}; use primitives::traits::{One, SimpleArithmetic, As, StaticLookup, Member}; use system::{IsDeadAccount, OnNewAccount}; diff --git a/substrate/srml/indices/src/mock.rs b/substrate/srml/indices/src/mock.rs index c8fe65151b..0123bc7fc8 100644 --- a/substrate/srml/indices/src/mock.rs +++ b/substrate/srml/indices/src/mock.rs @@ -23,6 +23,7 @@ use ref_thread_local::{ref_thread_local, RefThreadLocal}; use primitives::BuildStorage; use primitives::testing::{Digest, DigestItem, Header}; use substrate_primitives::{H256, Blake2Hasher}; +use srml_support::impl_outer_origin; use {runtime_io, system}; use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint}; diff --git a/substrate/srml/metadata/Cargo.toml b/substrate/srml/metadata/Cargo.toml index 9e9489af3f..f5f30d8b55 100644 --- a/substrate/srml/metadata/Cargo.toml +++ b/substrate/srml/metadata/Cargo.toml @@ -2,22 +2,23 @@ name = "srml-metadata" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -sr-std = { path = "../../core/sr-std", default-features = false } -substrate-primitives = { path = "../../core/primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } [features] default = ["std"] std = [ "parity-codec/std", "parity-codec-derive/std", - "sr-std/std", - "substrate-primitives/std", + "rstd/std", + "primitives/std", "serde", "serde_derive" ] diff --git a/substrate/srml/metadata/src/lib.rs b/substrate/srml/metadata/src/lib.rs index 1d1c65fb42..6b67b5adb5 100644 --- a/substrate/srml/metadata/src/lib.rs +++ b/substrate/srml/metadata/src/lib.rs @@ -22,21 +22,14 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[macro_use] -extern crate parity_codec_derive; -extern crate parity_codec as codec; -extern crate sr_std as rstd; -extern crate substrate_primitives as primitives; - #[cfg(feature = "std")] -extern crate serde; +use serde_derive::Serialize; #[cfg(feature = "std")] -#[macro_use] -extern crate serde_derive; - -use codec::{Encode, Output}; +use parity_codec::{Decode, Input}; #[cfg(feature = "std")] -use codec::{Decode, Input}; +use parity_codec_derive::Decode; +use parity_codec::{Encode, Output}; +use parity_codec_derive::Encode; use rstd::vec::Vec; #[cfg(feature = "std")] diff --git a/substrate/srml/session/Cargo.toml b/substrate/srml/session/Cargo.toml index 828c557bd9..3b9d8dd4f6 100644 --- a/substrate/srml/session/Cargo.toml +++ b/substrate/srml/session/Cargo.toml @@ -2,21 +2,24 @@ name = "srml-session" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } safe-mix = { version = "1.0", default-features = false} -substrate-primitives = { path = "../../core/primitives", default-features = false } parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-consensus = { path = "../consensus", default-features = false } -srml-system = { path = "../system", default-features = false } -srml-timestamp = { path = "../timestamp", default-features = false } +consensus = { package = "srml-consensus", path = "../consensus", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } +timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } + +[dev-dependencies] +substrate-primitives = { path = "../../core/primitives", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } [features] default = ["std"] @@ -25,12 +28,10 @@ std = [ "safe-mix/std", "parity-codec/std", "parity-codec-derive/std", - "substrate-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", "srml-support/std", - "sr-primitives/std", - "srml-consensus/std", - "srml-system/std", - "srml-timestamp/std" + "primitives/std", + "consensus/std", + "system/std", + "timestamp/std" ] diff --git a/substrate/srml/session/src/lib.rs b/substrate/srml/session/src/lib.rs index 4e22a59dbe..7f74811bfc 100644 --- a/substrate/srml/session/src/lib.rs +++ b/substrate/srml/session/src/lib.rs @@ -19,28 +19,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -extern crate sr_std as rstd; - -#[macro_use] -extern crate srml_support as runtime_support; - -extern crate parity_codec_derive; - -#[cfg(test)] -extern crate substrate_primitives; -#[cfg(test)] -extern crate sr_io as runtime_io; -extern crate parity_codec as codec; -extern crate sr_primitives as primitives; -extern crate srml_consensus as consensus; -extern crate srml_system as system; -extern crate srml_timestamp as timestamp; - use rstd::prelude::*; use primitives::traits::{As, Zero, One, Convert}; -use runtime_support::{StorageValue, StorageMap}; -use runtime_support::dispatch::Result; -use runtime_support::for_each_tuple; +use srml_support::{StorageValue, StorageMap, for_each_tuple, decl_module, decl_event, decl_storage}; +use srml_support::dispatch::Result; use system::ensure_signed; use rstd::ops::Mul; @@ -231,6 +213,7 @@ impl Module { #[cfg(test)] mod tests { use super::*; + use srml_support::{impl_outer_origin, assert_ok}; use runtime_io::with_externalities; use substrate_primitives::{H256, Blake2Hasher}; use primitives::BuildStorage; diff --git a/substrate/srml/staking/Cargo.toml b/substrate/srml/staking/Cargo.toml index a12deb92e3..640d9df205 100644 --- a/substrate/srml/staking/Cargo.toml +++ b/substrate/srml/staking/Cargo.toml @@ -2,6 +2,7 @@ name = "srml-staking" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" @@ -10,16 +11,18 @@ safe-mix = { version = "1.0", default-features = false} parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } substrate-keyring = { path = "../../core/keyring", optional = true } -substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } -srml-balances = { path = "../balances", default-features = false } -srml-consensus = { path = "../consensus", default-features = false } -srml-system = { path = "../system", default-features = false } -srml-session = { path = "../session", default-features = false } -srml-timestamp = { path = "../timestamp", default-features = false } +consensus = { package = "srml-consensus", path = "../consensus", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } +session = { package = "srml-session", path = "../session", default-features = false } + +[dev-dependencies] +substrate-primitives = { path = "../../core/primitives", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } +balances = { package = "srml-balances", path = "../balances", default-features = false } [features] default = ["std"] @@ -29,13 +32,9 @@ std = [ "substrate-keyring", "parity-codec/std", "parity-codec-derive/std", - "substrate-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", "srml-support/std", - "sr-primitives/std", - "srml-balances/std", - "srml-session/std", - "srml-system/std", - "srml-timestamp/std" + "primitives/std", + "session/std", + "system/std", ] diff --git a/substrate/srml/staking/src/lib.rs b/substrate/srml/staking/src/lib.rs index 6864f32989..b22190eae3 100644 --- a/substrate/srml/staking/src/lib.rs +++ b/substrate/srml/staking/src/lib.rs @@ -20,36 +20,12 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(feature = "std")] -extern crate serde; - -#[macro_use] -extern crate srml_support as runtime_support; - -extern crate sr_std as rstd; - -#[macro_use] -extern crate parity_codec_derive; - -extern crate parity_codec as codec; -extern crate sr_primitives as primitives; -extern crate srml_consensus as consensus; -extern crate srml_session as session; -extern crate srml_system as system; - -#[cfg(test)] -extern crate substrate_primitives; -#[cfg(test)] -extern crate sr_io as runtime_io; -#[cfg(test)] -extern crate srml_timestamp as timestamp; -#[cfg(test)] -extern crate srml_balances as balances; - use rstd::{prelude::*, cmp}; -use codec::HasCompact; -use runtime_support::{Parameter, StorageValue, StorageMap, dispatch::Result}; -use runtime_support::traits::{Currency, OnDilution, EnsureAccountLiquid, OnFreeBalanceZero}; +use parity_codec::HasCompact; +use parity_codec_derive::{Encode, Decode}; +use srml_support::{Parameter, StorageValue, StorageMap, dispatch::Result}; +use srml_support::{decl_module, decl_event, decl_storage, ensure}; +use srml_support::traits::{Currency, OnDilution, EnsureAccountLiquid, OnFreeBalanceZero}; use session::OnSessionChange; use primitives::Perbill; use primitives::traits::{Zero, One, Bounded, As, StaticLookup}; diff --git a/substrate/srml/staking/src/mock.rs b/substrate/srml/staking/src/mock.rs index 09d63d2701..5fc411e609 100644 --- a/substrate/srml/staking/src/mock.rs +++ b/substrate/srml/staking/src/mock.rs @@ -22,7 +22,8 @@ use primitives::{traits::IdentityLookup, BuildStorage, Perbill}; use primitives::testing::{Digest, DigestItem, Header, UintAuthorityId, ConvertUintAuthorityId}; use substrate_primitives::{H256, Blake2Hasher}; use runtime_io; -use {GenesisConfig, Module, Trait, consensus, session, system, timestamp, balances}; +use srml_support::impl_outer_origin; +use crate::{GenesisConfig, Module, Trait}; impl_outer_origin!{ pub enum Origin for Test {} diff --git a/substrate/srml/staking/src/tests.rs b/substrate/srml/staking/src/tests.rs index 79dfb98a60..ecc506ba3d 100644 --- a/substrate/srml/staking/src/tests.rs +++ b/substrate/srml/staking/src/tests.rs @@ -20,8 +20,9 @@ use super::*; use runtime_io::with_externalities; +use srml_support::{assert_ok, assert_noop}; use mock::{Balances, Session, Staking, System, Timestamp, Test, new_test_ext, Origin}; -use runtime_support::traits::Currency; +use srml_support::traits::Currency; #[test] fn note_null_offline_should_work() { diff --git a/substrate/srml/sudo/Cargo.toml b/substrate/srml/sudo/Cargo.toml index 3ce7f7373c..345b0b4a76 100644 --- a/substrate/srml/sudo/Cargo.toml +++ b/substrate/srml/sudo/Cargo.toml @@ -2,19 +2,22 @@ name = "srml-sudo" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } -substrate-primitives = { path = "../../core/primitives", default-features = false } sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } srml-support-procedural = { path = "../support/procedural" } -srml-system = { path = "../system", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } + +[dev-dependencies] +sr-io = { path = "../../core/sr-io", default-features = false } +substrate-primitives = { path = "../../core/primitives", default-features = false } [features] default = ["std"] @@ -23,9 +26,7 @@ std = [ "parity-codec/std", "parity-codec-derive/std", "sr-std/std", - "sr-io/std", "sr-primitives/std", - "substrate-primitives/std", "srml-support/std", - "srml-system/std", + "system/std", ] diff --git a/substrate/srml/sudo/src/lib.rs b/substrate/srml/sudo/src/lib.rs index 3ea2dda8d7..5ff7fee52d 100644 --- a/substrate/srml/sudo/src/lib.rs +++ b/substrate/srml/sudo/src/lib.rs @@ -19,22 +19,9 @@ #![cfg_attr(not(feature = "std"), no_std)] -extern crate sr_std; -#[cfg(test)] -extern crate sr_io; -#[cfg(test)] -extern crate substrate_primitives; -extern crate sr_primitives; -extern crate parity_codec_derive; -extern crate parity_codec as codec; -#[macro_use] -extern crate srml_support as support; - -extern crate srml_system as system; - use sr_std::prelude::*; use sr_primitives::traits::StaticLookup; -use support::{StorageValue, Parameter, Dispatchable}; +use srml_support::{StorageValue, Parameter, Dispatchable, decl_module, decl_event, decl_storage, ensure}; use system::ensure_signed; pub trait Trait: system::Trait { diff --git a/substrate/srml/system/Cargo.toml b/substrate/srml/system/Cargo.toml index e4f6bcee22..a45f4e7aea 100644 --- a/substrate/srml/system/Cargo.toml +++ b/substrate/srml/system/Cargo.toml @@ -2,29 +2,32 @@ name = "srml-system" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } +serde_derive = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } [features] default = ["std"] std = [ "serde/std", + "serde_derive", "safe-mix/std", "parity-codec/std", "parity-codec-derive/std", "substrate-primitives/std", - "sr-std/std", - "sr-io/std", + "rstd/std", + "runtime_io/std", "srml-support/std", - "sr-primitives/std", + "primitives/std", ] diff --git a/substrate/srml/system/src/lib.rs b/substrate/srml/system/src/lib.rs index 640a1d2bf4..eb75658214 100644 --- a/substrate/srml/system/src/lib.rs +++ b/substrate/srml/system/src/lib.rs @@ -19,32 +19,21 @@ #![cfg_attr(not(feature = "std"), no_std)] -extern crate substrate_primitives; - -#[cfg_attr(any(feature = "std", test), macro_use)] -extern crate sr_std as rstd; - -#[macro_use] -extern crate srml_support as runtime_support; - -#[macro_use] -extern crate parity_codec_derive; - -extern crate parity_codec as codec; -extern crate sr_io as runtime_io; -extern crate sr_primitives as primitives; -extern crate safe_mix; - +#[cfg(feature = "std")] +use serde_derive::Serialize; use rstd::prelude::*; +#[cfg(any(feature = "std", test))] +use rstd::map; use primitives::traits::{self, CheckEqual, SimpleArithmetic, SimpleBitOps, Zero, One, Bounded, Lookup, Hash, Member, MaybeDisplay, EnsureOrigin, Digest as DigestT, As, CurrentHeight, BlockNumberToHash, MaybeSerializeDebugButNotDeserialize, MaybeSerializeDebug, StaticLookup}; use substrate_primitives::storage::well_known_keys; -use runtime_support::{storage, StorageValue, StorageMap, Parameter}; +use srml_support::{storage, StorageValue, StorageMap, Parameter, decl_module, decl_event, decl_storage}; use safe_mix::TripletMix; +use parity_codec_derive::{Encode, Decode}; #[cfg(any(feature = "std", test))] -use codec::Encode; +use parity_codec::Encode; #[cfg(any(feature = "std", test))] use runtime_io::{twox_128, TestExternalities, Blake2Hasher}; @@ -75,8 +64,8 @@ impl IsDeadAccount for () { } /// Compute the extrinsics root of a list of extrinsics. -pub fn extrinsics_root(extrinsics: &[E]) -> H::Output { - extrinsics_data_root::(extrinsics.iter().map(codec::Encode::encode).collect()) +pub fn extrinsics_root(extrinsics: &[E]) -> H::Output { + extrinsics_data_root::(extrinsics.iter().map(parity_codec::Encode::encode).collect()) } /// Compute the extrinsics root of a list of extrinsics. @@ -226,7 +215,7 @@ decl_storage! { config(changes_trie_config): Option; build(|storage: &mut primitives::StorageMap, _: &mut primitives::ChildrenStorageMap, config: &GenesisConfig| { - use codec::Encode; + use parity_codec::Encode; storage.insert(well_known_keys::EXTRINSIC_INDEX.to_vec(), 0u32.encode()); @@ -466,6 +455,7 @@ mod tests { use primitives::BuildStorage; use primitives::traits::{BlakeTwo256, IdentityLookup}; use primitives::testing::{Digest, DigestItem, Header}; + use srml_support::impl_outer_origin; impl_outer_origin!{ pub enum Origin for Test where system = super {} diff --git a/substrate/srml/timestamp/Cargo.toml b/substrate/srml/timestamp/Cargo.toml index a56c4296e4..2da162c744 100644 --- a/substrate/srml/timestamp/Cargo.toml +++ b/substrate/srml/timestamp/Cargo.toml @@ -2,36 +2,34 @@ name = "srml-timestamp" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } parity-codec = { version = "3.0", default-features = false } parity-codec-derive = { version = "3.0", default-features = false } -substrate-primitives = { path = "../../core/primitives", default-features = false } -sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } -sr-primitives = { path = "../../core/sr-primitives", default-features = false } -substrate-inherents = { path = "../../core/inherents", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } +inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } srml-support = { path = "../support", default-features = false } -srml-system = { path = "../system", default-features = false } -srml-consensus = { path = "../consensus", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } +consensus = { package = "srml-consensus", path = "../consensus", default-features = false } [dev-dependencies] -sr-io = { path = "../../core/sr-io", default-features = true } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = true } +substrate-primitives = { path = "../../core/primitives", default-features = false } [features] default = ["std"] std = [ - "sr-std/std", - "sr-io/std", + "rstd/std", "srml-support/std", - "sr-primitives/std", - "srml-consensus/std", + "runtime_primitives/std", + "consensus/std", "serde/std", "parity-codec/std", "parity-codec-derive/std", - "substrate-primitives/std", - "srml-system/std", - "substrate-inherents/std", + "system/std", + "inherents/std", ] diff --git a/substrate/srml/timestamp/src/lib.rs b/substrate/srml/timestamp/src/lib.rs index 6b401b8446..d1d1f9f54e 100644 --- a/substrate/srml/timestamp/src/lib.rs +++ b/substrate/srml/timestamp/src/lib.rs @@ -32,28 +32,14 @@ #![cfg_attr(not(feature = "std"), no_std)] -extern crate sr_std as rstd; - -#[macro_use] -extern crate srml_support as runtime_support; - -#[cfg(test)] -extern crate substrate_primitives; -#[cfg(test)] -extern crate sr_io as runtime_io; -extern crate sr_primitives as runtime_primitives; -extern crate srml_system as system; -extern crate srml_consensus as consensus; -extern crate parity_codec as codec; -#[macro_use] -extern crate parity_codec_derive; -extern crate substrate_inherents as inherents; - -use runtime_support::{StorageValue, Parameter}; +#[cfg(feature = "std")] +use parity_codec_derive::Decode; +use parity_codec_derive::Encode; +use srml_support::{StorageValue, Parameter, decl_storage, decl_module}; +use srml_support::for_each_tuple; use runtime_primitives::traits::{As, SimpleArithmetic, Zero}; use system::ensure_inherent; use rstd::{result, ops::{Mul, Div}, cmp}; -use runtime_support::for_each_tuple; use inherents::{RuntimeString, InherentIdentifier, ProvideInherent, IsFatalError, InherentData}; #[cfg(feature = "std")] use inherents::ProvideInherentData; @@ -88,7 +74,7 @@ impl InherentError { #[cfg(feature = "std")] pub fn try_from(id: &InherentIdentifier, data: &[u8]) -> Option { if id == &INHERENT_IDENTIFIER { - ::decode(&mut &data[..]) + ::decode(&mut &data[..]) } else { None } @@ -268,6 +254,7 @@ impl ProvideInherent for Module { mod tests { use super::*; + use srml_support::{impl_outer_origin, assert_ok}; use runtime_io::{with_externalities, TestExternalities}; use substrate_primitives::H256; use runtime_primitives::BuildStorage;