smart_account_auth/data.rs
1use saa_common::{CredentialAddress, CredentialId, CredentialRecord};
2use saa_schema::saa_type;
3use crate::Credential;
4
5
6/// CredentialData is wrapper for dealing with multiple credentials at the same time.
7/// Implements both `Verifiable` and `CredentialWrapper` traits.
8#[saa_type]
9pub struct CredentialData {
10 /// A flag indicating that the environment can derive an additional credential
11 /// that isn't included in the list of credentials directly.
12 /// Most typically it's the transaction signer that has been verified beforehand
13 /// but can be any other authorized dicated by the environment / smart contract logic
14 pub use_native : Option<bool>,
15 /// An optional index indicating which credential will be used as the primary. Default to the first one
16 pub primary_index : Option<usize>,
17 /// An optional flag that tell us whether to perform an extensive validation before verifying each one thouroughly
18 pub pre_validate : Option<bool>,
19 /// An optional flag that indicates whether that
20 pub override_primary : Option<bool>,
21 /// The list of credentials to be verified
22 pub credentials : Vec<Credential>,
23}
24
25
26
27#[saa_type]
28pub struct VerifiedData {
29 /// a list of verified credentials that have passed all checks
30 pub credentials : Vec<CredentialRecord>,
31 /// a list of addresses (recognized by the environment) were derived from the credentials
32 pub addresses : Vec<CredentialAddress>,
33 /// an id of a credential that is considered primary in the batch
34 pub primary_id : CredentialId,
35 /// in case if we updating an existing state with new credentials, this flag indicates
36 /// whether to override the existing primary credential with the primary from this batch
37 pub override_primary : bool,
38 /// a flag indicating that the batch has credentials native to the environment like `caller` or `info.sender``
39 pub has_natives : bool,
40 /// a flag indicating that there is at least one credential wuth addutional properties to be reused e.g. `Passkeys``
41 pub has_extensions : bool,
42 #[cfg(feature = "replay")]
43 /// a nonce value used for replay attack protection
44 pub nonce : u64
45}