Run an ABCI query and print the results on STDOUT.
(
client: FendermintClient,
height: Height,
command: RpcQueryCommands,
)
| 74 | |
| 75 | /// Run an ABCI query and print the results on STDOUT. |
| 76 | async fn query( |
| 77 | client: FendermintClient, |
| 78 | height: Height, |
| 79 | command: RpcQueryCommands, |
| 80 | ) -> anyhow::Result<()> { |
| 81 | let height = FvmQueryHeight::from(height.value()); |
| 82 | match command { |
| 83 | RpcQueryCommands::Ipld { cid } => match client.ipld(&cid, height).await? { |
| 84 | Some(data) => println!("{}", to_b64(&data)), |
| 85 | None => eprintln!("CID not found"), |
| 86 | }, |
| 87 | RpcQueryCommands::ActorState { address } => { |
| 88 | match client.actor_state(&address, height).await?.value { |
| 89 | Some((id, state)) => { |
| 90 | let out = json! ({ |
| 91 | "id": id, |
| 92 | "state": state, |
| 93 | }); |
| 94 | print_json(&out)?; |
| 95 | } |
| 96 | None => { |
| 97 | eprintln!("actor not found") |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | RpcQueryCommands::StateParams => { |
| 102 | let res = client.state_params(height).await?; |
| 103 | let json = json!({ "response": res }); |
| 104 | print_json(&json)?; |
| 105 | } |
| 106 | }; |
| 107 | Ok(()) |
| 108 | } |
| 109 | |
| 110 | /// Create a client, make a call to Tendermint with a closure, then maybe extract some JSON |
| 111 | /// depending on the return value, finally print the result in JSON. |
nothing calls this directly
no test coverage detected