switchboard_solana/oracle_program/accounts/
permission.rs

1use crate::prelude::*;
2
3#[derive(Copy, Clone, AnchorSerialize, AnchorDeserialize, Eq, PartialEq)]
4pub enum SwitchboardPermission {
5    /// queue authority has permitted an Oracle Account to heartbeat on it's queue and receive update requests. Oracles always need permissions to join a queue.
6    PermitOracleHeartbeat = 1 << 0,
7    /// queue authority has permitted an Aggregator Account to request updates from it's oracles or join an existing crank. Note: Not required if a queue has unpermissionedFeedsEnabled.
8    PermitOracleQueueUsage = 1 << 1, // TODO: rename
9    /// queue authority has permitted a VRF Account to request randomness from it's oracles. Note: Not required if a queue has unpermissionedVrfEnabled.
10    PermitVrfRequests = 1 << 2,
11}
12
13#[account(zero_copy(unsafe))]
14#[repr(packed)]
15pub struct PermissionAccountData {
16    /// The authority that is allowed to set permissions for this account.
17    pub authority: Pubkey,
18    /// The SwitchboardPermission enumeration assigned by the granter to the grantee.
19    pub permissions: u32,
20    /// Public key of account that is granting permissions to use its resources.
21    pub granter: Pubkey,
22    /// Public key of account that is being assigned permissions to use a granters resources.
23    pub grantee: Pubkey,
24    /// unused currently. may want permission PDA per permission for
25    /// unique expiration periods, BUT currently only one permission
26    /// per account makes sense for the infra. Dont over engineer.
27    pub expiration: i64,
28    /// The PDA bump to derive the pubkey.
29    pub bump: u8,
30    /// Reserved for future info.
31    pub _ebuf: [u8; 255],
32}
33
34impl PermissionAccountData {
35    pub fn size() -> usize {
36        8 + std::mem::size_of::<PermissionAccountData>()
37    }
38}