|
@@ -104,6 +104,27 @@ pub fn approve<'a, 'b, 'c, 'info>(
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+pub fn initialize_account<'a, 'b, 'c, 'info>(
|
|
|
+ ctx: CpiContext<'a, 'b, 'c, 'info, InitializeAccount<'info>>,
|
|
|
+) -> ProgramResult {
|
|
|
+ let ix = spl_token::instruction::initialize_account(
|
|
|
+ &spl_token::ID,
|
|
|
+ ctx.accounts.account.key,
|
|
|
+ ctx.accounts.mint.key,
|
|
|
+ ctx.accounts.authority.key,
|
|
|
+ )?;
|
|
|
+ solana_program::program::invoke_signed(
|
|
|
+ &ix,
|
|
|
+ &[
|
|
|
+ ctx.accounts.account.clone(),
|
|
|
+ ctx.accounts.mint.clone(),
|
|
|
+ ctx.accounts.authority.clone(),
|
|
|
+ ctx.program.clone(),
|
|
|
+ ],
|
|
|
+ ctx.signer_seeds,
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Accounts)]
|
|
|
pub struct Transfer<'info> {
|
|
|
pub from: AccountInfo<'info>,
|
|
@@ -132,6 +153,13 @@ pub struct Approve<'info> {
|
|
|
pub authority: AccountInfo<'info>,
|
|
|
}
|
|
|
|
|
|
+#[derive(Accounts)]
|
|
|
+pub struct InitializeAccount<'info> {
|
|
|
+ pub account: AccountInfo<'info>,
|
|
|
+ pub mint: AccountInfo<'info>,
|
|
|
+ pub authority: AccountInfo<'info>,
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Clone)]
|
|
|
pub struct TokenAccount(spl_token::state::Account);
|
|
|
|