1pub mod reserve;
2
3use crate::{
4 Error,
5 interface::ic::get_current_subnet_pid,
6 memory::{Env, topology::SubnetCanisterRegistry},
7 ops::{
8 context::cfg_current_subnet,
9 prelude::*,
10 request::{CreateCanisterParent, create_canister_request},
11 },
12};
13
14pub async fn root_set_subnet_id() {
15 if let Ok(Some(subnet_pid)) = get_current_subnet_pid().await {
17 Env::set_subnet_pid(subnet_pid);
18 }
19}
20
21pub async fn root_create_canisters() -> Result<(), Error> {
23 let subnet_cfg = cfg_current_subnet()?;
25 for ty in &subnet_cfg.auto_create {
26 create_canister_request::<()>(ty, CreateCanisterParent::Root, None).await?;
27 }
28
29 for canister in SubnetCanisterRegistry::export() {
31 log!(Log::Info, "🥫 {} ({})", canister.ty, canister.pid);
32 }
33
34 Ok(())
35}