miden_standards/account/access/pausable/
manager.rs1use miden_protocol::account::component::{AccountComponentCode, AccountComponentMetadata};
2use miden_protocol::account::{AccountComponent, AccountProcedureRoot};
3
4use crate::account::account_component_code;
5use crate::procedure_root;
6
7account_component_code!(PAUSABLE_MANAGER_CODE, "miden-standards-access-pausable-manager.masp");
11
12procedure_root!(
13 PAUSABLE_MANAGER_PAUSE,
14 PausableManager::NAME,
15 PausableManager::PAUSE_PROC_NAME,
16 PausableManager::code()
17);
18
19procedure_root!(
20 PAUSABLE_MANAGER_UNPAUSE,
21 PausableManager::NAME,
22 PausableManager::UNPAUSE_PROC_NAME,
23 PausableManager::code()
24);
25
26#[derive(Debug, Clone, Copy, Default)]
43pub struct PausableManager;
44
45impl PausableManager {
46 pub const NAME: &'static str = "miden::standards::components::access::pausable::manager";
48
49 const PAUSE_PROC_NAME: &'static str = "pause";
50 const UNPAUSE_PROC_NAME: &'static str = "unpause";
51
52 pub fn code() -> &'static AccountComponentCode {
54 &PAUSABLE_MANAGER_CODE
55 }
56
57 pub fn pause_root() -> AccountProcedureRoot {
59 *PAUSABLE_MANAGER_PAUSE
60 }
61
62 pub fn unpause_root() -> AccountProcedureRoot {
64 *PAUSABLE_MANAGER_UNPAUSE
65 }
66}
67
68impl From<PausableManager> for AccountComponent {
69 fn from(_: PausableManager) -> Self {
70 let metadata = AccountComponentMetadata::new(PausableManager::NAME).with_description(
71 "PausableManager: pause / unpause admin procedures gated by the account-wide \
72 Authority component. Requires the Pausable companion component for storage and the \
73 Authority component for auth dispatch.",
74 );
75
76 AccountComponent::new(PausableManager::code().clone(), vec![], metadata).expect(
77 "pausable manager component should satisfy the requirements of a valid account component",
78 )
79 }
80}