Skip to content

Commit

Permalink
Create instruction processor stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Feb 17, 2024
1 parent 678189d commit 3539a25
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 78 deletions.
70 changes: 4 additions & 66 deletions programs/mpl-asset/src/instruction.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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 {}
26 changes: 26 additions & 0 deletions programs/mpl-asset/src/processor/burn.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
27 changes: 27 additions & 0 deletions programs/mpl-asset/src/processor/compress.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
12 changes: 10 additions & 2 deletions programs/mpl-asset/src/processor/create.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)?;
Expand Down
30 changes: 30 additions & 0 deletions programs/mpl-asset/src/processor/decompress.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
27 changes: 27 additions & 0 deletions programs/mpl-asset/src/processor/delegate.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
27 changes: 27 additions & 0 deletions programs/mpl-asset/src/processor/freeze.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
30 changes: 30 additions & 0 deletions programs/mpl-asset/src/processor/migrate.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
42 changes: 36 additions & 6 deletions programs/mpl-asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
27 changes: 27 additions & 0 deletions programs/mpl-asset/src/processor/thaw.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
27 changes: 27 additions & 0 deletions programs/mpl-asset/src/processor/transfer.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
Loading

0 comments on commit 3539a25

Please sign in to comment.