radix_engine_interface/blueprints/access_controller/
data.rs

1use crate::blueprints::resource::AccessRule;
2use crate::internal_prelude::*;
3#[cfg(feature = "fuzzing")]
4use arbitrary::Arbitrary;
5
6/// An enum of the roles in the Access Controller component
7#[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, ScryptoSbor, Hash)]
8pub enum Role {
9    Primary,
10    Recovery,
11    Confirmation,
12}
13
14/// The set of roles allowed to propose recoveries. Only Primary and Recovery roles can initiate,
15/// or propose recoveries, Confirmation can't initiate nor propose.
16#[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, ScryptoSbor, Hash)]
17pub enum Proposer {
18    Primary,
19    Recovery,
20}
21
22impl From<Proposer> for Role {
23    fn from(value: Proposer) -> Self {
24        match value {
25            Proposer::Primary => Role::Primary,
26            Proposer::Recovery => Role::Recovery,
27        }
28    }
29}
30
31/// A struct with the set of rule associated with each role - used when creating a new access
32/// controller for the initial rules and also used during recovery for proposing a rule set.
33#[cfg_attr(feature = "fuzzing", derive(Arbitrary))]
34#[derive(Debug, Clone, Eq, PartialEq, ScryptoSbor, ManifestSbor)]
35pub struct RuleSet {
36    pub primary_role: AccessRule,
37    pub recovery_role: AccessRule,
38    pub confirmation_role: AccessRule,
39}
40
41#[derive(Debug, Clone, PartialEq, Eq, ScryptoSbor)]
42pub struct RecoveryProposal {
43    /// The set of rules being proposed for the different roles.
44    pub rule_set: RuleSet,
45
46    /// The proposed delay of timed recoveries.
47    pub timed_recovery_delay_in_minutes: Option<u32>,
48}