diff --git a/substrate/srml/support/Cargo.toml b/substrate/srml/support/Cargo.toml index f23dcbb079..58ed26f1e1 100644 --- a/substrate/srml/support/Cargo.toml +++ b/substrate/srml/support/Cargo.toml @@ -2,17 +2,19 @@ name = "srml-support" version = "0.1.0" authors = ["Parity Technologies "] +edition = "2018" [dependencies] hex-literal = { version = "0.1.0", optional = true } 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 } srml-metadata = { path = "../metadata", default-features = false } sr-std = { path = "../../core/sr-std", default-features = false } -sr-io = { path = "../../core/sr-io", default-features = false } +runtime_io = { package = "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 } +inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } srml-support-procedural = { path = "./procedural" } mashup = "0.1.7" once_cell = { version = "0.1.6", default-features = false, optional = true } @@ -20,7 +22,6 @@ paste = "0.1" [dev-dependencies] pretty_assertions = "0.5.1" -parity-codec-derive = { version = "3.0" } [features] default = ["std"] @@ -29,12 +30,12 @@ std = [ "once_cell", "serde/std", "serde_derive", - "sr-io/std", + "runtime_io/std", "parity-codec/std", "sr-std/std", "sr-primitives/std", "srml-metadata/std", - "substrate-inherents/std", + "inherents/std", ] nightly = [] strict = [] diff --git a/substrate/srml/support/src/dispatch.rs b/substrate/srml/support/src/dispatch.rs index 8ac54aabf2..e3a8e6c8e3 100644 --- a/substrate/srml/support/src/dispatch.rs +++ b/substrate/srml/support/src/dispatch.rs @@ -17,11 +17,11 @@ //! Dispatch system. Contains a macro for defining runtime modules and //! generating values representing lazy module function calls. -pub use rstd::prelude::{Vec, Clone, Eq, PartialEq}; +pub use crate::rstd::prelude::{Vec, Clone, Eq, PartialEq}; #[cfg(feature = "std")] pub use std::fmt; -pub use rstd::result; -pub use codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef}; +pub use crate::rstd::result; +pub use crate::codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef}; pub use srml_metadata::{ FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata, OuterDispatchMetadata, OuterDispatchCall diff --git a/substrate/srml/support/src/double_map.rs b/substrate/srml/support/src/double_map.rs index afc707b4f1..fb5f4febe0 100644 --- a/substrate/srml/support/src/double_map.rs +++ b/substrate/srml/support/src/double_map.rs @@ -16,9 +16,9 @@ //! An implementation of double map backed by storage. -use rstd::prelude::*; -use codec::{Codec, Encode}; -use storage::unhashed; +use crate::rstd::prelude::*; +use crate::codec::{Codec, Encode}; +use crate::storage::unhashed; /// An implementation of a map with a two keys. /// diff --git a/substrate/srml/support/src/event.rs b/substrate/srml/support/src/event.rs index a3eb9ccee3..59abe95f64 100644 --- a/substrate/srml/support/src/event.rs +++ b/substrate/srml/support/src/event.rs @@ -101,7 +101,7 @@ macro_rules! decl_event { )* } ) => { - __decl_generic_event!( + $crate::__decl_generic_event!( $( #[ $attr ] )*; $evt_generic_param; $( $( $generic_rename = )* <$generic as $trait>::$trait_type ),*; @@ -117,7 +117,7 @@ macro_rules! decl_event { } ) => { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. - #[derive(Clone, PartialEq, Eq, Encode, Decode)] + #[derive(Clone, PartialEq, Eq, $crate::parity_codec_derive::Encode, $crate::parity_codec_derive::Decode)] #[cfg_attr(feature = "std", derive(Debug))] $(#[$attr])* pub enum Event { @@ -131,7 +131,7 @@ macro_rules! decl_event { impl Event { #[allow(dead_code)] pub fn metadata() -> &'static [ $crate::event::EventMetadata ] { - __events_to_metadata!(; $( $events )* ) + $crate::__events_to_metadata!(; $( $events )* ) } } } @@ -218,7 +218,7 @@ macro_rules! __decl_generic_event { ) => { pub type Event<$event_generic_param> = RawEvent<$( <$generic as $trait>::$trait_type ),*>; // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. - #[derive(Clone, PartialEq, Eq, Encode, Decode)] + #[derive(Clone, PartialEq, Eq, $crate::parity_codec_derive::Encode, $crate::parity_codec_derive::Decode)] #[cfg_attr(feature = "std", derive(Debug))] $(#[$attr])* pub enum RawEvent<$( $generic_param ),*> { @@ -232,7 +232,7 @@ macro_rules! __decl_generic_event { impl<$( $generic_param ),*> RawEvent<$( $generic_param ),*> { #[allow(dead_code)] pub fn metadata() -> &'static [$crate::event::EventMetadata] { - __events_to_metadata!(; $( $events )* ) + $crate::__events_to_metadata!(; $( $events )* ) } } } @@ -375,7 +375,7 @@ macro_rules! impl_outer_event { $( $module_name:ident::Event $( <$generic_param:ident> )*, )*; ) => { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. - #[derive(Clone, PartialEq, Eq, Encode, Decode)] + #[derive(Clone, PartialEq, Eq, $crate::parity_codec_derive::Encode, $crate::parity_codec_derive::Decode)] #[cfg_attr(feature = "std", derive(Debug))] $(#[$attr])* #[allow(non_camel_case_types)] @@ -454,6 +454,7 @@ macro_rules! __impl_outer_event_json_metadata { mod tests { use super::*; use serde_derive::Serialize; + use parity_codec_derive::{Encode, Decode}; mod system { pub trait Trait { diff --git a/substrate/srml/support/src/hashable.rs b/substrate/srml/support/src/hashable.rs index 23d0ee976a..3d8b706b89 100644 --- a/substrate/srml/support/src/hashable.rs +++ b/substrate/srml/support/src/hashable.rs @@ -16,7 +16,7 @@ //! Hashable trait. -use codec::Codec; +use crate::codec::Codec; use runtime_io::{blake2_256, twox_128, twox_256}; pub trait Hashable: Sized { diff --git a/substrate/srml/support/src/inherent.rs b/substrate/srml/support/src/inherent.rs index 0ae48143df..671059ebe1 100644 --- a/substrate/srml/support/src/inherent.rs +++ b/substrate/srml/support/src/inherent.rs @@ -15,9 +15,9 @@ // along with Substrate. If not, see . #[doc(hidden)] -pub use rstd::vec::Vec; +pub use crate::rstd::vec::Vec; #[doc(hidden)] -pub use runtime_primitives::traits::{Block as BlockT, Extrinsic}; +pub use crate::runtime_primitives::traits::{Block as BlockT, Extrinsic}; #[doc(hidden)] pub use inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError}; diff --git a/substrate/srml/support/src/lib.rs b/substrate/srml/support/src/lib.rs index 176a8dde4d..2f8fbd763d 100644 --- a/substrate/srml/support/src/lib.rs +++ b/substrate/srml/support/src/lib.rs @@ -20,37 +20,19 @@ #![cfg_attr(not(feature = "std"), feature(alloc))] #[cfg(feature = "std")] -pub extern crate serde; - +pub use serde; #[doc(hidden)] -pub extern crate sr_std as rstd; -extern crate sr_io as runtime_io; +pub use sr_std as rstd; #[doc(hidden)] -pub extern crate sr_primitives as runtime_primitives; -extern crate srml_metadata; - -extern crate mashup; -#[cfg_attr(test, macro_use)] -extern crate srml_support_procedural; -extern crate substrate_inherents as inherents; - -#[cfg(test)] -#[macro_use] -extern crate pretty_assertions; -#[cfg(feature = "std")] -extern crate serde_derive; -#[cfg(test)] -#[macro_use] -extern crate parity_codec_derive; - +pub use parity_codec as codec; #[doc(hidden)] -pub extern crate parity_codec as codec; - +pub use parity_codec_derive; #[cfg(feature = "std")] #[doc(hidden)] -pub extern crate once_cell; - -pub extern crate paste; +pub use once_cell; +#[doc(hidden)] +pub use paste; +pub use sr_primitives as runtime_primitives; pub use self::storage::generator::Storage as GenericStorage; diff --git a/substrate/srml/support/src/metadata.rs b/substrate/srml/support/src/metadata.rs index 5a958558fb..8fad426d0b 100644 --- a/substrate/srml/support/src/metadata.rs +++ b/substrate/srml/support/src/metadata.rs @@ -238,7 +238,8 @@ mod tests { StorageFunctionMetadata, ModuleMetadata, RuntimeMetadataPrefixed }; - use codec::{Decode, Encode}; + use crate::codec::{Encode, Decode}; + use parity_codec_derive::{Decode, Encode}; mod system { @@ -278,7 +279,7 @@ mod tests { } mod event_module { - use dispatch::Result; + use crate::dispatch::Result; pub trait Trait { type Origin; @@ -319,7 +320,7 @@ mod tests { pub struct Module for enum Call where origin: T::Origin {} } - decl_storage! { + crate::decl_storage! { trait Store for Module as TestStorage { StorageMethod : Option; } diff --git a/substrate/srml/support/src/storage/generator.rs b/substrate/srml/support/src/storage/generator.rs index a1dbfff4f0..4df4d06a6a 100644 --- a/substrate/srml/support/src/storage/generator.rs +++ b/substrate/srml/support/src/storage/generator.rs @@ -46,12 +46,12 @@ //!# fn main() { } //! ``` -use codec; -use rstd::vec::Vec; +use crate::codec; +use crate::rstd::vec::Vec; #[doc(hidden)] -pub use rstd::borrow::Borrow; +pub use crate::rstd::borrow::Borrow; #[doc(hidden)] -pub use rstd::marker::PhantomData; +pub use crate::rstd::marker::PhantomData; pub use srml_metadata::{ DecodeDifferent, StorageMetadata, StorageFunctionMetadata, @@ -525,7 +525,7 @@ mod tests { use std::cell::RefCell; use codec::Codec; use super::*; - use rstd::marker::PhantomData; + use crate::rstd::marker::PhantomData; impl Storage for RefCell, Vec>> { fn exists(&self, key: &[u8]) -> bool { @@ -600,7 +600,7 @@ mod tests { pub struct Module for enum Call where origin: T::Origin {} } - decl_storage! { + crate::decl_storage! { trait Store for Module as TestStorage { // non-getters: pub / $default @@ -923,7 +923,7 @@ mod test2 { type PairOf = (T, T); - decl_storage! { + crate::decl_storage! { trait Store for Module as TestStorage { SingleDef : u32; PairDef : PairOf; @@ -955,7 +955,7 @@ mod test3 { decl_module! { pub struct Module for enum Call where origin: T::Origin {} } - decl_storage! { + crate::decl_storage! { trait Store for Module as Test { Foo get(foo) config(initial_foo): u32; } diff --git a/substrate/srml/support/src/storage/mod.rs b/substrate/srml/support/src/storage/mod.rs index c788c7c402..96af955a64 100644 --- a/substrate/srml/support/src/storage/mod.rs +++ b/substrate/srml/support/src/storage/mod.rs @@ -16,10 +16,10 @@ //! Stuff to do with the runtime's storage. -use rstd::prelude::*; -use rstd::borrow::Borrow; +use crate::rstd::prelude::*; +use crate::rstd::borrow::Borrow; use runtime_io::{self, twox_128}; -use codec::{Codec, Decode, KeyedVec, Input}; +use crate::codec::{Codec, Decode, KeyedVec, Input}; #[macro_use] pub mod generator; @@ -32,7 +32,7 @@ struct IncrementalInput<'a> { impl<'a> Input for IncrementalInput<'a> { fn read(&mut self, into: &mut [u8]) -> usize { let len = runtime_io::read_storage(self.key, into, self.pos).unwrap_or(0); - let read = ::rstd::cmp::min(len, into.len()); + let read = crate::rstd::cmp::min(len, into.len()); self.pos += read; read } @@ -123,7 +123,7 @@ pub fn put_raw(key: &[u8], value: &[u8]) { /// The underlying runtime storage. pub struct RuntimeStorage; -impl ::GenericStorage for RuntimeStorage { +impl crate::GenericStorage for RuntimeStorage { fn exists(&self, key: &[u8]) -> bool { super::storage::exists(key) } @@ -396,7 +396,7 @@ pub trait StorageVec { } pub mod unhashed { - use rstd::borrow::Borrow; + use crate::rstd::borrow::Borrow; use super::{runtime_io, Codec, Decode, KeyedVec, Vec, IncrementalInput}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.