mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 07:31:08 +00:00
Migrate srml-support to the 2018 edition (#1663)
This commit is contained in:
committed by
Gav Wood
parent
ddb44db551
commit
87f0f6fd8f
@@ -2,17 +2,19 @@
|
|||||||
name = "srml-support"
|
name = "srml-support"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hex-literal = { version = "0.1.0", optional = true }
|
hex-literal = { version = "0.1.0", optional = true }
|
||||||
serde = { version = "1.0", default-features = false }
|
serde = { version = "1.0", default-features = false }
|
||||||
serde_derive = { version = "1.0", optional = true }
|
serde_derive = { version = "1.0", optional = true }
|
||||||
parity-codec = { version = "3.0", default-features = false }
|
parity-codec = { version = "3.0", default-features = false }
|
||||||
|
parity-codec-derive = { version = "3.0", default-features = false }
|
||||||
srml-metadata = { path = "../metadata", default-features = false }
|
srml-metadata = { path = "../metadata", default-features = false }
|
||||||
sr-std = { path = "../../core/sr-std", 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 }
|
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" }
|
srml-support-procedural = { path = "./procedural" }
|
||||||
mashup = "0.1.7"
|
mashup = "0.1.7"
|
||||||
once_cell = { version = "0.1.6", default-features = false, optional = true }
|
once_cell = { version = "0.1.6", default-features = false, optional = true }
|
||||||
@@ -20,7 +22,6 @@ paste = "0.1"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "0.5.1"
|
pretty_assertions = "0.5.1"
|
||||||
parity-codec-derive = { version = "3.0" }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
@@ -29,12 +30,12 @@ std = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"serde/std",
|
"serde/std",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"sr-io/std",
|
"runtime_io/std",
|
||||||
"parity-codec/std",
|
"parity-codec/std",
|
||||||
"sr-std/std",
|
"sr-std/std",
|
||||||
"sr-primitives/std",
|
"sr-primitives/std",
|
||||||
"srml-metadata/std",
|
"srml-metadata/std",
|
||||||
"substrate-inherents/std",
|
"inherents/std",
|
||||||
]
|
]
|
||||||
nightly = []
|
nightly = []
|
||||||
strict = []
|
strict = []
|
||||||
|
|||||||
@@ -17,11 +17,11 @@
|
|||||||
//! Dispatch system. Contains a macro for defining runtime modules and
|
//! Dispatch system. Contains a macro for defining runtime modules and
|
||||||
//! generating values representing lazy module function calls.
|
//! 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")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::fmt;
|
pub use std::fmt;
|
||||||
pub use rstd::result;
|
pub use crate::rstd::result;
|
||||||
pub use codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
|
pub use crate::codec::{Codec, Decode, Encode, Input, Output, HasCompact, EncodeAsRef};
|
||||||
pub use srml_metadata::{
|
pub use srml_metadata::{
|
||||||
FunctionMetadata, DecodeDifferent, DecodeDifferentArray,
|
FunctionMetadata, DecodeDifferent, DecodeDifferentArray,
|
||||||
FunctionArgumentMetadata, OuterDispatchMetadata, OuterDispatchCall
|
FunctionArgumentMetadata, OuterDispatchMetadata, OuterDispatchCall
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
//! An implementation of double map backed by storage.
|
//! An implementation of double map backed by storage.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use crate::rstd::prelude::*;
|
||||||
use codec::{Codec, Encode};
|
use crate::codec::{Codec, Encode};
|
||||||
use storage::unhashed;
|
use crate::storage::unhashed;
|
||||||
|
|
||||||
/// An implementation of a map with a two keys.
|
/// An implementation of a map with a two keys.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ macro_rules! decl_event {
|
|||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
__decl_generic_event!(
|
$crate::__decl_generic_event!(
|
||||||
$( #[ $attr ] )*;
|
$( #[ $attr ] )*;
|
||||||
$evt_generic_param;
|
$evt_generic_param;
|
||||||
$( $( $generic_rename = )* <$generic as $trait>::$trait_type ),*;
|
$( $( $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.
|
// 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))]
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
@@ -131,7 +131,7 @@ macro_rules! decl_event {
|
|||||||
impl Event {
|
impl Event {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn metadata() -> &'static [ $crate::event::EventMetadata ] {
|
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 ),*>;
|
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.
|
// 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))]
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub enum RawEvent<$( $generic_param ),*> {
|
pub enum RawEvent<$( $generic_param ),*> {
|
||||||
@@ -232,7 +232,7 @@ macro_rules! __decl_generic_event {
|
|||||||
impl<$( $generic_param ),*> RawEvent<$( $generic_param ),*> {
|
impl<$( $generic_param ),*> RawEvent<$( $generic_param ),*> {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn metadata() -> &'static [$crate::event::EventMetadata] {
|
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> )*, )*;
|
$( $module_name:ident::Event $( <$generic_param:ident> )*, )*;
|
||||||
) => {
|
) => {
|
||||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
// 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))]
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
@@ -454,6 +454,7 @@ macro_rules! __impl_outer_event_json_metadata {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use serde_derive::Serialize;
|
use serde_derive::Serialize;
|
||||||
|
use parity_codec_derive::{Encode, Decode};
|
||||||
|
|
||||||
mod system {
|
mod system {
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Hashable trait.
|
//! Hashable trait.
|
||||||
|
|
||||||
use codec::Codec;
|
use crate::codec::Codec;
|
||||||
use runtime_io::{blake2_256, twox_128, twox_256};
|
use runtime_io::{blake2_256, twox_128, twox_256};
|
||||||
|
|
||||||
pub trait Hashable: Sized {
|
pub trait Hashable: Sized {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use rstd::vec::Vec;
|
pub use crate::rstd::vec::Vec;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use runtime_primitives::traits::{Block as BlockT, Extrinsic};
|
pub use crate::runtime_primitives::traits::{Block as BlockT, Extrinsic};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError};
|
pub use inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError};
|
||||||
|
|
||||||
|
|||||||
@@ -20,37 +20,19 @@
|
|||||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub extern crate serde;
|
pub use serde;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern crate sr_std as rstd;
|
pub use sr_std as rstd;
|
||||||
extern crate sr_io as runtime_io;
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern crate sr_primitives as runtime_primitives;
|
pub use parity_codec as codec;
|
||||||
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;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern crate parity_codec as codec;
|
pub use parity_codec_derive;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub extern crate once_cell;
|
pub use once_cell;
|
||||||
|
#[doc(hidden)]
|
||||||
pub extern crate paste;
|
pub use paste;
|
||||||
|
pub use sr_primitives as runtime_primitives;
|
||||||
|
|
||||||
pub use self::storage::generator::Storage as GenericStorage;
|
pub use self::storage::generator::Storage as GenericStorage;
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,8 @@ mod tests {
|
|||||||
StorageFunctionMetadata,
|
StorageFunctionMetadata,
|
||||||
ModuleMetadata, RuntimeMetadataPrefixed
|
ModuleMetadata, RuntimeMetadataPrefixed
|
||||||
};
|
};
|
||||||
use codec::{Decode, Encode};
|
use crate::codec::{Encode, Decode};
|
||||||
|
use parity_codec_derive::{Decode, Encode};
|
||||||
|
|
||||||
|
|
||||||
mod system {
|
mod system {
|
||||||
@@ -278,7 +279,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod event_module {
|
mod event_module {
|
||||||
use dispatch::Result;
|
use crate::dispatch::Result;
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
type Origin;
|
type Origin;
|
||||||
@@ -319,7 +320,7 @@ mod tests {
|
|||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
crate::decl_storage! {
|
||||||
trait Store for Module<T: Trait> as TestStorage {
|
trait Store for Module<T: Trait> as TestStorage {
|
||||||
StorageMethod : Option<u32>;
|
StorageMethod : Option<u32>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,12 @@
|
|||||||
//!# fn main() { }
|
//!# fn main() { }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use codec;
|
use crate::codec;
|
||||||
use rstd::vec::Vec;
|
use crate::rstd::vec::Vec;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use rstd::borrow::Borrow;
|
pub use crate::rstd::borrow::Borrow;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use rstd::marker::PhantomData;
|
pub use crate::rstd::marker::PhantomData;
|
||||||
|
|
||||||
pub use srml_metadata::{
|
pub use srml_metadata::{
|
||||||
DecodeDifferent, StorageMetadata, StorageFunctionMetadata,
|
DecodeDifferent, StorageMetadata, StorageFunctionMetadata,
|
||||||
@@ -525,7 +525,7 @@ mod tests {
|
|||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use codec::Codec;
|
use codec::Codec;
|
||||||
use super::*;
|
use super::*;
|
||||||
use rstd::marker::PhantomData;
|
use crate::rstd::marker::PhantomData;
|
||||||
|
|
||||||
impl Storage for RefCell<HashMap<Vec<u8>, Vec<u8>>> {
|
impl Storage for RefCell<HashMap<Vec<u8>, Vec<u8>>> {
|
||||||
fn exists(&self, key: &[u8]) -> bool {
|
fn exists(&self, key: &[u8]) -> bool {
|
||||||
@@ -600,7 +600,7 @@ mod tests {
|
|||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
crate::decl_storage! {
|
||||||
trait Store for Module<T: Trait> as TestStorage {
|
trait Store for Module<T: Trait> as TestStorage {
|
||||||
// non-getters: pub / $default
|
// non-getters: pub / $default
|
||||||
|
|
||||||
@@ -923,7 +923,7 @@ mod test2 {
|
|||||||
|
|
||||||
type PairOf<T> = (T, T);
|
type PairOf<T> = (T, T);
|
||||||
|
|
||||||
decl_storage! {
|
crate::decl_storage! {
|
||||||
trait Store for Module<T: Trait> as TestStorage {
|
trait Store for Module<T: Trait> as TestStorage {
|
||||||
SingleDef : u32;
|
SingleDef : u32;
|
||||||
PairDef : PairOf<u32>;
|
PairDef : PairOf<u32>;
|
||||||
@@ -955,7 +955,7 @@ mod test3 {
|
|||||||
decl_module! {
|
decl_module! {
|
||||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||||
}
|
}
|
||||||
decl_storage! {
|
crate::decl_storage! {
|
||||||
trait Store for Module<T: Trait> as Test {
|
trait Store for Module<T: Trait> as Test {
|
||||||
Foo get(foo) config(initial_foo): u32;
|
Foo get(foo) config(initial_foo): u32;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
//! Stuff to do with the runtime's storage.
|
//! Stuff to do with the runtime's storage.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use crate::rstd::prelude::*;
|
||||||
use rstd::borrow::Borrow;
|
use crate::rstd::borrow::Borrow;
|
||||||
use runtime_io::{self, twox_128};
|
use runtime_io::{self, twox_128};
|
||||||
use codec::{Codec, Decode, KeyedVec, Input};
|
use crate::codec::{Codec, Decode, KeyedVec, Input};
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod generator;
|
pub mod generator;
|
||||||
@@ -32,7 +32,7 @@ struct IncrementalInput<'a> {
|
|||||||
impl<'a> Input for IncrementalInput<'a> {
|
impl<'a> Input for IncrementalInput<'a> {
|
||||||
fn read(&mut self, into: &mut [u8]) -> usize {
|
fn read(&mut self, into: &mut [u8]) -> usize {
|
||||||
let len = runtime_io::read_storage(self.key, into, self.pos).unwrap_or(0);
|
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;
|
self.pos += read;
|
||||||
read
|
read
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ pub fn put_raw(key: &[u8], value: &[u8]) {
|
|||||||
/// The underlying runtime storage.
|
/// The underlying runtime storage.
|
||||||
pub struct RuntimeStorage;
|
pub struct RuntimeStorage;
|
||||||
|
|
||||||
impl ::GenericStorage for RuntimeStorage {
|
impl crate::GenericStorage for RuntimeStorage {
|
||||||
fn exists(&self, key: &[u8]) -> bool {
|
fn exists(&self, key: &[u8]) -> bool {
|
||||||
super::storage::exists(key)
|
super::storage::exists(key)
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ pub trait StorageVec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod unhashed {
|
pub mod unhashed {
|
||||||
use rstd::borrow::Borrow;
|
use crate::rstd::borrow::Borrow;
|
||||||
use super::{runtime_io, Codec, Decode, KeyedVec, Vec, IncrementalInput};
|
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.
|
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
|
||||||
|
|||||||
Reference in New Issue
Block a user