0

im define in account context but give me error

#[account(mut)]
pub master_edition : Account<'info, mpl_token_metadata::state::MasterEditionV2>,

but it show error lint like this :

the trait bound `mpl_token_metadata::state::MasterEditionV2: anchor_lang::AccountSerialize` is not satisfied
the following other types implement trait `anchor_lang::AccountSerialize`:

so im try to unpack manually with :

    let master_edition = MasterEditionV2::from_account_info(
        &ctx.accounts.master_edition.to_account_info()
    );
    match master_edition {
        Ok(data) => {
            msg!("[master_edition] owner {:?}", ctx.accounts.master_edition.owner);
            msg!("[master_edition] key {:?}", ctx.accounts.master_edition.key);
            msg!("[master_edition] [unpack] max_supply {:?}", data.max_supply);
            msg!("[master_edition] [unpack] supply {:?}", data.supply);
            msg!("[master_edition] [unpack] key {:?}", data.key);
        },
        Err(err) => {
            msg!("[master_edition] error {:?}", err);
        }
    }

but give me error when transaction running :

[master_edition] error Custom(63)

what i miss something? thanks for alll help

1 Answer 1

1

The Anchor 0.27 release just added deserialization for the MasterEditionAccount account. You can find more information about it in the changelog and the corresponding pull request.

Include MasterEditionAccount to spl metadata to deserialize master edition v2 accounts

pub struct CreateDrop<'info> {
    /// authority over and payer for the drop
    #[account(mut)]
    pub authority: Signer<'info>,

    #[account(
        seeds = [state::PREFIX.as_bytes(), Metadata::id().as_ref(), metadata_mint.key().as_ref(), state::EDITION.as_bytes()],
        seeds::program = Metadata::id(),
        bump,
    )]

    #[account(constraint = master_edition.supply > 0)]
    pub master_edition: Account<'info, MasterEditionAccount>,
    
    ...
}

You may need to add the metadata feature to the anchor-spl dependency in Cargo.toml.

[dependencies]
anchor-spl = {version = "0.27.0",features = ["metadata"]}

Once enabled, you should be able to access the content using:

use anchor_spl::metadata::{...}

The Account types supported by Account<'info, T> are specific to Anchor, which is why trying to add the account type directly from mpl_token_metadata won't work.

#[account(mut)]
pub master_edition : Account<'info, mpl_token_metadata::state::MasterEditionV2>,

https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account/struct.Account.html#

1
  • thanks for your help, actually this turned out to be due to a personal problem where I misunderstood what a master edition was, instead I gave the mint address of the master edition. thanks for the help, previously I was using version 0.26.0, and thanks to you I finally upgraded to 0.27.0 and find directly class deserialize for MasterEditionAccount. thanks a lot for the help once again. Commented Mar 16, 2023 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.