diff --git a/programs/mpl-asset/src/instruction.rs b/programs/mpl-asset/src/instruction.rs index ef4ece8b..355c742d 100644 --- a/programs/mpl-asset/src/instruction.rs +++ b/programs/mpl-asset/src/instruction.rs @@ -1,7 +1,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; use shank::{ShankContext, ShankInstruction}; -use crate::state::DataState; +use crate::processor::{ + BurnArgs, CompressArgs, CreateArgs, DecompressArgs, DelegateArgs, FreezeArgs, MigrateArgs, + ThawArgs, TransferArgs, UpdateArgs, +}; #[derive(BorshDeserialize, BorshSerialize, Clone, Debug, ShankContext, ShankInstruction)] #[rustfmt::skip] @@ -110,68 +113,3 @@ pub enum MplAssetInstruction { #[account(4, optional, name="log_wrapper", desc = "The SPL Noop Program")] Decompress(DecompressArgs), } - -//TODO: Implement this struct -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct CompressionProof {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct CreateArgs { - pub data_state: DataState, - pub name: String, - pub uri: String, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub enum MigrationLevel { - MigrateOnly, - MigrateAndBurn, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct MigrateArgs { - pub data_state: DataState, - pub level: MigrationLevel, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct DelegateArgs {} - -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct BurnArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct TransferArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct UpdateArgs { - pub new_name: String, - pub new_uri: String, -} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct SetFreezeAuthorityArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct FreezeArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct ThawArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct CompressArgs {} - -#[repr(C)] -#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] -pub struct DecompressArgs {} diff --git a/programs/mpl-asset/src/processor/burn.rs b/programs/mpl-asset/src/processor/burn.rs new file mode 100644 index 00000000..f3e8eca7 --- /dev/null +++ b/programs/mpl-asset/src/processor/burn.rs @@ -0,0 +1,26 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct BurnArgs {} + +pub(crate) fn burn<'a>(accounts: &'a [AccountInfo<'a>], args: BurnArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/compress.rs b/programs/mpl-asset/src/processor/compress.rs new file mode 100644 index 00000000..d424241c --- /dev/null +++ b/programs/mpl-asset/src/processor/compress.rs @@ -0,0 +1,27 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct CompressArgs {} + +pub(crate) fn compress<'a>(accounts: &'a [AccountInfo<'a>], args: CompressArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/create.rs b/programs/mpl-asset/src/processor/create.rs index d3d312e2..f5c3d5b6 100644 --- a/programs/mpl-asset/src/processor/create.rs +++ b/programs/mpl-asset/src/processor/create.rs @@ -1,4 +1,4 @@ -use borsh::BorshSerialize; +use borsh::{BorshDeserialize, BorshSerialize}; use mpl_utils::assert_signer; use solana_program::{ account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, @@ -7,10 +7,18 @@ use solana_program::{ use crate::{ error::MplAssetError, - instruction::{accounts::CreateAccounts, CreateArgs}, + instruction::accounts::CreateAccounts, state::{Asset, Compressible, DataState, HashedAsset, Key}, }; +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub(crate) struct CreateArgs { + pub data_state: DataState, + pub name: String, + pub uri: String, +} + pub(crate) fn create<'a>(accounts: &'a [AccountInfo<'a>], args: CreateArgs) -> ProgramResult { // Accounts. let ctx = CreateAccounts::context(accounts)?; diff --git a/programs/mpl-asset/src/processor/decompress.rs b/programs/mpl-asset/src/processor/decompress.rs new file mode 100644 index 00000000..92f90ad9 --- /dev/null +++ b/programs/mpl-asset/src/processor/decompress.rs @@ -0,0 +1,30 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct DecompressArgs {} + +pub(crate) fn decompress<'a>( + accounts: &'a [AccountInfo<'a>], + args: DecompressArgs, +) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/delegate.rs b/programs/mpl-asset/src/processor/delegate.rs new file mode 100644 index 00000000..071e7884 --- /dev/null +++ b/programs/mpl-asset/src/processor/delegate.rs @@ -0,0 +1,27 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct DelegateArgs {} + +pub(crate) fn delegate<'a>(accounts: &'a [AccountInfo<'a>], args: DelegateArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/freeze.rs b/programs/mpl-asset/src/processor/freeze.rs new file mode 100644 index 00000000..b8f41a27 --- /dev/null +++ b/programs/mpl-asset/src/processor/freeze.rs @@ -0,0 +1,27 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct FreezeArgs {} + +pub(crate) fn freeze<'a>(accounts: &'a [AccountInfo<'a>], args: FreezeArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/migrate.rs b/programs/mpl-asset/src/processor/migrate.rs new file mode 100644 index 00000000..8d09e8be --- /dev/null +++ b/programs/mpl-asset/src/processor/migrate.rs @@ -0,0 +1,30 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct MigrateArgs { + pub data_state: DataState, + pub level: MigrationLevel, +} + +pub(crate) fn migrate<'a>(accounts: &'a [AccountInfo<'a>], args: MigrateArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/mod.rs b/programs/mpl-asset/src/processor/mod.rs index 9abce78a..9ff2feea 100644 --- a/programs/mpl-asset/src/processor/mod.rs +++ b/programs/mpl-asset/src/processor/mod.rs @@ -1,14 +1,44 @@ -mod create; - -use create::*; - -use borsh::BorshDeserialize; +use crate::instruction::MplAssetInstruction; +use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{ account_info::AccountInfo, entrypoint::ProgramResult, msg, program_error::ProgramError, pubkey::Pubkey, }; -use crate::instruction::MplAssetInstruction; +mod create; +pub(crate) use create::*; + +mod migrate; +pub(crate) use migrate::*; + +mod delegate; +pub(crate) use delegate::*; + +mod burn; +pub(crate) use burn::*; + +mod transfer; +pub(crate) use transfer::*; + +mod update; +pub(crate) use update::*; + +mod freeze; +pub(crate) use freeze::*; + +mod thaw; +pub(crate) use thaw::*; + +mod compress; +pub(crate) use compress::*; + +mod decompress; +pub(crate) use decompress::*; + +//TODO: Implement this struct +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct CompressionProof {} pub fn process_instruction<'a>( _program_id: &Pubkey, diff --git a/programs/mpl-asset/src/processor/thaw.rs b/programs/mpl-asset/src/processor/thaw.rs new file mode 100644 index 00000000..235dd0db --- /dev/null +++ b/programs/mpl-asset/src/processor/thaw.rs @@ -0,0 +1,27 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct ThawArgs {} + +pub(crate) fn thaw<'a>(accounts: &'a [AccountInfo<'a>], args: ThawArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/transfer.rs b/programs/mpl-asset/src/processor/transfer.rs new file mode 100644 index 00000000..1a7edcf6 --- /dev/null +++ b/programs/mpl-asset/src/processor/transfer.rs @@ -0,0 +1,27 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct TransferArgs {} + +pub(crate) fn transfer<'a>(accounts: &'a [AccountInfo<'a>], args: TransferArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/processor/update.rs b/programs/mpl-asset/src/processor/update.rs new file mode 100644 index 00000000..8f223a17 --- /dev/null +++ b/programs/mpl-asset/src/processor/update.rs @@ -0,0 +1,30 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use mpl_utils::assert_signer; +use solana_program::{ + account_info::AccountInfo, entrypoint::ProgramResult, program::invoke, + program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar, +}; + +use crate::{ + error::MplAssetError, + instruction::accounts::CreateAccounts, + state::{Asset, Compressible, DataState, HashedAsset, Key}, +}; + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub enum MigrationLevel { + MigrateOnly, + MigrateAndBurn, +} + +#[repr(C)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)] +pub struct UpdateArgs { + pub new_name: String, + pub new_uri: String, +} + +pub(crate) fn update<'a>(accounts: &'a [AccountInfo<'a>], args: UpdateArgs) -> ProgramResult { + Ok(()) +} diff --git a/programs/mpl-asset/src/state/collection.rs b/programs/mpl-asset/src/state/collection.rs index 1348e7fa..781792aa 100644 --- a/programs/mpl-asset/src/state/collection.rs +++ b/programs/mpl-asset/src/state/collection.rs @@ -8,8 +8,7 @@ pub struct CollectionData { pub owner: Pubkey, //32 pub name: String, //4 pub uri: String, //4 - // TBD creator stats: - pub num_minted: u64, - pub num_migrated: u64, - pub current_size: u64, + pub num_minted: u64, //8 + pub num_migrated: u64, //8 + pub current_size: u64, //8 }