use crate::ids::{
CanisterRole, ComponentSpecId, ComponentTopologyDigest, FleetSubnetRootReleaseSet,
ReleaseBuildId,
};
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
pub const ROOT_STORE_RELEASE_SET_MANIFEST_MAX_BYTES: u64 = 16 * 1_024 * 1_024;
pub const ROOT_STORE_RELEASE_SET_TEMPLATE_PREFIX: &str = "root-release-set:";
pub const ROOT_STORE_ARTIFACT_TEMPLATE_PREFIX: &str = "component:";
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootStoreArtifact {
pub role: CanisterRole,
pub package: String,
pub release_build_id: ReleaseBuildId,
pub wasm_relative_path: String,
pub wasm_size_bytes: u64,
pub wasm_sha256_hex: String,
pub wasm_gz_relative_path: String,
pub wasm_gz_size_bytes: u64,
pub wasm_gz_sha256_hex: String,
}
#[derive(
CandidType, Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
#[serde(rename_all = "snake_case")]
pub enum RootStoreReleaseSetEntryKind {
Component,
ComponentChild,
}
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootStoreReleaseSetEntry {
pub component_spec: ComponentSpecId,
pub kind: RootStoreReleaseSetEntryKind,
pub artifact: RootStoreArtifact,
}
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootStoreReleaseSetManifest {
pub release_build_id: ReleaseBuildId,
pub component_topology_digest: ComponentTopologyDigest,
pub entries: Vec<RootStoreReleaseSetEntry>,
}
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct RootStoreBootstrapRequest {
pub manifest_payload_size_bytes: u64,
}
#[derive(CandidType, Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct RootStoreCatalogEntry {
pub role: CanisterRole,
pub payload_hash: [u8; 32],
pub payload_size_bytes: u64,
}
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct RootStoreBootstrapResponse {
pub fleet_subnet_root: Principal,
pub wasm_store: Principal,
pub release_set: FleetSubnetRootReleaseSet,
pub catalog: Vec<RootStoreCatalogEntry>,
}