mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Refactor sr-api to not depend on client anymore (#4086)
* Refactor sr-api to not depend on client anymore * Fix benches * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Apply suggestions from code review
This commit is contained in:
committed by
Benjamin Kampmann
parent
e26d1a0b3e
commit
2ecffa1cd0
@@ -7,14 +7,8 @@ edition = "2018"
|
||||
[dependencies]
|
||||
generic-test-client = { package = "substrate-test-client", path = "../../test-client" }
|
||||
primitives = { package = "substrate-primitives", path = "../../primitives" }
|
||||
runtime = { package = "substrate-test-runtime", path = "../../test-runtime", default-features = false }
|
||||
block-builder = { package = "substrate-block-builder", path = "../../block-builder" }
|
||||
runtime = { package = "substrate-test-runtime", path = "../../test-runtime" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
|
||||
[features]
|
||||
default = [
|
||||
"std",
|
||||
]
|
||||
std = [
|
||||
"runtime/std",
|
||||
]
|
||||
|
||||
@@ -19,25 +19,34 @@
|
||||
use runtime;
|
||||
use sr_primitives::traits::ProvideRuntimeApi;
|
||||
use generic_test_client::client;
|
||||
use generic_test_client::client::block_builder::api::BlockBuilder;
|
||||
|
||||
use block_builder::BlockBuilderApi;
|
||||
|
||||
/// Extension trait for test block builder.
|
||||
pub trait BlockBuilderExt {
|
||||
/// Add transfer extrinsic to the block.
|
||||
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error>;
|
||||
/// Add storage change extrinsic to the block.
|
||||
fn push_storage_change(&mut self, key: Vec<u8>, value: Option<Vec<u8>>) -> Result<(), client::error::Error>;
|
||||
fn push_storage_change(
|
||||
&mut self,
|
||||
key: Vec<u8>,
|
||||
value: Option<Vec<u8>>,
|
||||
) -> Result<(), client::error::Error>;
|
||||
}
|
||||
|
||||
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>
|
||||
impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where
|
||||
A: ProvideRuntimeApi + 'a,
|
||||
A::Api: BlockBuilderApi<runtime::Block, Error = client::error::Error>,
|
||||
{
|
||||
fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> {
|
||||
self.push(transfer.into_signed_tx())
|
||||
}
|
||||
|
||||
fn push_storage_change(&mut self, key: Vec<u8>, value: Option<Vec<u8>>) -> Result<(), client::error::Error> {
|
||||
fn push_storage_change(
|
||||
&mut self,
|
||||
key: Vec<u8>,
|
||||
value: Option<Vec<u8>>,
|
||||
) -> Result<(), client::error::Error> {
|
||||
self.push(runtime::Extrinsic::StorageChange(key, value))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user