Allow the same account to be passed multiple times to a single instruction (#7795)

This commit is contained in:
Jack May
2020-01-22 09:11:56 -08:00
committed by GitHub
parent d854e90c23
commit 023074650f
33 changed files with 1392 additions and 765 deletions

View File

@@ -80,7 +80,8 @@ pub trait Sysvar:
if !Self::check_id(keyed_account.unsigned_key()) {
return Err(InstructionError::InvalidArgument);
}
Self::from_account(keyed_account.account).ok_or(InstructionError::InvalidArgument)
Self::from_account(&*keyed_account.try_account_ref()?)
.ok_or(InstructionError::InvalidArgument)
}
fn create_account(&self, lamports: u64) -> Account {
let data_len = Self::size_of().max(bincode::serialized_size(self).unwrap() as usize);

View File

@@ -21,10 +21,7 @@ pub fn verify_rent_exemption(
rent_sysvar_account: &KeyedAccount,
) -> Result<(), InstructionError> {
let rent = Rent::from_keyed_account(rent_sysvar_account)?;
if !rent.is_exempt(
keyed_account.account.lamports,
keyed_account.account.data.len(),
) {
if !rent.is_exempt(keyed_account.lamports()?, keyed_account.data_len()?) {
Err(InstructionError::InsufficientFunds)
} else {
Ok(())