Skip to content

Commit

Permalink
Update to use Token Metadata (and latest Blockbuster) Rust clients
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Jan 30, 2024
1 parent f321236 commit ec1b904
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
4 changes: 2 additions & 2 deletions blockbuster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 11 additions & 29 deletions blockbuster/src/programs/token_metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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,
}

Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ec1b904

Please sign in to comment.