Skip to content

Commit

Permalink
feat: add master edition account deserialization to spl metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kespinola committed Feb 8, 2023
1 parent cfdaac1 commit 5016784
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

- spl: Add `MasterEditionAccount` account deserialization to spl metadata ([#2393](https://github.com/coral-xyz/anchor/pull/2393)).
- lang: Add the `InitSpace` derive macro to automatically calculate the space at the initialization of an account ([#2346](https://github.com/coral-xyz/anchor/pull/2346)).
- cli: Add `env` option to verifiable builds ([#2325](https://github.com/coral-xyz/anchor/pull/2325)).
- cli: Add `idl close` command to close a program's IDL account ([#2329](https://github.com/coral-xyz/anchor/pull/2329)).
Expand Down
29 changes: 29 additions & 0 deletions spl/src/metadata.rs
Expand Up @@ -543,6 +543,35 @@ impl Deref for MetadataAccount {
}
}

#[derive(Clone, Debug, PartialEq)]
pub struct MasterEditionAccount(mpl_token_metadata::state::MasterEditionV2);

impl MasterEditionAccount {
pub const LEN: usize = mpl_token_metadata::state::MAX_MASTER_EDITION_LEN;
}

impl anchor_lang::AccountDeserialize for MasterEditionAccount {
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
let result = mpl_token_metadata::state::MasterEditionV2::safe_deserialize(buf)?;
Ok(MasterEditionAccount(result))
}
}

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

impl anchor_lang::AccountSerialize for MasterEditionAccount {}

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

#[derive(Clone)]
pub struct Metadata;

Expand Down

0 comments on commit 5016784

Please sign in to comment.