solana_stake_program/helpers/
mod.rs

1use {solana_instruction_error::InstructionError, solana_program_error::ProgramError};
2
3pub(crate) mod delegate;
4pub(crate) use delegate::*;
5
6pub(crate) mod split;
7pub(crate) use split::*;
8
9pub(crate) mod merge;
10pub(crate) use merge::*;
11
12pub(crate) fn checked_add(a: u64, b: u64) -> Result<u64, ProgramError> {
13    a.checked_add(b).ok_or(ProgramError::InsufficientFunds)
14}
15
16pub(crate) fn to_program_error(e: InstructionError) -> ProgramError {
17    ProgramError::try_from(e).unwrap_or(ProgramError::InvalidAccountData)
18}