use alloc::vec::Vec;
use miden_protocol::account::{AccountComponent, AccountProcedureRoot};
mod allow_all;
mod allowlist;
mod basic_allowlist;
mod basic_blocklist;
mod blocklist;
pub use allow_all::TransferAllowAll;
pub use allowlist::{AllowlistOwnerControlled, AllowlistStorage};
pub use basic_allowlist::BasicAllowlist;
pub use basic_blocklist::BasicBlocklist;
pub use blocklist::{BlocklistOwnerControlled, BlocklistStorage};
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub enum TransferPolicy {
#[default]
AllowAll,
Blocklist,
Allowlist { allow_list: AllowlistStorage },
Custom(AccountProcedureRoot),
}
impl TransferPolicy {
pub fn root(&self) -> AccountProcedureRoot {
match self {
Self::AllowAll => TransferAllowAll::root(),
Self::Blocklist => BasicBlocklist::root(),
Self::Allowlist { .. } => BasicAllowlist::root(),
Self::Custom(root) => *root,
}
}
pub(crate) fn into_components(self) -> Vec<AccountComponent> {
match self {
Self::AllowAll => vec![TransferAllowAll.into()],
Self::Blocklist => vec![BasicBlocklist::default().into()],
Self::Allowlist { allow_list } => vec![BasicAllowlist::from(allow_list).into()],
Self::Custom(_) => Vec::new(),
}
}
}