use miden_protocol::account::AccountComponent;
use miden_protocol::account::component::{AccountComponentCode, AccountComponentMetadata};
use crate::account::account_component_code;
account_component_code!(
ALLOWLIST_OWNER_CONTROLLED_CODE,
"faucets/policies/transfer/allowlist/owner_controlled.masl"
);
#[derive(Debug, Clone, Copy, Default)]
pub struct AllowlistOwnerControlled;
impl AllowlistOwnerControlled {
pub const NAME: &'static str =
"miden::standards::components::faucets::policies::transfer::allowlist::owner_controlled";
pub fn code() -> &'static AccountComponentCode {
&ALLOWLIST_OWNER_CONTROLLED_CODE
}
pub fn component_metadata() -> AccountComponentMetadata {
AccountComponentMetadata::new(Self::NAME).with_description(
"Owner-controlled allowlist admin: wraps `allowlist::allow_account` / \
`disallow_account` with Ownable2Step authorization.",
)
}
}
impl From<AllowlistOwnerControlled> for AccountComponent {
fn from(_: AllowlistOwnerControlled) -> Self {
let metadata = AllowlistOwnerControlled::component_metadata();
AccountComponent::new(AllowlistOwnerControlled::code().clone(), vec![], metadata)
.expect("owner-controlled allowlist admin component should be valid")
}
}