Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The minor version will be incremented upon a breaking change and the patch versi

### Features

* spl: Add `MetadataAccount` account deserialization. ([#2014](https://github.com/coral-xyz/anchor/pull/2014)).
Comment thread
armaniferrante marked this conversation as resolved.
Outdated
* lang: Add `realloc`, `realloc::payer`, and `realloc::zero` as a new constraint group for program accounts ([#1986](https://github.com/coral-xyz/anchor/pull/1986)).
* lang: Add `PartialEq` and `Eq` for `anchor_lang::Error` ([#1544](https://github.com/coral-xyz/anchor/pull/1544)).
* cli: Add `--skip-build` to `anchor publish` ([#1786](https://github.com/coral-xyz/anchor/pull/1841)).
Expand Down
29 changes: 29 additions & 0 deletions spl/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,32 @@ pub struct SetCollectionSize<'info> {
pub update_authority: AccountInfo<'info>,
pub system_program: AccountInfo<'info>,
}

#[derive(Clone, Debug, PartialEq)]
pub struct MetadataAccount(mpl_token_metadata::state::Metadata);
Comment thread
0xC0A1 marked this conversation as 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> {
let result = mpl_token_metadata::state::Metadata::safe_deserialize(buf)?;
Ok(MetadataAccount(result))
}
}

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