diff --git a/bin/cli/src/main.rs b/bin/cli/src/main.rs index 4072398..4195e0a 100644 --- a/bin/cli/src/main.rs +++ b/bin/cli/src/main.rs @@ -166,6 +166,10 @@ async fn main() -> Result<(), anyhow::Error> { let event = bytemuck::from_bytes::(&decoded[8..]); println!("ReferrerWithdrawLog - referer: {:?}, referer_token_account: {:?}, amount: {}", event.referer, event.referer_token_account, event.amount); } + &CREATE_REFERRAL_LOG_DISCRIMINANT => { + let event = bytemuck::from_bytes::(&decoded[8..]); + println!("CreateReferralLog - referer: {:?}, referee: {:?}, vault: {:?}, mint: {:?}", event.referer, event.referee, event.vault, event.mint); + } _ => panic!("Unknown log discriminant"), } } diff --git a/programs/autobahn-executor/src/instructions/execute_create_referral.rs b/programs/autobahn-executor/src/instructions/execute_create_referral.rs index df3c402..828e3e0 100644 --- a/programs/autobahn-executor/src/instructions/execute_create_referral.rs +++ b/programs/autobahn-executor/src/instructions/execute_create_referral.rs @@ -10,6 +10,8 @@ use solana_program::sysvar::Sysvar; use crate::create_pda::create_pda_account; +use crate::logs::{emit_stack, CreateReferralLog}; + pub fn execute_create_referral(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult { if let [payer, referrer, vault, mint, system_program, token_program] = accounts { // verify token program is passed @@ -56,6 +58,13 @@ pub fn execute_create_referral(accounts: &[AccountInfo], instruction_data: &[u8] let initialize_account_infos = [vault.clone(), mint.clone(), token_program.clone()]; invoke(&initialize_ix, &initialize_account_infos)?; + emit_stack(CreateReferralLog { + referee: *payer.key, + referer: *referrer.key, + vault: *vault.key, + mint: *mint.key, + })?; + Ok(()) } else { Err(ProgramError::NotEnoughAccountKeys) diff --git a/programs/autobahn-executor/src/logs.rs b/programs/autobahn-executor/src/logs.rs index 6cfe02d..5bf9e26 100644 --- a/programs/autobahn-executor/src/logs.rs +++ b/programs/autobahn-executor/src/logs.rs @@ -84,10 +84,20 @@ pub struct ReferrerWithdrawLog { pub amount: u64, } +#[repr(C)] +#[derive(Clone, Copy, Zeroable, Pod)] +pub struct CreateReferralLog { + pub referee: Pubkey, + pub referer: Pubkey, + pub vault: Pubkey, + pub mint: Pubkey, +} + pub const PLATFORM_FEE_LOG_DISCRIMINANT: [u8; 8] = [160, 183, 104, 34, 255, 190, 119, 188]; pub const REFERRER_FEE_LOG_DISCRIMINANT: [u8; 8] = [198, 149, 221, 27, 28, 103, 76, 95]; pub const REFERRER_WITHDRAW_LOG_DISCRIMINANT: [u8; 8] = [25, 7, 239, 41, 67, 36, 141, 92]; pub const SWAP_EVENT_DISCRIMINANT: [u8; 8] = [56, 178, 48, 245, 42, 152, 27, 75]; +pub const CREATE_REFERRAL_LOG_DISCRIMINANT: [u8; 8] = [114, 188, 157, 65, 100, 179, 129, 169]; discriminant!( PlatformFeeLog, @@ -106,6 +116,13 @@ discriminant!( REFERRER_WITHDRAW_LOG_DISCRIMINANT, test_referrer_withdraw_log ); + +discriminant!( + CreateReferralLog, + CREATE_REFERRAL_LOG_DISCRIMINANT, + test_create_referral_log +); + discriminant!(SwapEvent, SWAP_EVENT_DISCRIMINANT, test_swap_event); /// Canonical discriminant of the given struct. It is the hash of program ID and