use ore_api::prelude::*; use steel::*; /// Initialize sets up the ORE program to begin mining. pub fn process_initialize(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult { // Load accounts. let [signer_info, block_info, block_bets_info, sol_mint_info, system_program, token_program, associated_token_program] = accounts else { return Err(ProgramError::NotEnoughAccountKeys); }; signer_info.is_signer()?.has_address(&INITIALIZER_ADDRESS)?; block_info .is_empty()? .is_writable()? .has_seeds(&[BLOCK], &ore_api::ID)?; block_bets_info.is_empty()?.is_writable()?; sol_mint_info .has_address(&spl_token::native_mint::ID)? .as_mint()?; system_program.is_program(&system_program::ID)?; token_program.is_program(&spl_token::ID)?; associated_token_program.is_program(&spl_associated_token_account::ID)?; // Initialize config. create_program_account::( block_info, system_program, signer_info, &ore_api::ID, &[BLOCK], )?; let block = block_info.as_account_mut::(&ore_api::ID)?; block.current_round = 0; block.total_bets = 0; block.bet_count = 0; block.started_at = 0; block.ends_at = 0; block.payed_out = 0; block.mint = spl_token::native_mint::ID; block.reward = 0; block.noise = [0; 32]; // Initialize treasury token account. create_associated_token_account( signer_info, block_info, block_bets_info, sol_mint_info, system_program, token_program, associated_token_program, )?; Ok(()) }