difftreelog
refactor extract evm string error
in: master
2 files changed
crates/evm-coder/src/abi.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -163,8 +163,6 @@
self.write_padleft(&u128::to_be_bytes(*value))
}
- /// This method writes u128, and exists only for convenience, because there is
- /// no u256 support in rust
pub fn uint256(&mut self, value: &U256) {
let mut out = [0; 32];
value.to_big_endian(&mut out);
@@ -258,28 +256,6 @@
impl AbiWrite for () {
fn abi_write(&self, _writer: &mut AbiWriter) {}
-}
-
-/// Error, which can be constructed from any ToString type
-/// Encoded to Abi as Error(string)
-#[derive(Debug)]
-pub struct StringError(String);
-
-impl<E> From<E> for StringError
-where
- E: ToString,
-{
- fn from(e: E) -> Self {
- Self(e.to_string())
- }
-}
-
-impl From<StringError> for AbiWriter {
- fn from(v: StringError) -> Self {
- let mut out = AbiWriter::new_call(crate::fn_selector!(Error(string)));
- out.string(&v.0);
- out
- }
}
#[macro_export]
crates/evm-coder/src/execution.rsdiffbeforeafterboth1#[cfg(not(feature = "std"))]2use alloc::string::{String, ToString};3use evm_core::{ExitError, ExitFatal};4#[cfg(feature = "std")]5use std::string::{String, ToString};67#[derive(Debug)]8pub enum Error {9 Revert(String),10 Fatal(ExitFatal),11 Error(ExitError),12}1314impl<E> From<E> for Error15where16 E: ToString,17{18 fn from(e: E) -> Self {19 Self::Revert(e.to_string())20 }21}2223pub type Result<T> = core::result::Result<T, Error>;