MCPcopy Create free account
hub / github.com/dfinity/ic-repl / fetch_state_path

Function fetch_state_path

src/utils.rs:266–285  ·  view source on GitHub ↗
(agent: &Agent, mut path: StatePath)

Source from the content-addressed store, hash-verified

264
265#[tokio::main]
266pub async fn fetch_state_path(agent: &Agent, mut path: StatePath) -> anyhow::Result<IDLValue> {
267 if path.effective_id.is_none() {
268 let id = if path.path.len() >= 3
269 && path.path[0] == "subnet".into()
270 && matches!(path.kind, StateKind::Canister)
271 {
272 get_canister_id_from_subnet(agent, path.path[1].clone()).await.ok_or_else(|| anyhow!("Cannot find any canister on this subnet id. Put the effective canister id as the first argument"))?
273 } else {
274 Principal::from_text(match path.kind {
275 StateKind::Canister => "ryjl3-tyaaa-aaaaa-aaaba-cai",
276 StateKind::Subnet => {
277 "tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe"
278 }
279 })?
280 };
281 path.effective_id = Some(id);
282 eprintln!("Using {id} as effective canister/subnet id. To change it, put the effective id as the first argument.");
283 }
284 fetch_state_path_(agent, path).await
285}
286pub async fn fetch_metadata(
287 agent: &Agent,
288 id: Principal,

Callers 1

evalMethod · 0.85

Calls 3

from_textFunction · 0.85
fetch_state_path_Function · 0.85

Tested by

no test coverage detected