Skip to content

Commit

Permalink
spl: adding metadata account type (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrodriguez-io authored Aug 13, 2022
1 parent 9457180 commit d3ee9b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The minor version will be incremented upon a breaking change and the patch versi

* client: Add `transaction` functions to RequestBuilder ([#1958](https://github.com/coral-xyz/anchor/pull/1958)).
* spl: Add `create_metadata_accounts_v3` and `set_collection_size` wrappers ([#2119](https://github.com/coral-xyz/anchor/pull/2119))
* spl: Add `MetadataAccount` account deserialization. ([#2014](https://github.com/coral-xyz/anchor/pull/2014)).

## [0.25.0] - 2022-07-05

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

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

1 comment on commit d3ee9b5

@vercel
Copy link

@vercel vercel bot commented on d3ee9b5 Aug 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

www.anchor-lang.com
anchor-docs-git-master-200ms.vercel.app
anchor-lang.com
anchor-docs-200ms.vercel.app

Please sign in to comment.