mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
Implement runtime api client side directly in the runtime (#1094)
* 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
This commit is contained in:
@@ -20,8 +20,8 @@ use codec;
|
||||
use client;
|
||||
use keyring;
|
||||
use runtime;
|
||||
|
||||
use primitives::{Blake2Hasher};
|
||||
use runtime_primitives::traits::ProvideRuntimeApi;
|
||||
use client::block_builder::api::BlockBuilder;
|
||||
|
||||
/// Extension trait for test block builder.
|
||||
pub trait BlockBuilderExt {
|
||||
@@ -29,10 +29,9 @@ pub trait BlockBuilderExt {
|
||||
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error>;
|
||||
}
|
||||
|
||||
impl<'a, B, E> BlockBuilderExt for client::block_builder::BlockBuilder<'a, B, E, runtime::Block, Blake2Hasher>
|
||||
where
|
||||
B: client::backend::Backend<runtime::Block, Blake2Hasher>,
|
||||
E: client::CallExecutor<runtime::Block, Blake2Hasher> + Clone,
|
||||
impl<'a, A> BlockBuilderExt for client::block_builder::BlockBuilder<'a, runtime::Block, A> where
|
||||
A: ProvideRuntimeApi + client::blockchain::HeaderBackend<runtime::Block> + 'a,
|
||||
A::Api: BlockBuilder<runtime::Block>
|
||||
{
|
||||
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> {
|
||||
self.push(sign_tx(transfer))
|
||||
|
||||
@@ -35,11 +35,11 @@ pub trait TestClient: Sized {
|
||||
fn genesis_hash(&self) -> runtime::Hash;
|
||||
}
|
||||
|
||||
impl<B, E> TestClient for Client<B, E, runtime::Block>
|
||||
impl<B, E, RA> TestClient for Client<B, E, runtime::Block, RA>
|
||||
where
|
||||
B: client::backend::Backend<runtime::Block, Blake2Hasher>,
|
||||
E: client::CallExecutor<runtime::Block, Blake2Hasher>,
|
||||
Self: BlockImport<runtime::Block, Error=client::error::Error>
|
||||
Self: BlockImport<runtime::Block, Error=client::error::Error>,
|
||||
{
|
||||
fn justify_and_import(&self, origin: BlockOrigin, block: runtime::Block)
|
||||
-> client::error::Result<()>
|
||||
|
||||
@@ -27,6 +27,7 @@ pub extern crate substrate_client as client;
|
||||
pub extern crate substrate_keyring as keyring;
|
||||
pub extern crate substrate_test_runtime as runtime;
|
||||
pub extern crate substrate_consensus_common as consensus;
|
||||
extern crate substrate_state_machine as state_machine;
|
||||
|
||||
pub mod client_ext;
|
||||
pub mod trait_tests;
|
||||
@@ -65,12 +66,12 @@ pub type Executor = client::LocalCallExecutor<
|
||||
>;
|
||||
|
||||
/// Creates new client instance used for tests.
|
||||
pub fn new() -> client::Client<Backend, Executor, runtime::Block> {
|
||||
pub fn new() -> client::Client<Backend, Executor, runtime::Block, runtime::ClientWithApi> {
|
||||
new_with_backend(Arc::new(Backend::new()), false)
|
||||
}
|
||||
|
||||
/// Creates new test client instance that suports changes trie creation.
|
||||
pub fn new_with_changes_trie() -> client::Client<Backend, Executor, runtime::Block> {
|
||||
pub fn new_with_changes_trie() -> client::Client<Backend, Executor, runtime::Block, runtime::ClientWithApi> {
|
||||
new_with_backend(Arc::new(Backend::new()), true)
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ pub fn new_with_changes_trie() -> client::Client<Backend, Executor, runtime::Blo
|
||||
pub fn new_with_backend<B>(
|
||||
backend: Arc<B>,
|
||||
support_changes_trie: bool
|
||||
) -> client::Client<B, client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>, runtime::Block>
|
||||
) -> client::Client<B, client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>, runtime::Block, runtime::ClientWithApi>
|
||||
where
|
||||
B: backend::LocalBackend<runtime::Block, Blake2Hasher>,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user