* issue #10831: added --with-memo option to all cli commands that submit transactions. Also, improve the block command to show UTF-8 string instead of integer values for memo program data. * Fixed tests and changed some syntax according to feedback. * Use spl_memo id (all versions where applicable) instead of hardcoding id. * Update Cargo.toml in programs/bpf. * Update formatting via cargo fmt. * Update to use spl_memo version 3.0.1, which simplifies package imports
This commit is contained in:
22
cli/src/memo.rs
Normal file
22
cli/src/memo.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use solana_sdk::instruction::Instruction;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use spl_memo::id;
|
||||
|
||||
pub trait WithMemo {
|
||||
fn with_memo<T: AsRef<str>>(self, memo: Option<T>) -> Self;
|
||||
}
|
||||
|
||||
impl WithMemo for Vec<Instruction> {
|
||||
fn with_memo<T: AsRef<str>>(mut self, memo: Option<T>) -> Self {
|
||||
if let Some(memo) = &memo {
|
||||
let memo = memo.as_ref();
|
||||
let memo_ix = Instruction {
|
||||
program_id: Pubkey::new(&id().to_bytes()),
|
||||
accounts: vec![],
|
||||
data: memo.as_bytes().to_vec(),
|
||||
};
|
||||
self.push(memo_ix);
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user