canic-core 0.46.4

Canic — a canister orchestration and management toolkit for the Internet Computer
Documentation
/// Runtime wire-level endpoint names used by `canic-core` for inter-canister calls.
///
/// Keep these synchronized with the macro-defined endpoints.
use crate::{api::ic::ProtectedInternalEndpoint, ids::CanisterRole};

pub const CANIC_RESPONSE_CAPABILITY_V1: &str = "canic_response_capability_v1";
pub const CANIC_REQUEST_DELEGATION: &str = "canic_request_delegation";
pub const CANIC_REQUEST_ROLE_ATTESTATION: &str = "canic_request_role_attestation";
pub const CANIC_REQUEST_INTERNAL_INVOCATION_PROOF: &str = "canic_request_internal_invocation_proof";
pub const CANIC_ATTESTATION_KEY_SET: &str = "canic_attestation_key_set";
pub const CANIC_BOOTSTRAP_STATUS: &str = "canic_bootstrap_status";
pub const CANIC_CYCLE_BALANCE: &str = "canic_cycle_balance";
pub const CANIC_CYCLE_TRACKER: &str = "canic_cycle_tracker";
pub const CANIC_CYCLE_TOPUPS: &str = "canic_cycle_topups";
pub const CANIC_METADATA: &str = "canic_metadata";
pub const CANIC_WASM_STORE_CATALOG: &str = "canic_wasm_store_catalog";
pub const CANIC_WASM_STORE_INFO: &str = "canic_wasm_store_info";
pub const CANIC_WASM_STORE_STATUS: &str = "canic_wasm_store_status";
pub const CANIC_WASM_STORE_PREPARE_GC: &str = "canic_wasm_store_prepare_gc";
pub const CANIC_WASM_STORE_BEGIN_GC: &str = "canic_wasm_store_begin_gc";
pub const CANIC_WASM_STORE_COMPLETE_GC: &str = "canic_wasm_store_complete_gc";
pub const CANIC_WASM_STORE_PREPARE: &str = "canic_wasm_store_prepare";
pub const CANIC_WASM_STORE_CHUNK: &str = "canic_wasm_store_chunk";
pub const CANIC_WASM_STORE_PUBLISH_CHUNK: &str = "canic_wasm_store_publish_chunk";
pub const CANIC_WASM_STORE_STAGE_MANIFEST: &str = "canic_wasm_store_stage_manifest";
pub const CANIC_WASM_STORE_BOOTSTRAP_RESUME_ROOT_ADMIN: &str =
    "canic_wasm_store_bootstrap_resume_root_admin";
pub const CANIC_WASM_STORE_BOOTSTRAP_DEBUG: &str = "canic_wasm_store_bootstrap_debug";
pub const CANIC_WASM_STORE_OVERVIEW: &str = "canic_wasm_store_overview";
pub const CANIC_TEMPLATE_PREPARE_ADMIN: &str = "canic_template_prepare_admin";
pub const CANIC_TEMPLATE_PUBLISH_CHUNK_ADMIN: &str = "canic_template_publish_chunk_admin";
pub const CANIC_TEMPLATE_STAGE_MANIFEST_ADMIN: &str = "canic_template_stage_manifest_admin";

pub const CANIC_SYNC_STATE: &str = "canic_sync_state";
pub const CANIC_SYNC_TOPOLOGY: &str = "canic_sync_topology";

pub const CANIC_WASM_STORE_PROTECTED_UPDATE_METHODS: &[&str] = &[
    CANIC_WASM_STORE_BEGIN_GC,
    CANIC_WASM_STORE_CHUNK,
    CANIC_WASM_STORE_COMPLETE_GC,
    CANIC_WASM_STORE_INFO,
    CANIC_WASM_STORE_PREPARE,
    CANIC_WASM_STORE_PREPARE_GC,
    CANIC_WASM_STORE_PUBLISH_CHUNK,
    CANIC_WASM_STORE_STAGE_MANIFEST,
];

pub const CANIC_WASM_STORE_STRUCTURAL_QUERY_METHODS: &[&str] =
    &[CANIC_WASM_STORE_CATALOG, CANIC_WASM_STORE_STATUS];

#[must_use]
pub fn canic_wasm_store_method_requires_internal_proof(method: &str) -> bool {
    CANIC_WASM_STORE_PROTECTED_UPDATE_METHODS.contains(&method)
}

#[must_use]
pub fn canic_wasm_store_begin_gc_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_BEGIN_GC)
}

#[must_use]
pub fn canic_wasm_store_chunk_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_CHUNK)
}

#[must_use]
pub fn canic_wasm_store_complete_gc_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_COMPLETE_GC)
}

#[must_use]
pub fn canic_wasm_store_info_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_INFO)
}

#[must_use]
pub fn canic_wasm_store_prepare_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_PREPARE)
}

#[must_use]
pub fn canic_wasm_store_prepare_gc_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_PREPARE_GC)
}

#[must_use]
pub fn canic_wasm_store_publish_chunk_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_PUBLISH_CHUNK)
}

#[must_use]
pub fn canic_wasm_store_stage_manifest_endpoint() -> ProtectedInternalEndpoint {
    wasm_store_root_endpoint(CANIC_WASM_STORE_STAGE_MANIFEST)
}

fn wasm_store_root_endpoint(method: &'static str) -> ProtectedInternalEndpoint {
    ProtectedInternalEndpoint::new(method, [CanisterRole::ROOT])
}