Skip to content

Commit

Permalink
removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
0xvv committed May 31, 2022
1 parent e3eb1c5 commit 695664d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ impl SimpleCast {
let striped_value = strip_0x(&value);
let bytes = hex::decode(striped_value).expect("Could not decode hex");
let item = rlp::decode::<Item>(&bytes).expect("Could not decode rlp");
Ok(format!("{:x}", item))
Ok(format!("{}", item))
}

/// Converts an Ethereum address to its checksum format
Expand Down
31 changes: 4 additions & 27 deletions cast/src/rlp_converter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ethers_core::utils::rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
use serde_json::Value;
use std::fmt::{Debug, Display, Formatter, LowerHex};
use std::fmt::{Debug, Display, Formatter};

/// Arbitrarly nested data
/// Item::Array(vec![]); is equivalent to []
Expand Down Expand Up @@ -65,7 +65,7 @@ impl FromIterator<Item> for Item {
}

// Display as hex values
impl LowerHex for Item {
impl Display for Item {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Item::Data(dat) => {
Expand All @@ -75,9 +75,9 @@ impl LowerHex for Item {
write!(f, "[")?;
for item in arr {
if arr.last() == Some(item) {
write!(f, "{item:x}")?;
write!(f, "{item}")?;
} else {
write!(f, "{item:x},")?;
write!(f, "{item},")?;
}
}
write!(f, "]")?;
Expand All @@ -87,29 +87,6 @@ impl LowerHex for Item {
}
}

// Tries to display as string values
impl Display for Item {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Item::Data(dat) => {
write!(f, "\"{}\"", String::from_utf8_lossy(dat).into_owned())?;
}
Item::Array(arr) => {
write!(f, "[")?;
for item in arr {
if arr.last() == Some(item) {
write!(f, "{}", item)?;
} else {
write!(f, "{},", item)?;
};
}
write!(f, "]")?;
}
};
Ok(())
}
}

#[macro_use]
#[cfg(test)]
mod test {
Expand Down

0 comments on commit 695664d

Please sign in to comment.