junobuild_shared/mgmt/
types.rs

1pub mod cmc {
2    use candid::{CandidType, Principal};
3    use ic_cdk::management_canister::{CanisterId, CanisterSettings};
4    use ic_ledger_types::BlockIndex;
5    use serde::Deserialize;
6
7    pub type Cycles = u128;
8
9    #[derive(CandidType, Deserialize)]
10    pub enum NotifyError {
11        Refunded {
12            reason: String,
13            block_index: Option<BlockIndex>,
14        },
15        InvalidTransaction(String),
16        TransactionTooOld(BlockIndex),
17        Processing,
18        Other {
19            error_code: u64,
20            error_message: String,
21        },
22    }
23
24    #[derive(CandidType, Deserialize)]
25    pub struct TopUpCanisterArgs {
26        pub block_index: BlockIndex,
27        pub canister_id: Principal,
28    }
29
30    #[derive(CandidType, Deserialize)]
31    pub enum CreateCanisterError {
32        Refunded {
33            refund_amount: u128,
34            create_error: String,
35        },
36    }
37
38    pub type CreateCanisterResult = Result<CanisterId, CreateCanisterError>;
39
40    #[derive(CandidType, Deserialize)]
41    pub struct SubnetFilter {
42        pub subnet_type: Option<String>,
43    }
44
45    pub type SubnetId = Principal;
46
47    #[derive(CandidType, Deserialize)]
48    pub enum SubnetSelection {
49        /// Choose a random subnet that satisfies the specified properties
50        Filter(SubnetFilter),
51        /// Choose a specific subnet
52        Subnet { subnet: SubnetId },
53    }
54
55    #[derive(CandidType, Deserialize)]
56    pub struct CreateCanister {
57        #[deprecated(note = "use subnet_selection instead")]
58        pub subnet_type: Option<String>,
59        pub subnet_selection: Option<SubnetSelection>,
60        pub settings: Option<CanisterSettings>,
61    }
62}
63
64pub mod ic {
65    use crate::types::core::Blob;
66    use candid::{Nat, Principal};
67
68    pub struct WasmArg {
69        pub wasm: Blob,
70        pub install_arg: Vec<u8>,
71    }
72
73    pub struct CreateCanisterInitSettingsArg {
74        pub controllers: Vec<Principal>,
75        pub freezing_threshold: Nat,
76    }
77}