Skip to content

Commit 67c8291

Browse files
committed
Replace rustc_hex crate with hex
1 parent 77aae90 commit 67c8291

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ publish = false
99
edition = "2018"
1010

1111
[dependencies]
12+
hex = "0.4.0"
1213
wasmi = "0.5"
13-
rustc-hex = "1.0"
1414
serde = { version = "1.0", features = ["derive"] }
1515
serde_yaml = "0.8"
1616
log = "0.4"

src/main.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate rustc_hex;
1+
extern crate hex;
22
extern crate wasmi;
33
#[macro_use]
44
extern crate log;
@@ -8,7 +8,6 @@ extern crate ssz;
88
extern crate ssz_derive;
99

1010
use primitive_types::U256;
11-
use rustc_hex::{FromHex, ToHex};
1211
use serde::{Deserialize, Serialize};
1312
use ssz::{Decode, Encode};
1413
use std::convert::{TryFrom, TryInto};
@@ -35,8 +34,8 @@ impl From<std::io::Error> for ScoutError {
3534
}
3635
}
3736

38-
impl From<rustc_hex::FromHexError> for ScoutError {
39-
fn from(error: rustc_hex::FromHexError) -> Self {
37+
impl From<hex::FromHexError> for ScoutError {
38+
fn from(error: hex::FromHexError) -> Self {
4039
ScoutError {
4140
0: error.description().to_string(),
4241
}
@@ -193,7 +192,7 @@ impl<'a> Externals for Runtime<'a> {
193192
let tmp = memory
194193
.get(ptr, length as usize)
195194
.expect("expects reading from memory to succeed");
196-
debug!("deposit: {}", tmp.to_hex());
195+
debug!("deposit: {}", hex::encode(tmp.clone()));
197196
self.deposits.push(tmp);
198197

199198
Ok(None)
@@ -231,7 +230,7 @@ impl<'a> Externals for Runtime<'a> {
231230
memory
232231
.get_into(ptr, &mut buf)
233232
.expect("expects reading from memory to succeed");
234-
debug!("print.hex: {}", buf.to_hex());
233+
debug!("print.hex: {}", hex::encode(buf).clone());
235234
Ok(None)
236235
}
237236
BIGNUM_ADD256_FUNC => {
@@ -497,7 +496,8 @@ impl Default for BLSPubKey {
497496

498497
impl fmt::Debug for BLSPubKey {
499498
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
500-
write!(f, "{}", self.0.to_hex())
499+
unimplemented!()
500+
// write!(f, "{}", hex::encode(self.0))
501501
}
502502
}
503503

@@ -518,7 +518,8 @@ impl Default for BLSSignature {
518518

519519
impl fmt::Debug for BLSSignature {
520520
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
521-
write!(f, "{}", self.0.to_hex())
521+
unimplemented!()
522+
// write!(f, "{}", hex::encode(self.0))
522523
}
523524
}
524525

@@ -574,7 +575,7 @@ pub struct ShardState {
574575

575576
impl fmt::Display for ShardBlockBody {
576577
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
577-
write!(f, "{}", self.data.to_hex())
578+
write!(f, "{}", hex::encode(self.data.clone()))
578579
}
579580
}
580581

@@ -593,7 +594,7 @@ impl fmt::Display for ShardState {
593594
let states: Vec<String> = self
594595
.exec_env_states
595596
.iter()
596-
.map(|x| x.bytes.to_hex())
597+
.map(|state| hex::encode(state.bytes))
597598
.collect();
598599
write!(
599600
f,
@@ -723,7 +724,7 @@ struct TestFile {
723724
}
724725

725726
fn hex_to_slice(input: &str, output: &mut [u8]) -> Result<(), ScoutError> {
726-
let tmp = input.from_hex()?;
727+
let tmp = hex::decode(input)?;
727728
if tmp.len() != output.len() {
728729
return Err(ScoutError("Length mismatch from hex input".to_string()));
729730
}
@@ -791,7 +792,7 @@ impl TryFrom<TestShardBlock> for ShardBlock {
791792
Ok(ShardBlock {
792793
env: input.env,
793794
data: ShardBlockBody {
794-
data: input.data.from_hex()?,
795+
data: hex::decode(input.data)?,
795796
},
796797
})
797798
}

0 commit comments

Comments
 (0)