Skip to main content

canic_core/api/
lifecycle.rs

1use crate::{
2    dto::{abi::v1::CanisterInitPayload, subnet::SubnetIdentity},
3    ids::CanisterRole,
4    lifecycle,
5};
6
7///
8/// LifecycleApi
9///
10
11pub struct LifecycleApi;
12
13impl LifecycleApi {
14    pub fn init_root_canister_before_bootstrap(
15        identity: SubnetIdentity,
16        config_str: &str,
17        config_path: &str,
18    ) {
19        lifecycle::init::init_root_canister_before_bootstrap(identity, config_str, config_path);
20    }
21
22    pub fn schedule_init_root_bootstrap() {
23        lifecycle::init::schedule_init_root_bootstrap();
24    }
25
26    pub fn post_upgrade_root_canister_before_bootstrap(config_str: &str, config_path: &str) {
27        lifecycle::upgrade::post_upgrade_root_canister_before_bootstrap(config_str, config_path);
28    }
29
30    pub fn schedule_post_upgrade_root_bootstrap() {
31        lifecycle::upgrade::schedule_post_upgrade_root_bootstrap();
32    }
33
34    pub fn init_nonroot_canister_before_bootstrap(
35        role: CanisterRole,
36        payload: CanisterInitPayload,
37        config_str: &str,
38        config_path: &str,
39    ) {
40        lifecycle::init::init_nonroot_canister_before_bootstrap(
41            role,
42            payload,
43            config_str,
44            config_path,
45        );
46    }
47
48    pub fn init_nonroot_canister_before_bootstrap_with_attestation_cache(
49        role: CanisterRole,
50        payload: CanisterInitPayload,
51        config_str: &str,
52        config_path: &str,
53    ) {
54        lifecycle::init::init_nonroot_canister_before_bootstrap_with_attestation_cache(
55            role,
56            payload,
57            config_str,
58            config_path,
59        );
60    }
61
62    pub fn schedule_init_nonroot_bootstrap(args: Option<Vec<u8>>) {
63        lifecycle::init::schedule_init_nonroot_bootstrap(args);
64    }
65
66    pub fn post_upgrade_nonroot_canister_before_bootstrap(
67        role: CanisterRole,
68        config_str: &str,
69        config_path: &str,
70    ) {
71        lifecycle::upgrade::post_upgrade_nonroot_canister_before_bootstrap(
72            role,
73            config_str,
74            config_path,
75        );
76    }
77
78    pub fn post_upgrade_nonroot_canister_before_bootstrap_with_attestation_cache(
79        role: CanisterRole,
80        config_str: &str,
81        config_path: &str,
82    ) {
83        lifecycle::upgrade::post_upgrade_nonroot_canister_before_bootstrap_with_attestation_cache(
84            role,
85            config_str,
86            config_path,
87        );
88    }
89
90    pub fn schedule_post_upgrade_nonroot_bootstrap() {
91        lifecycle::upgrade::schedule_post_upgrade_nonroot_bootstrap();
92    }
93}