From 303d8824d770bc18457b6d1b6ee20f196cdfe660 Mon Sep 17 00:00:00 2001 From: Nhan Phan Date: Tue, 5 Mar 2024 14:59:31 -0800 Subject: [PATCH] rename collection, add solana account tratit to rust client --- .../{collectionData.ts => collection.ts} | 85 +++++++++---------- clients/js/src/generated/accounts/index.ts | 2 +- .../src/hooked/fetchCollectionWithPlugins.ts | 12 +-- clients/js/test/addPlugin.test.ts | 8 +- clients/js/test/createCollection.test.ts | 8 +- .../{collection_data.rs => collection.rs} | 6 +- clients/rust/src/generated/accounts/mod.rs | 4 +- clients/rust/src/hooked/mod.rs | 23 ++++- idls/mpl_core.json | 2 +- programs/mpl-core/src/plugins/utils.rs | 6 +- .../src/processor/add_plugin_authority.rs | 4 +- programs/mpl-core/src/processor/burn.rs | 6 +- .../src/processor/create_collection.rs | 4 +- .../mpl-core/src/processor/remove_plugin.rs | 6 +- .../src/processor/remove_plugin_authority.rs | 6 +- programs/mpl-core/src/processor/update.rs | 4 +- programs/mpl-core/src/state/collection.rs | 10 +-- .../mpl-core/src/state/update_authority.rs | 6 +- programs/mpl-core/src/utils.rs | 4 +- 19 files changed, 111 insertions(+), 95 deletions(-) rename clients/js/src/generated/accounts/{collectionData.ts => collection.ts} (59%) rename clients/rust/src/generated/accounts/{collection_data.rs => collection.rs} (94%) diff --git a/clients/js/src/generated/accounts/collectionData.ts b/clients/js/src/generated/accounts/collection.ts similarity index 59% rename from clients/js/src/generated/accounts/collectionData.ts rename to clients/js/src/generated/accounts/collection.ts index bd220422..4a7abea7 100644 --- a/clients/js/src/generated/accounts/collectionData.ts +++ b/clients/js/src/generated/accounts/collection.ts @@ -21,6 +21,7 @@ import { } from '@metaplex-foundation/umi'; import { Serializer, + mapSerializer, publicKey as publicKeySerializer, string, struct, @@ -28,9 +29,9 @@ import { } from '@metaplex-foundation/umi/serializers'; import { Key, KeyArgs, getKeySerializer } from '../types'; -export type CollectionData = Account; +export type Collection = Account; -export type CollectionDataAccountData = { +export type CollectionAccountData = { key: Key; updateAuthority: PublicKey; name: string; @@ -39,8 +40,7 @@ export type CollectionDataAccountData = { currentSize: number; }; -export type CollectionDataAccountDataArgs = { - key: KeyArgs; +export type CollectionAccountDataArgs = { updateAuthority: PublicKey; name: string; uri: string; @@ -48,89 +48,85 @@ export type CollectionDataAccountDataArgs = { currentSize: number; }; -export function getCollectionDataAccountDataSerializer(): Serializer< - CollectionDataAccountDataArgs, - CollectionDataAccountData +export function getCollectionAccountDataSerializer(): Serializer< + CollectionAccountDataArgs, + CollectionAccountData > { - return struct( - [ - ['key', getKeySerializer()], - ['updateAuthority', publicKeySerializer()], - ['name', string()], - ['uri', string()], - ['numMinted', u32()], - ['currentSize', u32()], - ], - { description: 'CollectionDataAccountData' } - ) as Serializer; + return mapSerializer( + struct( + [ + ['key', getKeySerializer()], + ['updateAuthority', publicKeySerializer()], + ['name', string()], + ['uri', string()], + ['numMinted', u32()], + ['currentSize', u32()], + ], + { description: 'CollectionAccountData' } + ), + (value) => ({ ...value, key: Key.Collection }) + ) as Serializer; } -export function deserializeCollectionData( - rawAccount: RpcAccount -): CollectionData { - return deserializeAccount( - rawAccount, - getCollectionDataAccountDataSerializer() - ); +export function deserializeCollection(rawAccount: RpcAccount): Collection { + return deserializeAccount(rawAccount, getCollectionAccountDataSerializer()); } -export async function fetchCollectionData( +export async function fetchCollection( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions -): Promise { +): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); - assertAccountExists(maybeAccount, 'CollectionData'); - return deserializeCollectionData(maybeAccount); + assertAccountExists(maybeAccount, 'Collection'); + return deserializeCollection(maybeAccount); } -export async function safeFetchCollectionData( +export async function safeFetchCollection( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions -): Promise { +): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); - return maybeAccount.exists ? deserializeCollectionData(maybeAccount) : null; + return maybeAccount.exists ? deserializeCollection(maybeAccount) : null; } -export async function fetchAllCollectionData( +export async function fetchAllCollection( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions -): Promise { +): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts.map((maybeAccount) => { - assertAccountExists(maybeAccount, 'CollectionData'); - return deserializeCollectionData(maybeAccount); + assertAccountExists(maybeAccount, 'Collection'); + return deserializeCollection(maybeAccount); }); } -export async function safeFetchAllCollectionData( +export async function safeFetchAllCollection( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions -): Promise { +): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts .filter((maybeAccount) => maybeAccount.exists) - .map((maybeAccount) => - deserializeCollectionData(maybeAccount as RpcAccount) - ); + .map((maybeAccount) => deserializeCollection(maybeAccount as RpcAccount)); } -export function getCollectionDataGpaBuilder( +export function getCollectionGpaBuilder( context: Pick ) { const programId = context.programs.getPublicKey( @@ -153,7 +149,6 @@ export function getCollectionDataGpaBuilder( numMinted: [null, u32()], currentSize: [null, u32()], }) - .deserializeUsing((account) => - deserializeCollectionData(account) - ); + .deserializeUsing((account) => deserializeCollection(account)) + .whereField('key', Key.Collection); } diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts index 8e62c9ad..989ec459 100644 --- a/clients/js/src/generated/accounts/index.ts +++ b/clients/js/src/generated/accounts/index.ts @@ -7,7 +7,7 @@ */ export * from './asset'; -export * from './collectionData'; +export * from './collection'; export * from './hashedAsset'; export * from './pluginHeader'; export * from './pluginRegistry'; diff --git a/clients/js/src/hooked/fetchCollectionWithPlugins.ts b/clients/js/src/hooked/fetchCollectionWithPlugins.ts index 46793557..6a451e4f 100644 --- a/clients/js/src/hooked/fetchCollectionWithPlugins.ts +++ b/clients/js/src/hooked/fetchCollectionWithPlugins.ts @@ -7,18 +7,18 @@ import { publicKey as toPublicKey, } from '@metaplex-foundation/umi'; import { - CollectionData, + Collection, PluginHeaderAccountData, PluginRegistryAccountData, - deserializeCollectionData, - getCollectionDataAccountDataSerializer, + deserializeCollection, + getCollectionAccountDataSerializer, getPluginHeaderAccountDataSerializer, getPluginRegistryAccountDataSerializer, getPluginSerializer, } from '../generated'; import { PluginList, PluginWithAuthorities } from '.'; -export type CollectionWithPlugins = CollectionData & PluginList; +export type CollectionWithPlugins = Collection & PluginList; export async function fetchCollectionWithPlugins( context: Pick, @@ -30,9 +30,9 @@ export async function fetchCollectionWithPlugins( options ); assertAccountExists(maybeAccount, 'Collection'); - const collection = deserializeCollectionData(maybeAccount); + const collection = deserializeCollection(maybeAccount); const collectionData = - getCollectionDataAccountDataSerializer().serialize(collection); + getCollectionAccountDataSerializer().serialize(collection); let pluginHeader: PluginHeaderAccountData | undefined; let pluginRegistry: PluginRegistryAccountData | undefined; diff --git a/clients/js/test/addPlugin.test.ts b/clients/js/test/addPlugin.test.ts index e788b2b7..55e09df5 100644 --- a/clients/js/test/addPlugin.test.ts +++ b/clients/js/test/addPlugin.test.ts @@ -4,7 +4,7 @@ import test from 'ava'; import { Asset, AssetWithPlugins, - CollectionData, + Collection, CollectionWithPlugins, DataState, PluginType, @@ -14,7 +14,7 @@ import { createCollection, fetchAsset, fetchAssetWithPlugins, - fetchCollectionData, + fetchCollection, fetchCollectionWithPlugins, updateAuthority, } from '../src'; @@ -101,9 +101,9 @@ test('it can add a plugin to a collection', async (t) => { }).sendAndConfirm(umi); // Then an account was created with the correct data. - const collection = await fetchCollectionData(umi, collectionAddress.publicKey); + const collection = await fetchCollection(umi, collectionAddress.publicKey); // console.log("Account State:", collection); - t.like(collection, { + t.like(collection, { publicKey: collectionAddress.publicKey, updateAuthority: umi.identity.publicKey, name: 'Test Bread', diff --git a/clients/js/test/createCollection.test.ts b/clients/js/test/createCollection.test.ts index 1750cf40..ce738b21 100644 --- a/clients/js/test/createCollection.test.ts +++ b/clients/js/test/createCollection.test.ts @@ -2,13 +2,13 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; import { AssetWithPlugins, - CollectionData, + Collection, CollectionWithPlugins, DataState, create, createCollection, fetchAssetWithPlugins, - fetchCollectionData, + fetchCollection, fetchCollectionWithPlugins, updateAuthority, } from '../src'; @@ -28,12 +28,12 @@ test('it can create a new collection', async (t) => { }).sendAndConfirm(umi); // Then an account was created with the correct data. - const collection = await fetchCollectionData( + const collection = await fetchCollection( umi, collectionAddress.publicKey ); // console.log("Account State:", collection); - t.like(collection, { + t.like(collection, { publicKey: collectionAddress.publicKey, updateAuthority: umi.identity.publicKey, name: 'Test Bread Collection', diff --git a/clients/rust/src/generated/accounts/collection_data.rs b/clients/rust/src/generated/accounts/collection.rs similarity index 94% rename from clients/rust/src/generated/accounts/collection_data.rs rename to clients/rust/src/generated/accounts/collection.rs index 3fd21140..a2e4b27a 100644 --- a/clients/rust/src/generated/accounts/collection_data.rs +++ b/clients/rust/src/generated/accounts/collection.rs @@ -12,7 +12,7 @@ use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct CollectionData { +pub struct Collection { pub key: Key, #[cfg_attr( feature = "serde", @@ -25,7 +25,7 @@ pub struct CollectionData { pub current_size: u32, } -impl CollectionData { +impl Collection { #[inline(always)] pub fn from_bytes(data: &[u8]) -> Result { let mut data = data; @@ -33,7 +33,7 @@ impl CollectionData { } } -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for CollectionData { +impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Collection { type Error = std::io::Error; fn try_from( diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index 8c790ac5..ab535f77 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -6,13 +6,13 @@ //! pub(crate) mod asset; -pub(crate) mod collection_data; +pub(crate) mod collection; pub(crate) mod hashed_asset; pub(crate) mod plugin_header; pub(crate) mod plugin_registry; pub use self::asset::*; -pub use self::collection_data::*; +pub use self::collection::*; pub use self::hashed_asset::*; pub use self::plugin_header::*; pub use self::plugin_registry::*; diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs index fe115c42..380e8e02 100644 --- a/clients/rust/src/hooked/mod.rs +++ b/clients/rust/src/hooked/mod.rs @@ -4,7 +4,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; pub use plugins::*; use crate::{ - accounts::{Asset, PluginHeader, PluginRegistry}, + accounts::{Asset, Collection, PluginHeader, PluginRegistry}, errors::MplCoreError, types::{Key, Plugin, PluginType}, }; @@ -28,6 +28,11 @@ impl Asset { pub const BASE_LENGTH: usize = 1 + 32 + 33 + 4 + 4; } +impl Collection { + /// The base length of the collection account with an empty name and uri. + pub const BASE_LENGTH: usize = 1 + 32 + 4 + 4 + 4 + 4; +} + impl DataBlob for Asset { fn get_initial_size() -> usize { Asset::BASE_LENGTH @@ -44,6 +49,22 @@ impl SolanaAccount for Asset { } } +impl DataBlob for Collection { + fn get_initial_size() -> usize { + Self::BASE_LENGTH + } + + fn get_size(&self) -> usize { + Self::BASE_LENGTH + self.name.len() + self.uri.len() + } +} + +impl SolanaAccount for Collection { + fn key() -> Key { + Key::Collection + } +} + impl SolanaAccount for PluginRegistry { fn key() -> Key { Key::PluginRegistry diff --git a/idls/mpl_core.json b/idls/mpl_core.json index 369952b9..f035181d 100644 --- a/idls/mpl_core.json +++ b/idls/mpl_core.json @@ -1334,7 +1334,7 @@ } }, { - "name": "CollectionData", + "name": "Collection", "type": { "kind": "struct", "fields": [ diff --git a/programs/mpl-core/src/plugins/utils.rs b/programs/mpl-core/src/plugins/utils.rs index 5f24545d..27f68172 100644 --- a/programs/mpl-core/src/plugins/utils.rs +++ b/programs/mpl-core/src/plugins/utils.rs @@ -6,7 +6,7 @@ use solana_program::{ use crate::{ error::MplCoreError, - state::{Asset, Authority, CollectionData, CoreAsset, DataBlob, Key, SolanaAccount}, + state::{Asset, Authority, Collection, CoreAsset, DataBlob, Key, SolanaAccount}, utils::{assert_authority, load_key, resize_or_reallocate_account}, }; @@ -30,7 +30,7 @@ pub fn create_meta_idempotent<'a>( Key::Collection => { let collection = { let mut bytes: &[u8] = &(*account.data).borrow(); - CollectionData::deserialize(&mut bytes)? + Collection::deserialize(&mut bytes)? }; collection.get_size() @@ -194,7 +194,7 @@ pub fn initialize_plugin<'a>( Key::Collection => { let collection = { let mut bytes: &[u8] = &(*account.data).borrow(); - CollectionData::deserialize(&mut bytes)? + Collection::deserialize(&mut bytes)? }; collection.get_size() diff --git a/programs/mpl-core/src/processor/add_plugin_authority.rs b/programs/mpl-core/src/processor/add_plugin_authority.rs index dafe2c69..9ed068cb 100644 --- a/programs/mpl-core/src/processor/add_plugin_authority.rs +++ b/programs/mpl-core/src/processor/add_plugin_authority.rs @@ -6,7 +6,7 @@ use crate::{ error::MplCoreError, instruction::accounts::{AddCollectionPluginAuthorityAccounts, AddPluginAuthorityAccounts}, plugins::{add_authority_to_plugin, PluginType}, - state::{Asset, Authority, CollectionData, CoreAsset, DataBlob, SolanaAccount}, + state::{Asset, Authority, Collection, CoreAsset, DataBlob, SolanaAccount}, utils::fetch_core_data, }; @@ -66,7 +66,7 @@ pub(crate) fn add_collection_plugin_authority<'a>( None => ctx.accounts.authority, }; - process_add_plugin_authority::( + process_add_plugin_authority::( ctx.accounts.collection, ctx.accounts.authority, payer, diff --git a/programs/mpl-core/src/processor/burn.rs b/programs/mpl-core/src/processor/burn.rs index f61e0157..66afc1d1 100644 --- a/programs/mpl-core/src/processor/burn.rs +++ b/programs/mpl-core/src/processor/burn.rs @@ -6,7 +6,7 @@ use crate::{ error::MplCoreError, instruction::accounts::{BurnAccounts, BurnCollectionAccounts}, plugins::{CheckResult, Plugin, ValidationResult}, - state::{Asset, CollectionData, Compressible, CompressionProof, Key}, + state::{Asset, Collection, Compressible, CompressionProof, Key}, utils::{close_program_account, fetch_core_data, load_key, verify_proof}, }; @@ -105,10 +105,10 @@ pub(crate) fn burn_collection<'a>( } let (collection, _, plugin_registry) = - fetch_core_data::(ctx.accounts.collection)?; + fetch_core_data::(ctx.accounts.collection)?; let mut approved = false; - match CollectionData::check_burn() { + match Collection::check_burn() { CheckResult::CanApprove | CheckResult::CanReject => { match collection.validate_burn(&ctx.accounts)? { ValidationResult::Approved => { diff --git a/programs/mpl-core/src/processor/create_collection.rs b/programs/mpl-core/src/processor/create_collection.rs index 170cb55d..e5140f1b 100644 --- a/programs/mpl-core/src/processor/create_collection.rs +++ b/programs/mpl-core/src/processor/create_collection.rs @@ -9,7 +9,7 @@ use crate::{ error::MplCoreError, instruction::accounts::CreateCollectionAccounts, plugins::{create_meta_idempotent, initialize_plugin, Plugin}, - state::{CollectionData, Key}, + state::{Collection, Key}, }; #[repr(C)] @@ -36,7 +36,7 @@ pub(crate) fn create_collection<'a>( return Err(MplCoreError::InvalidSystemProgram.into()); } - let new_collection = CollectionData { + let new_collection = Collection { key: Key::Collection, update_authority: *ctx .accounts diff --git a/programs/mpl-core/src/processor/remove_plugin.rs b/programs/mpl-core/src/processor/remove_plugin.rs index 008726ec..38e973ec 100644 --- a/programs/mpl-core/src/processor/remove_plugin.rs +++ b/programs/mpl-core/src/processor/remove_plugin.rs @@ -6,7 +6,7 @@ use crate::{ error::MplCoreError, instruction::accounts::{RemoveCollectionPluginAccounts, RemovePluginAccounts}, plugins::{delete_plugin, PluginType}, - state::{Asset, Authority, CollectionData, SolanaAccount, UpdateAuthority}, + state::{Asset, Authority, Collection, SolanaAccount, UpdateAuthority}, utils::fetch_core_data, }; @@ -54,7 +54,7 @@ pub(crate) fn remove_plugin<'a>( if collection_info.key != &collection_address { return Err(MplCoreError::InvalidCollection.into()); } - let collection = CollectionData::load(collection_info, 0)?; + let collection = Collection::load(collection_info, 0)?; if ctx.accounts.authority.key == &collection.update_authority { Authority::UpdateAuthority } else { @@ -102,7 +102,7 @@ pub(crate) fn remove_collection_plugin<'a>( }; let (collection, plugin_header, plugin_registry) = - fetch_core_data::(ctx.accounts.collection)?; + fetch_core_data::(ctx.accounts.collection)?; // We don't have anything to delete if there's no plugin meta. if plugin_header.is_none() || plugin_registry.is_none() { diff --git a/programs/mpl-core/src/processor/remove_plugin_authority.rs b/programs/mpl-core/src/processor/remove_plugin_authority.rs index a251f05d..81b065cf 100644 --- a/programs/mpl-core/src/processor/remove_plugin_authority.rs +++ b/programs/mpl-core/src/processor/remove_plugin_authority.rs @@ -8,7 +8,7 @@ use crate::{ RemoveCollectionPluginAuthorityAccounts, RemovePluginAuthorityAccounts, }, plugins::{remove_authority_from_plugin, PluginHeader, PluginRegistry, PluginType}, - state::{Asset, Authority, CollectionData, SolanaAccount, UpdateAuthority}, + state::{Asset, Authority, Collection, SolanaAccount, UpdateAuthority}, utils::fetch_core_data, }; @@ -48,7 +48,7 @@ pub(crate) fn remove_plugin_authority<'a>( if collection_info.key != &collection_address { return Err(MplCoreError::InvalidCollection.into()); } - let collection = CollectionData::load(collection_info, 0)?; + let collection = Collection::load(collection_info, 0)?; if ctx.accounts.authority.key == &collection.update_authority { Authority::UpdateAuthority } else { @@ -99,7 +99,7 @@ pub(crate) fn remove_collection_plugin_authority<'a>( }; let (_, plugin_header, mut plugin_registry) = - fetch_core_data::(ctx.accounts.collection)?; + fetch_core_data::(ctx.accounts.collection)?; process_remove_plugin_authority( ctx.accounts.collection, diff --git a/programs/mpl-core/src/processor/update.rs b/programs/mpl-core/src/processor/update.rs index 86e35f51..15abb889 100644 --- a/programs/mpl-core/src/processor/update.rs +++ b/programs/mpl-core/src/processor/update.rs @@ -8,7 +8,7 @@ use crate::{ error::MplCoreError, instruction::accounts::{UpdateAccounts, UpdateCollectionAccounts}, plugins::{CheckResult, Plugin, RegistryRecord, ValidationResult}, - state::{Asset, CollectionData, DataBlob, SolanaAccount, UpdateAuthority}, + state::{Asset, Collection, DataBlob, SolanaAccount, UpdateAuthority}, utils::{fetch_core_data, resize_or_reallocate_account}, }; @@ -178,7 +178,7 @@ pub(crate) fn update_collection<'a>( }; let (mut asset, plugin_header, plugin_registry) = - fetch_core_data::(ctx.accounts.collection)?; + fetch_core_data::(ctx.accounts.collection)?; let asset_size = asset.get_size() as isize; let mut approved = false; diff --git a/programs/mpl-core/src/state/collection.rs b/programs/mpl-core/src/state/collection.rs index e5d5790b..3b5e4788 100644 --- a/programs/mpl-core/src/state/collection.rs +++ b/programs/mpl-core/src/state/collection.rs @@ -11,7 +11,7 @@ use super::{CoreAsset, DataBlob, Key, SolanaAccount, UpdateAuthority}; /// The representation of a collection of assets. #[derive(Clone, BorshSerialize, BorshDeserialize, Debug, ShankAccount)] -pub struct CollectionData { +pub struct Collection { /// The account discriminator. pub key: Key, //1 /// The update authority of the collection. @@ -26,7 +26,7 @@ pub struct CollectionData { pub current_size: u32, //4 } -impl CollectionData { +impl Collection { /// The base length of the collection account with an empty name and uri. pub const BASE_LENGTH: usize = 1 + 32 + 4 + 4 + 4 + 4; @@ -98,7 +98,7 @@ impl CollectionData { } } -impl DataBlob for CollectionData { +impl DataBlob for Collection { fn get_initial_size() -> usize { Self::BASE_LENGTH } @@ -108,13 +108,13 @@ impl DataBlob for CollectionData { } } -impl SolanaAccount for CollectionData { +impl SolanaAccount for Collection { fn key() -> Key { Key::Collection } } -impl CoreAsset for CollectionData { +impl CoreAsset for Collection { fn update_authority(&self) -> UpdateAuthority { UpdateAuthority::Collection(self.update_authority) } diff --git a/programs/mpl-core/src/state/update_authority.rs b/programs/mpl-core/src/state/update_authority.rs index 8d02a315..245069b6 100644 --- a/programs/mpl-core/src/state/update_authority.rs +++ b/programs/mpl-core/src/state/update_authority.rs @@ -10,7 +10,7 @@ use crate::{ }, plugins::{fetch_plugin, CheckResult, PluginType, UpdateDelegate, ValidationResult}, processor::CreateArgs, - state::{Authority, CollectionData, SolanaAccount}, + state::{Authority, Collection, SolanaAccount}, utils::assert_collection_authority, }; @@ -57,7 +57,7 @@ impl UpdateAuthority { if collection_info.key != collection_address { return Err(MplCoreError::InvalidCollection.into()); } - let collection = CollectionData::load(collection_info, 0)?; + let collection = Collection::load(collection_info, 0)?; solana_program::msg!("Collection: {:?}", collection); let authority = match ctx.authority { @@ -68,7 +68,7 @@ impl UpdateAuthority { None => ctx.payer, }; - let maybe_update_delegate = fetch_plugin::( + let maybe_update_delegate = fetch_plugin::( collection_info, PluginType::UpdateDelegate, ); diff --git a/programs/mpl-core/src/utils.rs b/programs/mpl-core/src/utils.rs index a1a551f7..393a5350 100644 --- a/programs/mpl-core/src/utils.rs +++ b/programs/mpl-core/src/utils.rs @@ -8,7 +8,7 @@ use crate::{ error::MplCoreError, plugins::{PluginHeader, PluginRegistry}, state::{ - Asset, Authority, CollectionData, Compressible, CompressionProof, CoreAsset, DataBlob, + Asset, Authority, Collection, Compressible, CompressionProof, CoreAsset, DataBlob, HashablePluginSchema, HashedAsset, HashedAssetSchema, Key, SolanaAccount, }, }; @@ -60,7 +60,7 @@ pub fn assert_authority( /// Assert that the account info address is in the authorities array. pub fn assert_collection_authority( - asset: &CollectionData, + asset: &Collection, authority: &AccountInfo, authorities: &[Authority], ) -> ProgramResult {