Skip to content

Commit

Permalink
init PR to add freeze and thaw delegated account
Browse files Browse the repository at this point in the history
  • Loading branch information
surfertas committed Sep 5, 2022
1 parent c1c4f6c commit c7ad3b9
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions spl/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,46 @@ pub fn set_collection_size<'info>(
Ok(())
}

pub fn freeze_delegated_account<'info>(
ctx: CpiContext<'_, '_, '_, 'info, FreezeDelegatedAccount<'info>>,
) -> Result<()> {
let ix = mpl_token_metadata::instruction::freeze_delegated_account(
ID,
*ctx.accounts.delegate.key,
*ctx.accounts.token_account.key,
*ctx.accounts.edition.key,
*ctx.accounts.mint.key,
);

solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
)?;

Ok(())
}

pub fn thaw_delegated_account<'info>(
ctx: CpiContext<'_, '_, '_, 'info, ThawDelegatedAccount<'info>>,
) -> Result<()> {
let ix = mpl_token_metadata::instruction::thaw_delegated_account(
ID,
*ctx.accounts.delegate.key,
*ctx.accounts.token_account.key,
*ctx.accounts.edition.key,
*ctx.accounts.mint.key,
);

solana_program::program::invoke_signed(
&ix,
&ToAccountInfos::to_account_infos(&ctx),
ctx.signer_seeds,
)?;

Ok(())
}

#[derive(Accounts)]
pub struct CreateMetadataAccountsV2<'info> {
pub metadata: AccountInfo<'info>,
Expand Down Expand Up @@ -268,6 +308,26 @@ pub struct SetCollectionSize<'info> {
pub system_program: AccountInfo<'info>,
}

#[derive(Accounts)]
pub struct FreezeDelegatedAccount<'info> {
pub metadata: AccountInfo<'info>,
pub delegate: AccountInfo<'info>,
pub token_account: AccountInfo<'info>,
pub edition: AccountInfo<'info>,
pub mint: AccountInfo<'info>,
pub token_program: AccountInfo<'info>,
}

#[derive(Accounts)]
pub struct ThawDelegatedAccount<'info> {
pub metadata: AccountInfo<'info>,
pub delegate: AccountInfo<'info>,
pub token_account: AccountInfo<'info>,
pub edition: AccountInfo<'info>,
pub mint: AccountInfo<'info>,
pub token_program: AccountInfo<'info>,
}

#[derive(Clone, Debug, PartialEq)]
pub struct MetadataAccount(mpl_token_metadata::state::Metadata);

Expand Down

0 comments on commit c7ad3b9

Please sign in to comment.