From 076feefc72114d17257785b4a0db20a2f511da7b Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Tue, 23 Sep 2025 15:18:11 -0700 Subject: [PATCH] automations --- cli/src/main.rs | 28 ++++++++++++++++++++++++++++ program/src/deploy.rs | 5 +++-- program/src/whitelist.rs | 3 ++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index b91421e..b52e298 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -31,6 +31,9 @@ async fn main() { .expect("Missing COMMAND env var") .as_str() { + "automations" => { + log_automations(&rpc).await.unwrap(); + } "boost" => { boost(&rpc, &payer).await.unwrap(); } @@ -266,6 +269,21 @@ async fn set_fee_collector( Ok(()) } +async fn log_automations(rpc: &RpcClient) -> Result<(), anyhow::Error> { + let automations = get_automations(rpc).await?; + for (i, (address, automation)) in automations.iter().enumerate() { + println!("[{}/{}] {}", i + 1, automations.len(), address); + println!(" authority: {}", automation.authority); + println!(" balance: {}", automation.balance); + println!(" executor: {}", automation.executor); + println!(" fee: {}", automation.fee); + println!(" mask: {}", automation.mask); + println!(" strategy: {}", automation.strategy); + println!(); + } + Ok(()) +} + async fn log_treasury(rpc: &RpcClient) -> Result<(), anyhow::Error> { let treasury_address = ore_api::state::treasury_pda().0; let treasury = get_treasury(rpc).await?; @@ -354,6 +372,16 @@ fn print_board(board: Board, clock: &Clock) { ); } +async fn get_automations(rpc: &RpcClient) -> Result, anyhow::Error> { + const REGOLITH_EXECUTOR: Pubkey = pubkey!("HNWhK5f8RMWBqcA7mXJPaxdTPGrha3rrqUrri7HSKb3T"); + let filter = RpcFilterType::Memcmp(Memcmp::new_base58_encoded( + 56, + ®OLITH_EXECUTOR.to_bytes(), + )); + let automations = get_program_accounts::(rpc, ore_api::ID, vec![filter]).await?; + Ok(automations) +} + async fn get_board(rpc: &RpcClient) -> Result { let board_pda = ore_api::state::board_pda(); let account = rpc.get_account(&board_pda.0).await?; diff --git a/program/src/deploy.rs b/program/src/deploy.rs index 34acb4a..862bab0 100644 --- a/program/src/deploy.rs +++ b/program/src/deploy.rs @@ -117,7 +117,8 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul .assert_mut(|m| { if let Some(automation) = &automation { // only run automation once per round - m.authority == automation.authority && m.round_id < board.id + m.authority == automation.authority + && (m.round_id < board.id || board.slot_hash != [0; 32]) } else { m.authority == *signer_info.key } @@ -169,7 +170,7 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul // Update square if is_first_move { - square.miners[square_id][square.count[square_id] as usize] = *signer_info.key; + square.miners[square_id][square.count[square_id] as usize] = miner.authority; square.count[square_id] += 1; } diff --git a/program/src/whitelist.rs b/program/src/whitelist.rs index e15ac20..24ac72e 100644 --- a/program/src/whitelist.rs +++ b/program/src/whitelist.rs @@ -1,8 +1,9 @@ use solana_program::pubkey; use steel::*; -pub const AUTHORIZED_ACCOUNTS: [Pubkey; 3] = [ +pub const AUTHORIZED_ACCOUNTS: [Pubkey; 4] = [ pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"), + pubkey!("HNWhK5f8RMWBqcA7mXJPaxdTPGrha3rrqUrri7HSKb3T"), pubkey!("6B9PjpHfbhPcSakS5UQ7ZctgbPujfsryVRpDecskGLiz"), pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk"), // pubkey!("By5JFFueXCqeqLk5MzR8ZSwFxASz3SKWX2TVfT1LTFbX"),