mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 06:17:56 +00:00
Migrate srml-support to the 2018 edition (#1663)
This commit is contained in:
committed by
Gav Wood
parent
ddb44db551
commit
87f0f6fd8f
@@ -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
|
||||
|
||||
@@ -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.
|
||||
///
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[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};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<T: Trait> for enum Call where origin: T::Origin {}
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
StorageMethod : Option<u32>;
|
||||
}
|
||||
|
||||
@@ -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<HashMap<Vec<u8>, Vec<u8>>> {
|
||||
fn exists(&self, key: &[u8]) -> bool {
|
||||
@@ -600,7 +600,7 @@ mod tests {
|
||||
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 {
|
||||
// non-getters: pub / $default
|
||||
|
||||
@@ -923,7 +923,7 @@ mod test2 {
|
||||
|
||||
type PairOf<T> = (T, T);
|
||||
|
||||
decl_storage! {
|
||||
crate::decl_storage! {
|
||||
trait Store for Module<T: Trait> as TestStorage {
|
||||
SingleDef : u32;
|
||||
PairDef : PairOf<u32>;
|
||||
@@ -955,7 +955,7 @@ mod test3 {
|
||||
decl_module! {
|
||||
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 {
|
||||
Foo get(foo) config(initial_foo): u32;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user