mirror of
https://github.com/d0zingcat/ore.git
synced 2026-06-03 07:36:49 +00:00
fix
This commit is contained in:
@@ -29,12 +29,6 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
|
|||||||
token_program.is_program(&spl_token::ID)?;
|
token_program.is_program(&spl_token::ID)?;
|
||||||
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
||||||
|
|
||||||
// Whitelist
|
|
||||||
assert!(
|
|
||||||
AUTHORIZED_ACCOUNTS.contains(&signer_info.key),
|
|
||||||
"Signer not whitelisted"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Open stake account.
|
// Open stake account.
|
||||||
let stake = if stake_info.data_is_empty() {
|
let stake = if stake_info.data_is_empty() {
|
||||||
create_program_account::<Stake>(
|
create_program_account::<Stake>(
|
||||||
@@ -100,5 +94,10 @@ pub fn process_deposit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResu
|
|||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Safety check.
|
||||||
|
let stake_tokens =
|
||||||
|
stake_tokens_info.as_associated_token_account(stake_info.key, mint_info.key)?;
|
||||||
|
assert!(stake_tokens.amount() >= stake.balance);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub fn process_instruction(
|
|||||||
// Staker
|
// Staker
|
||||||
OreInstruction::Deposit => process_deposit(accounts, data)?,
|
OreInstruction::Deposit => process_deposit(accounts, data)?,
|
||||||
OreInstruction::Withdraw => process_withdraw(accounts, data)?,
|
OreInstruction::Withdraw => process_withdraw(accounts, data)?,
|
||||||
// OreInstruction::ClaimYield => process_claim_yield(accounts, data)?,
|
OreInstruction::ClaimYield => process_claim_yield(accounts, data)?,
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
OreInstruction::Bury => process_bury(accounts, data)?,
|
OreInstruction::Bury => process_bury(accounts, data)?,
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
|||||||
token_program.is_program(&spl_token::ID)?;
|
token_program.is_program(&spl_token::ID)?;
|
||||||
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
||||||
|
|
||||||
assert!(
|
|
||||||
AUTHORIZED_ACCOUNTS.contains(&signer_info.key),
|
|
||||||
"Signer not whitelisted"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Open recipient token account.
|
// Open recipient token account.
|
||||||
if recipient_info.data_is_empty() {
|
if recipient_info.data_is_empty() {
|
||||||
create_associated_token_account(
|
create_associated_token_account(
|
||||||
@@ -72,5 +67,10 @@ pub fn process_withdraw(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramRes
|
|||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Safety check.
|
||||||
|
let stake_tokens =
|
||||||
|
stake_tokens_info.as_associated_token_account(stake_info.key, mint_info.key)?;
|
||||||
|
assert!(stake_tokens.amount() >= stake.balance);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user