mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-27 23:21:05 +00:00
5d64be26c3
* Move module metadata from json string to custom metadata * Revisit the metadata structures 1. Move the structures into the metadata crate. 2. Switch to using Cow/MaybeOwnedArray to support Encode/Decode * Adapt to new metadata structures * Convert event json metadata to new metadata structures * Convert storage json metadata to new metadata structures * Convert runtime metadata from json to new metadata structs * Implements new metadata structures in client and runtime * Fixes errors on `no_std` * Fixes errors after rebasing master * Do not use `Cow` anymore in metadata Also replace `String` with our own type definition `StringBuf`. This fixes compilation on `no_std`. * Wrap `RuntimeMetadata` in `RuntimeMetadataVersioned` to support versioning * Move metadata into `srml` and make core unaware of the implementation
130 lines
2.7 KiB
Rust
130 lines
2.7 KiB
Rust
// Copyright 2017 Parity Technologies (UK) Ltd.
|
|
// This file is part of Substrate.
|
|
|
|
// Substrate is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Substrate is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// tag::description[]
|
|
//! Support code for the runtime.
|
|
// end::description[]
|
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
extern crate alloc;
|
|
|
|
#[cfg(feature = "std")]
|
|
extern crate serde;
|
|
|
|
extern crate sr_std as rstd;
|
|
extern crate sr_io as runtime_io;
|
|
extern crate substrate_primitives as primitives;
|
|
extern crate substrate_metadata;
|
|
|
|
extern crate mashup;
|
|
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate pretty_assertions;
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate parity_codec_derive;
|
|
|
|
#[doc(hidden)]
|
|
pub extern crate parity_codec as codec;
|
|
pub use self::storage::generator::Storage as GenericStorage;
|
|
|
|
#[cfg(feature = "std")]
|
|
pub mod alloc {
|
|
pub use std::boxed;
|
|
pub use std::vec;
|
|
}
|
|
|
|
#[macro_use]
|
|
pub mod dispatch;
|
|
#[macro_use]
|
|
pub mod storage;
|
|
mod hashable;
|
|
#[macro_use]
|
|
pub mod event;
|
|
#[macro_use]
|
|
pub mod metadata;
|
|
#[macro_use]
|
|
mod origin;
|
|
#[macro_use]
|
|
mod runtime;
|
|
|
|
pub use self::storage::{StorageVec, StorageList, StorageValue, StorageMap};
|
|
pub use self::hashable::Hashable;
|
|
pub use self::dispatch::{Parameter, Dispatchable, Callable, IsSubType};
|
|
pub use runtime_io::print;
|
|
|
|
|
|
#[macro_export]
|
|
macro_rules! fail {
|
|
( $y:expr ) => {{
|
|
return Err($y);
|
|
}}
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! ensure {
|
|
( $x:expr, $y:expr ) => {{
|
|
if !$x {
|
|
fail!($y);
|
|
}
|
|
}}
|
|
}
|
|
|
|
#[macro_export]
|
|
#[cfg(feature = "std")]
|
|
macro_rules! assert_noop {
|
|
( $x:expr , $y:expr ) => {
|
|
let h = runtime_io::storage_root();
|
|
assert_err!($x, $y);
|
|
assert_eq!(h, runtime_io::storage_root());
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
#[cfg(feature = "std")]
|
|
macro_rules! assert_err {
|
|
( $x:expr , $y:expr ) => {
|
|
assert_eq!($x, Err($y));
|
|
}
|
|
}
|
|
|
|
#[macro_export]
|
|
#[cfg(feature = "std")]
|
|
macro_rules! assert_ok {
|
|
( $x:expr ) => {
|
|
assert_eq!($x, Ok(()));
|
|
};
|
|
( $x:expr, $y:expr ) => {
|
|
assert_eq!($x, Ok($y));
|
|
}
|
|
}
|
|
|
|
/// The void type - it cannot exist.
|
|
// Oh rust, you crack me up...
|
|
#[derive(Clone, Eq, PartialEq)]
|
|
#[cfg_attr(feature = "std", derive(Debug))]
|
|
pub enum Void {}
|
|
|
|
#[doc(hidden)]
|
|
pub use mashup::*;
|