diff --git a/clients/js/test/_setup.ts b/clients/js/test/_setup.ts index d53ab9f..90aa739 100644 --- a/clients/js/test/_setup.ts +++ b/clients/js/test/_setup.ts @@ -11,7 +11,6 @@ import { Asset, fetchAsset, createCollection as baseCreateCollection, - AssetWithPlugins } from '@metaplex-foundation/mpl-core' import { createAssociatedToken, @@ -373,4 +372,4 @@ export const yesterday = (): DateTime => now() - 3600n * 24n; export const tomorrow = (): DateTime => now() + 3600n * 24n; // TODO move to mpl-core -export const isFrozen = (asset: AssetWithPlugins): boolean => asset.freeze?.frozen || false; +export const isFrozen = (asset: Asset): boolean => asset.freeze?.frozen || false; diff --git a/clients/js/test/defaultGuards/freezeSolPayment.test.ts b/clients/js/test/defaultGuards/freezeSolPayment.test.ts index 74af9c7..75617af 100644 --- a/clients/js/test/defaultGuards/freezeSolPayment.test.ts +++ b/clients/js/test/defaultGuards/freezeSolPayment.test.ts @@ -19,7 +19,7 @@ import { } from '@metaplex-foundation/umi'; import { generateSignerWithSol } from '@metaplex-foundation/umi-bundle-tests'; import test, { Assertions } from 'ava'; -import { AssetWithPlugins, fetchAssetWithPlugins } from '@metaplex-foundation/mpl-core'; +import { Asset, fetchAsset } from '@metaplex-foundation/mpl-core'; import { fetchFreezeEscrow, findCandyGuardPda, @@ -89,7 +89,7 @@ test('it transfers SOL to an escrow account and freezes the NFT', async (t) => { await assertSuccessfulMint(t, umi, { mint, owner: umi.identity }); // And the NFT is frozen. - const asset = await fetchAssetWithPlugins(umi, mint.publicKey); + const asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true, 'NFT is frozen'); // And cannot be thawed since not all NFTs have been minted. @@ -183,14 +183,14 @@ test('it can thaw an NFT once all NFTs are minted', async (t) => { // And given we minted the only frozen NFT from that candy machine. const mint = await mintNft(umi, candyMachine, destination, collection); - let asset = await fetchAssetWithPlugins(umi, mint.publicKey); + let asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true, 'NFT is frozen'); // When we thaw the NFT. await thawNft(umi, candyMachine, destination, mint.publicKey, collection); // Then the NFT is thawed. - asset = await fetchAssetWithPlugins(umi, mint.publicKey); + asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), false, 'NFT is thawed'); }); @@ -379,8 +379,8 @@ test('it can have multiple freeze escrow and reuse the same ones', async (t) => // Then all NFTs except for group D have been frozen. const [tokenA, tokenB, tokenC, tokenD] = await Promise.all( [mintA, mintB, mintC, mintD].map( - ({ publicKey: mint }): Promise => - fetchAssetWithPlugins(umi, mint) + ({ publicKey: mint }): Promise => + fetchAsset(umi, mint) ) ); @@ -624,7 +624,7 @@ test('it transfers SOL to an escrow account and locks the Programmable NFT', asy await assertSuccessfulMint(t, umi, { mint, owner: umi.identity }); // And the pNFT is frozen. - const asset = await fetchAssetWithPlugins(umi, mint.publicKey); + const asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true); // And cannot be thawed since not all NFTs have been minted. @@ -696,7 +696,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { ) .sendAndConfirm(umi); - let asset = await fetchAssetWithPlugins(umi, mint.publicKey); + let asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true, 'asset is frozen'); // When we thaw the locked asset. @@ -716,7 +716,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { .sendAndConfirm(umi); // Then the asset is unlocked. - asset = await fetchAssetWithPlugins(umi, mint.publicKey); + asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), false, 'asset is frozen'); // And the freeze escrow ATA account is closed. diff --git a/clients/js/test/defaultGuards/freezeTokenPayment.test.ts b/clients/js/test/defaultGuards/freezeTokenPayment.test.ts index d7113df..f91d71d 100644 --- a/clients/js/test/defaultGuards/freezeTokenPayment.test.ts +++ b/clients/js/test/defaultGuards/freezeTokenPayment.test.ts @@ -18,7 +18,7 @@ import { Umi, } from '@metaplex-foundation/umi'; import test, { Assertions } from 'ava'; -import { AssetWithPlugins, fetchAssetWithPlugins } from '@metaplex-foundation/mpl-core'; +import { Asset, fetchAsset } from '@metaplex-foundation/mpl-core'; import { addConfigLines, fetchFreezeEscrow, @@ -106,7 +106,7 @@ test('it transfers tokens to an escrow account and freezes the NFT', async (t) = // Then minting was successful. await assertSuccessfulMint(t, umi, { mint, owner: umi.identity }); - const asset = await fetchAssetWithPlugins(umi, mint.publicKey); + const asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true); // And cannot be thawed since not all NFTs have been minted. @@ -227,14 +227,14 @@ test('it can thaw an NFT once all NFTs are minted', async (t) => { destinationAta, collection ); - let asset = await fetchAssetWithPlugins(umi, mint.publicKey); + let asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true); // When we thaw the NFT. await thawNft(umi, candyMachine, tokenMint, destinationAta, mint.publicKey, collection); // Then the NFT is thawed. - asset = await fetchAssetWithPlugins(umi, mint.publicKey); + asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), false); }); @@ -493,8 +493,8 @@ test('it can have multiple freeze escrow and reuse the same ones', async (t) => // Then all NFTs except for group D have been frozen. const [tokenA, tokenB, tokenC, tokenD] = await Promise.all( [nftA, nftB, nftC, nftD].map( - ({ publicKey: mint }): Promise => - fetchAssetWithPlugins(umi, mint) + ({ publicKey: mint }): Promise => + fetchAsset(umi, mint) ) ); @@ -791,7 +791,7 @@ test('it transfers tokens to an escrow account and locks the Programmable NFT', // Then minting was successful. await assertSuccessfulMint(t, umi, { mint, owner: umi.identity }); - const asset = await fetchAssetWithPlugins(umi, mint.publicKey); + const asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true); // And cannot be thawed since not all NFTs have been minted. @@ -874,7 +874,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { ) .sendAndConfirm(umi); - let asset = await fetchAssetWithPlugins(umi, mint.publicKey); + let asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), true); // When we thaw the locked PNFT. @@ -894,7 +894,7 @@ test('it can thaw a Programmable NFT once all NFTs are minted', async (t) => { ) .sendAndConfirm(umi); - asset = await fetchAssetWithPlugins(umi, mint.publicKey); + asset = await fetchAsset(umi, mint.publicKey); t.is(isFrozen(asset), false); // And the freeze escrow ATA account is closed. diff --git a/programs/candy-guard/program/src/guards/freeze_sol_payment.rs b/programs/candy-guard/program/src/guards/freeze_sol_payment.rs index a82ce74..183dc83 100644 --- a/programs/candy-guard/program/src/guards/freeze_sol_payment.rs +++ b/programs/candy-guard/program/src/guards/freeze_sol_payment.rs @@ -3,7 +3,7 @@ use super::*; use anchor_lang::AccountsClose; use mpl_candy_machine_core_asset::CandyMachine; use mpl_core::{ - accounts::Asset, + accounts::BaseAsset, instructions::{ ApprovePluginAuthorityCpiBuilder, AddPluginCpiBuilder, RevokePluginAuthorityCpiBuilder, UpdatePluginCpiBuilder, @@ -510,7 +510,7 @@ pub fn thaw_nft<'info>( &[bump], ]; - let maybe_freeze_plugin = mpl_core::fetch_plugin::(&asset, PluginType::Freeze); + let maybe_freeze_plugin = mpl_core::fetch_plugin::(&asset, PluginType::Freeze); let is_frozen = match maybe_freeze_plugin { Ok((_, freeze_plugin, _)) => freeze_plugin.frozen, diff --git a/programs/candy-machine-core/program/src/instructions/mint_asset.rs b/programs/candy-machine-core/program/src/instructions/mint_asset.rs index 5798aad..63a499d 100644 --- a/programs/candy-machine-core/program/src/instructions/mint_asset.rs +++ b/programs/candy-machine-core/program/src/instructions/mint_asset.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; use arrayref::array_ref; -use mpl_core::{self, accounts::Collection, fetch_plugin, instructions::CreateCpiBuilder, types::{PluginType, UpdateDelegate}}; +use mpl_core::{self, accounts::BaseCollection, fetch_plugin, instructions::CreateCpiBuilder, types::{PluginType, UpdateDelegate}}; use solana_program::sysvar; use crate::{ @@ -71,7 +71,7 @@ pub(crate) fn process_mint_asset( return err!(CandyError::IncorrectOwner); } - let (auth, _, _) = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate)?; + let (auth, _, _) = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate)?; assert_plugin_pubkey_authority(&auth, &accounts.authority_pda.key())?; diff --git a/programs/candy-machine-core/program/src/utils.rs b/programs/candy-machine-core/program/src/utils.rs index d26d97a..92ebaf4 100644 --- a/programs/candy-machine-core/program/src/utils.rs +++ b/programs/candy-machine-core/program/src/utils.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; use arrayref::array_ref; -use mpl_core::{accounts::Collection, fetch_plugin, instructions::{ApproveCollectionPluginAuthorityCpiBuilder, AddCollectionPluginCpiBuilder, RevokeCollectionPluginAuthorityCpiBuilder }, types::{Authority, Plugin, PluginType, UpdateDelegate}}; +use mpl_core::{accounts::BaseCollection, fetch_plugin, instructions::{ApproveCollectionPluginAuthorityCpiBuilder, AddCollectionPluginCpiBuilder, RevokeCollectionPluginAuthorityCpiBuilder }, types::{Authority, Plugin, PluginType, UpdateDelegate}}; use mpl_token_metadata::{ accounts::Metadata, instructions::{ @@ -289,7 +289,7 @@ pub fn assert_plugin_pubkey_authority( pub fn approve_asset_collection_delegate(accounts: ApproveAssetDelegateHelperAccounts) -> Result<()> { // add UpdateDelegate plugin if it does not exist on the Collection - let maybe_update_plugin = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate); + let maybe_update_plugin = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate); if maybe_update_plugin.is_err() { AddCollectionPluginCpiBuilder::new(&accounts.mpl_core_program) .collection(&accounts.collection) @@ -301,7 +301,7 @@ pub fn approve_asset_collection_delegate(accounts: ApproveAssetDelegateHelperAcc } // add CM authority to collection if it doesn't exist - let (auth, _, _) = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate)?; + let (auth, _, _) = fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate)?; let auth_to_add = Authority::Pubkey { address: accounts.authority_pda.key() }; @@ -327,7 +327,7 @@ pub fn revoke_asset_collection_delegate( candy_machine: Pubkey, signer_bump: u8, ) -> Result<()> { - let maybe_update_delegate_plugin = mpl_core::fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate); + let maybe_update_delegate_plugin = mpl_core::fetch_plugin::(&accounts.collection, PluginType::UpdateDelegate); let has_auth = match maybe_update_delegate_plugin { Ok((auth, _, _)) => auth == Authority::Pubkey {