Add message helpers to get program info (#14047)

This commit is contained in:
Jack May 2020-12-10 16:39:43 -08:00 committed by GitHub
parent 7abd8084b6
commit d9655ea507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -280,6 +280,16 @@ impl Message {
bincode::serialize(self).unwrap()
}
pub fn program_id(&self, instruction_index: usize) -> Option<&Pubkey> {
Some(
&self.account_keys[self.instructions.get(instruction_index)?.program_id_index as usize],
)
}
pub fn program_index(&self, instruction_index: usize) -> Option<usize> {
Some(self.instructions.get(instruction_index)?.program_id_index as usize)
}
pub fn program_ids(&self) -> Vec<&Pubkey> {
self.instructions
.iter()