Skip to main content

canic_core/dto/
state.rs

1use crate::dto::prelude::*;
2
3//
4// AppCommand
5//
6
7#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
8pub enum AppCommand {
9    SetStatus(AppStatus),
10    SetCyclesFundingEnabled(bool),
11}
12
13//
14// AppCommandResponse
15//
16
17#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
18pub enum AppCommandResponse {
19    Status(SetStateResponse<AppStatus>),
20    CyclesFundingEnabled(SetStateResponse<bool>),
21}
22
23//
24// SetStateResponse
25//
26
27#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
28pub struct SetStateResponse<T> {
29    pub previous: T,
30    pub current: T,
31    pub changed: bool,
32}
33
34//
35// AppStatus
36//
37
38#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
39pub enum AppStatus {
40    Active,
41    Readonly,
42    Stopped,
43}
44
45//
46// AppMode
47//
48
49#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
50pub enum AppMode {
51    Enabled,
52    Readonly,
53    Disabled,
54}
55
56//
57// AppStateInput
58//
59
60#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
61pub struct AppStateInput {
62    pub mode: AppMode,
63    pub cycles_funding_enabled: bool,
64}
65
66//
67// AppStateResponse
68//
69
70#[derive(CandidType, Deserialize)]
71pub struct AppStateResponse {
72    pub mode: AppMode,
73    pub cycles_funding_enabled: bool,
74}
75
76//
77// SubnetRootPublicKeyInput
78//
79
80#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
81pub struct SubnetRootPublicKeyInput {
82    pub public_key_sec1: Vec<u8>,
83    pub key_name: String,
84    pub key_hash: [u8; 32],
85}
86
87//
88// SubnetAuthStateInput
89//
90
91#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
92pub struct SubnetAuthStateInput {
93    pub delegated_root_public_key: Option<SubnetRootPublicKeyInput>,
94}
95
96//
97// SubnetStateInput
98//
99
100#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
101pub struct SubnetStateInput {
102    pub auth: SubnetAuthStateInput,
103}
104
105//
106// SubnetStateResponse
107//
108
109#[derive(CandidType, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
110pub struct SubnetStateResponse {
111    pub auth: SubnetAuthStateInput,
112}
113
114//
115// BootstrapStatusResponse
116//
117
118#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
119pub struct BootstrapStatusResponse {
120    pub ready: bool,
121    pub phase: String,
122    pub last_error: Option<String>,
123}