mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
test
This commit is contained in:
@@ -35,6 +35,9 @@ pub const MINER: &[u8] = b"miner";
|
||||
/// The seed of the mint account PDA.
|
||||
pub const MINT: &[u8] = b"mint";
|
||||
|
||||
/// The seed of the log authority PDA.
|
||||
// pub const LOG: &[u8] = b"log";
|
||||
|
||||
/// The seed of the permit account PDA.
|
||||
pub const PERMIT: &[u8] = b"permit";
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ pub fn open(signer: Pubkey, id: u64) -> Instruction {
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
AccountMeta::new_readonly(ore_api::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::rent::ID, false),
|
||||
],
|
||||
data: Open {
|
||||
@@ -92,15 +93,20 @@ pub fn log(signer: Pubkey, msg: &[u8]) -> Instruction {
|
||||
data.extend_from_slice(msg);
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![AccountMeta::new(signer, true)],
|
||||
accounts: vec![AccountMeta::new(signer, false)],
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn program_log(block_id: u64, block_info: AccountInfo, msg: &[u8]) -> Result<(), ProgramError> {
|
||||
pub fn program_log(
|
||||
block_id: u64,
|
||||
block_info: AccountInfo,
|
||||
// ore_program: AccountInfo,
|
||||
msg: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
invoke_signed(
|
||||
&log(*block_info.key, msg),
|
||||
&[block_info.clone()],
|
||||
&[block_info],
|
||||
&crate::ID,
|
||||
&[BLOCK, &block_id.to_le_bytes()],
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let [signer_info, block_info, config_info, collateral_info, commitment_info, market_info, mint_base_info, mint_quote_info, sender_info, treasury_info, vault_base_info, vault_quote_info, system_program, token_program, associated_token_program, rent_sysvar] =
|
||||
let [signer_info, block_info, config_info, collateral_info, commitment_info, market_info, mint_base_info, mint_quote_info, sender_info, treasury_info, vault_base_info, vault_quote_info, system_program, token_program, associated_token_program, ore_program, rent_sysvar] =
|
||||
accounts
|
||||
else {
|
||||
return Err(ProgramError::NotEnoughAccountKeys);
|
||||
@@ -39,6 +39,7 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
system_program.is_program(&system_program::ID)?;
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
associated_token_program.is_program(&spl_associated_token_account::ID)?;
|
||||
ore_program.is_program(&ore_api::ID)?;
|
||||
rent_sysvar.is_sysvar(&sysvar::rent::ID)?;
|
||||
|
||||
// Error out if start slot is within the current period.
|
||||
@@ -312,23 +313,28 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
&[BLOCK, &id.to_le_bytes()],
|
||||
)?;
|
||||
|
||||
// Emit event.
|
||||
program_log(
|
||||
block.id,
|
||||
block_info.clone(),
|
||||
&OpenEvent {
|
||||
disc: OreEvent::Open as u64,
|
||||
id,
|
||||
start_slot,
|
||||
signer: *signer_info.key,
|
||||
reward_config: block.reward,
|
||||
liquidity_base: market.base.liquidity() as u64,
|
||||
liquidity_quote: market.quote.liquidity() as u64,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.to_bytes(),
|
||||
let msg = OpenEvent {
|
||||
disc: OreEvent::Open as u64,
|
||||
id,
|
||||
start_slot,
|
||||
signer: *signer_info.key,
|
||||
reward_config: block.reward,
|
||||
liquidity_base: market.base.liquidity() as u64,
|
||||
liquidity_quote: market.quote.liquidity() as u64,
|
||||
ts: clock.unix_timestamp,
|
||||
}
|
||||
.to_bytes();
|
||||
|
||||
invoke_signed(
|
||||
&ore_api::sdk::log(*block_info.key, &msg),
|
||||
&[block_info, ore_program],
|
||||
&crate::ID,
|
||||
&[BLOCK, &block_id.to_le_bytes()],
|
||||
)?;
|
||||
|
||||
// Emit event.
|
||||
program_log(id, block_info.clone(), &msg)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user