Skip to content

Commit 4f0ef71

Browse files
committed
Replace rustc_hex crate with hex
1 parent 473691b commit 4f0ef71

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 13 additions & 12 deletions
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
}
@@ -246,7 +245,7 @@ impl<'a> Externals for Runtime<'a> {
246245
let tmp = memory
247246
.get(ptr, length as usize)
248247
.expect("expects reading from memory to succeed");
249-
debug!("deposit: {}", tmp.to_hex());
248+
debug!("deposit: {}", hex::encode(tmp.clone()));
250249
self.deposits.push(tmp);
251250

252251
Ok(None)
@@ -284,7 +283,7 @@ impl<'a> Externals for Runtime<'a> {
284283
memory
285284
.get_into(ptr, &mut buf)
286285
.expect("expects reading from memory to succeed");
287-
debug!("print.hex: {}", buf.to_hex());
286+
debug!("print.hex: {}", hex::encode(buf).clone());
288287
Ok(None)
289288
}
290289
BIGNUM_ADD256_FUNC => {
@@ -550,7 +549,8 @@ impl Default for BLSPubKey {
550549

551550
impl fmt::Debug for BLSPubKey {
552551
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
553-
write!(f, "{}", self.0.to_hex())
552+
unimplemented!()
553+
// write!(f, "{}", hex::encode(self.0))
554554
}
555555
}
556556

@@ -571,7 +571,8 @@ impl Default for BLSSignature {
571571

572572
impl fmt::Debug for BLSSignature {
573573
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
574-
write!(f, "{}", self.0.to_hex())
574+
unimplemented!()
575+
// write!(f, "{}", hex::encode(self.0))
575576
}
576577
}
577578

@@ -628,7 +629,7 @@ pub struct ShardState {
628629

629630
impl fmt::Display for ShardBlockBody {
630631
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
631-
write!(f, "{}", self.data.to_hex())
632+
write!(f, "{}", hex::encode(self.data.clone()))
632633
}
633634
}
634635

@@ -647,7 +648,7 @@ impl fmt::Display for ShardState {
647648
let states: Vec<String> = self
648649
.exec_env_states
649650
.iter()
650-
.map(|x| x.bytes.to_hex())
651+
.map(|state| hex::encode(state.bytes))
651652
.collect();
652653
write!(
653654
f,
@@ -762,7 +763,7 @@ struct TestFile {
762763
}
763764

764765
fn hex_to_slice(input: &str, output: &mut [u8]) -> Result<(), ScoutError> {
765-
let tmp = input.from_hex()?;
766+
let tmp = hex::decode(input)?;
766767
if tmp.len() != output.len() {
767768
return Err(ScoutError("Length mismatch from hex input".to_string()));
768769
}
@@ -844,7 +845,7 @@ impl TryFrom<TestShardBlock> for ShardBlock {
844845
Ok(ShardBlock {
845846
env: input.env,
846847
data: ShardBlockBody {
847-
data: input.data.from_hex()?,
848+
data: hex::decode(input.data)?,
848849
},
849850
})
850851
}

0 commit comments

Comments
 (0)