|
1 | | -// placeholder |
| 1 | +#![allow(clippy::too_many_arguments)] |
| 2 | +#![allow(unexpected_cfgs)] |
| 3 | +#![allow(deprecated)] |
| 4 | + |
| 5 | +use anchor_lang::{prelude::*, solana_program::instruction::Instruction}; |
| 6 | + |
| 7 | +declare_id!("CompressedTokenTestProgram11111111111111111"); |
| 8 | + |
| 9 | +#[program] |
| 10 | +pub mod compressed_token_test { |
| 11 | + use super::*; |
| 12 | + |
| 13 | + /// Wrapper for write_to_cpi_context mode mint_action CPI |
| 14 | + /// All accounts are in remaining_accounts (unchecked) |
| 15 | + pub fn write_to_cpi_context_mint_action<'info>( |
| 16 | + ctx: Context<'_, '_, '_, 'info, MintActionCpiWrapper<'info>>, |
| 17 | + inputs: Vec<u8>, |
| 18 | + ) -> Result<()> { |
| 19 | + execute_mint_action_cpi(ctx, inputs) |
| 20 | + } |
| 21 | + |
| 22 | + /// Wrapper for execute_cpi_context mode mint_action CPI |
| 23 | + /// All accounts are in remaining_accounts (unchecked) |
| 24 | + pub fn execute_cpi_context_mint_action<'info>( |
| 25 | + ctx: Context<'_, '_, '_, 'info, MintActionCpiWrapper<'info>>, |
| 26 | + inputs: Vec<u8>, |
| 27 | + ) -> Result<()> { |
| 28 | + execute_mint_action_cpi(ctx, inputs) |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +/// Minimal account structure - only compressed token program ID |
| 33 | +/// Everything else goes in remaining_accounts with no validation |
| 34 | +#[derive(Accounts)] |
| 35 | +pub struct MintActionCpiWrapper<'info> { |
| 36 | + /// CHECK: Compressed token program - no validation |
| 37 | + pub compressed_token_program: AccountInfo<'info>, |
| 38 | +} |
| 39 | + |
| 40 | +/// Shared implementation for both wrapper instructions |
| 41 | +/// Passes through raw instruction bytes and accounts without any validation |
| 42 | +fn execute_mint_action_cpi<'info>( |
| 43 | + ctx: Context<'_, '_, '_, 'info, MintActionCpiWrapper<'info>>, |
| 44 | + inputs: Vec<u8>, |
| 45 | +) -> Result<()> { |
| 46 | + // Build account_metas from remaining_accounts - pass through as-is |
| 47 | + let account_metas: Vec<AccountMeta> = ctx |
| 48 | + .remaining_accounts |
| 49 | + .iter() |
| 50 | + .map(|acc| { |
| 51 | + if acc.is_writable { |
| 52 | + AccountMeta::new(*acc.key, acc.is_signer) |
| 53 | + } else { |
| 54 | + AccountMeta::new_readonly(*acc.key, acc.is_signer) |
| 55 | + } |
| 56 | + }) |
| 57 | + .collect(); |
| 58 | + |
| 59 | + // Build instruction with raw bytes (no validation) |
| 60 | + let instruction = Instruction { |
| 61 | + program_id: *ctx.accounts.compressed_token_program.key, |
| 62 | + accounts: account_metas, |
| 63 | + data: inputs, // Pass through raw instruction bytes |
| 64 | + }; |
| 65 | + |
| 66 | + // Simple invoke without any signer seeds |
| 67 | + anchor_lang::solana_program::program::invoke(&instruction, ctx.remaining_accounts)?; |
| 68 | + |
| 69 | + Ok(()) |
| 70 | +} |
0 commit comments