radix_engine_interface/blueprints/access_controller/
data.rs

1use crate::blueprints::resource::AccessRule;
2use crate::internal_prelude::*;
3
4/// An enum of the roles in the Access Controller component
5#[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, ScryptoSbor, Hash)]
6pub enum Role {
7    Primary,
8    Recovery,
9    Confirmation,
10}
11
12/// The set of roles allowed to propose recoveries. Only Primary and Recovery roles can initiate,
13/// or propose recoveries, Confirmation can't initiate nor propose.
14#[derive(Debug, Clone, Copy, PartialOrd, PartialEq, Ord, Eq, ScryptoSbor, Hash)]
15pub enum Proposer {
16    Primary,
17    Recovery,
18}
19
20impl From<Proposer> for Role {
21    fn from(value: Proposer) -> Self {
22        match value {
23            Proposer::Primary => Role::Primary,
24            Proposer::Recovery => Role::Recovery,
25        }
26    }
27}
28
29/// A struct with the set of rule associated with each role - used when creating a new access
30/// controller for the initial rules and also used during recovery for proposing a rule set.
31#[cfg_attr(feature = "fuzzing", derive(::arbitrary::Arbitrary))]
32#[derive(Debug, Clone, Eq, PartialEq, ScryptoSbor, ManifestSbor)]
33pub struct RuleSet {
34    pub primary_role: AccessRule,
35    pub recovery_role: AccessRule,
36    pub confirmation_role: AccessRule,
37}
38
39#[cfg_attr(
40    feature = "fuzzing",
41    derive(::arbitrary::Arbitrary, ::serde::Serialize, ::serde::Deserialize)
42)]
43#[derive(Debug, Clone, Eq, PartialEq, ManifestSbor, ScryptoDescribe)]
44pub struct ManifestRuleSet {
45    pub primary_role: ManifestAccessRule,
46    pub recovery_role: ManifestAccessRule,
47    pub confirmation_role: ManifestAccessRule,
48}
49
50impl From<RuleSet> for ManifestRuleSet {
51    fn from(value: RuleSet) -> Self {
52        Self {
53            primary_role: value.primary_role.into(),
54            recovery_role: value.recovery_role.into(),
55            confirmation_role: value.confirmation_role.into(),
56        }
57    }
58}
59
60#[derive(Debug, Clone, PartialEq, Eq, ScryptoSbor, ManifestSbor)]
61pub struct RecoveryProposal {
62    /// The set of rules being proposed for the different roles.
63    pub rule_set: RuleSet,
64
65    /// The proposed delay of timed recoveries.
66    pub timed_recovery_delay_in_minutes: Option<u32>,
67}
68
69#[derive(Debug, Clone, PartialEq, Eq, ManifestSbor, ScryptoDescribe)]
70pub struct ManifestRecoveryProposal {
71    /// The set of rules being proposed for the different roles.
72    pub rule_set: ManifestRuleSet,
73
74    /// The proposed delay of timed recoveries.
75    pub timed_recovery_delay_in_minutes: Option<u32>,
76}
77
78impl From<RecoveryProposal> for ManifestRecoveryProposal {
79    fn from(value: RecoveryProposal) -> Self {
80        Self {
81            rule_set: value.rule_set.into(),
82            timed_recovery_delay_in_minutes: value.timed_recovery_delay_in_minutes,
83        }
84    }
85}