mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 11:47:59 +00:00
9063d1acae
* Move `initialise_block` into `Core` trait as it is crucial calling the API functions * Switch to first version of new runtime API implementation * Fixes bug in tests * Reenable asserts * Directly use the `TestAPI` in the tests * Start improving the api traits :100644 100644 898aadc7 49217199 M Cargo.lock :100644 10064461570436465ed664 M core/client/src/backend.rs :100644 100644 5d0c886b 64d710fd M core/client/src/block_builder.rs :100644 100644 c447855e 5ecbe474 M core/client/src/client.rs :100644 100644139cef13f90dbf3d M core/client/src/error.rs :100644 100644 2800c503 3298e66a M core/client/src/runtime_api.rs :100644 100644affa1c5c809b08bc M core/primitives/src/lib.rs :100644 1006442877dfa9d5547413 M core/sr-api/Cargo.toml :100644 100644 9a49784d 6a625a03 M core/sr-api/src/lib.rs :100644 100644 7c28e1c7 a1a444a9 M core/sr-primitives/src/traits.rs :100644 1006442e113ab6dcc01a6d M srml/metadata/Cargo.toml :100644 100644ea722a700809531aM srml/metadata/src/lib.rs * Refactoring * Move `sr-api` into client and more refactoring * Fixes tests * Some documentation and cleanup * Fixes compilation after rebase * More refactoring and more documentation * Makes `substrate-client` compilable on `wasm` On `wasm` it basically just exports the runtime api stuff. * Fixes grumbles * Updates wasm files after rebasing the master * Remove TODO comment * Remove whitespaces * Fixes after rebasing master * Another rebase, another fix commit
159 lines
3.7 KiB
Rust
159 lines
3.7 KiB
Rust
// Copyright 2017-2018 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/>.
|
|
|
|
//! Shareable Substrate types.
|
|
|
|
#![warn(missing_docs)]
|
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
|
|
|
#[macro_use]
|
|
extern crate crunchy;
|
|
#[macro_use]
|
|
extern crate fixed_hash;
|
|
#[macro_use]
|
|
extern crate uint as uint_crate;
|
|
#[macro_use]
|
|
extern crate parity_codec_derive;
|
|
|
|
extern crate rustc_hex;
|
|
extern crate byteorder;
|
|
extern crate parity_codec as codec;
|
|
|
|
#[cfg(feature = "std")]
|
|
extern crate serde;
|
|
#[cfg(feature = "std")]
|
|
extern crate twox_hash;
|
|
|
|
#[cfg(feature = "std")]
|
|
extern crate blake2_rfc;
|
|
#[cfg(feature = "std")]
|
|
extern crate ring;
|
|
#[cfg(feature = "std")]
|
|
extern crate base58;
|
|
#[cfg(feature = "std")]
|
|
extern crate untrusted;
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate hex_literal;
|
|
|
|
#[cfg(feature = "std")]
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
#[cfg(feature = "std")]
|
|
extern crate core;
|
|
#[cfg(feature = "std")]
|
|
extern crate wasmi;
|
|
extern crate hash_db;
|
|
extern crate hash256_std_hasher;
|
|
|
|
extern crate sr_std as rstd;
|
|
|
|
#[cfg(test)]
|
|
extern crate substrate_serializer;
|
|
|
|
#[cfg(test)]
|
|
extern crate heapsize;
|
|
|
|
#[cfg(test)]
|
|
#[macro_use]
|
|
extern crate pretty_assertions;
|
|
|
|
#[macro_export]
|
|
macro_rules! map {
|
|
($( $name:expr => $value:expr ),*) => (
|
|
vec![ $( ( $name, $value ) ),* ].into_iter().collect()
|
|
)
|
|
}
|
|
|
|
use rstd::prelude::*;
|
|
use rstd::ops::Deref;
|
|
|
|
#[cfg(feature = "std")]
|
|
pub mod bytes;
|
|
#[cfg(feature = "std")]
|
|
pub mod hashing;
|
|
#[cfg(feature = "std")]
|
|
pub use hashing::{blake2_256, twox_128, twox_256};
|
|
#[cfg(feature = "std")]
|
|
pub mod hexdisplay;
|
|
#[cfg(feature = "std")]
|
|
pub mod ed25519;
|
|
|
|
pub mod u32_trait;
|
|
|
|
pub mod hash;
|
|
mod hasher;
|
|
pub mod sandbox;
|
|
pub mod storage;
|
|
pub mod uint;
|
|
mod authority_id;
|
|
mod changes_trie;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
pub use self::hash::{H160, H256, H512, convert_hash};
|
|
pub use self::uint::U256;
|
|
pub use authority_id::AuthorityId;
|
|
pub use changes_trie::ChangesTrieConfiguration;
|
|
|
|
pub use hash_db::Hasher;
|
|
// Switch back to Blake after PoC-3 is out
|
|
// pub use self::hasher::blake::BlakeHasher;
|
|
pub use self::hasher::blake2::Blake2Hasher;
|
|
|
|
/// A 512-bit value interpreted as a signature.
|
|
pub type Signature = hash::H512;
|
|
|
|
/// Hex-serialised shim for `Vec<u8>`.
|
|
#[derive(PartialEq, Eq, Clone)]
|
|
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug, Hash, PartialOrd, Ord))]
|
|
pub struct Bytes(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8>);
|
|
|
|
impl From<Vec<u8>> for Bytes {
|
|
fn from(s: Vec<u8>) -> Self { Bytes(s) }
|
|
}
|
|
|
|
impl From<OpaqueMetadata> for Bytes {
|
|
fn from(s: OpaqueMetadata) -> Self { Bytes(s.0) }
|
|
}
|
|
|
|
impl Deref for Bytes {
|
|
type Target = [u8];
|
|
fn deref(&self) -> &[u8] { &self.0[..] }
|
|
}
|
|
|
|
/// Stores the encoded `RuntimeMetadata` for the native side as opaque type.
|
|
#[derive(Encode, Decode)]
|
|
pub struct OpaqueMetadata(Vec<u8>);
|
|
|
|
impl OpaqueMetadata {
|
|
/// Creates a new instance with the given metadata blob.
|
|
pub fn new(metadata: Vec<u8>) -> Self {
|
|
OpaqueMetadata(metadata)
|
|
}
|
|
}
|
|
|
|
impl rstd::ops::Deref for OpaqueMetadata {
|
|
type Target = Vec<u8>;
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.0
|
|
}
|
|
}
|