#![cfg_attr(not(feature = "std"), no_std)]
#![feature(assert_matches)]
extern crate alloc;
pub use pallet_3vm_evm_primitives::{
ExitError, ExitRevert, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput,
};
use sp_std::{borrow, borrow::ToOwned};
pub mod costs;
pub mod data;
pub mod handle;
pub mod modifier;
pub mod precompile_set;
pub mod substrate;
pub mod testing;
pub type EvmResult<T = ()> = Result<T, PrecompileFailure>;
pub trait StatefulPrecompile {
fn new() -> Self;
fn execute(&self, handle: &mut impl PrecompileHandle) -> EvmResult<PrecompileOutput>;
}
#[must_use]
pub fn error<T: Into<borrow::Cow<'static, str>>>(text: T) -> PrecompileFailure {
PrecompileFailure::Error {
exit_status: ExitError::Other(text.into()),
}
}
#[must_use]
pub fn revert(output: impl AsRef<[u8]>) -> PrecompileFailure {
PrecompileFailure::Revert {
exit_status: ExitRevert::Reverted,
output: output.as_ref().to_owned(),
}
}
#[must_use]
pub fn succeed(output: impl AsRef<[u8]>) -> PrecompileOutput {
PrecompileOutput {
exit_status: ExitSucceed::Returned,
output: output.as_ref().to_owned(),
}
}