use sc_block_builder::BlockBuilderApi;
use sp_api::{ApiExt, ProvideRuntimeApi};
use substrate_test_runtime::*;
pub trait BlockBuilderExt {
fn push_transfer(
&mut self,
transfer: substrate_test_runtime::Transfer,
) -> Result<(), sp_blockchain::Error>;
fn push_storage_change(
&mut self,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), sp_blockchain::Error>;
fn push_deposit_log_digest_item(
&mut self,
log: sp_runtime::generic::DigestItem,
) -> Result<(), sp_blockchain::Error>;
}
impl<'a, A> BlockBuilderExt for sc_block_builder::BlockBuilder<'a, substrate_test_runtime::Block, A>
where
A: ProvideRuntimeApi<substrate_test_runtime::Block>
+ sp_api::CallApiAt<substrate_test_runtime::Block>
+ 'a,
A::Api: BlockBuilderApi<substrate_test_runtime::Block> + ApiExt<substrate_test_runtime::Block>,
{
fn push_transfer(
&mut self,
transfer: substrate_test_runtime::Transfer,
) -> Result<(), sp_blockchain::Error> {
self.push(transfer.into_unchecked_extrinsic())
}
fn push_storage_change(
&mut self,
key: Vec<u8>,
value: Option<Vec<u8>>,
) -> Result<(), sp_blockchain::Error> {
self.push(ExtrinsicBuilder::new_storage_change(key, value).build())
}
fn push_deposit_log_digest_item(
&mut self,
log: sp_runtime::generic::DigestItem,
) -> Result<(), sp_blockchain::Error> {
self.push(ExtrinsicBuilder::new_deposit_log_digest_item(log).build())
}
}