Skip to main content

apl_token_metadata/
lib.rs

1#![deny(missing_docs)]
2#![cfg_attr(not(test), forbid(unsafe_code))]
3
4//! Arch Network Token Metadata Standard
5
6pub mod error;
7pub mod instruction;
8pub mod processor;
9pub mod state;
10
11// Exclude the on-chain entrypoint when building unit tests or when the
12// consumer opts into the "no-entrypoint" feature (host-side contexts).
13#[cfg(all(not(feature = "no-entrypoint"), not(test)))]
14mod entrypoint;
15
16use arch_program::{entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey};
17
18arch_program::declare_id!("MetaLUJnthcRKvy3ayXTnVcxaXqca1fbaQox8ChQqAk");
19
20/// Checks that the supplied program ID is the correct one for Arch Token Metadata
21pub fn check_program_account(program_id: &Pubkey) -> ProgramResult {
22    if !check_id(program_id) {
23        return Err(ProgramError::IncorrectProgramId);
24    }
25    Ok(())
26}
27
28/// PDA seed for metadata account
29pub const METADATA_SEED: &[u8] = b"metadata";
30
31/// PDA seed for attributes account
32pub const ATTRIBUTES_SEED: &[u8] = b"attributes";
33
34/// Helper to derive the `TokenMetadata` PDA for a given mint
35pub fn find_metadata_pda_with_program(program_id: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) {
36    Pubkey::find_program_address(&[METADATA_SEED, mint.as_ref()], program_id)
37}
38
39/// Helper to derive the `TokenMetadataAttributes` PDA for a given mint
40pub fn find_attributes_pda_with_program(program_id: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) {
41    Pubkey::find_program_address(&[ATTRIBUTES_SEED, mint.as_ref()], program_id)
42}