Respect RefCell when calling invoke (#12858)

* Respect RefCell when calling invoke

* nudge
This commit is contained in:
Jack May
2020-10-14 18:06:41 -07:00
committed by GitHub
parent f70762913c
commit 969f7b015b
3 changed files with 164 additions and 15 deletions

View File

@ -16,6 +16,22 @@ pub fn invoke_signed(
account_infos: &[AccountInfo],
signers_seeds: &[&[&[u8]]],
) -> ProgramResult {
// Check that the account RefCells are consistent with the request
for account_meta in instruction.accounts.iter() {
for account_info in account_infos.iter() {
if account_meta.pubkey == *account_info.key {
if account_meta.is_writable {
let _ = account_info.try_borrow_mut_lamports()?;
let _ = account_info.try_borrow_mut_data()?;
} else {
let _ = account_info.try_borrow_lamports()?;
let _ = account_info.try_borrow_data()?;
}
break;
}
}
}
let result = unsafe {
sol_invoke_signed_rust(
instruction as *const _ as *const u8,