1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
use serde_bytes::{ByteArray, ByteBuf};
use std::collections::BTreeSet;

#[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)]
pub struct ClusterInfo {
    pub name: String,
    pub ecdsa_key_name: String,
    pub ecdsa_token_public_key: String,
    pub token_expiration: u64, // in seconds
    pub managers: BTreeSet<Principal>,
    pub subject_authz_total: u64,
    pub bucket_latest_version: ByteArray<32>,
    pub bucket_wasm_total: u64,
    pub bucket_deployed_total: u64,
    pub bucket_deployment_logs: u64,
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
pub struct WasmInfo {
    pub created_at: u64, // in milliseconds
    pub created_by: Principal,
    pub description: String,
    pub wasm: ByteBuf,
    pub hash: ByteArray<32>, // sha256 hash of the wasm data
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
pub struct AddWasmInput {
    pub description: String,
    pub wasm: ByteBuf,
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
pub struct DeployWasmInput {
    pub canister: Principal,
    pub args: Option<ByteBuf>,
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
pub struct BucketDeploymentInfo {
    pub deploy_at: u64, // in milliseconds
    pub canister: Principal,
    pub prev_hash: ByteArray<32>,
    pub wasm_hash: ByteArray<32>,
    pub args: Option<ByteBuf>,
    pub error: Option<String>,
}