add freeze and thaw delegated account instructions (#2164)

This commit is contained in:
surfertas 2022-09-06 23:30:50 +09:00 committed by GitHub
parent 8ee4600785
commit 0c70d183ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 0 deletions

View File

@ -18,6 +18,7 @@ The minor version will be incremented upon a breaking change and the patch versi
* lang: Add parsing for consts from impl blocks for IDL PDA seeds generation ([#2128](https://github.com/coral-xyz/anchor/pull/2014))
* lang: Account closing reassigns to system program and reallocates ([#2169](https://github.com/coral-xyz/anchor/pull/2169)).
* ts: Add coders for SPL programs ([#2143](https://github.com/coral-xyz/anchor/pull/2143)).
* spl: Add `freeze_delegated_account` and `thaw_delegated_account` wrappers ([#2164](https://github.com/coral-xyz/anchor/pull/2164))
### Fixes

View File

@ -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>,
@ -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);