From 8b095c23363b0b9bf7a4158e7926cf897883e55d Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Fri, 27 Sep 2024 07:41:48 +0000 Subject: [PATCH] account validation checks --- program/src/mine.rs | 5 ++++- program/src/reset.rs | 4 +++- program/src/upgrade.rs | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/program/src/mine.rs b/program/src/mine.rs index 1cdadb7..14683a1 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -6,6 +6,7 @@ use ore_api::{ error::OreError, event::MineEvent, instruction::Mine, + loaders::OreAccountInfoValidation, state::{Bus, Config, Proof}, }; use solana_program::program::set_return_data; @@ -32,7 +33,9 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { }; signer_info.is_signer()?; let bus = bus_info.to_account_mut::(&ore_api::ID)?; - let config = config_info.to_account::(&ore_api::ID)?; + let config = config_info + .is_config()? + .to_account::(&ore_api::ID)?; let proof = proof_info .to_account_mut::(&ore_api::ID)? .check_mut(|p| p.miner == *signer_info.key)?; diff --git a/program/src/reset.rs b/program/src/reset.rs index 2800139..6625f6d 100644 --- a/program/src/reset.rs +++ b/program/src/reset.rs @@ -39,7 +39,9 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul let bus_7 = bus_7_info .to_account_mut::(&ore_api::ID)? .check_mut(|b| b.id == 7)?; - let config = config_info.to_account_mut::(&ore_api::ID)?; + let config = config_info + .is_config()? + .to_account_mut::(&ore_api::ID)?; let mint = mint_info .has_address(&MINT_ADDRESS)? .is_writable()? diff --git a/program/src/upgrade.rs b/program/src/upgrade.rs index 058c400..140a499 100644 --- a/program/src/upgrade.rs +++ b/program/src/upgrade.rs @@ -1,4 +1,4 @@ -use ore_api::{consts::*, error::OreError, instruction::Stake}; +use ore_api::{consts::*, error::OreError, instruction::Stake, loaders::OreAccountInfoValidation}; use steel::*; /// Upgrade allows a user to migrate a v1 token to a v2 token at a 1:1 exchange rate. @@ -32,6 +32,7 @@ pub fn process_upgrade(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu .to_token_account()? .check(|t| t.owner == *signer_info.key)? .check(|t| t.mint == MINT_V1_ADDRESS)?; + treasury_info.is_treasury()?; token_program.is_program(&spl_token::ID)?; // Burn v1 tokens