Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spl: adding metadata account type #2014

Merged
28 changes: 28 additions & 0 deletions spl/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,31 @@ pub struct MintNewEditionFromMasterEditionViaToken<'info> {
//
pub metadata_mint: AccountInfo<'info>,
}

#[derive(Clone, Debug, PartialEq)]
pub struct MetadataAccount(mpl_token_metadata::state::Metadata);
kevinrodriguez-io marked this conversation as resolved.
Show resolved Hide resolved

impl MetadataAccount {
pub const LEN: usize = mpl_token_metadata::state::MAX_METADATA_LEN;
}

impl anchor_lang::AccountDeserialize for MetadataAccount {
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
meta_deser(buf).map(MetadataAccount).map_err(Into::into)
kevinrodriguez-io marked this conversation as resolved.
Show resolved Hide resolved
}
}

impl anchor_lang::AccountSerialize for MetadataAccount {}

impl anchor_lang::Owner for MetadataAccount {
fn owner() -> Pubkey {
ID
}
}

impl Deref for MetadataAccount {
type Target = mpl_token_metadata::state::Metadata;
fn deref(&self) -> &Self::Target {
&self.0
}
}