mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 22:31:06 +00:00
Rearrange export structure to something a bit more convenient.
This commit is contained in:
Generated
+3
-3
@@ -558,7 +558,7 @@ dependencies = [
|
|||||||
name = "native-runtime"
|
name = "native-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"runtime-support 0.1.0",
|
"runtime-std 0.1.0",
|
||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -737,7 +737,7 @@ dependencies = [
|
|||||||
"polkadot-primitives 0.1.0",
|
"polkadot-primitives 0.1.0",
|
||||||
"polkadot-serializer 0.1.0",
|
"polkadot-serializer 0.1.0",
|
||||||
"polkadot-state-machine 0.1.0",
|
"polkadot-state-machine 0.1.0",
|
||||||
"runtime-support 0.1.0",
|
"runtime-std 0.1.0",
|
||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -921,7 +921,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "runtime-support"
|
name = "runtime-std"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"environmental 0.1.0",
|
"environmental 0.1.0",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ parity-wasm = "0.15.0"
|
|||||||
byteorder = "1.1"
|
byteorder = "1.1"
|
||||||
rustc-hex = "1.0.0"
|
rustc-hex = "1.0.0"
|
||||||
native-runtime = { path = "../native-runtime", version = "0.1" }
|
native-runtime = { path = "../native-runtime", version = "0.1" }
|
||||||
runtime-support = { path = "../native-runtime/support", version = "0.1" }
|
runtime-std = { path = "../native-runtime/std", version = "0.1" }
|
||||||
memcmp = { version = "0.0.6" }
|
memcmp = { version = "0.0.6" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ extern crate parity_wasm;
|
|||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
extern crate rustc_hex;
|
extern crate rustc_hex;
|
||||||
extern crate native_runtime;
|
extern crate native_runtime;
|
||||||
extern crate runtime_support;
|
extern crate runtime_std;
|
||||||
extern crate memcmp;
|
extern crate memcmp;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use state_machine::{Externalities, CodeExecutor};
|
|||||||
use error::{Error, ErrorKind, Result};
|
use error::{Error, ErrorKind, Result};
|
||||||
use wasm_executor::WasmExecutor;
|
use wasm_executor::WasmExecutor;
|
||||||
use native_runtime as runtime;
|
use native_runtime as runtime;
|
||||||
use runtime_support;
|
use runtime_std;
|
||||||
|
|
||||||
pub struct NativeExecutor;
|
pub struct NativeExecutor;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ impl CodeExecutor for NativeExecutor {
|
|||||||
// get a proper build script, this must be strictly adhered to or things will go wrong.
|
// get a proper build script, this must be strictly adhered to or things will go wrong.
|
||||||
let native_equivalent = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm");
|
let native_equivalent = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm");
|
||||||
if code == &native_equivalent[..] {
|
if code == &native_equivalent[..] {
|
||||||
runtime_support::with_externalities(ext, || match method {
|
runtime_std::with_externalities(ext, || match method {
|
||||||
"execute_block" => catch_unwind(|| runtime::execute_block(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
|
"execute_block" => catch_unwind(|| runtime::execute_block(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
|
||||||
"execute_transaction" => catch_unwind(|| runtime::execute_transaction(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
|
"execute_transaction" => catch_unwind(|| runtime::execute_transaction(&data.0)).map_err(|_| ErrorKind::Runtime.into()),
|
||||||
_ => Err(ErrorKind::MethodNotFound(method.to_owned()).into()),
|
_ => Err(ErrorKind::MethodNotFound(method.to_owned()).into()),
|
||||||
@@ -37,11 +37,10 @@ impl CodeExecutor for NativeExecutor {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use primitives::twox_128;
|
use native_runtime::codec::KeyedVec;
|
||||||
use native_runtime::testing::{TestExternalities, one, two};
|
use native_runtime::support::{TestExternalities, one, two, StaticHexInto};
|
||||||
use native_runtime::statichex::StaticHexInto;
|
|
||||||
use native_runtime::keyedvec::KeyedVec;
|
|
||||||
use native_runtime::runtime::staking::balance;
|
use native_runtime::runtime::staking::balance;
|
||||||
|
use primitives::twox_128;
|
||||||
|
|
||||||
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
|
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ mod tests {
|
|||||||
let r = NativeExecutor.call(&mut t, &native_equivalent_code[..], "execute_transaction", &CallData(tx()));
|
let r = NativeExecutor.call(&mut t, &native_equivalent_code[..], "execute_transaction", &CallData(tx()));
|
||||||
assert!(r.is_ok());
|
assert!(r.is_ok());
|
||||||
|
|
||||||
runtime_support::with_externalities(&mut t, || {
|
runtime_std::with_externalities(&mut t, || {
|
||||||
assert_eq!(balance(&one), 42);
|
assert_eq!(balance(&one), 42);
|
||||||
assert_eq!(balance(&two), 69);
|
assert_eq!(balance(&two), 69);
|
||||||
});
|
});
|
||||||
@@ -101,7 +100,7 @@ mod tests {
|
|||||||
let r = NativeExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
|
let r = NativeExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
|
||||||
assert!(r.is_ok());
|
assert!(r.is_ok());
|
||||||
|
|
||||||
runtime_support::with_externalities(&mut t, || {
|
runtime_std::with_externalities(&mut t, || {
|
||||||
assert_eq!(balance(&one), 42);
|
assert_eq!(balance(&one), 42);
|
||||||
assert_eq!(balance(&two), 69);
|
assert_eq!(balance(&two), 69);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -274,8 +274,11 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use rustc_hex::FromHex;
|
use rustc_hex::FromHex;
|
||||||
use native_runtime::testing::TestExternalities;
|
use primitives::{blake2_256, twox_128};
|
||||||
use primitives::hashing::blake2_256;
|
use runtime_std;
|
||||||
|
use native_runtime::support::{one, two, StaticHexInto, TestExternalities};
|
||||||
|
use native_runtime::codec::KeyedVec;
|
||||||
|
use native_runtime::runtime::staking::balance;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn returning_should_work() {
|
fn returning_should_work() {
|
||||||
@@ -373,13 +376,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
use primitives::twox_128;
|
|
||||||
use native_runtime::testing::{one, two};
|
|
||||||
use native_runtime::statichex::StaticHexInto;
|
|
||||||
use native_runtime::keyedvec::KeyedVec;
|
|
||||||
use native_runtime::runtime::staking::balance;
|
|
||||||
use runtime_support;
|
|
||||||
|
|
||||||
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
|
fn tx() -> Vec<u8> { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -407,7 +403,7 @@ mod tests {
|
|||||||
let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
|
let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx()));
|
||||||
assert!(r.is_ok());
|
assert!(r.is_ok());
|
||||||
|
|
||||||
runtime_support::with_externalities(&mut t, || {
|
runtime_std::with_externalities(&mut t, || {
|
||||||
assert_eq!(balance(&one), 42);
|
assert_eq!(balance(&one), 42);
|
||||||
assert_eq!(balance(&two), 69);
|
assert_eq!(balance(&two), 69);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ with-std = []
|
|||||||
without-std = []
|
without-std = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
runtime-support = { path = "./support", version = "0.1" }
|
runtime-std = { path = "./std", version = "0.1" }
|
||||||
rustc-hex = "1.0"
|
rustc-hex = "1.0"
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "runtime-support"
|
name = "runtime-std"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
Generated
+3
-3
@@ -13,11 +13,11 @@ version = "0.1.0"
|
|||||||
name = "runtime-polkadot"
|
name = "runtime-polkadot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"runtime-support 0.1.0",
|
"runtime-std 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "runtime-support"
|
name = "runtime-std"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pwasm-alloc 0.1.0",
|
"pwasm-alloc 0.1.0",
|
||||||
@@ -28,6 +28,6 @@ dependencies = [
|
|||||||
name = "runtime-test"
|
name = "runtime-test"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"runtime-support 0.1.0",
|
"runtime-std 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cargo +nightly build --target=wasm32-unknown-unknown --release
|
cargo +nightly build --target=wasm32-unknown-unknown --release
|
||||||
dirs=`find * -maxdepth 0 -type d | grep -v pwasm- | grep -v support`
|
dirs=`find * -maxdepth 0 -type d | grep -v pwasm- | grep -v std`
|
||||||
for i in $dirs
|
for i in $dirs
|
||||||
do
|
do
|
||||||
if [[ -e $i/Cargo.toml ]]
|
if [[ -e $i/Cargo.toml ]]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
runtime-support = { path = "../support", version = "0.1" }
|
runtime-std = { path = "../std", version = "0.1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["without-std"]
|
default = ["without-std"]
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Vec<u8> serialiser.
|
//! Vec<u8> serialiser.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use slicable::Slicable;
|
use super::slicable::Slicable;
|
||||||
|
|
||||||
/// Trait to allow itself to be serialised into a `Vec<u8>`
|
/// Trait to allow itself to be serialised into a `Vec<u8>`
|
||||||
pub trait Joiner {
|
pub trait Joiner {
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Serialiser and prepender.
|
//! Serialiser and prepender.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use slicable::Slicable;
|
use super::slicable::Slicable;
|
||||||
|
|
||||||
/// Trait to allow itselg to be serialised and prepended by a given slice.
|
/// Trait to allow itselg to be serialised and prepended by a given slice.
|
||||||
pub trait KeyedVec {
|
pub trait KeyedVec {
|
||||||
|
|||||||
@@ -16,8 +16,14 @@
|
|||||||
|
|
||||||
//! Codec utils.
|
//! Codec utils.
|
||||||
|
|
||||||
pub mod endiansensitive;
|
mod endiansensitive;
|
||||||
pub mod streamreader;
|
mod slicable;
|
||||||
pub mod joiner;
|
mod streamreader;
|
||||||
pub mod slicable;
|
mod joiner;
|
||||||
pub mod keyedvec;
|
mod keyedvec;
|
||||||
|
|
||||||
|
pub use self::endiansensitive::EndianSensitive;
|
||||||
|
pub use self::slicable::{Slicable, NonTrivialSlicable};
|
||||||
|
pub use self::streamreader::StreamReader;
|
||||||
|
pub use self::joiner::Joiner;
|
||||||
|
pub use self::keyedvec::KeyedVec;
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
//! Serialisation.
|
//! Serialisation.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use runtime_support::{mem, slice};
|
use runtime_std::{mem, slice};
|
||||||
use joiner::Joiner;
|
use super::joiner::Joiner;
|
||||||
use endiansensitive::EndianSensitive;
|
use super::endiansensitive::EndianSensitive;
|
||||||
|
|
||||||
/// Trait that allows zero-copy read/write of value-references to/from slices in LE format.
|
/// Trait that allows zero-copy read/write of value-references to/from slices in LE format.
|
||||||
pub trait Slicable: Sized {
|
pub trait Slicable: Sized {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Deserialiser.
|
//! Deserialiser.
|
||||||
|
|
||||||
use slicable::Slicable;
|
use super::slicable::Slicable;
|
||||||
|
|
||||||
/// Simple deserialiser.
|
/// Simple deserialiser.
|
||||||
pub struct StreamReader<'a> {
|
pub struct StreamReader<'a> {
|
||||||
|
|||||||
@@ -20,23 +20,19 @@
|
|||||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate runtime_support;
|
extern crate runtime_std;
|
||||||
|
|
||||||
#[cfg(feature = "with-std")]
|
#[cfg(feature = "with-std")]
|
||||||
extern crate rustc_hex;
|
extern crate rustc_hex;
|
||||||
|
|
||||||
mod codec;
|
pub mod codec;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod support;
|
pub mod support;
|
||||||
pub mod primitives;
|
pub mod primitives;
|
||||||
pub mod runtime;
|
pub mod runtime;
|
||||||
pub use codec::{endiansensitive, streamreader, joiner, slicable, keyedvec};
|
|
||||||
pub use support::{environment, storable, hashable};
|
|
||||||
#[cfg(feature = "with-std")]
|
|
||||||
pub use support::{testing, statichex};
|
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use slicable::Slicable;
|
use codec::Slicable;
|
||||||
use primitives::{Block, UncheckedTransaction};
|
use primitives::{Block, UncheckedTransaction};
|
||||||
|
|
||||||
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
|
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
|
|
||||||
//! Block type.
|
//! Block type.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use streamreader::StreamReader;
|
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||||
use joiner::Joiner;
|
|
||||||
use slicable::{Slicable, NonTrivialSlicable};
|
|
||||||
use primitives::{Header, UncheckedTransaction};
|
use primitives::{Header, UncheckedTransaction};
|
||||||
|
|
||||||
/// A Polkadot relay chain block.
|
/// A Polkadot relay chain block.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Digest type.
|
//! Digest type.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
|
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
//! Function data: This describes a function that can be called from an external transaction.
|
//! Function data: This describes a function that can be called from an external transaction.
|
||||||
|
|
||||||
use primitives::AccountID;
|
use primitives::AccountID;
|
||||||
use streamreader::StreamReader;
|
use codec::StreamReader;
|
||||||
use runtime::{staking, session, timestamp, governance};
|
use runtime::{staking, session, timestamp, governance};
|
||||||
|
|
||||||
/// Public functions that can be dispatched to.
|
/// Public functions that can be dispatched to.
|
||||||
|
|||||||
@@ -16,11 +16,9 @@
|
|||||||
|
|
||||||
//! Block header type.
|
//! Block header type.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use streamreader::StreamReader;
|
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||||
use joiner::Joiner;
|
use runtime_std::mem;
|
||||||
use slicable::{Slicable, NonTrivialSlicable};
|
|
||||||
use runtime_support::mem;
|
|
||||||
use primitives::{BlockNumber, Hash, Digest};
|
use primitives::{BlockNumber, Hash, Digest};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
@@ -17,11 +17,9 @@
|
|||||||
//! Proposal: This describes a combination of a function ID and data that can be used to call into
|
//! Proposal: This describes a combination of a function ID and data that can be used to call into
|
||||||
//! an internal function.
|
//! an internal function.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use runtime_support::mem;
|
use runtime_std::mem;
|
||||||
use slicable::Slicable;
|
use codec::{Slicable, Joiner, StreamReader};
|
||||||
use joiner::Joiner;
|
|
||||||
use streamreader::StreamReader;
|
|
||||||
use runtime::{system, governance, staking, session};
|
use runtime::{system, governance, staking, session};
|
||||||
|
|
||||||
/// Internal functions that can be dispatched to.
|
/// Internal functions that can be dispatched to.
|
||||||
|
|||||||
@@ -17,10 +17,9 @@
|
|||||||
//! Tests.
|
//! Tests.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use joiner::Joiner;
|
use codec::{Joiner, Slicable};
|
||||||
use slicable::{Slicable, NonTrivialSlicable};
|
use primitives::Function;
|
||||||
use function::Function;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialise_transaction_works() {
|
fn serialise_transaction_works() {
|
||||||
|
|||||||
@@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
//! Transaction type.
|
//! Transaction type.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use streamreader::StreamReader;
|
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||||
use joiner::Joiner;
|
|
||||||
use slicable::{Slicable, NonTrivialSlicable};
|
|
||||||
use primitives::{AccountID, TxOrder, Function};
|
use primitives::{AccountID, TxOrder, Function};
|
||||||
use runtime_support::mem;
|
use runtime_std::mem;
|
||||||
|
|
||||||
/// A vetted and verified transaction from the external world.
|
/// A vetted and verified transaction from the external world.
|
||||||
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
|
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
|
||||||
|
|||||||
@@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
//! Unchecked Transaction type.
|
//! Unchecked Transaction type.
|
||||||
|
|
||||||
use slicable::{Slicable, NonTrivialSlicable};
|
use runtime_std::{mem, ed25519_verify};
|
||||||
use streamreader::StreamReader;
|
use runtime_std::prelude::*;
|
||||||
use joiner::Joiner;
|
use codec::{Slicable, NonTrivialSlicable, StreamReader, Joiner};
|
||||||
use primitives::Transaction;
|
use primitives::Transaction;
|
||||||
use runtime_support::{mem, ed25519_verify};
|
|
||||||
use runtime_support::prelude::*;
|
|
||||||
|
|
||||||
#[cfg(feature = "with-std")]
|
#[cfg(feature = "with-std")]
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Conensus module for runtime; manages the authority set ready for the native code.
|
//! Conensus module for runtime; manages the authority set ready for the native code.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use storable::StorageVec;
|
use support::StorageVec;
|
||||||
use primitives::SessionKey;
|
use primitives::SessionKey;
|
||||||
|
|
||||||
struct AuthorityStorageVec {}
|
struct AuthorityStorageVec {}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
//! At the end of the era, all validators approvals are tallied and if there are sufficient to pass
|
//! At the end of the era, all validators approvals are tallied and if there are sufficient to pass
|
||||||
//! the proposal then it is enacted. All items in storage concerning the proposal are reset.
|
//! the proposal then it is enacted. All items in storage concerning the proposal are reset.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use keyedvec::KeyedVec;
|
use codec::KeyedVec;
|
||||||
use storable::{Storable, StorageVec, kill};
|
use support::{Storable, StorageVec, kill};
|
||||||
use primitives::{AccountID, Hash, BlockNumber, Proposal};
|
use primitives::{AccountID, Hash, BlockNumber, Proposal};
|
||||||
use runtime::{staking, system, session};
|
use runtime::{staking, system, session};
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ pub fn end_of_an_era() {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use runtime_support::{with_externalities, twox_128};
|
use runtime_std::{with_externalities, twox_128};
|
||||||
use keyedvec::KeyedVec;
|
use keyedvec::KeyedVec;
|
||||||
use joiner::Joiner;
|
use joiner::Joiner;
|
||||||
use testing::{one, two, TestExternalities};
|
use testing::{one, two, TestExternalities};
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
//! Session manager: is told the validators and allows them to manage their session keys for the
|
//! Session manager: is told the validators and allows them to manage their session keys for the
|
||||||
//! consensus module.
|
//! consensus module.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use keyedvec::KeyedVec;
|
use codec::KeyedVec;
|
||||||
use storable::{kill, Storable, StorageVec};
|
use support::{kill, Storable, StorageVec};
|
||||||
use primitives::{AccountID, SessionKey, BlockNumber};
|
use primitives::{AccountID, SessionKey, BlockNumber};
|
||||||
use runtime::{system, staking, consensus};
|
use runtime::{system, staking, consensus};
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ fn rotate_session() {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use runtime_support::{with_externalities, twox_128};
|
use runtime_std::{with_externalities, twox_128};
|
||||||
use keyedvec::KeyedVec;
|
use keyedvec::KeyedVec;
|
||||||
use joiner::Joiner;
|
use joiner::Joiner;
|
||||||
use testing::{one, two, TestExternalities};
|
use testing::{one, two, TestExternalities};
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
//! Staking manager: Handles balances and periodically determines the best set of validators.
|
//! Staking manager: Handles balances and periodically determines the best set of validators.
|
||||||
|
|
||||||
use runtime_support::prelude::*;
|
use runtime_std::prelude::*;
|
||||||
use runtime_support::cell::RefCell;
|
use runtime_std::cell::RefCell;
|
||||||
use keyedvec::KeyedVec;
|
use codec::KeyedVec;
|
||||||
use storable::{Storable, StorageVec};
|
use support::{Storable, StorageVec};
|
||||||
use primitives::{BlockNumber, AccountID};
|
use primitives::{BlockNumber, AccountID};
|
||||||
use runtime::{system, session, governance};
|
use runtime::{system, session, governance};
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ fn new_era() {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use runtime_support::{with_externalities, twox_128};
|
use runtime_std::{with_externalities, twox_128};
|
||||||
use keyedvec::KeyedVec;
|
use keyedvec::KeyedVec;
|
||||||
use joiner::Joiner;
|
use joiner::Joiner;
|
||||||
use testing::{one, two, TestExternalities};
|
use testing::{one, two, TestExternalities};
|
||||||
|
|||||||
@@ -17,14 +17,11 @@
|
|||||||
//! System manager: Handles all of the top-level stuff; executing block/transaction, setting code
|
//! System manager: Handles all of the top-level stuff; executing block/transaction, setting code
|
||||||
//! and depositing logs.
|
//! and depositing logs.
|
||||||
|
|
||||||
|
use runtime_std::prelude::*;
|
||||||
|
use runtime_std::{mem, print};
|
||||||
|
use codec::KeyedVec;
|
||||||
|
use support::{Hashable, Storable, with_env};
|
||||||
use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder};
|
use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder};
|
||||||
use runtime_support::mem;
|
|
||||||
use runtime_support::prelude::*;
|
|
||||||
use runtime_support::print;
|
|
||||||
use hashable::Hashable;
|
|
||||||
use storable::Storable;
|
|
||||||
use keyedvec::KeyedVec;
|
|
||||||
use environment::with_env;
|
|
||||||
use runtime::{staking, session};
|
use runtime::{staking, session};
|
||||||
|
|
||||||
/// The current block number being processed. Set by `execute_block`.
|
/// The current block number being processed. Set by `execute_block`.
|
||||||
@@ -120,7 +117,7 @@ mod tests {
|
|||||||
use function::Function;
|
use function::Function;
|
||||||
use keyedvec::KeyedVec;
|
use keyedvec::KeyedVec;
|
||||||
use slicable::Slicable;
|
use slicable::Slicable;
|
||||||
use runtime_support::{with_externalities, twox_128};
|
use runtime_std::{with_externalities, twox_128};
|
||||||
use primitives::{UncheckedTransaction, Transaction};
|
use primitives::{UncheckedTransaction, Transaction};
|
||||||
use statichex::StaticHexInto;
|
use statichex::StaticHexInto;
|
||||||
use runtime::{system, staking};
|
use runtime::{system, staking};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Timestamp manager: just handles the current timestamp.
|
//! Timestamp manager: just handles the current timestamp.
|
||||||
|
|
||||||
use storable::Storable;
|
use support::Storable;
|
||||||
|
|
||||||
/// Representation of a time.
|
/// Representation of a time.
|
||||||
pub type Timestamp = u64;
|
pub type Timestamp = u64;
|
||||||
@@ -35,7 +35,7 @@ pub fn set(now: Timestamp) {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use joiner::Joiner;
|
use joiner::Joiner;
|
||||||
use keyedvec::KeyedVec;
|
use keyedvec::KeyedVec;
|
||||||
use runtime_support::{with_externalities, twox_128};
|
use runtime_std::{with_externalities, twox_128};
|
||||||
use runtime::timestamp;
|
use runtime::timestamp;
|
||||||
use testing::TestExternalities;
|
use testing::TestExternalities;
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
//! Environment API: Allows certain information to be accessed throughout the runtime.
|
//! Environment API: Allows certain information to be accessed throughout the runtime.
|
||||||
|
|
||||||
use runtime_support::boxed::Box;
|
use runtime_std::boxed::Box;
|
||||||
use runtime_support::mem;
|
use runtime_std::mem;
|
||||||
use runtime_support::cell::RefCell;
|
use runtime_std::cell::RefCell;
|
||||||
use runtime_support::rc::Rc;
|
use runtime_std::rc::Rc;
|
||||||
|
|
||||||
use primitives::{BlockNumber, Digest};
|
use primitives::{BlockNumber, Digest};
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Hashable trait.
|
//! Hashable trait.
|
||||||
|
|
||||||
use slicable::Slicable;
|
use codec::Slicable;
|
||||||
use runtime_support::{blake2_256, twox_128, twox_256};
|
use runtime_std::{blake2_256, twox_128, twox_256};
|
||||||
|
|
||||||
pub trait Hashable: Sized {
|
pub trait Hashable: Sized {
|
||||||
fn blake2_256(&self) -> [u8; 32];
|
fn blake2_256(&self) -> [u8; 32];
|
||||||
|
|||||||
@@ -16,12 +16,19 @@
|
|||||||
|
|
||||||
//! Support code for the runtime.
|
//! Support code for the runtime.
|
||||||
|
|
||||||
pub mod environment;
|
mod environment;
|
||||||
pub mod storable;
|
mod storable;
|
||||||
pub mod hashable;
|
mod hashable;
|
||||||
|
|
||||||
#[cfg(feature = "with-std")]
|
#[cfg(feature = "with-std")]
|
||||||
pub mod statichex;
|
mod statichex;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[cfg(feature = "with-std")]
|
#[cfg(feature = "with-std")]
|
||||||
pub mod testing;
|
mod testing;
|
||||||
|
|
||||||
|
pub use self::environment::{Environment, with_env};
|
||||||
|
pub use self::storable::{StorageVec, Storable, kill};
|
||||||
|
pub use self::hashable::Hashable;
|
||||||
|
#[cfg(feature = "with-std")]
|
||||||
|
pub use self::statichex::{StaticHexConversion, StaticHexInto};
|
||||||
|
#[cfg(feature = "with-std")]
|
||||||
|
pub use self::testing::{AsBytesRef, HexDisplay, TestExternalities, one, two};
|
||||||
|
|||||||
@@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
//! Stuff to do with the runtime's storage.
|
//! Stuff to do with the runtime's storage.
|
||||||
|
|
||||||
use slicable::Slicable;
|
use runtime_std::prelude::*;
|
||||||
use keyedvec::KeyedVec;
|
use runtime_std::{self, twox_128};
|
||||||
use runtime_support::prelude::*;
|
use codec::{Slicable, KeyedVec};
|
||||||
use runtime_support::{self, twox_128};
|
|
||||||
|
|
||||||
/// Trait for a value which may be stored in the storage DB.
|
/// Trait for a value which may be stored in the storage DB.
|
||||||
pub trait Storable {
|
pub trait Storable {
|
||||||
@@ -51,23 +50,23 @@ pub trait Storable {
|
|||||||
|
|
||||||
/// Remove `key` from storage.
|
/// Remove `key` from storage.
|
||||||
pub fn kill(key: &[u8]) {
|
pub fn kill(key: &[u8]) {
|
||||||
runtime_support::set_storage(&twox_128(key)[..], b"");
|
runtime_std::set_storage(&twox_128(key)[..], b"");
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Sized + Slicable> Storable for T {
|
impl<T: Sized + Slicable> Storable for T {
|
||||||
fn lookup(key: &[u8]) -> Option<Self> {
|
fn lookup(key: &[u8]) -> Option<Self> {
|
||||||
Slicable::set_as_slice(&|out, offset|
|
Slicable::set_as_slice(&|out, offset|
|
||||||
runtime_support::read_storage(&twox_128(key)[..], out, offset) >= out.len()
|
runtime_std::read_storage(&twox_128(key)[..], out, offset) >= out.len()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn store(&self, key: &[u8]) {
|
fn store(&self, key: &[u8]) {
|
||||||
self.as_slice_then(|slice| runtime_support::set_storage(&twox_128(key)[..], slice));
|
self.as_slice_then(|slice| runtime_std::set_storage(&twox_128(key)[..], slice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Storable for [u8] {
|
impl Storable for [u8] {
|
||||||
fn store(&self, key: &[u8]) {
|
fn store(&self, key: &[u8]) {
|
||||||
runtime_support::set_storage(&twox_128(key)[..], self)
|
runtime_std::set_storage(&twox_128(key)[..], self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,9 +109,9 @@ pub trait StorageVec {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use runtime_support::with_externalities;
|
use runtime_std::with_externalities;
|
||||||
use testing::{TestExternalities, HexDisplay};
|
use testing::{TestExternalities, HexDisplay};
|
||||||
use runtime_support::{storage, twox_128};
|
use runtime_std::{storage, twox_128};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn integers_can_be_stored() {
|
fn integers_can_be_stored() {
|
||||||
@@ -153,7 +152,7 @@ mod tests {
|
|||||||
fn vecs_can_be_retrieved() {
|
fn vecs_can_be_retrieved() {
|
||||||
let mut t = TestExternalities { storage: HashMap::new(), };
|
let mut t = TestExternalities { storage: HashMap::new(), };
|
||||||
with_externalities(&mut t, || {
|
with_externalities(&mut t, || {
|
||||||
runtime_support::set_storage(&twox_128(b":test"), b"\x0b\0\0\0Hello world");
|
runtime_std::set_storage(&twox_128(b":test"), b"\x0b\0\0\0Hello world");
|
||||||
let x = b"Hello world".to_vec();
|
let x = b"Hello world".to_vec();
|
||||||
println!("Hex: {}", HexDisplay::from(&storage(&twox_128(b":test"))));
|
println!("Hex: {}", HexDisplay::from(&storage(&twox_128(b":test"))));
|
||||||
let y = <Vec<u8>>::lookup(b":test").unwrap();
|
let y = <Vec<u8>>::lookup(b":test").unwrap();
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
//! Testing helpers.
|
//! Testing helpers.
|
||||||
|
|
||||||
use runtime_support::{Externalities, ExternalitiesError};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use runtime_std::{Externalities, ExternalitiesError};
|
||||||
use primitives::AccountID;
|
use primitives::AccountID;
|
||||||
use statichex::StaticHexInto;
|
use super::statichex::StaticHexInto;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
/// Simple externaties implementation.
|
/// Simple externaties implementation.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "runtime-support"
|
name = "runtime-std"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
BIN
Binary file not shown.
Binary file not shown.
@@ -7,4 +7,4 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
runtime-support = { path = "../support", version = "0.1" }
|
runtime-std = { path = "../std", version = "0.1" }
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ extern crate alloc;
|
|||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate runtime_support;
|
extern crate runtime_std;
|
||||||
use runtime_support::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify};
|
use runtime_std::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify};
|
||||||
|
|
||||||
fn test_blake2_256(input: &[u8]) -> Vec<u8> {
|
fn test_blake2_256(input: &[u8]) -> Vec<u8> {
|
||||||
blake2_256(&input).to_vec()
|
blake2_256(&input).to_vec()
|
||||||
|
|||||||
Reference in New Issue
Block a user