From 51c620b07320e9a3a0f6c2320f4692fd2a051a51 Mon Sep 17 00:00:00 2001 From: blockiosaurus Date: Sat, 17 Feb 2024 12:24:43 -0700 Subject: [PATCH] Updating instruction accounts. --- programs/mpl-asset/src/instruction.rs | 66 +++++++++++----------- programs/mpl-asset/src/plugins/mod.rs | 1 - programs/mpl-asset/src/processor/create.rs | 8 ++- programs/mpl-asset/src/state/mod.rs | 19 +++++-- 4 files changed, 55 insertions(+), 39 deletions(-) diff --git a/programs/mpl-asset/src/instruction.rs b/programs/mpl-asset/src/instruction.rs index f01c1c57..73dc1719 100644 --- a/programs/mpl-asset/src/instruction.rs +++ b/programs/mpl-asset/src/instruction.rs @@ -9,22 +9,24 @@ pub enum MplAssetInstruction { /// Create a new mpl-asset. /// This function creates the initial mpl-asset #[account(0, writable, signer, name="asset_address", desc = "The address of the new asset")] - #[account(1, optional, name="authority", desc = "The authority of the new asset")] - #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] - #[account(3, optional, name="owner", desc = "The owner of the new asset. Defaults to the authority if not present.")] - #[account(4, name="system_program", desc = "The system program")] - #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] + #[account(2, optional, name="update_authority", desc = "The authority of the new asset")] + #[account(3, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(4, optional, name="owner", desc = "The owner of the new asset. Defaults to the authority if not present.")] + #[account(5, name="system_program", desc = "The system program")] + #[account(6, optional, name="log_wrapper", desc = "The SPL Noop Program")] Create(CreateArgs), /// Migrate an mpl-token-metadata asset to an mpl-asset. #[account(0, writable, signer, name="asset_address", desc = "The address of the new asset")] - #[account(1, optional, name="authority", desc = "The authority of the new asset")] + #[account(1, optional, signer, name="owner", desc = "The authority of the new asset")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] - #[account(3, writable, name="token", desc="Token account")] - #[account(4, name="token_owner", desc="Token account owner")] - #[account(5, name="mint", desc="Mint of token asset")] + // Dependent on how migration is handled + #[account(3, optional, writable, name="collection", desc="mpl-token-metadata collection metadata or mpl-asset collection")] + #[account(4, writable, name="token", desc="Token account")] + #[account(5, writable, name="mint", desc="Mint of token asset")] #[account(6, writable, name="metadata", desc="Metadata (pda of ['metadata', program id, mint id])")] - #[account(7, optional, name="edition", desc="Edition of token asset")] + #[account(7, optional, writable, name="edition", desc="Edition of token asset")] #[account(8, optional, writable, name="owner_token_record", desc="Owner token record account")] #[account(9, name="spl_token_program", desc="SPL Token Program")] #[account(10, name="spl_ata_program", desc="SPL Associated Token Account program")] @@ -37,49 +39,47 @@ pub enum MplAssetInstruction { /// Delegate an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] #[account(1, optional, name="collection", desc = "The collection to which the asset belongs")] - #[account(2, name="owner", desc = "The owner of the asset")] - #[account(3, name="delegate", desc = "The new simple delegate for the asset")] - #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(2, writable, signer, name="owner", desc = "The owner of the asset")] + #[account(3, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(4, name="delegate", desc = "The new simple delegate for the asset")] + #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] Delegate(DelegateArgs), /// Burn an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] - #[account(1, optional, name="collection", desc = "The collection to which the asset belongs")] + #[account(1, optional, writable, name="collection", desc = "The collection to which the asset belongs")] #[account(2, signer, name="authority", desc = "The owner or delegate of the asset")] - #[account(3, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(3, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] Burn(BurnArgs), /// Transfer an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] #[account(1, optional, name="collection", desc = "The collection to which the asset belongs")] #[account(2, signer, name="authority", desc = "The owner or delegate of the asset")] - #[account(3, name="new_owner", desc = "The new owner to which to transfer the asset")] - #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(3, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(4, name="new_owner", desc = "The new owner to which to transfer the asset")] + #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] Transfer(TransferArgs), /// Update an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] #[account(1, signer, name="authority", desc = "The update authority or update authority delegate of the asset")] - #[account(2, optional, name="new_update_authority", desc = "The new update authority of the asset")] - #[account(3, name="system_program", desc = "The system program")] - #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(2, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(3, optional, name="new_update_authority", desc = "The new update authority of the asset")] + #[account(4, name="system_program", desc = "The system program")] + #[account(5, optional, name="log_wrapper", desc = "The SPL Noop Program")] Update(UpdateArgs), - /// Set freeze authority for an mpl-asset. - #[account(0, writable, name="asset_address", desc = "The address of the asset")] - #[account(1, name="new_freeze_authority", desc = "The new freeze authority of the asset")] - #[account(2, optional, name="log_wrapper", desc = "The SPL Noop Program")] - SetFreezeAuthority(SetFreezeAuthorityArgs), - /// Freeze an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] - #[account(1, signer, name="authority", desc = "The freeze authority of the asset")] + #[account(1, signer, name="delegate", desc = "The delegate of the asset")] #[account(2, optional, name="log_wrapper", desc = "The SPL Noop Program")] Freeze(FreezeArgs), /// Thaw an mpl-asset. #[account(0, writable, name="asset_address", desc = "The address of the asset")] - #[account(1, signer, name="authority", desc = "The freeze authority of the asset")] + #[account(1, signer, name="delegate", desc = "The delegate of the asset")] #[account(2, optional, name="log_wrapper", desc = "The SPL Noop Program")] Thaw(ThawArgs), @@ -87,16 +87,18 @@ pub enum MplAssetInstruction { /// This function creates the initial mpl-asset #[account(0, writable, name="asset_address", desc = "The address of the asset")] #[account(1, signer, name="owner", desc = "The owner or delegate of the asset")] - #[account(2, name="system_program", desc = "The system program")] - #[account(3, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(2, optional, writable, signer, name="payer", desc = "The account receiving the storage fees")] + #[account(3, name="system_program", desc = "The system program")] + #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] Compress(CompressArgs), /// Create a new mpl-asset. /// This function creates the initial mpl-asset #[account(0, writable, name="asset_address", desc = "The address of the asset")] #[account(1, signer, name="owner", desc = "The owner or delegate of the asset")] - #[account(2, name="system_program", desc = "The system program")] - #[account(3, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(2, optional, writable, signer, name="payer", desc = "The account paying for the storage fees")] + #[account(3, name="system_program", desc = "The system program")] + #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] Decompress(DecompressArgs), } diff --git a/programs/mpl-asset/src/plugins/mod.rs b/programs/mpl-asset/src/plugins/mod.rs index 387a3e47..3ca36b7a 100644 --- a/programs/mpl-asset/src/plugins/mod.rs +++ b/programs/mpl-asset/src/plugins/mod.rs @@ -2,7 +2,6 @@ mod royalties; pub use royalties::*; use borsh::{BorshDeserialize, BorshSerialize}; -use solana_program::program_error::ProgramError; use std::collections::HashMap; use crate::state::Authority; diff --git a/programs/mpl-asset/src/processor/create.rs b/programs/mpl-asset/src/processor/create.rs index 2fcac1a2..d3d312e2 100644 --- a/programs/mpl-asset/src/processor/create.rs +++ b/programs/mpl-asset/src/processor/create.rs @@ -26,11 +26,15 @@ pub(crate) fn create<'a>(accounts: &'a [AccountInfo<'a>], args: CreateArgs) -> P let new_asset = Asset { key: Key::Asset, - update_authority: *ctx.accounts.authority.unwrap_or(ctx.accounts.payer).key, + update_authority: *ctx + .accounts + .update_authority + .unwrap_or(ctx.accounts.payer) + .key, owner: *ctx .accounts .owner - .unwrap_or(ctx.accounts.authority.unwrap_or(ctx.accounts.payer)) + .unwrap_or(ctx.accounts.update_authority.unwrap_or(ctx.accounts.payer)) .key, name: args.name, uri: args.uri, diff --git a/programs/mpl-asset/src/state/mod.rs b/programs/mpl-asset/src/state/mod.rs index 6919c76e..1b398b07 100644 --- a/programs/mpl-asset/src/state/mod.rs +++ b/programs/mpl-asset/src/state/mod.rs @@ -5,13 +5,9 @@ mod plugin_header; pub use plugin_header::*; use borsh::{BorshDeserialize, BorshSerialize}; -use solana_program::account_info::AccountInfo; -use solana_program::entrypoint::ProgramResult; -use solana_program::msg; use solana_program::program_error::ProgramError; use solana_program::pubkey::Pubkey; -use crate::error::MplAssetError; use crate::plugins::Plugin; #[repr(C)] @@ -27,6 +23,21 @@ pub enum Authority { Owner, Permanent { address: Pubkey }, SameAs { plugin: Plugin }, + Collection, +} + +#[repr(C)] +#[derive(Clone, BorshSerialize, BorshDeserialize, Debug, Eq, PartialEq)] +pub enum ExtraAccounts { + None, + SplHook { + extra_account_metas: Pubkey, + }, + MplHook { + mint_pda: Option, + collection_pda: Option, + owner_pda: Option, + }, } pub trait Compressible {