#![no_main] use spel_framework::prelude::*; use spel_framework::context::ProgramContext; use nssa_core::account::AccountWithMetadata; risc0_zkvm::guest::entry!(main); #[lez_program(instruction = "ata_core::Instruction")] mod ata { #[allow(unused_imports)] use super::*; /// Create the Associated Token Account for (owner, definition). /// Idempotent: no-op if the account already exists. #[instruction] pub fn create( ctx: ProgramContext, owner: AccountWithMetadata, token_definition: AccountWithMetadata, ata_account: AccountWithMetadata, ) -> SpelResult { let (post_states, chained_calls) = ata_program::create::create_associated_token_account( owner, token_definition, ata_account, ctx.self_program_id, ); Ok(spel_framework::SpelOutput::execute(post_states, chained_calls)) } /// Transfer tokens FROM owner's ATA to a recipient token holding account. /// The recipient holding account must already be initialized. #[instruction] pub fn transfer( ctx: ProgramContext, owner: AccountWithMetadata, sender_ata: AccountWithMetadata, recipient: AccountWithMetadata, amount: u128, ) -> SpelResult { let (post_states, chained_calls) = ata_program::transfer::transfer_from_associated_token_account( owner, sender_ata, recipient, ctx.self_program_id, amount, ); Ok(spel_framework::SpelOutput::execute(post_states, chained_calls)) } /// Burn tokens FROM owner's ATA. #[instruction] pub fn burn( ctx: ProgramContext, owner: AccountWithMetadata, holder_ata: AccountWithMetadata, token_definition: AccountWithMetadata, amount: u128, ) -> SpelResult { let (post_states, chained_calls) = ata_program::burn::burn_from_associated_token_account( owner, holder_ata, token_definition, ctx.self_program_id, amount, ); Ok(spel_framework::SpelOutput::execute(post_states, chained_calls)) } }