Skip to main content

anchor_spl/
memo.rs

1use anchor_lang::{context::CpiContext, solana_program::pubkey::Pubkey, Accounts, Result};
2pub use spl_memo_interface::{instruction as spl_memo, v3::ID};
3
4pub fn build_memo<'info>(ctx: CpiContext<'_, '_, '_, 'info, BuildMemo>, memo: &[u8]) -> Result<()> {
5    let ix = spl_memo::build_memo(
6        &ID,
7        memo,
8        &ctx.remaining_accounts
9            .iter()
10            .map(|account| account.key)
11            .collect::<Vec<_>>(),
12    );
13    anchor_lang::solana_program::program::invoke_signed(
14        &ix,
15        &ctx.remaining_accounts,
16        ctx.signer_seeds,
17    )
18    .map_err(Into::into)
19}
20
21#[derive(Accounts)]
22pub struct BuildMemo {}
23
24#[derive(Clone)]
25pub struct Memo;
26
27impl anchor_lang::Id for Memo {
28    fn id() -> Pubkey {
29        ID
30    }
31}