use crate::replay_policy::{
quota::{
DEPLOYMENT_QUOTA_V1, DEPLOYMENT_RESERVE_V1, VALUE_TRANSFER_QUOTA_V1,
VALUE_TRANSFER_RESERVE_V1,
},
types::{
CostClass, ReplayCommandKindLabel, ReplayCycleReservePolicyLabel,
ReplayImplementationStatus, ReplayPolicy, ReplayQuotaPolicyLabel,
RootCapabilityCommandReplayPolicy,
},
};
pub const ROOT_CAPABILITY_COMMAND_REPLAY_POLICY_MANIFEST: &[RootCapabilityCommandReplayPolicy] = &[
root_capability_replay_protected(
"ProvisionCanister",
command_kind("root.provision.v1"),
ReplayImplementationStatus::Implemented,
CostClass::ManagementDeployment,
Some(DEPLOYMENT_QUOTA_V1),
Some(DEPLOYMENT_RESERVE_V1),
),
root_capability_replay_protected(
"UpgradeCanister",
command_kind("root.upgrade.v1"),
ReplayImplementationStatus::Implemented,
CostClass::ManagementDeployment,
Some(DEPLOYMENT_QUOTA_V1),
Some(DEPLOYMENT_RESERVE_V1),
),
root_capability_replay_protected(
"RecycleCanister",
command_kind("root.recycle_canister.v1"),
ReplayImplementationStatus::Implemented,
CostClass::ManagementDeployment,
Some(DEPLOYMENT_QUOTA_V1),
Some(DEPLOYMENT_RESERVE_V1),
),
root_capability_replay_protected(
"RequestCycles",
command_kind("root.request_cycles.v1"),
ReplayImplementationStatus::Implemented,
CostClass::ValueTransfer,
Some(VALUE_TRANSFER_QUOTA_V1),
Some(VALUE_TRANSFER_RESERVE_V1),
),
];
#[must_use]
pub const fn root_capability_command_replay_policy_manifest()
-> &'static [RootCapabilityCommandReplayPolicy] {
ROOT_CAPABILITY_COMMAND_REPLAY_POLICY_MANIFEST
}
const fn command_kind(label: &'static str) -> ReplayCommandKindLabel {
ReplayCommandKindLabel::new(label)
}
const fn root_capability_replay_protected(
variant: &'static str,
command_kind: ReplayCommandKindLabel,
implementation_status: ReplayImplementationStatus,
cost_class: CostClass,
quota_policy: Option<ReplayQuotaPolicyLabel>,
cycle_reserve_policy: Option<ReplayCycleReservePolicyLabel>,
) -> RootCapabilityCommandReplayPolicy {
RootCapabilityCommandReplayPolicy {
variant,
replay_policy: ReplayPolicy::ReplayProtected {
command_kind,
requires_operation_id: true,
},
implementation_status,
cost_class,
quota_policy,
cycle_reserve_policy,
}
}