So I want to be able to read the fields of an NFT metadata account from within my instruction logic.
I'm passing in the NFT as an unchecked account in my accounts context struct like so (note the collection_mint
and collection_metadata
fields):
#[derive(Accounts)]
pub struct InitializePair<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(
init,
payer = payer,
space = 8 + Pair::SIZE
)]
pub pair: Account<'info, Pair>,
/// CHECK: validated in access control logic
pub nft_collection_mint: UncheckedAccount<'info>,
/// CHECK: validated in access control logic
pub nft_collection_metadata: UncheckedAccount<'info>,
pub quote_token_mint: Account<'info, Mint>,
#[account(
init,
payer = payer,
token::mint = quote_token_mint,
token::authority = program_as_signer,
seeds = [b"quote", pair.key().as_ref()],
bump
)]
pub quote_token_vault: Account<'info, TokenAccount>,
pub system_program: Program<'info, System>,
pub token_program: Program<'info, Token>,
pub rent: Sysvar<'info, Rent>,
pub token_metadata: Program<'info, TokenMetadata>,
#[account(seeds = [b"program", b"signer"], bump)]
pub program_as_signer: UncheckedAccount<'info>,
}
Assume I know that the collection_metadata is valid and exists (i have not included that logic here to keep this short), I want to read the collection
and collection_details
fields on the Metadata account. Not sure how to access this. I imagine I need to deserialize the account data somehow?