(agent: &Agent, mut path: StatePath)
| 264 | |
| 265 | #[tokio::main] |
| 266 | pub 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 | } |
| 286 | pub async fn fetch_metadata( |
| 287 | agent: &Agent, |
| 288 | id: Principal, |
no test coverage detected