apl-token-metadata 0.6.4

On-chain program for Arch Token Metadata
Documentation
#![deny(missing_docs)]
#![cfg_attr(not(test), forbid(unsafe_code))]

//! On-chain token metadata program for the Arch runtime.
//!
//! This crate provides:
//! - deterministic PDA helpers for metadata and attribute accounts
//! - instruction and processor logic for create/update/finalize flows
//! - state definitions for metadata payloads stored on chain
//!
//! Package details:
//! - Cargo package: `apl-token-metadata`
//! - Library crate: `apl_token_metadata`
//! - Program ID and PDA helpers live in this file
//! - Instruction, state, and processor logic live in sibling modules

pub mod error;
pub mod instruction;
pub mod processor;
pub mod state;

// Exclude the on-chain entrypoint when building unit tests or when the
// consumer opts into the "no-entrypoint" feature (host-side contexts).
#[cfg(all(not(feature = "no-entrypoint"), not(test)))]
mod entrypoint;

use arch_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};

arch_program::declare_id!("MetaLUJnthcRKvy3ayXTnVcxaXqca1fbaQox8ChQqAk");

/// Checks that the supplied program ID is the correct one for Arch Token Metadata
pub fn check_program_account(program_id: &Pubkey) -> ProgramResult {
    if !check_id(program_id) {
        return Err(ProgramError::IncorrectProgramId);
    }
    Ok(())
}

/// PDA seed for metadata account
pub const METADATA_SEED: &[u8] = b"metadata";

/// PDA seed for attributes account
pub const ATTRIBUTES_SEED: &[u8] = b"attributes";

/// Helper to derive the `TokenMetadata` PDA for a given mint
pub fn find_metadata_pda_with_program(program_id: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[METADATA_SEED, mint.as_ref()], program_id)
}

/// Helper to derive the `TokenMetadataAttributes` PDA for a given mint
pub fn find_attributes_pda_with_program(program_id: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[ATTRIBUTES_SEED, mint.as_ref()], program_id)
}