๐ณPre Authorization
// PDA Seeds: ['pre-authorization', token_account, debit_authority]
pub struct PreAuthorization {
pub bump: u8, // The canocial bump in the PDA seed
pub paused: bool, // Set to true if the pre-authorization is paused
pub token_account: Pubkey, // The account from which funds can be debited
pub variant: PreAuthorizationVariant, // Recurring or One-Time variant (see below)
pub debit_authority: Pubkey, // The authority that needs to sign to debit via the pre-auth
pub activation_unix_timestamp: i64, // The timestamp at which this pre-auth becomes debitable
}
pub enum PreAuthorizationVariant {
OneTime {
amount_authorized: u64, // Total amount that can be debited via this pre-auth
expiry_unix_timestamp: i64, // Any debits should occur before this timestamp
amount_debited: u64, // Tracks total debited so far via this pre-auth
},
Recurring {
repeat_frequency_seconds: u64, // The time period between cycles
recurring_amount_authorized: u64, // Total amount that can be debited via this pre-auth in each cycle
amount_debited_last_cycle: u64, // Tracks amount debited in the "last_debited_cycle" (see below)
amount_debited_total: u64, // Tracks total amount debited via this pre-auth
last_debited_cycle: u64, // Tracks the cycle in which the last debit occured via this pre-auth
// None: infinite recurring
// Some(n): approved for n cycles from activation,
num_cycles: Option<u64>, // Set this to limit duration of the recurring pre-auth
// true: amount authorized is reset to "recurring_amount_authorized" each cycle
// false: unused amounts from prev. cycles carries forward to new cycles
reset_every_cycle: bool, // WARNING: setting this to false will cause the "recurring_amount_authorized" to accumulate across cycles
},
}Last updated