Add Cross-program invocations (#9582)
This commit is contained in:
28
programs/bpf/rust/invoked/src/instruction.rs
Normal file
28
programs/bpf/rust/invoked/src/instruction.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! @brief Example Rust-based BPF program that issues a cross-program-invocation
|
||||
|
||||
use solana_sdk::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
pub fn create_instruction(
|
||||
program_id: Pubkey,
|
||||
arguments: &[(&Pubkey, bool, bool)],
|
||||
data: Vec<u8>,
|
||||
) -> Instruction {
|
||||
let accounts = arguments
|
||||
.iter()
|
||||
.map(|(key, is_writable, is_signer)| {
|
||||
if *is_writable {
|
||||
AccountMeta::new(**key, *is_signer)
|
||||
} else {
|
||||
AccountMeta::new_readonly(**key, *is_signer)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Instruction {
|
||||
program_id,
|
||||
accounts,
|
||||
data,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user