-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spl: add feature memo to support cpi to spl-memo (#2661)
- Loading branch information
Showing
5 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,6 @@ pub mod stake; | |
|
||
#[cfg(feature = "metadata")] | ||
pub mod metadata; | ||
|
||
#[cfg(feature = "memo")] | ||
pub mod memo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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>, memo: &[u8]) -> Result<()> { | ||
let ix = spl_memo::build_memo( | ||
memo, | ||
&ctx.remaining_accounts | ||
.iter() | ||
.map(|account| account.key) | ||
.collect::<Vec<_>>(), | ||
); | ||
solana_program::program::invoke_signed(&ix, &ctx.remaining_accounts, ctx.signer_seeds) | ||
.map_err(Into::into) | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct BuildMemo {} | ||
|
||
#[derive(Clone)] | ||
pub struct Memo; | ||
|
||
impl anchor_lang::Id for Memo { | ||
fn id() -> Pubkey { | ||
ID | ||
} | ||
} |
23eeb1e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
anchor-docs – ./
anchor-docs-200ms.vercel.app
anchor-docs-git-master-200ms.vercel.app
www.anchor-lang.com
anchor-lang.com