#[repr(packed(1))]
pub struct FunctionAccountData {
Show 52 fields pub is_scheduled: u8, pub is_triggered: u8, pub permissions: u32, pub status: FunctionStatus, pub bump: u8, pub creator_seed: [u8; 32], pub name: [u8; 64], pub metadata: [u8; 256], pub created_at_slot: u64, pub created_at: i64, pub updated_at: i64, pub enclave: Quote, pub mr_enclaves: [[u8; 32]; 32], pub container_registry: [u8; 64], pub container: [u8; 64], pub version: [u8; 32], pub params_schema: [u8; 256], pub default_container_params: [u8; 256], pub authority: Pubkey, pub attestation_queue: Pubkey, pub queue_idx: u32, pub address_lookup_table: Pubkey, pub schedule: [u8; 64], pub last_execution_timestamp: i64, pub next_allowed_timestamp: i64, pub trigger_count: u64, pub triggered_since: i64, pub permission_expiration: i64, pub num_requests: u64, pub requests_disabled: u8, pub requests_require_authorization: u8, pub reserved1: [u8; 8], pub requests_fee: u64, pub escrow_wallet: Pubkey, pub escrow_token_wallet: Pubkey, pub reward_escrow_wallet: Pubkey, pub reward_escrow_token_wallet: Pubkey, pub error_status: u8, pub num_routines: u64, pub routines_disabled: BoolWithLock, pub routines_require_authorization: u8, pub routines_dev_fee: u64, pub mr_enclave: [u8; 32], pub verification_status: u8, pub verification_timestamp: i64, pub valid_until: i64, pub num_services: u64, pub services_enabled: BoolWithLock, pub services_require_authorization: u8, pub services_signer_rotation_interval: i64, pub services_dev_fee: u64, pub _ebuf: [u8; 930],
}

Fields§

§is_scheduled: u8
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

Whether the function is invoked on a schedule or by request

§is_triggered: u8
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

Whether the function has been manually triggered with the function_trigger instruction

§permissions: u32

The function permissions granted by the attestation_queue.authority

§status: FunctionStatus§bump: u8

PDA bump.

§creator_seed: [u8; 32]

The payer who originally created the function. Cannot change, used to derive PDA.

§name: [u8; 64]

The name of the function for easier identification.

§metadata: [u8; 256]

The metadata of the function for easier identification.

§created_at_slot: u64

The Solana slot when the function was created. (PDA)

§created_at: i64

The unix timestamp when the function was created.

§updated_at: i64

The unix timestamp when the function config (container, registry, version, or schedule) was changed.

§enclave: Quote

The enclave quote

§mr_enclaves: [[u8; 32]; 32]

An array of permitted mr_enclave measurements for the function.

§container_registry: [u8; 64]

The off-chain registry to fetch the function container from.

§container: [u8; 64]

The identifier of the container in the given container_registry.

§version: [u8; 32]

The version tag of the container to pull.

§params_schema: [u8; 256]
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

The expected schema for the container params.

§default_container_params: [u8; 256]
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

The default params passed to the container during scheduled execution.

§authority: Pubkey

The authority of the function which is authorized to make account changes.

§attestation_queue: Pubkey

The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements.

§queue_idx: u32

An incrementer used to rotate through an AttestationQueue’s verifiers.

§address_lookup_table: Pubkey

The address_lookup_table of the function used to increase the number of accounts we can fit into a function result.

§schedule: [u8; 64]
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

The cron schedule to run the function on.

§last_execution_timestamp: i64
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

The unix timestamp when the function was last run.

§next_allowed_timestamp: i64
👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

The unix timestamp when the function is allowed to run next.

§trigger_count: u64
👎Deprecated since 0.28.35: please use a FunctionRequestAccountData for all on-demand executions

The number of times to trigger the function upon the next invocation.

§triggered_since: i64
👎Deprecated since 0.28.35: please use a FunctionRequestAccountData for all on-demand executions

Time this function has been sitting in an explicitly triggered state

§permission_expiration: i64

UNUSED. The unix timestamp when the current permissions expire.

§num_requests: u64

Number of requests created for this function. Used to prevent closing when there are live requests.

§requests_disabled: u8

Whether custom requests have been disabled for this function.

§requests_require_authorization: u8

Whether new requests need to be authorized by the FunctionAccount authority before being initialized. Useful if you want to use CPIs to control request account creation.

§reserved1: [u8; 8]

DEPRECATED.

§requests_fee: u64

The dev fee that is paid out from the request’s escrow to the function’s escrow on each successful invocation. This is used to reward the function maintainer for providing the function. 0 = No Fee. Sender = requests’s escrow_token_wallet. Receiver = function’s reward_token_wallet.

§escrow_wallet: Pubkey

The SwitchboardWallet that will handle pre-funding rewards paid out to function verifiers.

§escrow_token_wallet: Pubkey

The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners.

§reward_escrow_wallet: Pubkey

The SwitchboardWallet that will handle acruing rewards from requests. Defaults to the escrow_wallet.

§reward_escrow_token_wallet: Pubkey

The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters.

§error_status: u8
👎Deprecated since 0.28.35: please use the error_status field on your function consumer (request or routine)

The last reported error code if the most recent response was a failure

§num_routines: u64

Number of routines created for this function. Used to prevent closing when there are live routines.

§routines_disabled: BoolWithLock

Whether custom routines have been disabled for this function.

§routines_require_authorization: u8

Whether new routines need to be authorized by the FunctionAccount authority before being initialized. Useful if you want to provide AccessControl and only allow certain parties to run routines.

§routines_dev_fee: u64

The fee that is paid out from the routine’s escrow to the function’s escrow on each successful invocation. This is used to reward the function maintainer for providing the function. 0 = No Fee. Sender = routine’s escrow_token_wallet. Receiver = function’s reward_token_wallet.

§mr_enclave: [u8; 32]

The functions MRENCLAVE measurement dictating the contents of the secure enclave.

§verification_status: u8

The VerificationStatus of the quote.

§verification_timestamp: i64

The unix timestamp when the quote was last verified.

§valid_until: i64

The unix timestamp when the quotes verification status expires.

§num_services: u64

Number of services created for this function. Used to prevent closing when there are live services.

§services_enabled: BoolWithLock

Whether custom services have been disabled for this function.

§services_require_authorization: u8

Whether new services need to be authorized by the FunctionAccount authority before being initialized. Useful if you want to provide AccessControl and only allow certain parties to run services.

§services_signer_rotation_interval: i64

The number of seconds before a service needs to rotate their keypair, excluding reboots. This is used to payout the services_dev_fee each time the signer is rotated. 0 = No rotation required.

§services_dev_fee: u64

The fee that is paid out from the service’s escrow to the function’s escrow on each successful signer rotation. This is used to reward the function maintainer for providing the function. 0 = No Fee. Sender = services’s escrow_token_wallet. Receiver = function’s reward_token_wallet.

§_ebuf: [u8; 930]

Reserved.

Implementations§

source§

impl FunctionAccountData

source

pub fn size() -> usize

source

pub fn new<'info>( function_account_info: &'info AccountInfo<'info> ) -> Result<Ref<'info, FunctionAccountData>>

Returns the deserialized Switchboard Function account

§Arguments
  • function_account_info - A Solana AccountInfo referencing an existing Switchboard FunctionAccount
§Examples
use switchboard_solana::FunctionAccountData;

let function_account = FunctionAccountData::new(function_account_info)?;
source

pub fn new_from_bytes(data: &[u8]) -> Result<&FunctionAccountData>

Returns the deserialized Switchboard Function account

§Arguments
  • data - A Solana AccountInfo’s data buffer
§Examples
use switchboard_solana::FunctionAccountData;

let function_account = FunctionAccountData::new(function_account_info.try_borrow_data()?)?;
source

pub fn validate(&self, signer: &AccountInfo<'_>) -> Result<bool>

Validate that the provided accounts correspond to the expected function accounts

§Arguments
  • signer - Solana AccountInfo for a signer
source

pub fn validate_signer<'a>(&self, signer: &AccountInfo<'a>) -> Result<bool>

👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions

Validate that the provided accounts correspond to the expected function accounts

§Arguments
  • signer - Solana AccountInfo for a signer\
source

pub fn validate_request( &self, request: &FunctionRequestAccountData, enclave_signer: &AccountInfo<'_> ) -> Result<bool>

Validates that the provided request is assigned to the same AttestationQueueAccountData as the function and the provided enclave_signer matches the enclave_signer stored in the request’s active_request field.

§Arguments
  • request - The FunctionRequestAccountData being validated.
  • enclave_signer - The AccountInfo of the enclave signer to validate.
§Errors

Returns an error if:

  • the function and request have different attestation queues
  • the request’s verified signer does not match the provided enclave_signer
  • the enclave_signer did not sign the transaction
§Returns

Returns Ok(true) if the validation succeeds, Ok(false) otherwise.

§Examples
use switchboard_solana::FunctionRequestAccountData;

#[derive(Accounts)]
pub struct Settle<'info> {
    // YOUR PROGRAM ACCOUNTS
    #[account(
        mut,
        has_one = switchboard_request,
    )]
    pub user: AccountLoader<'info, UserState>,

    // SWITCHBOARD ACCOUNTS
    #[account(
        constraint = function.load()?.validate_request(
            &request,
            &enclave_signer.to_account_info()
        )?
    )]
    pub function: AccountLoader<'info, FunctionAccountData>,
    #[account(
        has_one = function,
    )]
    pub request: Box<Account<'info, FunctionRequestAccountData>>,
    pub enclave_signer: Signer<'info>,
}
source

pub fn validate_routine( &self, routine: &FunctionRoutineAccountData, enclave_signer: &AccountInfo<'_> ) -> Result<bool>

Validates that the provided routine is assigned to the same AttestationQueueAccountData as the function and the provided enclave_signer matches the enclave_signer stored in the routine’s enclave_signer field.

§Arguments
  • routine - The FunctionRoutineAccountData being validated.
  • enclave_signer - The AccountInfo of the enclave signer to validate.
§Errors

Returns an error if:

  • the function and routine have different attestation queues
  • the routine’s verified signer does not match the provided enclave_signer
  • the enclave_signer did not sign the transaction
§Returns

Returns Ok(true) if the validation succeeds, Ok(false) otherwise.

§Examples
use switchboard_solana::FunctionRoutineAccountData;

#[derive(Accounts)]
pub struct Settle<'info> {
    // YOUR PROGRAM ACCOUNTS
    #[account(
        mut,
        has_one = switchboard_routine,
    )]
    pub user: AccountLoader<'info, UserState>,

    // SWITCHBOARD ACCOUNTS
    pub switchboard_function: AccountLoader<'info, FunctionAccountData>,
    #[account(
        constraint = switchboard_routine.validate_signer(
            &switchboard_function.to_account_info(),
            &enclave_signer.to_account_info()
        )?
    )]
    pub switchboard_routine: Box<Account<'info, FunctionRoutineAccountData>>,
    pub enclave_signer: Signer<'info>,
}
source

pub fn validate_service( &self, service: &FunctionServiceAccountData, enclave_signer: &AccountInfo<'_> ) -> Result<bool>

Validates that the provided routine is assigned to the same AttestationQueueAccountData as the function and the provided enclave_signer matches the enclave_signer stored in the routine’s enclave_signer field.

§Arguments
  • routine - The FunctionRoutineAccountData being validated.
  • enclave_signer - The AccountInfo of the enclave signer to validate.
§Errors

Returns an error if:

  • the function and routine have different attestation queues
  • the routine’s verified signer does not match the provided enclave_signer
  • the enclave_signer did not sign the transaction
§Returns

Returns Ok(true) if the validation succeeds, Ok(false) otherwise.

§Examples
use switchboard_solana::FunctionServiceAccountData;

#[derive(Accounts)]
pub struct Settle<'info> {
    // YOUR PROGRAM ACCOUNTS
    #[account(
        mut,
        has_one = switchboard_routine,
    )]
    pub user: AccountLoader<'info, UserState>,

    // SWITCHBOARD ACCOUNTS
    pub switchboard_function: AccountLoader<'info, FunctionAccountData>,
    #[account(
        constraint = switchboard_routine.validate_service(
            &switchboard_function.to_account_info(),
            &enclave_signer.to_account_info()
        )?
    )]
    pub switchboard_service: Box<Account<'info, FunctionServiceAccountData>>,
    pub enclave_signer: Signer<'info>,
}
source

pub fn is_empty_schedule(&self) -> bool

👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions
source

pub fn get_container(&self) -> String

source

pub fn get_container_registry(&self) -> String

source

pub fn get_version(&self) -> String

source

pub fn get_name(&self) -> String

source

pub fn get_function_name(&self) -> String

source

pub fn assert_permissions( &self, queue_require_usage_permissions: bool ) -> Result<()>

Asserts that the permissions are valid for the given queue’s access control level.

§Arguments
  • queue_require_usage_permissions - A boolean indicating whether queue usage permissions are required.
§Errors

Returns an error if the queue usage permissions are required but not present.

source

pub fn assert_mr_enclave(&self, mr_enclave: &[u8; 32]) -> Result<()>

Asserts that the given mr_enclave is valid by checking it against the enclave set. If the mr_enclave is invalid, returns an InvalidMrEnclave error.

source

pub fn is_valid_enclave(&self, mr_enclave: &[u8; 32]) -> bool

Checks if the given mr_enclave is valid by verifying if it exists in the list of valid mr_enclaves stored in the current instance of FunctionImpl.

§Arguments
  • mr_enclave - A reference to a 32-byte array representing the mr_enclave value of the enclave to be validated.
§Returns

A boolean value indicating whether the given mr_enclave is valid or not.

source

pub fn parse_enclaves(&self) -> Vec<[u8; 32]>

Parses the enclave measurements and returns a vector of 32-byte arrays representing the non-empty mr_enclaves.

§Example
use crate::FunctionAccountData;

let function = FunctionAccountData::default();
let parsed_enclaves = function.parse_enclaves();
assert_eq(0, parsed_enclaves.len());
source

pub fn assert_has_enclaves(&self) -> Result<()>

Asserts that the current instance has enclaves.

§Errors

Returns an error of type SwitchboardError::MrEnclavesEmpty if the enclaves are empty.

source

pub fn ready_for_routines(&self) -> Result<()>

Checks if the function is ready to execute routines.

§Errors

Returns an error if:

  • Routines are disabled.
  • The function has 0 valid mr_enclaves.
  • The function status is not Active.
§Returns

Returns Ok(()) if the function is ready to execute routines.

source

pub fn ready_for_requests(&self) -> Result<()>

Checks if the function is ready to execute requests.

§Errors

Returns an error if:

  • Requests are disabled.
  • The function has 0 valid mr_enclaves.
  • The function status is not Active.
§Returns

Returns Ok(()) if the function is ready to execute requests.

source

pub fn ready_for_services(&self) -> Result<()>

Checks if the function is ready to execute services.

§Errors

Returns an error if:

  • Services are disabled.
  • The function has 0 valid mr_enclaves.
  • The function status is not Active.
§Returns

Returns Ok(()) if the function is ready to execute requests.

source

pub fn get_reward_token_wallet(&self) -> Pubkey

Returns the public key of the reward token wallet. If the reward escrow token wallet is set, it returns the reward escrow token wallet. Otherwise, it returns the escrow token wallet.

source§

impl FunctionAccountData

source

pub async fn get_program_accounts( rpc: &RpcClient, filters: FunctionFilters, commitment: Option<CommitmentLevel> ) -> Result<Vec<(Pubkey, FunctionAccountData)>, SbError>

source

pub async fn get_or_create_from_seed( rpc: &RpcClient, payer: Arc<Keypair>, attestation_queue: Pubkey, seed: Option<&str>, params: Option<FunctionInitParams> ) -> Result<Pubkey, SbError>

source

pub fn get_discriminator_filter() -> RpcFilterType

source

pub fn get_permissions_filter(permissions: &u32) -> RpcFilterType

source

pub fn get_is_triggered_filter() -> RpcFilterType

👎Deprecated since 0.28.35: please use a FunctionRequestAccountData for all on-demand executions
source

pub fn get_is_scheduled_filter() -> RpcFilterType

👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions
source

pub fn get_is_active_filter() -> RpcFilterType

source

pub fn get_queue_filter(queue_pubkey: &Pubkey) -> RpcFilterType

source

pub fn get_authority_filter(authority_pubkey: &Pubkey) -> RpcFilterType

source

pub fn get_queue_and_authority_filter( queue_pubkey: &Pubkey, authority_pubkey: &Pubkey ) -> RpcFilterType

source

pub fn get_queue_idx_filter(queue_idx: &u32) -> RpcFilterType

source

pub fn get_metadata_filter(metadata: Vec<u8>) -> RpcFilterType

source

pub fn get_is_ready_filters(queue_pubkey: &Pubkey) -> Vec<RpcFilterType>

👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData or FunctionRequestAccountData for all function executions.
source

pub fn get_schedule(&self) -> Option<Schedule>

source

pub fn get_last_execution_datetime(&self) -> DateTime<Utc>

source

pub fn get_next_execution_datetime(&self) -> Option<DateTime<Utc>>

source

pub fn should_execute(&self, now: DateTime<Utc>) -> bool

source

pub fn is_scheduled(&self) -> bool

👎Deprecated since 0.28.35: please use a FunctionRoutineAccountData for all scheduled executions
source

pub fn fetch(client: &RpcClient, pubkey: Pubkey) -> Result<Self, SbError>

source

pub async fn fetch_async( client: &RpcClient, pubkey: Pubkey ) -> Result<Self, SbError>

source

pub fn fetch_sync<T: SyncClient>( client: &T, pubkey: Pubkey ) -> Result<Self, SbError>

source

pub fn build_ix( accounts: &FunctionInitAccounts, params: &FunctionInitParams ) -> Result<Instruction, SbError>

Trait Implementations§

source§

impl AccountDeserialize for FunctionAccountData

source§

fn try_deserialize(buf: &mut &[u8]) -> Result<Self>

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account.
source§

fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>

Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed.
source§

impl Clone for FunctionAccountData

source§

fn clone(&self) -> FunctionAccountData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for FunctionAccountData

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Discriminator for FunctionAccountData

source§

const DISCRIMINATOR: [u8; 8] = _

§

fn discriminator() -> [u8; 8]

source§

impl Owner for FunctionAccountData

source§

impl PartialEq for FunctionAccountData

source§

fn eq(&self, other: &FunctionAccountData) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Zeroable for FunctionAccountData

§

fn zeroed() -> Self

source§

impl Copy for FunctionAccountData

source§

impl Pod for FunctionAccountData

source§

impl StructuralPartialEq for FunctionAccountData

source§

impl ZeroCopy for FunctionAccountData

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> AnyBitPattern for T
where T: Pod,

§

impl<T> NoUninit for T
where T: Pod,