Skip to content

Commit

Permalink
spl: adding metadata account type
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrodriguez-io committed Jun 29, 2022
1 parent a1bb494 commit 2707307
Showing 1 changed file with 28 additions and 0 deletions.
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);

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)
}
}

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
}
}

0 comments on commit 2707307

Please sign in to comment.