Skip to content

Commit

Permalink
chore: multiple signers by remaining_accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
kAsky53 committed Oct 12, 2023
1 parent 869fe68 commit 23ddd3d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions spl/src/memo.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
use anchor_lang::solana_program::account_info::AccountInfo;
use anchor_lang::solana_program::pubkey::Pubkey;
use anchor_lang::Result;
use anchor_lang::{context::CpiContext, Accounts};

pub use spl_memo;
pub use spl_memo::ID;

pub fn build_memo<'info>(
ctx: CpiContext<'_, '_, '_, 'info, BuildMemo<'info>>,
memo: &[u8],
) -> Result<()> {
let ix = spl_memo::build_memo(memo, &[ctx.accounts.signer.key]);
solana_program::program::invoke_signed(&ix, &[ctx.accounts.signer], ctx.signer_seeds)
pub fn build_memo<'info>(ctx: CpiContext<'_, '_, '_, 'info, BuildMemo>, memo: &[u8]) -> Result<()> {
let mut signer_pubkeys: Vec<&Pubkey> = vec![];
for i in 0..ctx.remaining_accounts.len() {
signer_pubkeys.push(ctx.remaining_accounts[i].key);
}

let ix = spl_memo::build_memo(memo, &signer_pubkeys);
solana_program::program::invoke_signed(&ix, &ctx.remaining_accounts, ctx.signer_seeds)
.map_err(Into::into)
}

#[derive(Accounts)]
pub struct BuildMemo<'info> {
pub signer: AccountInfo<'info>,
}
pub struct BuildMemo {}

#[derive(Clone)]
pub struct Memo;
Expand Down

0 comments on commit 23ddd3d

Please sign in to comment.