|
1 | 1 | use crate::Env;
|
2 | 2 | use alloc::vec::Vec;
|
| 3 | +use core::fmt; |
3 | 4 |
|
4 | 5 | /// A precompile operation result.
|
5 | 6 | ///
|
@@ -32,3 +33,33 @@ pub enum PrecompileError {
|
32 | 33 | /// The proof verification failed.
|
33 | 34 | BlobVerifyKzgProofFailed,
|
34 | 35 | }
|
| 36 | + |
| 37 | +#[cfg(feature = "std")] |
| 38 | +impl std::error::Error for PrecompileError {} |
| 39 | + |
| 40 | +impl fmt::Display for PrecompileError { |
| 41 | + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 42 | + match self { |
| 43 | + PrecompileError::OutOfGas => write!(f, "out of gas"), |
| 44 | + PrecompileError::Blake2WrongLength => write!(f, "wrong input length for blake2"), |
| 45 | + PrecompileError::Blake2WrongFinalIndicatorFlag => { |
| 46 | + write!(f, "wrong final indicator flag for blake2") |
| 47 | + } |
| 48 | + PrecompileError::ModexpExpOverflow => write!(f, "modexp exp overflow"), |
| 49 | + PrecompileError::ModexpBaseOverflow => write!(f, "modexp base overflow"), |
| 50 | + PrecompileError::ModexpModOverflow => write!(f, "modexp mod overflow"), |
| 51 | + PrecompileError::Bn128FieldPointNotAMember => { |
| 52 | + write!(f, "field point not a member of bn128 curve") |
| 53 | + } |
| 54 | + PrecompileError::Bn128AffineGFailedToCreate => { |
| 55 | + write!(f, "failed to create affine g point for bn128 curve") |
| 56 | + } |
| 57 | + PrecompileError::Bn128PairLength => write!(f, "bn128 invalid pair length"), |
| 58 | + PrecompileError::BlobInvalidInputLength => write!(f, "invalid blob input length"), |
| 59 | + PrecompileError::BlobMismatchedVersion => write!(f, "mismatched blob version"), |
| 60 | + PrecompileError::BlobVerifyKzgProofFailed => { |
| 61 | + write!(f, "verifying blob kzg proof failed") |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments