radix_engine/blueprints/access_controller/v1/
state.rs

1use super::internal_prelude::*;
2use crate::internal_prelude::*;
3use crate::*;
4use radix_blueprint_schema_init::*;
5use radix_engine_interface::api::*;
6use radix_engine_interface::blueprints::resource::*;
7use radix_engine_interface::object_modules::metadata::*;
8use sbor::rust::prelude::*;
9
10#[derive(Debug, PartialEq, Eq, ScryptoSbor)]
11#[sbor(type_name = "AccessControllerSubstate")]
12pub struct AccessControllerV1Substate {
13    /// A vault where the asset controlled by the access controller lives.
14    pub controlled_asset: Vault,
15
16    /// The amount of time (in minutes) that it takes for timed recovery to be done. Maximum is
17    /// 4,294,967,295 minutes which is 8171.5511700913 years. When this is [`None`], then timed
18    /// recovery can not be performed through this access controller.
19    pub timed_recovery_delay_in_minutes: Option<u32>,
20
21    /// The resource address of the recovery badge that will be used by the wallet and optionally
22    /// by other clients as well.
23    pub recovery_badge: ResourceAddress,
24
25    /// The states of the Access Controller.
26    pub state: (
27        // Controls whether the primary role is locked or unlocked
28        PrimaryRoleLockingState,
29        // Primary role recovery and withdraw states
30        PrimaryRoleRecoveryAttemptState,
31        PrimaryRoleBadgeWithdrawAttemptState,
32        // Recovery role recovery and withdraw states
33        RecoveryRoleRecoveryAttemptState,
34        RecoveryRoleBadgeWithdrawAttemptState,
35    ),
36}
37
38impl AccessControllerV1Substate {
39    pub fn new(
40        controlled_asset: Vault,
41        timed_recovery_delay_in_minutes: Option<u32>,
42        recovery_badge: ResourceAddress,
43    ) -> Self {
44        Self {
45            controlled_asset,
46            timed_recovery_delay_in_minutes,
47            recovery_badge,
48            state: Default::default(),
49        }
50    }
51}
52
53declare_native_blueprint_state! {
54    blueprint_ident: AccessController,
55    blueprint_snake_case: access_controller,
56    features: {
57    },
58    fields: {
59        state:  {
60            ident: State,
61            field_type: {
62                kind: StaticSingleVersioned,
63            },
64            condition: Condition::Always,
65        }
66    },
67    collections: {}
68}
69
70pub type AccessControllerStateV1 = AccessControllerV1Substate;