Load executable accounts from invoke context (#14574)

This commit is contained in:
Jack May
2021-01-14 00:19:22 -08:00
committed by GitHub
parent cfcca1cd3c
commit 6e8a1ba7de
5 changed files with 378 additions and 272 deletions

View File

@ -541,18 +541,19 @@ impl MessageProcessor {
}
}
// validate the caller has access to the program account
// validate the caller has access to the program account and that it is executable
let program_id = instruction.program_id;
let _ = keyed_accounts
match keyed_accounts
.iter()
.find_map(|keyed_account| {
if &program_id == keyed_account.unsigned_key() {
Some(keyed_account)
} else {
None
.find(|keyed_account| &program_id == keyed_account.unsigned_key())
{
Some(keyed_account) => {
if !keyed_account.executable()? {
return Err(InstructionError::AccountNotExecutable);
}
})
.ok_or(InstructionError::MissingAccount)?;
}
None => return Err(InstructionError::MissingAccount),
}
let message = Message::new(&[instruction.clone()], None);
let program_id_index = message.instructions[0].program_id_index as usize;