WritableAccount.add/subtract_lamports (#16750)

* add/sub lamports

* make add/sub return Result

* sample replacements

* cleanup

* fix up a few tests as examples

* move enum, cleanup, impl from

* fmt

* cleanup

* add lamports.rs
This commit is contained in:
Jeff Washington (jwash)
2021-04-23 15:20:48 -05:00
committed by GitHub
parent be29568318
commit 48c07d32f0
6 changed files with 101 additions and 8 deletions

View File

@ -0,0 +1,22 @@
use crate::instruction::InstructionError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum LamportsError {
/// arithmetic underflowed
#[error("Arithmetic underflowed")]
ArithmeticUnderflow,
/// arithmetic overflowed
#[error("Arithmetic overflowed")]
ArithmeticOverflow,
}
impl From<LamportsError> for InstructionError {
fn from(error: LamportsError) -> Self {
match error {
LamportsError::ArithmeticOverflow => InstructionError::ArithmeticOverflow,
LamportsError::ArithmeticUnderflow => InstructionError::ArithmeticOverflow,
}
}
}

View File

@ -20,6 +20,7 @@ pub mod fee_calculator;
pub mod hash;
pub mod incinerator;
pub mod instruction;
pub mod lamports;
pub mod loader_instruction;
pub mod loader_upgradeable_instruction;
pub mod log;