MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / query

Function query

fendermint/app/src/cmd/rpc.rs:76–108  ·  view source on GitHub ↗

Run an ABCI query and print the results on STDOUT.

(
    client: FendermintClient,
    height: Height,
    command: RpcQueryCommands,
)

Source from the content-addressed store, hash-verified

74
75/// Run an ABCI query and print the results on STDOUT.
76async 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.

Callers

nothing calls this directly

Calls 4

print_jsonFunction · 0.85
ipldMethod · 0.80
actor_stateMethod · 0.45
state_paramsMethod · 0.45

Tested by

no test coverage detected