From ec1b904fe4379dfec1332e7846e375d2d95ec4a9 Mon Sep 17 00:00:00 2001 From: Michael Danenberg <56533526+danenbm@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:48:54 -0800 Subject: [PATCH] Update to use Token Metadata (and latest Blockbuster) Rust clients --- blockbuster/Cargo.toml | 4 +- .../src/programs/token_metadata/mod.rs | 40 +++++-------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/blockbuster/Cargo.toml b/blockbuster/Cargo.toml index 59a245b..5d14ad6 100644 --- a/blockbuster/Cargo.toml +++ b/blockbuster/Cargo.toml @@ -11,8 +11,8 @@ readme = "../README.md" [dependencies] spl-account-compression = { version = "0.2.0", features = ["no-entrypoint"] } spl-noop = { version = "0.2.0", features = ["no-entrypoint"] } -mpl-bubblegum = "=1.0.1-beta.4" -mpl-token-metadata = { version = "2.0.0-beta.1", features = ["no-entrypoint", "serde-feature"] } +mpl-bubblegum = "1.2.0" +mpl-token-metadata = { version = "4.0.0", features = ["serde"], path = "/home/danenbm/Metaplex-Workspace/mpl-token-metadata/clients/rust" } plerkle_serialization = { version = "1.6.0" } spl-token = { version = "4.0.0", features = ["no-entrypoint"] } async-trait = "0.1.57" diff --git a/blockbuster/src/programs/token_metadata/mod.rs b/blockbuster/src/programs/token_metadata/mod.rs index a00447c..7eac5c5 100644 --- a/blockbuster/src/programs/token_metadata/mod.rs +++ b/blockbuster/src/programs/token_metadata/mod.rs @@ -10,11 +10,11 @@ use plerkle_serialization::AccountInfo; pub use mpl_bubblegum::{types::LeafSchema, InstructionName, LeafSchemaEvent}; use mpl_token_metadata::{ - state::{ - CollectionAuthorityRecord, Edition, EditionMarker, Key, MasterEditionV1, MasterEditionV2, - Metadata, ReservationListV1, ReservationListV2, UseAuthorityRecord, + accounts::{ + CollectionAuthorityRecord, DeprecatedMasterEditionV1, Edition, EditionMarker, + MasterEdition, Metadata, UseAuthorityRecord, }, - utils::meta_deser_unchecked, + types::Key, }; pubkeys!( @@ -25,14 +25,12 @@ pubkeys!( #[allow(clippy::large_enum_variant)] pub enum TokenMetadataAccountData { EditionV1(Edition), - MasterEditionV1(MasterEditionV1), + MasterEditionV1(DeprecatedMasterEditionV1), MetadataV1(Metadata), - MasterEditionV2(MasterEditionV2), + MasterEditionV2(MasterEdition), EditionMarker(EditionMarker), UseAuthorityRecord(UseAuthorityRecord), CollectionAuthorityRecord(CollectionAuthorityRecord), - ReservationListV2(ReservationListV2), - ReservationListV1(ReservationListV1), EmptyAccount, } @@ -100,19 +98,19 @@ impl ProgramParser for TokenMetadataParser { } } Key::MasterEditionV1 => { - let account: MasterEditionV2 = try_from_slice_unchecked(&account_data)?; + let account: DeprecatedMasterEditionV1 = try_from_slice_unchecked(&account_data)?; TokenMetadataAccountState { key: account.key, - data: TokenMetadataAccountData::MasterEditionV2(account), + data: TokenMetadataAccountData::MasterEditionV1(account), } } Key::MasterEditionV2 => { - let account: MasterEditionV1 = try_from_slice_unchecked(&account_data)?; + let account: MasterEdition = try_from_slice_unchecked(&account_data)?; TokenMetadataAccountState { key: account.key, - data: TokenMetadataAccountData::MasterEditionV1(account), + data: TokenMetadataAccountData::MasterEditionV2(account), } } Key::UseAuthorityRecord => { @@ -140,29 +138,13 @@ impl ProgramParser for TokenMetadataParser { } } Key::MetadataV1 => { - let account: Metadata = meta_deser_unchecked(&mut account_data.as_slice())?; + let account = Metadata::safe_deserialize(&account_data)?; TokenMetadataAccountState { key: account.key, data: TokenMetadataAccountData::MetadataV1(account), } } - Key::ReservationListV1 => { - let account: ReservationListV1 = try_from_slice_unchecked(&account_data)?; - - TokenMetadataAccountState { - key: account.key, - data: TokenMetadataAccountData::ReservationListV1(account), - } - } - Key::ReservationListV2 => { - let account: ReservationListV2 = try_from_slice_unchecked(&account_data)?; - - TokenMetadataAccountState { - key: account.key, - data: TokenMetadataAccountData::ReservationListV2(account), - } - } Key::Uninitialized => { return Err(BlockbusterError::UninitializedAccount); }