mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
misc
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
use ore_api::prelude::*;
|
||||
use steel::*;
|
||||
|
||||
use crate::whitelist::AUTHORIZED_ACCOUNTS;
|
||||
|
||||
/// Sets the executor.
|
||||
pub fn process_automate(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
@@ -27,10 +25,10 @@ pub fn process_automate(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
||||
)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Check whitelist
|
||||
if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
||||
return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
||||
}
|
||||
// // Check whitelist
|
||||
// if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
||||
// return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
||||
// }
|
||||
|
||||
// Close account if executor is Pubkey::default().
|
||||
if *executor_info.key == Pubkey::default() {
|
||||
|
||||
@@ -23,14 +23,41 @@ pub fn process_claim_seeker(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Progr
|
||||
signer_info.is_signer()?;
|
||||
miner_info.is_writable()?;
|
||||
mint_info.has_owner(&spl_token_2022::ID)?;
|
||||
seeker_info.is_writable()?.is_empty()?;
|
||||
seeker_info
|
||||
.is_writable()?
|
||||
.has_seeds(&[SEEKER, &mint_info.key.to_bytes()], &ore_api::ID)?;
|
||||
token_account_info
|
||||
.as_associated_token_account(signer_info.key, mint_info.key)?
|
||||
.assert(|t| t.amount() == 1)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Load mint.
|
||||
let mint_data = mint_info.try_borrow_data()?;
|
||||
let mint = PodStateWithExtensions::<PodMint>::unpack(&mint_data)?;
|
||||
|
||||
// Check mint authority.
|
||||
assert!(
|
||||
mint.base.mint_authority
|
||||
== PodCOption::some(pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4")),
|
||||
"mint authority mismatch"
|
||||
);
|
||||
|
||||
// Check metadata pointer.
|
||||
let ext = mint.get_extension::<MetadataPointer>()?;
|
||||
assert!(
|
||||
ext.authority.0 == pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4"),
|
||||
"metadata authority mismatch"
|
||||
);
|
||||
assert!(
|
||||
ext.metadata_address.0 == pubkey!("GT22s89nU4iWFkNXj1Bw6uYhJJWDRPpShHt4Bk8f99Te"),
|
||||
"metadata address mismatch"
|
||||
);
|
||||
|
||||
// Open seeker account.
|
||||
// Each genesis token can only be claimed once.
|
||||
if !seeker_info.data_is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
create_program_account::<Seeker>(
|
||||
seeker_info,
|
||||
system_program,
|
||||
@@ -68,28 +95,6 @@ pub fn process_claim_seeker(accounts: &[AccountInfo<'_>], _data: &[u8]) -> Progr
|
||||
.assert_mut(|m| m.is_seeker == 0)?
|
||||
};
|
||||
|
||||
// Load mint.
|
||||
let mint_data = mint_info.try_borrow_data()?;
|
||||
let mint = PodStateWithExtensions::<PodMint>::unpack(&mint_data)?;
|
||||
|
||||
// Check mint authority.
|
||||
assert!(
|
||||
mint.base.mint_authority
|
||||
== PodCOption::some(pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4")),
|
||||
"mint authority mismatch"
|
||||
);
|
||||
|
||||
// Check metadata pointer.
|
||||
let ext = mint.get_extension::<MetadataPointer>()?;
|
||||
assert!(
|
||||
ext.authority.0 == pubkey!("GT2zuHVaZQYZSyQMgJPLzvkmyztfyXg2NJunqFp4p3A4"),
|
||||
"metadata authority mismatch"
|
||||
);
|
||||
assert!(
|
||||
ext.metadata_address.0 == pubkey!("GT22s89nU4iWFkNXj1Bw6uYhJJWDRPpShHt4Bk8f99Te"),
|
||||
"metadata address mismatch"
|
||||
);
|
||||
|
||||
// Flag the miner as a Seeker.
|
||||
miner.is_seeker = 1;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ use ore_api::prelude::*;
|
||||
use solana_program::{keccak::hashv, log::sol_log, native_token::lamports_to_sol};
|
||||
use steel::*;
|
||||
|
||||
use crate::whitelist::AUTHORIZED_ACCOUNTS;
|
||||
|
||||
/// Deploys capital to prospect on a square.
|
||||
pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
// Parse data.
|
||||
@@ -32,10 +30,10 @@ pub fn process_deploy(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
||||
let square = square_info.as_account_mut::<Square>(&ore_api::ID)?;
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
|
||||
// Check whitelist
|
||||
if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
||||
return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
||||
}
|
||||
// // Check whitelist
|
||||
// if !AUTHORIZED_ACCOUNTS.contains(&signer_info.key) {
|
||||
// return Err(trace("Not authorized", OreError::NotAuthorized.into()));
|
||||
// }
|
||||
|
||||
// Check if signer is the automation executor.
|
||||
let automation = if !automation_info.data_is_empty() {
|
||||
|
||||
@@ -11,7 +11,6 @@ mod migrate_miner;
|
||||
mod reset;
|
||||
mod set_admin;
|
||||
mod set_fee_collector;
|
||||
mod whitelist;
|
||||
mod wrap;
|
||||
|
||||
use automate::*;
|
||||
@@ -59,7 +58,6 @@ pub fn process_instruction(
|
||||
// Seeker
|
||||
OreInstruction::ClaimSeeker => process_claim_seeker(accounts, data)?,
|
||||
OreInstruction::MigrateMiner => process_migrate_miner(accounts, data)?,
|
||||
// _ => return Err(ProgramError::InvalidInstructionData),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use ore_api::prelude::*;
|
||||
use solana_program::slot_hashes::SlotHashes;
|
||||
use solana_program::{log::sol_log, slot_hashes::SlotHashes};
|
||||
use steel::*;
|
||||
|
||||
/// Pays out the winners and block reward.
|
||||
@@ -298,7 +298,13 @@ fn get_winning_square(r: u64) -> usize {
|
||||
fn is_motherlode_activated(r: u64) -> bool {
|
||||
// Returns true if the motherlode was activated with 1/625 chance.
|
||||
let r = r.reverse_bits();
|
||||
(r % 625) == 0
|
||||
let x = r % 625;
|
||||
if x == 0 {
|
||||
sol_log("Motherlode was activated");
|
||||
} else {
|
||||
sol_log(&format!("Motherlode missed by {}", x).as_str());
|
||||
}
|
||||
x == 0
|
||||
}
|
||||
|
||||
/// Randomly selects a winning miner based on their proportional deposits.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use solana_program::pubkey;
|
||||
use steel::*;
|
||||
|
||||
#[deprecated(note = "No longer used")]
|
||||
pub const AUTHORIZED_ACCOUNTS: [Pubkey; 280] = [
|
||||
pubkey!("pqspJ298ryBjazPAr95J9sULCVpZe3HbZTWkbC1zrkS"),
|
||||
pubkey!("HNWhK5f8RMWBqcA7mXJPaxdTPGrha3rrqUrri7HSKb3T"),
|
||||
|
||||
Reference in New Issue
Block a user