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

Function fetch_metadata

src/utils.rs:286–304  ·  view source on GitHub ↗
(
    agent: &Agent,
    id: Principal,
    sub_paths: &str,
)

Source from the content-addressed store, hash-verified

284 fetch_state_path_(agent, path).await
285}
286pub async fn fetch_metadata(
287 agent: &Agent,
288 id: Principal,
289 sub_paths: &str,
290) -> anyhow::Result<Vec<u8>> {
291 let mut path: Vec<ic_agent::hash_tree::Label<Vec<u8>>> =
292 vec!["canister".as_bytes().into(), id.as_slice().into()];
293 path.extend(sub_paths.split('/').map(|s| s.as_bytes().into()));
294 let path = StatePath {
295 path,
296 effective_id: Some(id),
297 kind: StateKind::Canister,
298 result: StateType::Blob,
299 };
300 match fetch_state_path_(agent, path).await? {
301 IDLValue::Blob(b) => Ok(b),
302 _ => unreachable!(),
303 }
304}
305async fn get_canister_id_from_subnet(
306 agent: &Agent,
307 subnet_id: ic_agent::hash_tree::Label<Vec<u8>>,

Callers 1

fetch_actorFunction · 0.85

Calls 1

fetch_state_path_Function · 0.85

Tested by

no test coverage detected