diff --git a/ethabi/Cargo.toml b/ethabi/Cargo.toml index e52c3a5d7..cc0d5b9c3 100644 --- a/ethabi/Cargo.toml +++ b/ethabi/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" [dependencies] hex = { version = "0.4", default-features = false, features = ["alloc"] } serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] } -serde_json = { version = "1.0", optional = true } +serde_json = { version = "1.0", optional = true, default-features = false, features = ["alloc"] } sha3 = { version = "0.10", default-features = false } ethereum-types = { version = "0.14.0", default-features = false } thiserror = { version = "1", optional = true } @@ -23,6 +23,9 @@ uint = { version = "0.9.0", default-features = false, optional = true } regex = { version = "1.5.4", optional = true } once_cell = { version = "1.9.0", optional = true } +[target.'cfg(not(feature = "std"))'.dependencies] +displaydoc = { version = "0.2", default-features = false } + [dev-dependencies] hex-literal = "0.3" paste = "1" @@ -41,6 +44,7 @@ std = [ "thiserror", "uint?/std", "serde?/std", + "serde_json?/std", ] serde = [ diff --git a/ethabi/src/errors.rs b/ethabi/src/errors.rs index c0eb7821e..e7b6147d4 100644 --- a/ethabi/src/errors.rs +++ b/ethabi/src/errors.rs @@ -13,12 +13,15 @@ use crate::no_std_prelude::*; use core::num; #[cfg(feature = "std")] use thiserror::Error; +#[cfg(not(feature = "std"))] +use displaydoc::Display; /// Ethabi result type pub type Result = core::result::Result; /// Ethabi errors #[cfg_attr(feature = "std", derive(Error))] +#[cfg_attr(not(feature = "std"), derive(Display))] #[derive(Debug)] pub enum Error { /// Invalid entity such as a bad function name.