revm_precompile/
fatal_precompile.rsuse crate::primitives::{Address, Bytes};
use crate::{
Precompile, PrecompileErrors, PrecompileResult, PrecompileWithAddress, StatefulPrecompile,
};
use std::{string::String, sync::Arc};
use wiring::default::CfgEnv;
pub fn fatal_precompile(address: Address, msg: String) -> PrecompileWithAddress {
PrecompileWithAddress(address, FatalPrecompile::new_precompile(msg))
}
pub struct FatalPrecompile {
msg: String,
}
impl FatalPrecompile {
pub fn new(msg: String) -> Self {
Self { msg }
}
pub fn new_precompile(msg: String) -> Precompile {
Precompile::Stateful(Arc::new(Self::new(msg)))
}
}
impl StatefulPrecompile for FatalPrecompile {
fn call(&self, _: &Bytes, _: u64, _: &CfgEnv) -> PrecompileResult {
Err(PrecompileErrors::Fatal {
msg: self.msg.clone(),
})
}
}