#[cfg(feature = "ethers-core")]
pub use ethers_core::types::Bytes;
#[cfg(not(feature = "ethers-core"))]
mod bytes;
#[cfg(not(feature = "ethers-core"))]
pub use crate::bytes::Bytes;
pub mod serde_as;
pub fn decode_hex(value: &str) -> Result<Vec<u8>, hex::FromHexError> {
if let Some(value) = value.strip_prefix("0x") {
hex::decode(value)
} else {
hex::decode(value)
}
}
pub trait ToHex {
fn to_hex(&self) -> String;
fn to_hex_upper(&self) -> String {
self.to_hex().to_uppercase()
}
}
impl<T: AsRef<[u8]>> ToHex for T {
fn to_hex(&self) -> String {
format!("0x{}", hex::encode(self))
}
fn to_hex_upper(&self) -> String {
format!("0x{}", hex::encode_upper(self))
}
}