From 8e52242b8ca838a44e135b48af758fa2b643176c Mon Sep 17 00:00:00 2001 From: jpbogle Date: Sun, 10 Oct 2021 17:18:17 -0700 Subject: [PATCH] spl: Add thaw_account token utility (#867) --- spl/src/token.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spl/src/token.rs b/spl/src/token.rs index c6ddec26..8655321c 100644 --- a/spl/src/token.rs +++ b/spl/src/token.rs @@ -170,6 +170,27 @@ pub fn freeze_account<'a, 'b, 'c, 'info>( ) } +pub fn thaw_account<'a, 'b, 'c, 'info>( + ctx: CpiContext<'a, 'b, 'c, 'info, ThawAccount<'info>>, +) -> ProgramResult { + let ix = spl_token::instruction::thaw_account( + &spl_token::ID, + ctx.accounts.account.key, + ctx.accounts.mint.key, + ctx.accounts.authority.key, + &[], // TODO: Support multisig signers. + )?; + solana_program::program::invoke_signed( + &ix, + &[ + ctx.accounts.account.clone(), + ctx.accounts.mint.clone(), + ctx.accounts.authority.clone(), + ], + ctx.signer_seeds, + ) +} + pub fn initialize_mint<'a, 'b, 'c, 'info>( ctx: CpiContext<'a, 'b, 'c, 'info, InitializeMint<'info>>, decimals: u8, @@ -273,6 +294,13 @@ pub struct FreezeAccount<'info> { pub authority: AccountInfo<'info>, } +#[derive(Accounts)] +pub struct ThawAccount<'info> { + pub account: AccountInfo<'info>, + pub mint: AccountInfo<'info>, + pub authority: AccountInfo<'info>, +} + #[derive(Accounts)] pub struct InitializeMint<'info> { pub mint: AccountInfo<'info>,