diff --git a/programs/mpl-core/src/instruction.rs b/programs/mpl-core/src/instruction.rs index ff25b42e..5f09a9f3 100644 --- a/programs/mpl-core/src/instruction.rs +++ b/programs/mpl-core/src/instruction.rs @@ -164,21 +164,19 @@ pub(crate) enum MplAssetInstruction { #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] UpdateCollection(UpdateCollectionArgs), - /// Create a new mpl-core. - /// This function creates the initial mpl-core + /// Compress an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, name="collection", desc = "The collection to which the asset belongs")] - #[account(2, signer, name="owner", desc = "The owner or delegate of the asset")] + #[account(2, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(3, optional, writable, signer, name="payer", desc = "The account receiving the storage fees")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] Compress(CompressArgs), - /// Create a new mpl-core. - /// This function creates the initial mpl-core + /// Decompress an mpl-core. #[account(0, writable, name="asset", desc = "The address of the asset")] #[account(1, optional, name="collection", desc = "The collection to which the asset belongs")] - #[account(2, signer, name="owner", desc = "The owner or delegate of the asset")] + #[account(2, signer, name="authority", desc = "The owner or delegate of the asset")] #[account(3, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] #[account(4, name="system_program", desc = "The system program")] #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] diff --git a/programs/mpl-core/src/plugins/burn.rs b/programs/mpl-core/src/plugins/burn.rs index f7ff798b..0f6d7078 100644 --- a/programs/mpl-core/src/plugins/burn.rs +++ b/programs/mpl-core/src/plugins/burn.rs @@ -1,10 +1,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, program_error::ProgramError}; -use crate::{ - processor::{CompressArgs, CreateArgs, DecompressArgs}, - state::{Authority, DataBlob}, -}; +use crate::state::{Authority, DataBlob}; use super::{PluginValidation, ValidationResult}; @@ -41,7 +38,6 @@ impl PluginValidation for Burn { fn validate_create( &self, _authority_info: &AccountInfo, - _args: &CreateArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -83,7 +79,6 @@ impl PluginValidation for Burn { fn validate_compress( &self, _authority_info: &AccountInfo, - _args: &CompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -92,7 +87,6 @@ impl PluginValidation for Burn { fn validate_decompress( &self, _authority_info: &AccountInfo, - _args: &DecompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/plugins/freeze.rs b/programs/mpl-core/src/plugins/freeze.rs index 25c553b0..e63338a5 100644 --- a/programs/mpl-core/src/plugins/freeze.rs +++ b/programs/mpl-core/src/plugins/freeze.rs @@ -1,10 +1,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, program_error::ProgramError}; -use crate::{ - processor::{ApprovePluginAuthorityArgs, CompressArgs, CreateArgs, DecompressArgs}, - state::{Asset, Authority, DataBlob}, -}; +use crate::state::{Asset, Authority, DataBlob}; use super::{PluginValidation, ValidationResult}; @@ -44,7 +41,6 @@ impl PluginValidation for Freeze { fn validate_create( &self, _authority_info: &AccountInfo, - _args: &CreateArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -109,7 +105,6 @@ impl PluginValidation for Freeze { fn validate_compress( &self, _authority_info: &AccountInfo, - _args: &CompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -118,7 +113,6 @@ impl PluginValidation for Freeze { fn validate_decompress( &self, _authority_info: &AccountInfo, - _args: &DecompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -127,7 +121,6 @@ impl PluginValidation for Freeze { fn validate_add_authority( &self, _authority_info: &AccountInfo, - _args: &ApprovePluginAuthorityArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/plugins/lifecycle.rs b/programs/mpl-core/src/plugins/lifecycle.rs index 0ccb934e..ce3fef81 100644 --- a/programs/mpl-core/src/plugins/lifecycle.rs +++ b/programs/mpl-core/src/plugins/lifecycle.rs @@ -4,10 +4,6 @@ use solana_program::{account_info::AccountInfo, program_error::ProgramError}; use crate::{ error::MplCoreError, - processor::{ - ApprovePluginAuthorityArgs, CompressArgs, CreateArgs, DecompressArgs, - RevokePluginAuthorityArgs, - }, state::{Asset, Authority, Key}, }; @@ -84,17 +80,17 @@ impl Plugin { pub(crate) fn validate_create( plugin: &Plugin, authority: &AccountInfo, - args: &CreateArgs, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { Plugin::Reserved => Err(MplCoreError::InvalidPlugin.into()), - Plugin::Royalties(royalties) => royalties.validate_create(authority, args, authorities), - Plugin::Freeze(freeze) => freeze.validate_create(authority, args, authorities), - Plugin::Burn(burn) => burn.validate_create(authority, args, authorities), - Plugin::Transfer(transfer) => transfer.validate_create(authority, args, authorities), + Plugin::Royalties(royalties) => royalties.validate_create(authority, authorities), + Plugin::Freeze(freeze) => freeze.validate_create(authority, authorities), + Plugin::Burn(burn) => burn.validate_create(authority, authorities), + Plugin::Transfer(transfer) => transfer.validate_create(authority, authorities), Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_create(authority, args, authorities) + update_delegate.validate_create(authority, authorities) } } } @@ -124,6 +120,7 @@ impl Plugin { plugin: &Plugin, asset: &Asset, authority: &AccountInfo, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { @@ -189,19 +186,17 @@ impl Plugin { pub(crate) fn validate_compress( plugin: &Plugin, authority: &AccountInfo, - args: &CompressArgs, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { Plugin::Reserved => Err(MplCoreError::InvalidPlugin.into()), - Plugin::Royalties(royalties) => { - royalties.validate_compress(authority, args, authorities) - } - Plugin::Freeze(freeze) => freeze.validate_compress(authority, args, authorities), - Plugin::Burn(burn) => burn.validate_compress(authority, args, authorities), - Plugin::Transfer(transfer) => transfer.validate_compress(authority, args, authorities), + Plugin::Royalties(royalties) => royalties.validate_compress(authority, authorities), + Plugin::Freeze(freeze) => freeze.validate_compress(authority, authorities), + Plugin::Burn(burn) => burn.validate_compress(authority, authorities), + Plugin::Transfer(transfer) => transfer.validate_compress(authority, authorities), Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_compress(authority, args, authorities) + update_delegate.validate_compress(authority, authorities) } } } @@ -210,21 +205,17 @@ impl Plugin { pub(crate) fn validate_decompress( plugin: &Plugin, authority: &AccountInfo, - args: &DecompressArgs, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { Plugin::Reserved => Err(MplCoreError::InvalidPlugin.into()), - Plugin::Royalties(royalties) => { - royalties.validate_decompress(authority, args, authorities) - } - Plugin::Freeze(freeze) => freeze.validate_decompress(authority, args, authorities), - Plugin::Burn(burn) => burn.validate_decompress(authority, args, authorities), - Plugin::Transfer(transfer) => { - transfer.validate_decompress(authority, args, authorities) - } + Plugin::Royalties(royalties) => royalties.validate_decompress(authority, authorities), + Plugin::Freeze(freeze) => freeze.validate_decompress(authority, authorities), + Plugin::Burn(burn) => burn.validate_decompress(authority, authorities), + Plugin::Transfer(transfer) => transfer.validate_decompress(authority, authorities), Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_decompress(authority, args, authorities) + update_delegate.validate_decompress(authority, authorities) } } } @@ -234,21 +225,19 @@ impl Plugin { pub(crate) fn validate_add_plugin_authority( plugin: &Plugin, authority: &AccountInfo, - args: &ApprovePluginAuthorityArgs, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { Plugin::Reserved => Err(MplCoreError::InvalidPlugin.into()), Plugin::Royalties(royalties) => { - royalties.validate_add_authority(authority, args, authorities) - } - Plugin::Freeze(freeze) => freeze.validate_add_authority(authority, args, authorities), - Plugin::Burn(burn) => burn.validate_add_authority(authority, args, authorities), - Plugin::Transfer(transfer) => { - transfer.validate_add_authority(authority, args, authorities) + royalties.validate_add_authority(authority, authorities) } + Plugin::Freeze(freeze) => freeze.validate_add_authority(authority, authorities), + Plugin::Burn(burn) => burn.validate_add_authority(authority, authorities), + Plugin::Transfer(transfer) => transfer.validate_add_authority(authority, authorities), Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_add_authority(authority, args, authorities) + update_delegate.validate_add_authority(authority, authorities) } } } @@ -258,23 +247,21 @@ impl Plugin { pub(crate) fn validate_remove_plugin_authority( plugin: &Plugin, authority: &AccountInfo, - args: &RevokePluginAuthorityArgs, + _unused: Option<&AccountInfo>, authorities: &Authority, ) -> Result { match plugin { Plugin::Reserved => Err(MplCoreError::InvalidPlugin.into()), Plugin::Royalties(royalties) => { - royalties.validate_remove_authority(authority, args, authorities) - } - Plugin::Freeze(freeze) => { - freeze.validate_remove_authority(authority, args, authorities) + royalties.validate_remove_authority(authority, authorities) } - Plugin::Burn(burn) => burn.validate_remove_authority(authority, args, authorities), + Plugin::Freeze(freeze) => freeze.validate_remove_authority(authority, authorities), + Plugin::Burn(burn) => burn.validate_remove_authority(authority, authorities), Plugin::Transfer(transfer) => { - transfer.validate_remove_authority(authority, args, authorities) + transfer.validate_remove_authority(authority, authorities) } Plugin::UpdateDelegate(update_delegate) => { - update_delegate.validate_remove_authority(authority, args, authorities) + update_delegate.validate_remove_authority(authority, authorities) } } } @@ -298,7 +285,6 @@ pub(crate) trait PluginValidation { fn validate_create( &self, authority: &AccountInfo, - args: &CreateArgs, authorities: &Authority, ) -> Result; @@ -349,7 +335,6 @@ pub(crate) trait PluginValidation { fn validate_compress( &self, authority: &AccountInfo, - args: &CompressArgs, authorities: &Authority, ) -> Result; @@ -357,7 +342,6 @@ pub(crate) trait PluginValidation { fn validate_decompress( &self, authority: &AccountInfo, - args: &DecompressArgs, authorities: &Authority, ) -> Result; @@ -365,7 +349,6 @@ pub(crate) trait PluginValidation { fn validate_add_authority( &self, _authority: &AccountInfo, - _args: &ApprovePluginAuthorityArgs, _authorities: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -375,7 +358,6 @@ pub(crate) trait PluginValidation { fn validate_remove_authority( &self, _authority: &AccountInfo, - _args: &RevokePluginAuthorityArgs, _authorities: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/plugins/royalties.rs b/programs/mpl-core/src/plugins/royalties.rs index 3dafa3c2..d1135687 100644 --- a/programs/mpl-core/src/plugins/royalties.rs +++ b/programs/mpl-core/src/plugins/royalties.rs @@ -1,10 +1,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; -use crate::{ - processor::{CompressArgs, CreateArgs, DecompressArgs}, - state::Authority, -}; +use crate::state::Authority; use super::{PluginValidation, ValidationResult}; @@ -41,7 +38,6 @@ impl PluginValidation for Royalties { fn validate_create( &self, _authority_info: &AccountInfo, - _args: &CreateArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -93,7 +89,6 @@ impl PluginValidation for Royalties { fn validate_compress( &self, _authority_info: &AccountInfo, - _args: &CompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -102,7 +97,6 @@ impl PluginValidation for Royalties { fn validate_decompress( &self, _authority_info: &AccountInfo, - _args: &DecompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/plugins/transfer.rs b/programs/mpl-core/src/plugins/transfer.rs index ceab7332..f5aa42f0 100644 --- a/programs/mpl-core/src/plugins/transfer.rs +++ b/programs/mpl-core/src/plugins/transfer.rs @@ -1,10 +1,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, program_error::ProgramError}; -use crate::{ - processor::{CompressArgs, CreateArgs, DecompressArgs}, - state::{Authority, DataBlob}, -}; +use crate::state::{Authority, DataBlob}; use super::{PluginValidation, ValidationResult}; @@ -41,7 +38,6 @@ impl PluginValidation for Transfer { fn validate_create( &self, _authority_info: &AccountInfo, - _args: &CreateArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -91,7 +87,6 @@ impl PluginValidation for Transfer { fn validate_compress( &self, _authority_info: &AccountInfo, - _args: &CompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -100,7 +95,6 @@ impl PluginValidation for Transfer { fn validate_decompress( &self, _authority_info: &AccountInfo, - _args: &DecompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/plugins/update_delegate.rs b/programs/mpl-core/src/plugins/update_delegate.rs index 6c4ae82b..4402f433 100644 --- a/programs/mpl-core/src/plugins/update_delegate.rs +++ b/programs/mpl-core/src/plugins/update_delegate.rs @@ -1,10 +1,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{account_info::AccountInfo, program_error::ProgramError}; -use crate::{ - processor::{CompressArgs, CreateArgs, DecompressArgs}, - state::{Authority, DataBlob}, -}; +use crate::state::{Authority, DataBlob}; use super::{PluginValidation, ValidationResult}; @@ -41,7 +38,6 @@ impl PluginValidation for UpdateDelegate { fn validate_create( &self, _authority_info: &AccountInfo, - _args: &CreateArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -75,7 +71,6 @@ impl PluginValidation for UpdateDelegate { fn validate_compress( &self, _authority_info: &AccountInfo, - _args: &CompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) @@ -84,7 +79,6 @@ impl PluginValidation for UpdateDelegate { fn validate_decompress( &self, _authority_info: &AccountInfo, - _args: &DecompressArgs, _authority: &Authority, ) -> Result { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/processor/compress.rs b/programs/mpl-core/src/processor/compress.rs index 2c94fb0f..e17165b4 100644 --- a/programs/mpl-core/src/processor/compress.rs +++ b/programs/mpl-core/src/processor/compress.rs @@ -7,72 +7,46 @@ use solana_program::{ use crate::{ error::MplCoreError, instruction::accounts::CompressAccounts, - plugins::{CheckResult, Plugin, PluginType, RegistryRecord, ValidationResult}, - state::{Asset, Compressible, HashablePluginSchema, HashedAsset, HashedAssetSchema, Key}, - utils::{fetch_core_data, load_key, resize_or_reallocate_account}, + plugins::{Plugin, PluginType, RegistryRecord}, + state::{ + Asset, Collection, Compressible, HashablePluginSchema, HashedAsset, HashedAssetSchema, Key, + }, + utils::{fetch_core_data, load_key, resize_or_reallocate_account, validate_asset_permissions}, }; #[repr(C)] #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] pub struct CompressArgs {} -pub(crate) fn compress<'a>(accounts: &'a [AccountInfo<'a>], args: CompressArgs) -> ProgramResult { +pub(crate) fn compress<'a>(accounts: &'a [AccountInfo<'a>], _args: CompressArgs) -> ProgramResult { // Accounts. let ctx = CompressAccounts::context(accounts)?; // Guards. - assert_signer(ctx.accounts.owner)?; + assert_signer(ctx.accounts.authority)?; let payer = if let Some(payer) = ctx.accounts.payer { assert_signer(payer)?; payer } else { - ctx.accounts.owner + ctx.accounts.authority }; match load_key(ctx.accounts.asset, 0)? { Key::Asset => { let (asset, _, plugin_registry) = fetch_core_data::(ctx.accounts.asset)?; - let mut approved = false; - match Asset::check_compress() { - CheckResult::CanApprove | CheckResult::CanReject => { - match asset.validate_compress(&ctx.accounts)? { - ValidationResult::Approved => { - approved = true; - } - ValidationResult::Rejected => { - return Err(MplCoreError::InvalidAuthority.into()) - } - ValidationResult::Pass => (), - } - } - CheckResult::None => (), - }; - - if let Some(plugin_registry) = &plugin_registry { - for record in &plugin_registry.registry { - if matches!( - PluginType::check_compress(&record.plugin_type), - CheckResult::CanApprove | CheckResult::CanReject - ) { - let result = Plugin::validate_compress( - &Plugin::load(ctx.accounts.asset, record.offset)?, - ctx.accounts.owner, - &args, - &record.authority, - )?; - if result == ValidationResult::Rejected { - return Err(MplCoreError::InvalidAuthority.into()); - } else if result == ValidationResult::Approved { - approved = true; - } - } - } - }; - - if !approved { - return Err(MplCoreError::InvalidAuthority.into()); - } + let _ = validate_asset_permissions( + ctx.accounts.authority, + ctx.accounts.asset, + ctx.accounts.collection, + None, + Asset::check_compress, + Collection::check_compress, + PluginType::check_compress, + Asset::validate_compress, + Collection::validate_compress, + Plugin::validate_compress, + )?; let mut plugin_hashes = vec![]; if let Some(plugin_registry) = plugin_registry { diff --git a/programs/mpl-core/src/processor/create.rs b/programs/mpl-core/src/processor/create.rs index 7ffa68cc..bfb51685 100644 --- a/programs/mpl-core/src/processor/create.rs +++ b/programs/mpl-core/src/processor/create.rs @@ -144,7 +144,7 @@ pub(crate) fn create<'a>(accounts: &'a [AccountInfo<'a>], args: CreateArgs) -> P ctx.accounts .owner .unwrap_or(ctx.accounts.update_authority.unwrap_or(ctx.accounts.payer)), - &args, + None, &record.authority, )?; if result == ValidationResult::Rejected { diff --git a/programs/mpl-core/src/processor/decompress.rs b/programs/mpl-core/src/processor/decompress.rs index 9c5e6844..f27fc3ef 100644 --- a/programs/mpl-core/src/processor/decompress.rs +++ b/programs/mpl-core/src/processor/decompress.rs @@ -8,12 +8,9 @@ use solana_program::{ use crate::{ error::MplCoreError, instruction::accounts::DecompressAccounts, - plugins::{ - create_meta_idempotent, initialize_plugin, CheckResult, Plugin, PluginType, - ValidationResult, - }, - state::{Asset, CompressionProof, Key}, - utils::{fetch_core_data, load_key, resize_or_reallocate_account, verify_proof}, + plugins::{create_meta_idempotent, initialize_plugin, Plugin, PluginType}, + state::{Asset, Collection, CompressionProof, Key}, + utils::{load_key, resize_or_reallocate_account, validate_asset_permissions, verify_proof}, }; #[repr(C)] @@ -30,12 +27,12 @@ pub(crate) fn decompress<'a>( let ctx = DecompressAccounts::context(accounts)?; // Guards. - assert_signer(ctx.accounts.owner)?; + assert_signer(ctx.accounts.authority)?; let payer = if let Some(payer) = ctx.accounts.payer { assert_signer(payer)?; payer } else { - ctx.accounts.owner + ctx.accounts.authority }; if *ctx.accounts.system_program.key != system_program::id() { @@ -44,6 +41,7 @@ pub(crate) fn decompress<'a>( match load_key(ctx.accounts.asset, 0)? { Key::HashedAsset => { + // Verify the proof and rebuild Asset struct in account. let (asset, plugins) = verify_proof(ctx.accounts.asset, &args.compression_proof)?; let serialized_data = asset.try_to_vec()?; @@ -60,6 +58,7 @@ pub(crate) fn decompress<'a>( serialized_data.len(), ); + // Add the plugins. if !plugins.is_empty() { create_meta_idempotent(ctx.accounts.asset, payer, ctx.accounts.system_program)?; @@ -74,48 +73,21 @@ pub(crate) fn decompress<'a>( } } - let (asset, _, plugin_registry) = fetch_core_data::(ctx.accounts.asset)?; + // Validate permissions. + //let (asset, _, plugin_registry) = fetch_core_data::(ctx.accounts.asset)?; - let mut approved = false; - match Asset::check_decompress() { - CheckResult::CanApprove | CheckResult::CanReject => { - match asset.validate_decompress(&ctx.accounts)? { - ValidationResult::Approved => { - approved = true; - } - ValidationResult::Rejected => { - return Err(MplCoreError::InvalidAuthority.into()) - } - ValidationResult::Pass => (), - } - } - CheckResult::None => (), - }; - - if let Some(plugin_registry) = plugin_registry { - for record in plugin_registry.registry { - if matches!( - PluginType::check_decompress(&record.plugin_type), - CheckResult::CanApprove | CheckResult::CanReject - ) { - let result = Plugin::validate_decompress( - &Plugin::load(ctx.accounts.asset, record.offset)?, - ctx.accounts.owner, - &args, - &record.authority, - )?; - if result == ValidationResult::Rejected { - return Err(MplCoreError::InvalidAuthority.into()); - } else if result == ValidationResult::Approved { - approved = true; - } - } - } - }; - - if !approved { - return Err(MplCoreError::InvalidAuthority.into()); - } + let _ = validate_asset_permissions( + ctx.accounts.authority, + ctx.accounts.asset, + ctx.accounts.collection, + None, + Asset::check_decompress, + Collection::check_decompress, + PluginType::check_decompress, + Asset::validate_decompress, + Collection::validate_decompress, + Plugin::validate_decompress, + )?; } Key::Asset => return Err(MplCoreError::AlreadyDecompressed.into()), _ => return Err(MplCoreError::IncorrectAccount.into()), diff --git a/programs/mpl-core/src/processor/update_plugin.rs b/programs/mpl-core/src/processor/update_plugin.rs index 5a52eca8..422a5a45 100644 --- a/programs/mpl-core/src/processor/update_plugin.rs +++ b/programs/mpl-core/src/processor/update_plugin.rs @@ -42,6 +42,7 @@ pub(crate) fn update_plugin<'a>( &Plugin::load(ctx.accounts.asset, registry_record.offset)?, &asset, ctx.accounts.authority, + None, ®istry_record.authority, )?; if result == ValidationResult::Rejected { @@ -90,6 +91,7 @@ pub(crate) fn update_collection_plugin<'a>( &Plugin::load(ctx.accounts.collection, registry_record.offset)?, &asset, ctx.accounts.authority, + None, ®istry_record.authority, )?; if result == ValidationResult::Rejected { diff --git a/programs/mpl-core/src/state/asset.rs b/programs/mpl-core/src/state/asset.rs index 40e7223f..54e3856f 100644 --- a/programs/mpl-core/src/state/asset.rs +++ b/programs/mpl-core/src/state/asset.rs @@ -3,7 +3,6 @@ use shank::ShankAccount; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ - instruction::accounts::{CompressAccounts, DecompressAccounts}, plugins::{CheckResult, ValidationResult}, state::{Compressible, CompressionProof, DataBlob, Key, SolanaAccount}, }; @@ -90,9 +89,9 @@ impl Asset { /// Validate the compress lifecycle event. pub fn validate_compress( &self, - ctx: &CompressAccounts, + authority: &AccountInfo, ) -> Result { - if ctx.owner.key == &self.owner { + if authority.key == &self.owner { Ok(ValidationResult::Approved) } else { Ok(ValidationResult::Pass) @@ -102,9 +101,9 @@ impl Asset { /// Validate the decompress lifecycle event. pub fn validate_decompress( &self, - ctx: &DecompressAccounts, + authority: &AccountInfo, ) -> Result { - if ctx.owner.key == &self.owner { + if authority.key == &self.owner { Ok(ValidationResult::Approved) } else { Ok(ValidationResult::Pass) diff --git a/programs/mpl-core/src/state/collection.rs b/programs/mpl-core/src/state/collection.rs index f674cba2..f29dc981 100644 --- a/programs/mpl-core/src/state/collection.rs +++ b/programs/mpl-core/src/state/collection.rs @@ -78,6 +78,14 @@ impl Collection { Ok(ValidationResult::Pass) } + /// Validate the burn lifecycle event. + pub fn validate_burn( + &self, + _authority: &AccountInfo, + ) -> Result { + Ok(ValidationResult::Pass) + } + /// Validate the update lifecycle event. pub fn validate_update( &self, @@ -90,13 +98,20 @@ impl Collection { } } - /// Validate the burn lifecycle event. - pub fn validate_burn(&self, authority: &AccountInfo) -> Result { - if authority.key == &self.update_authority { - Ok(ValidationResult::Approved) - } else { - Ok(ValidationResult::Pass) - } + /// Validate the compress lifecycle event. + pub fn validate_compress( + &self, + _authority: &AccountInfo, + ) -> Result { + Ok(ValidationResult::Pass) + } + + /// Validate the decompress lifecycle event. + pub fn validate_decompress( + &self, + _authority: &AccountInfo, + ) -> Result { + Ok(ValidationResult::Pass) } } diff --git a/programs/mpl-core/src/state/mod.rs b/programs/mpl-core/src/state/mod.rs index 1869a9a1..0955c4ad 100644 --- a/programs/mpl-core/src/state/mod.rs +++ b/programs/mpl-core/src/state/mod.rs @@ -14,7 +14,7 @@ mod collection; pub use collection::*; mod collect; -pub use collect::*; +pub(crate) use collect::*; mod update_authority; pub use update_authority::*;