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 804 : #define FD_SYSTEM_PROGRAM_ERR_ACCT_ALREADY_IN_USE (0) /* SystemError::AccountAlreadyInUse */ 10 81 : #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 48 : #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 1518 : #define FD_SYSTEM_PROGRAM_ERR_ADDR_WITH_SEED_MISMATCH (5) /* SystemError::AddressWithSeedMismatch */ 15 39 : #define FD_SYSTEM_PROGRAM_ERR_NONCE_NO_RECENT_BLOCKHASHES (6) /* SystemError::NonceNoRecentBlockhashes */ 16 15 : #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 : FD_PROTOTYPES_BEGIN 20 : 21 : /* fd_system_program_execute is the entrypoint for the system program */ 22 : 23 : int fd_system_program_execute( fd_exec_instr_ctx_t * ctx ) ; 24 : 25 : /* System program instruction handlers */ 26 : 27 : int fd_system_program_exec_create_account ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_create_account_t const * data ); 28 : int fd_system_program_exec_assign ( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const * owner ); 29 : int fd_system_program_exec_transfer ( fd_exec_instr_ctx_t * ctx, ulong lamports ); 30 : 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 ); 31 : int fd_system_program_exec_advance_nonce_account ( fd_exec_instr_ctx_t * ctx ); 32 : int fd_system_program_exec_withdraw_nonce_account ( fd_exec_instr_ctx_t * ctx, ulong lamports ); 33 : int fd_system_program_exec_initialize_nonce_account( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const * pubkey ); 34 : int fd_system_program_exec_authorize_nonce_account ( fd_exec_instr_ctx_t * ctx, fd_pubkey_t const * pubkey ); 35 : int fd_system_program_exec_allocate ( fd_exec_instr_ctx_t * ctx, ulong space ); 36 : int fd_system_program_exec_allocate_with_seed ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_allocate_with_seed_t const * data ); 37 : int fd_system_program_exec_assign_with_seed ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_assign_with_seed_t const * data ); 38 : int fd_system_program_exec_transfer_with_seed ( fd_exec_instr_ctx_t * ctx, fd_system_program_instruction_transfer_with_seed_t const * data ); 39 : int fd_system_program_exec_upgrade_nonce_account ( fd_exec_instr_ctx_t * ctx ); 40 : 41 : /* User APIs */ 42 : 43 : /* fd_load_nonce_account loads the state of a nonce account associated 44 : with a transaction (txn_ctx). Attempts to create a new 45 : fd_nonce_state_versions_t object at *state, using valloc as the heap 46 : allocator. Returns 1 on success and transfers ownership of the new 47 : state object to the caller. On failure, returns zero and does not 48 : create a new state object. *perr is set to an executor error code. */ 49 : 50 : int 51 : fd_load_nonce_account( fd_exec_txn_ctx_t const * txn_ctx, 52 : fd_nonce_state_versions_t * state, 53 : fd_valloc_t valloc, 54 : int * perr ); 55 : 56 : /* fd_check_transaction_age returns 1 if the transactions age is 57 : valid, returns 0 otherwise. This is determined by the age of 58 : the blockhash provided in the transaction message or by the 59 : validity of the nonce provided in the transaction. */ 60 : 61 : int 62 : fd_check_transaction_age( fd_exec_txn_ctx_t const * txn_ctx ); 63 : 64 : FD_PROTOTYPES_END 65 : 66 : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_system_program_h */