revm_precompile/
fatal_precompile.rsuse crate::primitives::{
Address, Bytes, Env, Precompile, PrecompileErrors, PrecompileResult, StatefulPrecompile,
};
use crate::PrecompileWithAddress;
use std::{string::String, sync::Arc};
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, _: &Env) -> PrecompileResult {
Err(PrecompileErrors::Fatal {
msg: self.msg.clone(),
})
}
}