miden_standards/account/auth/
no_auth.rs1use miden_protocol::account::component::AccountComponentMetadata;
2use miden_protocol::account::{AccountComponent, AccountType};
3
4use crate::account::components::no_auth_library;
5
6pub struct NoAuth;
21
22impl NoAuth {
23 pub const NAME: &'static str = "miden::standards::components::auth::no_auth";
25
26 pub fn new() -> Self {
28 Self
29 }
30
31 pub fn component_metadata() -> AccountComponentMetadata {
33 AccountComponentMetadata::new(Self::NAME, AccountType::all())
34 .with_description("No authentication component")
35 }
36}
37
38impl Default for NoAuth {
39 fn default() -> Self {
40 Self::new()
41 }
42}
43
44impl From<NoAuth> for AccountComponent {
45 fn from(_: NoAuth) -> Self {
46 let metadata = NoAuth::component_metadata();
47
48 AccountComponent::new(no_auth_library(), vec![], metadata)
49 .expect("NoAuth component should satisfy the requirements of a valid account component")
50 }
51}
52
53#[cfg(test)]
57mod tests {
58 use miden_protocol::account::AccountBuilder;
59
60 use super::*;
61 use crate::account::wallets::BasicWallet;
62
63 #[test]
64 fn test_no_auth_component() {
65 let _account = AccountBuilder::new([0; 32])
67 .with_auth_component(NoAuth)
68 .with_component(BasicWallet)
69 .build()
70 .expect("account building failed");
71 }
72}