Skip to content

Commit 74afe53

Browse files
committed
Replace rustc_hex crate with hex
1 parent e3aa0f4 commit 74afe53

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,11 +1,10 @@
1-
extern crate rustc_hex;
1+
extern crate hex;
22
extern crate wasmi;
33
#[macro_use]
44
extern crate log;
55
extern crate env_logger;
66

77
use primitive_types::U256;
8-
use rustc_hex::{FromHex, ToHex};
98
use serde::{Deserialize, Serialize};
109
use std::convert::{TryFrom, TryInto};
1110
use std::env;
@@ -37,8 +36,8 @@ impl From<std::io::Error> for ScoutError {
3736
}
3837
}
3938

40-
impl From<rustc_hex::FromHexError> for ScoutError {
41-
fn from(error: rustc_hex::FromHexError) -> Self {
39+
impl From<hex::FromHexError> for ScoutError {
40+
fn from(error: hex::FromHexError) -> Self {
4241
ScoutError {
4342
0: error.description().to_string(),
4443
}
@@ -248,7 +247,7 @@ impl<'a> Externals for Runtime<'a> {
248247
let tmp = memory
249248
.get(ptr, length as usize)
250249
.expect("expects reading from memory to succeed");
251-
debug!("deposit: {}", tmp.to_hex());
250+
debug!("deposit: {}", hex::encode(tmp.clone()));
252251
self.deposits.push(tmp);
253252

254253
Ok(None)
@@ -286,7 +285,7 @@ impl<'a> Externals for Runtime<'a> {
286285
memory
287286
.get_into(ptr, &mut buf)
288287
.expect("expects reading from memory to succeed");
289-
debug!("print.hex: {}", buf.to_hex());
288+
debug!("print.hex: {}", hex::encode(buf).clone());
290289
Ok(None)
291290
}
292291
BIGNUM_ADD256_FUNC => {
@@ -552,7 +551,8 @@ impl Default for BLSPubKey {
552551

553552
impl fmt::Debug for BLSPubKey {
554553
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
555-
write!(f, "{}", self.0.to_hex())
554+
unimplemented!()
555+
// write!(f, "{}", hex::encode(self.0))
556556
}
557557
}
558558

@@ -573,7 +573,8 @@ impl Default for BLSSignature {
573573

574574
impl fmt::Debug for BLSSignature {
575575
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
576-
write!(f, "{}", self.0.to_hex())
576+
unimplemented!()
577+
// write!(f, "{}", hex::encode(self.0))
577578
}
578579
}
579580

@@ -653,7 +654,7 @@ pub struct ShardState {
653654

654655
impl fmt::Display for ShardBlockBody {
655656
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
656-
write!(f, "{}", self.data.to_hex())
657+
write!(f, "{}", hex::encode(self.data.clone()))
657658
}
658659
}
659660

@@ -672,7 +673,7 @@ impl fmt::Display for ShardState {
672673
let states: Vec<String> = self
673674
.exec_env_states
674675
.iter()
675-
.map(|x| x.bytes.to_hex())
676+
.map(|state| hex::encode(state.bytes))
676677
.collect();
677678
write!(
678679
f,
@@ -784,7 +785,7 @@ struct TestFile {
784785
}
785786

786787
fn hex_to_slice(input: &str, output: &mut [u8]) -> Result<(), ScoutError> {
787-
let tmp = input.from_hex()?;
788+
let tmp = hex::decode(input)?;
788789
if tmp.len() != output.len() {
789790
return Err(ScoutError("Length mismatch from hex input".to_string()));
790791
}
@@ -866,7 +867,7 @@ impl TryFrom<TestShardBlock> for ShardBlock {
866867
Ok(ShardBlock {
867868
env: input.env,
868869
data: ShardBlockBody {
869-
data: input.data.from_hex()?,
870+
data: hex::decode(input.data)?,
870871
},
871872
})
872873
}

0 commit comments

Comments
 (0)