staging_node_inspect/
command.rs1use crate::{
22 cli::{InspectCmd, InspectSubCmd},
23 Inspector,
24};
25use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams};
26use sc_service::Configuration;
27use sp_runtime::traits::Block;
28
29type HostFunctions =
30 (sp_io::SubstrateHostFunctions, sp_statement_store::runtime_api::HostFunctions);
31
32impl InspectCmd {
33 pub fn run<B, RA>(&self, config: Configuration) -> Result<()>
35 where
36 B: Block,
37 RA: Send + Sync + 'static,
38 {
39 let executor = sc_service::new_wasm_executor::<HostFunctions>(&config.executor);
40 let client = sc_service::new_full_client::<B, RA, _>(&config, None, executor)?;
41 let inspect = Inspector::<B>::new(client);
42
43 match &self.command {
44 InspectSubCmd::Block { input } => {
45 let input = input.parse()?;
46 let res = inspect.block(input).map_err(|e| e.to_string())?;
47 println!("{res}");
48 Ok(())
49 },
50 InspectSubCmd::Extrinsic { input } => {
51 let input = input.parse()?;
52 let res = inspect.extrinsic(input).map_err(|e| e.to_string())?;
53 println!("{res}");
54 Ok(())
55 },
56 }
57 }
58}
59
60impl CliConfiguration for InspectCmd {
61 fn shared_params(&self) -> &SharedParams {
62 &self.shared_params
63 }
64
65 fn import_params(&self) -> Option<&ImportParams> {
66 Some(&self.import_params)
67 }
68}