diff --git a/api/src/sdk.rs b/api/src/sdk.rs index b89c9fc..13253db 100644 --- a/api/src/sdk.rs +++ b/api/src/sdk.rs @@ -124,6 +124,8 @@ pub fn deploy( let miner_address = miner_pda(signer).0; let square_address = square_pda().0; + // Convert array of 25 booleans into a 32-bit mask where each bit represents whether + // that square index is selected (1) or not (0) let mut mask: u32 = 0; for (i, &square) in squares.iter().enumerate() { if square { diff --git a/program/src/claim_ore.rs b/program/src/claim_ore.rs index 04c71e6..ac8cfcf 100644 --- a/program/src/claim_ore.rs +++ b/program/src/claim_ore.rs @@ -1,4 +1,6 @@ use ore_api::prelude::*; +use solana_program::log::sol_log; +use spl_token::amount_to_ui_amount; use steel::*; /// Claims a block reward. @@ -43,6 +45,14 @@ pub fn process_claim_ore(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe // Normalize amount. let amount = miner.rewards_ore.min(amount); + sol_log( + &format!( + "Claiming {} ORE", + amount_to_ui_amount(amount, TOKEN_DECIMALS) + ) + .as_str(), + ); + // Update miner. miner.rewards_ore -= amount; diff --git a/program/src/claim_sol.rs b/program/src/claim_sol.rs index 7794cdc..d8cced4 100644 --- a/program/src/claim_sol.rs +++ b/program/src/claim_sol.rs @@ -1,4 +1,5 @@ use ore_api::prelude::*; +use solana_program::{log::sol_log, native_token::lamports_to_sol}; use steel::*; /// Claims a block reward. @@ -20,6 +21,8 @@ pub fn process_claim_sol(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRe // Normalize amount. let amount = miner.rewards_sol.min(amount); + sol_log(&format!("Claiming {} SOL", lamports_to_sol(amount)).as_str()); + // Update miner. miner.rewards_sol -= amount; diff --git a/program/src/deploy.rs b/program/src/deploy.rs index 7c9b97d..5aa4141 100644 --- a/program/src/deploy.rs +++ b/program/src/deploy.rs @@ -1,4 +1,5 @@ use ore_api::prelude::*; +use solana_program::{log::sol_log, native_token::lamports_to_sol}; use steel::*; use crate::whitelist::AUTHORIZED_ACCOUNTS; @@ -10,12 +11,23 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul let amount = u64::from_le_bytes(args.amount); let mask = u32::from_le_bytes(args.squares); - // Parse squares. + // Convert 32-bit mask into array of 25 booleans, where each bit in the mask + // determines if that square index is selected (true) or not (false) let mut squares = [false; 25]; for i in 0..25 { squares[i] = (mask & (1 << i)) != 0; } + sol_log( + &format!( + "Deploying {} SOL to {} squares: {:?}", + lamports_to_sol(amount), + squares.iter().filter(|&&s| s).count(), + squares + ) + .as_str(), + ); + // Load accounts. let clock = Clock::get()?; let [signer_info, board_info, config_info, fee_collector_info, miner_info, square_info, system_program] =