Both kinds of LamportsError are turned into InstructionError::ArithmeticOverflow anyway. (#26273)

This commit is contained in:
Alexander Meißner 2022-06-28 10:04:54 +02:00 committed by GitHub
parent de5b6a2989
commit e8fed88669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -177,13 +177,11 @@ pub fn withdraw_nonce_account(
return Err(InstructionError::MissingRequiredSignature);
}
from.checked_sub_lamports(lamports)
.map_err(|_| InstructionError::ArithmeticOverflow)?;
from.checked_sub_lamports(lamports)?;
drop(from);
let mut to = instruction_context
.try_borrow_instruction_account(transaction_context, to_account_index)?;
to.checked_add_lamports(lamports)
.map_err(|_| InstructionError::ArithmeticOverflow)?;
to.checked_add_lamports(lamports)?;
Ok(())
}

View File

@ -4,7 +4,6 @@ use {
crate::{
account::{AccountSharedData, ReadableAccount, WritableAccount},
instruction::InstructionError,
lamports::LamportsError,
pubkey::Pubkey,
},
std::{
@ -559,7 +558,7 @@ impl<'a> BorrowedAccount<'a> {
self.set_lamports(
self.get_lamports()
.checked_add(lamports)
.ok_or(LamportsError::ArithmeticOverflow)?,
.ok_or(InstructionError::ArithmeticOverflow)?,
)
}
@ -568,7 +567,7 @@ impl<'a> BorrowedAccount<'a> {
self.set_lamports(
self.get_lamports()
.checked_sub(lamports)
.ok_or(LamportsError::ArithmeticUnderflow)?,
.ok_or(InstructionError::ArithmeticOverflow)?,
)
}