Skip to content

Commit

Permalink
Add intitial instrucitons to MplAssetInstruction enum
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Feb 17, 2024
1 parent 245f184 commit db00a23
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 9 deletions.
136 changes: 135 additions & 1 deletion programs/mpl-asset/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,147 @@ pub enum MplAssetInstruction {
#[account(4, name="system_program", desc = "The system program")]
#[account(5, 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(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")]
#[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(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")]
#[account(11, name="system_program", desc = "The system program")]
#[account(12, optional, name="log_wrapper", desc = "The SPL Noop Program")]
#[account(13, optional, name="authorization_rules_program", desc="Token Authorization Rules Program")]
#[account(14, optional, name="authorization_rules", desc="Token Authorization Rules account")]
Migrate(MigrateArgs),

/// 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")]
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(2, signer, name="authority", desc = "The owner or delegate of the asset")]
#[account(3, 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")]
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")]
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(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(2, optional, name="log_wrapper", desc = "The SPL Noop Program")]
Thaw(ThawArgs),

/// 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")]
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")]
Decompress(DecompressArgs),
}

#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct CreateArgs {
pub data_state: DataState,
pub watermark: bool,
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 {}
6 changes: 1 addition & 5 deletions programs/mpl-asset/src/processor/create.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use borsh::BorshSerialize;
use mpl_utils::assert_signer;
use solana_program::{
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult, program::invoke,
account_info::AccountInfo, entrypoint::ProgramResult, program::invoke,
program_memory::sol_memcpy, rent::Rent, system_instruction, system_program, sysvar::Sysvar,
};

Expand Down Expand Up @@ -46,10 +46,6 @@ pub(crate) fn create<'a>(accounts: &'a [AccountInfo<'a>], args: CreateArgs) -> P
let hashed_asset = HashedAsset {
key: Key::HashedAsset,
hash: new_asset.hash()?,
watermark_slot: match args.watermark {
true => Some(Clock::get()?.slot),
false => None,
},
};

hashed_asset.try_to_vec()?
Expand Down
5 changes: 2 additions & 3 deletions programs/mpl-asset/src/state/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ impl Compressible for Asset {

#[derive(Clone, BorshSerialize, BorshDeserialize, Debug, ShankAccount)]
pub struct HashedAsset {
pub key: Key, //1
pub hash: [u8; 32], //32
pub watermark_slot: Option<u64>, //1 | 9
pub key: Key, //1
pub hash: [u8; 32], //32
}

0 comments on commit db00a23

Please sign in to comment.