Skip to content

Commit

Permalink
unified event emittance
Browse files Browse the repository at this point in the history
  • Loading branch information
ananas-block committed Aug 8, 2024
1 parent 963648f commit 5f2b6bd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
2 changes: 0 additions & 2 deletions programs/system/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ pub enum SystemProgramError {
ComputeOutputSumFailed,
#[msg("Computing rpc sum failed.")]
ComputeRpcSumFailed,
#[msg("InvalidNoopPubkey")]
InvalidNoopPubkey,
#[msg("InvalidAddress")]
InvalidAddress,
#[msg("DeriveAddressError")]
Expand Down
26 changes: 4 additions & 22 deletions programs/system/src/invoke/emit_event.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use account_compression::utils::constants::NOOP_PUBKEY;
use anchor_lang::{
prelude::*,
solana_program::{instruction::Instruction, program::invoke},
Bumps,
};
use account_compression::emit_indexer_event;
use anchor_lang::{prelude::*, Bumps};

use crate::{
errors::SystemProgramError,
Expand Down Expand Up @@ -36,12 +32,6 @@ pub fn emit_state_transition_event<'a, 'b, 'c: 'info, 'info, A: InvokeAccounts<'
is_compress: inputs.is_compress,
};

if ctx.accounts.get_noop_program().key() != Pubkey::new_from_array(NOOP_PUBKEY)
|| !ctx.accounts.get_noop_program().executable
{
return err!(SystemProgramError::InvalidNoopPubkey);
}

// 10240 = 10 * 1024 the max instruction data of a cpi.
let data_capacity = 10240;
let mut data = Vec::with_capacity(data_capacity);
Expand All @@ -55,14 +45,6 @@ pub fn emit_state_transition_event<'a, 'b, 'c: 'info, 'info, A: InvokeAccounts<'
);
return err!(SystemProgramError::InvalidCapacity);
}
let instruction = Instruction {
program_id: ctx.accounts.get_noop_program().key(),
accounts: vec![],
data,
};
invoke(
&instruction,
&[ctx.accounts.get_noop_program().to_account_info()],
)?;
Ok(())

emit_indexer_event(data, ctx.accounts.get_noop_program())
}
2 changes: 1 addition & 1 deletion test-programs/compressed-token-test/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ async fn test_mint_to_failing() {
assert_rpc_error(
result,
0,
light_system_program::errors::SystemProgramError::InvalidNoopPubkey.into(),
account_compression::errors::AccountCompressionErrorCode::InvalidNoopPubkey.into(),
)
.unwrap();
}
Expand Down

0 comments on commit 5f2b6bd

Please sign in to comment.