mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-23 23:33:10 +00:00
- Updated `nssa_core` and `spel-framework` dependencies to their respective release candidates in `Cargo.toml` and `Cargo.lock` files for `amm`, `ata`, and `token` modules. - Enhanced the `new_definition` function in `amm/src/new_definition.rs` to include new claim logic and updated PDA seed calculations. - Modified tests in `integration_tests/tests/amm.rs`, `integration_tests/tests/ata.rs`, and `integration_tests/tests/token.rs` to accommodate changes in transaction handling and account initialization. - Refactored account initialization logic in `ata/src/create.rs` and `token/src/initialize.rs` to include authorization claims. - Updated various functions in `token/src/mint.rs`, `token/src/new_definition.rs`, and `token/src/transfer.rs` to utilize the new claim system for account states. - Adjusted the IDL generation tool to use the latest version of `spel-framework-core`.
72 lines
2.2 KiB
Rust
72 lines
2.2 KiB
Rust
#![no_main]
|
|
|
|
use spel_framework::prelude::*;
|
|
use nssa_core::{account::AccountWithMetadata, program::ProgramId};
|
|
|
|
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(
|
|
owner: AccountWithMetadata,
|
|
token_definition: AccountWithMetadata,
|
|
ata_account: AccountWithMetadata,
|
|
ata_program_id: ProgramId,
|
|
) -> SpelResult {
|
|
let (post_states, chained_calls) = ata_program::create::create_associated_token_account(
|
|
owner,
|
|
token_definition,
|
|
ata_account,
|
|
ata_program_id,
|
|
);
|
|
Ok(SpelOutput::with_chained_calls(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(
|
|
owner: AccountWithMetadata,
|
|
sender_ata: AccountWithMetadata,
|
|
recipient: AccountWithMetadata,
|
|
ata_program_id: ProgramId,
|
|
amount: u128,
|
|
) -> SpelResult {
|
|
let (post_states, chained_calls) =
|
|
ata_program::transfer::transfer_from_associated_token_account(
|
|
owner,
|
|
sender_ata,
|
|
recipient,
|
|
ata_program_id,
|
|
amount,
|
|
);
|
|
Ok(SpelOutput::with_chained_calls(post_states, chained_calls))
|
|
}
|
|
|
|
/// Burn tokens FROM owner's ATA.
|
|
#[instruction]
|
|
pub fn burn(
|
|
owner: AccountWithMetadata,
|
|
holder_ata: AccountWithMetadata,
|
|
token_definition: AccountWithMetadata,
|
|
ata_program_id: ProgramId,
|
|
amount: u128,
|
|
) -> SpelResult {
|
|
let (post_states, chained_calls) =
|
|
ata_program::burn::burn_from_associated_token_account(
|
|
owner,
|
|
holder_ata,
|
|
token_definition,
|
|
ata_program_id,
|
|
amount,
|
|
);
|
|
Ok(SpelOutput::with_chained_calls(post_states, chained_calls))
|
|
}
|
|
}
|