mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Rearrange export structure to something a bit more convenient.
This commit is contained in:
Generated
+3
-3
@@ -13,11 +13,11 @@ version = "0.1.0"
|
||||
name = "runtime-polkadot"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"runtime-support 0.1.0",
|
||||
"runtime-std 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "runtime-support"
|
||||
name = "runtime-std"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"pwasm-alloc 0.1.0",
|
||||
@@ -28,6 +28,6 @@ dependencies = [
|
||||
name = "runtime-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"runtime-support 0.1.0",
|
||||
"runtime-std 0.1.0",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
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
|
||||
do
|
||||
if [[ -e $i/Cargo.toml ]]
|
||||
|
||||
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
runtime-support = { path = "../support", version = "0.1" }
|
||||
runtime-std = { path = "../std", version = "0.1" }
|
||||
|
||||
[features]
|
||||
default = ["without-std"]
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Vec<u8> serialiser.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use slicable::Slicable;
|
||||
use runtime_std::prelude::*;
|
||||
use super::slicable::Slicable;
|
||||
|
||||
/// Trait to allow itself to be serialised into a `Vec<u8>`
|
||||
pub trait Joiner {
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Serialiser and prepender.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use slicable::Slicable;
|
||||
use runtime_std::prelude::*;
|
||||
use super::slicable::Slicable;
|
||||
|
||||
/// Trait to allow itselg to be serialised and prepended by a given slice.
|
||||
pub trait KeyedVec {
|
||||
|
||||
@@ -16,8 +16,14 @@
|
||||
|
||||
//! Codec utils.
|
||||
|
||||
pub mod endiansensitive;
|
||||
pub mod streamreader;
|
||||
pub mod joiner;
|
||||
pub mod slicable;
|
||||
pub mod keyedvec;
|
||||
mod endiansensitive;
|
||||
mod slicable;
|
||||
mod streamreader;
|
||||
mod joiner;
|
||||
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.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use runtime_support::{mem, slice};
|
||||
use joiner::Joiner;
|
||||
use endiansensitive::EndianSensitive;
|
||||
use runtime_std::prelude::*;
|
||||
use runtime_std::{mem, slice};
|
||||
use super::joiner::Joiner;
|
||||
use super::endiansensitive::EndianSensitive;
|
||||
|
||||
/// Trait that allows zero-copy read/write of value-references to/from slices in LE format.
|
||||
pub trait Slicable: Sized {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Deserialiser.
|
||||
|
||||
use slicable::Slicable;
|
||||
use super::slicable::Slicable;
|
||||
|
||||
/// Simple deserialiser.
|
||||
pub struct StreamReader<'a> {
|
||||
|
||||
@@ -20,23 +20,19 @@
|
||||
#![cfg_attr(feature = "strict", deny(warnings))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate runtime_support;
|
||||
extern crate runtime_std;
|
||||
|
||||
#[cfg(feature = "with-std")]
|
||||
extern crate rustc_hex;
|
||||
|
||||
mod codec;
|
||||
pub mod codec;
|
||||
#[macro_use]
|
||||
mod support;
|
||||
pub mod support;
|
||||
pub mod primitives;
|
||||
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 slicable::Slicable;
|
||||
use runtime_std::prelude::*;
|
||||
use codec::Slicable;
|
||||
use primitives::{Block, UncheckedTransaction};
|
||||
|
||||
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
//! Block type.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use streamreader::StreamReader;
|
||||
use joiner::Joiner;
|
||||
use slicable::{Slicable, NonTrivialSlicable};
|
||||
use runtime_std::prelude::*;
|
||||
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||
use primitives::{Header, UncheckedTransaction};
|
||||
|
||||
/// A Polkadot relay chain block.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Digest type.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use runtime_std::prelude::*;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
#[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.
|
||||
|
||||
use primitives::AccountID;
|
||||
use streamreader::StreamReader;
|
||||
use codec::StreamReader;
|
||||
use runtime::{staking, session, timestamp, governance};
|
||||
|
||||
/// Public functions that can be dispatched to.
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
|
||||
//! Block header type.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use streamreader::StreamReader;
|
||||
use joiner::Joiner;
|
||||
use slicable::{Slicable, NonTrivialSlicable};
|
||||
use runtime_support::mem;
|
||||
use runtime_std::prelude::*;
|
||||
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||
use runtime_std::mem;
|
||||
use primitives::{BlockNumber, Hash, Digest};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
//! Proposal: This describes a combination of a function ID and data that can be used to call into
|
||||
//! an internal function.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use runtime_support::mem;
|
||||
use slicable::Slicable;
|
||||
use joiner::Joiner;
|
||||
use streamreader::StreamReader;
|
||||
use runtime_std::prelude::*;
|
||||
use runtime_std::mem;
|
||||
use codec::{Slicable, Joiner, StreamReader};
|
||||
use runtime::{system, governance, staking, session};
|
||||
|
||||
/// Internal functions that can be dispatched to.
|
||||
|
||||
@@ -17,10 +17,9 @@
|
||||
//! Tests.
|
||||
|
||||
use super::*;
|
||||
use runtime_support::prelude::*;
|
||||
use joiner::Joiner;
|
||||
use slicable::{Slicable, NonTrivialSlicable};
|
||||
use function::Function;
|
||||
use runtime_std::prelude::*;
|
||||
use codec::{Joiner, Slicable};
|
||||
use primitives::Function;
|
||||
|
||||
#[test]
|
||||
fn serialise_transaction_works() {
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
//! Transaction type.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use streamreader::StreamReader;
|
||||
use joiner::Joiner;
|
||||
use slicable::{Slicable, NonTrivialSlicable};
|
||||
use runtime_std::prelude::*;
|
||||
use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable};
|
||||
use primitives::{AccountID, TxOrder, Function};
|
||||
use runtime_support::mem;
|
||||
use runtime_std::mem;
|
||||
|
||||
/// A vetted and verified transaction from the external world.
|
||||
#[cfg_attr(feature = "with-std", derive(PartialEq, Debug))]
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
//! Unchecked Transaction type.
|
||||
|
||||
use slicable::{Slicable, NonTrivialSlicable};
|
||||
use streamreader::StreamReader;
|
||||
use joiner::Joiner;
|
||||
use runtime_std::{mem, ed25519_verify};
|
||||
use runtime_std::prelude::*;
|
||||
use codec::{Slicable, NonTrivialSlicable, StreamReader, Joiner};
|
||||
use primitives::Transaction;
|
||||
use runtime_support::{mem, ed25519_verify};
|
||||
use runtime_support::prelude::*;
|
||||
|
||||
#[cfg(feature = "with-std")]
|
||||
use std::fmt;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Conensus module for runtime; manages the authority set ready for the native code.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use storable::StorageVec;
|
||||
use runtime_std::prelude::*;
|
||||
use support::StorageVec;
|
||||
use primitives::SessionKey;
|
||||
|
||||
struct AuthorityStorageVec {}
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
//! 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.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use keyedvec::KeyedVec;
|
||||
use storable::{Storable, StorageVec, kill};
|
||||
use runtime_std::prelude::*;
|
||||
use codec::KeyedVec;
|
||||
use support::{Storable, StorageVec, kill};
|
||||
use primitives::{AccountID, Hash, BlockNumber, Proposal};
|
||||
use runtime::{staking, system, session};
|
||||
|
||||
@@ -105,7 +105,7 @@ pub fn end_of_an_era() {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use runtime_support::{with_externalities, twox_128};
|
||||
use runtime_std::{with_externalities, twox_128};
|
||||
use keyedvec::KeyedVec;
|
||||
use joiner::Joiner;
|
||||
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
|
||||
//! consensus module.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use keyedvec::KeyedVec;
|
||||
use storable::{kill, Storable, StorageVec};
|
||||
use runtime_std::prelude::*;
|
||||
use codec::KeyedVec;
|
||||
use support::{kill, Storable, StorageVec};
|
||||
use primitives::{AccountID, SessionKey, BlockNumber};
|
||||
use runtime::{system, staking, consensus};
|
||||
|
||||
@@ -118,7 +118,7 @@ fn rotate_session() {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use runtime_support::{with_externalities, twox_128};
|
||||
use runtime_std::{with_externalities, twox_128};
|
||||
use keyedvec::KeyedVec;
|
||||
use joiner::Joiner;
|
||||
use testing::{one, two, TestExternalities};
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
//! Staking manager: Handles balances and periodically determines the best set of validators.
|
||||
|
||||
use runtime_support::prelude::*;
|
||||
use runtime_support::cell::RefCell;
|
||||
use keyedvec::KeyedVec;
|
||||
use storable::{Storable, StorageVec};
|
||||
use runtime_std::prelude::*;
|
||||
use runtime_std::cell::RefCell;
|
||||
use codec::KeyedVec;
|
||||
use support::{Storable, StorageVec};
|
||||
use primitives::{BlockNumber, AccountID};
|
||||
use runtime::{system, session, governance};
|
||||
|
||||
@@ -190,7 +190,7 @@ fn new_era() {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use runtime_support::{with_externalities, twox_128};
|
||||
use runtime_std::{with_externalities, twox_128};
|
||||
use keyedvec::KeyedVec;
|
||||
use joiner::Joiner;
|
||||
use testing::{one, two, TestExternalities};
|
||||
|
||||
@@ -17,14 +17,11 @@
|
||||
//! System manager: Handles all of the top-level stuff; executing block/transaction, setting code
|
||||
//! 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 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};
|
||||
|
||||
/// The current block number being processed. Set by `execute_block`.
|
||||
@@ -120,7 +117,7 @@ mod tests {
|
||||
use function::Function;
|
||||
use keyedvec::KeyedVec;
|
||||
use slicable::Slicable;
|
||||
use runtime_support::{with_externalities, twox_128};
|
||||
use runtime_std::{with_externalities, twox_128};
|
||||
use primitives::{UncheckedTransaction, Transaction};
|
||||
use statichex::StaticHexInto;
|
||||
use runtime::{system, staking};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Timestamp manager: just handles the current timestamp.
|
||||
|
||||
use storable::Storable;
|
||||
use support::Storable;
|
||||
|
||||
/// Representation of a time.
|
||||
pub type Timestamp = u64;
|
||||
@@ -35,7 +35,7 @@ pub fn set(now: Timestamp) {
|
||||
mod tests {
|
||||
use joiner::Joiner;
|
||||
use keyedvec::KeyedVec;
|
||||
use runtime_support::{with_externalities, twox_128};
|
||||
use runtime_std::{with_externalities, twox_128};
|
||||
use runtime::timestamp;
|
||||
use testing::TestExternalities;
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
//! Environment API: Allows certain information to be accessed throughout the runtime.
|
||||
|
||||
use runtime_support::boxed::Box;
|
||||
use runtime_support::mem;
|
||||
use runtime_support::cell::RefCell;
|
||||
use runtime_support::rc::Rc;
|
||||
use runtime_std::boxed::Box;
|
||||
use runtime_std::mem;
|
||||
use runtime_std::cell::RefCell;
|
||||
use runtime_std::rc::Rc;
|
||||
|
||||
use primitives::{BlockNumber, Digest};
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Hashable trait.
|
||||
|
||||
use slicable::Slicable;
|
||||
use runtime_support::{blake2_256, twox_128, twox_256};
|
||||
use codec::Slicable;
|
||||
use runtime_std::{blake2_256, twox_128, twox_256};
|
||||
|
||||
pub trait Hashable: Sized {
|
||||
fn blake2_256(&self) -> [u8; 32];
|
||||
|
||||
@@ -16,12 +16,19 @@
|
||||
|
||||
//! Support code for the runtime.
|
||||
|
||||
pub mod environment;
|
||||
pub mod storable;
|
||||
pub mod hashable;
|
||||
|
||||
mod environment;
|
||||
mod storable;
|
||||
mod hashable;
|
||||
#[cfg(feature = "with-std")]
|
||||
pub mod statichex;
|
||||
mod statichex;
|
||||
#[macro_use]
|
||||
#[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.
|
||||
|
||||
use slicable::Slicable;
|
||||
use keyedvec::KeyedVec;
|
||||
use runtime_support::prelude::*;
|
||||
use runtime_support::{self, twox_128};
|
||||
use runtime_std::prelude::*;
|
||||
use runtime_std::{self, twox_128};
|
||||
use codec::{Slicable, KeyedVec};
|
||||
|
||||
/// Trait for a value which may be stored in the storage DB.
|
||||
pub trait Storable {
|
||||
@@ -51,23 +50,23 @@ pub trait Storable {
|
||||
|
||||
/// Remove `key` from storage.
|
||||
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 {
|
||||
fn lookup(key: &[u8]) -> Option<Self> {
|
||||
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]) {
|
||||
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] {
|
||||
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 {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
use runtime_support::with_externalities;
|
||||
use runtime_std::with_externalities;
|
||||
use testing::{TestExternalities, HexDisplay};
|
||||
use runtime_support::{storage, twox_128};
|
||||
use runtime_std::{storage, twox_128};
|
||||
|
||||
#[test]
|
||||
fn integers_can_be_stored() {
|
||||
@@ -153,7 +152,7 @@ mod tests {
|
||||
fn vecs_can_be_retrieved() {
|
||||
let mut t = TestExternalities { storage: HashMap::new(), };
|
||||
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();
|
||||
println!("Hex: {}", HexDisplay::from(&storage(&twox_128(b":test"))));
|
||||
let y = <Vec<u8>>::lookup(b":test").unwrap();
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
//! Testing helpers.
|
||||
|
||||
use runtime_support::{Externalities, ExternalitiesError};
|
||||
use std::collections::HashMap;
|
||||
use runtime_std::{Externalities, ExternalitiesError};
|
||||
use primitives::AccountID;
|
||||
use statichex::StaticHexInto;
|
||||
use super::statichex::StaticHexInto;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
/// Simple externaties implementation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "runtime-support"
|
||||
name = "runtime-std"
|
||||
version = "0.1.0"
|
||||
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"]
|
||||
|
||||
[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;
|
||||
|
||||
#[macro_use]
|
||||
extern crate runtime_support;
|
||||
use runtime_support::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify};
|
||||
extern crate runtime_std;
|
||||
use runtime_std::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify};
|
||||
|
||||
fn test_blake2_256(input: &[u8]) -> Vec<u8> {
|
||||
blake2_256(&input).to_vec()
|
||||
|
||||
Reference in New Issue
Block a user