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 =
41 sc_service::new_full_client::<B, RA, _>(&config, None, executor, Default::default())?;
42 let inspect = Inspector::<B>::new(client);
43
44 match &self.command {
45 InspectSubCmd::Block { input } => {
46 let input = input.parse()?;
47 let res = inspect.block(input).map_err(|e| e.to_string())?;
48 println!("{res}");
49 Ok(())
50 },
51 InspectSubCmd::Extrinsic { input } => {
52 let input = input.parse()?;
53 let res = inspect.extrinsic(input).map_err(|e| e.to_string())?;
54 println!("{res}");
55 Ok(())
56 },
57 }
58 }
59}
60
61impl CliConfiguration for InspectCmd {
62 fn shared_params(&self) -> &SharedParams {
63 &self.shared_params
64 }
65
66 fn import_params(&self) -> Option<&ImportParams> {
67 Some(&self.import_params)
68 }
69}