LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_system_program.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 9 10 90.0 %
Date: 2026-03-19 18:19:27 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_program_fd_system_program_h
       2             : #define HEADER_fd_src_flamenco_runtime_program_fd_system_program_h
       3             : 
       4             : #include "../../fd_flamenco_base.h"
       5             : #include "../../types/fd_types.h"
       6             : 
       7             : /* Custom error types */
       8             : 
       9         272 : #define FD_SYSTEM_PROGRAM_ERR_ACCT_ALREADY_IN_USE              (0)  /* SystemError::AccountAlreadyInUse */
      10          24 : #define FD_SYSTEM_PROGRAM_ERR_RESULT_WITH_NEGATIVE_LAMPORTS    (1)  /* SystemError::ResultWithNegativeLamports */
      11             : #define FD_SYSTEM_PROGRAM_ERR_INVALID_PROGRAM_ID               (2)  /* SystemError::InvalidProgramId */
      12          15 : #define FD_SYSTEM_PROGRAM_ERR_INVALID_ACCT_DATA_LEN            (3)  /* SystemError::InvalidAccountDataLength */
      13             : #define FD_SYSTEM_PROGRAM_ERR_MAX_SEED_LEN_EXCEEDED            (4)  /* SystemError::MaxSeedLengthExceeded */
      14         505 : #define FD_SYSTEM_PROGRAM_ERR_ADDR_WITH_SEED_MISMATCH          (5)  /* SystemError::AddressWithSeedMismatch */
      15          15 : #define FD_SYSTEM_PROGRAM_ERR_NONCE_NO_RECENT_BLOCKHASHES      (6)  /* SystemError::NonceNoRecentBlockhashes */
      16           0 : #define FD_SYSTEM_PROGRAM_ERR_NONCE_BLOCKHASH_NOT_EXPIRED      (7)  /* SystemError::NonceBlockhashNotExpired */
      17             : #define FD_SYSTEM_PROGRAM_ERR_NONCE_UNEXPECTED_BLOCKHASH_VALUE (8)  /* SystemError::NonceUnexpectedBlockhashValue */
      18             : 
      19          21 : #define FD_SYSTEM_PROGRAM_NONCE_DLEN (80UL)
      20             : 
      21             : /* https://github.com/anza-xyz/solana-sdk/blob/nonce-account%40v2.2.1/nonce-account/src/lib.rs#L49-L53 */
      22          11 : #define FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_UNKNOWN (-1)
      23        4065 : #define FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_SYSTEM  (0)
      24        4108 : #define FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_NONCE   (1)
      25             : 
      26             : FD_PROTOTYPES_BEGIN
      27             : 
      28             : /* fd_system_program_execute is the entrypoint for the system program */
      29             : 
      30             : int fd_system_program_execute( fd_exec_instr_ctx_t * ctx ) ;
      31             : 
      32             : /* System program instruction handlers */
      33             : 
      34             : int fd_system_program_exec_create_account              ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_create_account_t const *           data     );
      35             : int fd_system_program_exec_assign                      ( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const *                                              owner    );
      36             : int fd_system_program_exec_transfer                    ( fd_exec_instr_ctx_t * ctx, ulong                                                            lamports );
      37             : int fd_system_program_exec_create_account_with_seed    ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_create_account_with_seed_t const * data     );
      38             : int fd_system_program_exec_advance_nonce_account       ( fd_exec_instr_ctx_t * ctx                                                                            );
      39             : int fd_system_program_exec_withdraw_nonce_account      ( fd_exec_instr_ctx_t * ctx, ulong                                                            lamports );
      40             : int fd_system_program_exec_initialize_nonce_account    ( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const *                                              pubkey   );
      41             : int fd_system_program_exec_authorize_nonce_account     ( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const *                                              pubkey   );
      42             : int fd_system_program_exec_allocate                    ( fd_exec_instr_ctx_t * ctx, ulong                                                            space    );
      43             : int fd_system_program_exec_allocate_with_seed          ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_allocate_with_seed_t const *       data     );
      44             : int fd_system_program_exec_assign_with_seed            ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_assign_with_seed_t const *         data     );
      45             : int fd_system_program_exec_transfer_with_seed          ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_transfer_with_seed_t const *       data     );
      46             : int fd_system_program_exec_upgrade_nonce_account       ( fd_exec_instr_ctx_t * ctx                                                                            );
      47             : int fd_system_program_exec_create_account_allow_prefund( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_create_account_t const *           data     );
      48             : 
      49             : /* User APIs */
      50             : 
      51             : /* fd_check_transaction_age returns 0 if the transactions age is valid,
      52             :    returns non-zero otherwise. This is determined by the age of the
      53             :    blockhash provided in the transaction message or by the validity of
      54             :    the nonce provided in the transaction. */
      55             : 
      56             : int
      57             : fd_check_transaction_age( fd_runtime_t *      runtime,
      58             :                           fd_bank_t *         bank,
      59             :                           fd_txn_in_t const * txn_in,
      60             :                           fd_txn_out_t *      txn_out );
      61             : 
      62             : /* `fd_get_system_account_kind()` determines whether an account is
      63             :    a normal system program account or a nonce account. Returns:
      64             :    - FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_SYSTEM if the account is a
      65             :      normal system program account
      66             :    - FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_NONCE if the account is a
      67             :      nonce account
      68             :    - FD_SYSTEM_PROGRAM_NONCE_ACCOUNT_KIND_UNKNOWN otherwise
      69             :    https://github.com/anza-xyz/solana-sdk/blob/nonce-account%40v2.2.1/nonce-account/src/lib.rs#L55-L71 */
      70             : 
      71             : int
      72             : fd_get_system_account_kind( fd_account_meta_t const * meta );
      73             : 
      74             : FD_PROTOTYPES_END
      75             : 
      76             : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_system_program_h */

Generated by: LCOV version 1.14