feat: add sync native to anchor_spl::token (#1833)

This commit is contained in:
Pierre 2022-04-25 19:39:35 +02:00 committed by GitHub
parent cb4549fdf3
commit 282c394666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -18,6 +18,7 @@ The minor version will be incremented upon a breaking change and the patch versi
* cli: `build` now adds docs to idl. This can be turned off with `--no-docs` ([#1561](https://github.com/project-serum/anchor/pull/1561)).
* lang: Add `PartialEq` and `Eq` for `anchor_lang::Error` ([#1544](https://github.com/project-serum/anchor/pull/1544)).
* cli: Add `b` and `t` aliases for `build` and `test` respectively ([#1823](https://github.com/project-serum/anchor/pull/1823)).
* spl: Add `sync_native` token program CPI wrapper function ([#1833](https://github.com/project-serum/anchor/pull/1833)).
### Fixes

View File

@ -258,6 +258,14 @@ pub fn set_authority<'a, 'b, 'c, 'info>(
.map_err(Into::into)
}
pub fn sync_native<'a, 'b, 'c, 'info>(
ctx: CpiContext<'a, 'b, 'c, 'info, SyncNative<'info>>,
) -> Result<()> {
let ix = spl_token::instruction::sync_native(&spl_token::ID, ctx.accounts.account.key)?;
solana_program::program::invoke_signed(&ix, &[ctx.accounts.account.clone()], ctx.signer_seeds)
.map_err(Into::into)
}
#[derive(Accounts)]
pub struct Transfer<'info> {
pub from: AccountInfo<'info>,
@ -333,6 +341,11 @@ pub struct SetAuthority<'info> {
pub account_or_mint: AccountInfo<'info>,
}
#[derive(Accounts)]
pub struct SyncNative<'info> {
pub account: AccountInfo<'info>,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct TokenAccount(spl_token::state::Account);