Merge branch 'master' of github.com:gavofyork/ethcore-util into io

This commit is contained in:
arkpar 2016-01-13 23:20:12 +01:00
commit e4ef044d44

View File

@ -18,12 +18,7 @@ pub fn bytes_from_json(json: &Json) -> Bytes {
}
pub fn address_from_json(json: &Json) -> Address {
let s = json.as_string().unwrap_or("0000000000000000000000000000000000000000");
if s.len() % 2 == 1 {
address_from_hex(&("0".to_string() + &(clean(s).to_string()))[..])
} else {
address_from_hex(clean(s))
}
From::from(json.as_string().unwrap_or("0000000000000000000000000000000000000000"))
}
pub fn h256_from_json(json: &Json) -> H256 {
@ -35,7 +30,7 @@ pub fn h256_from_json(json: &Json) -> H256 {
}
}
pub fn u256_from_hex(s: &str) -> U256 {
pub fn u256_from_str(s: &str) -> U256 {
if s.len() >= 2 && &s[0..2] == "0x" {
U256::from_str(&s[2..]).unwrap_or(U256::from(0))
} else {
@ -44,7 +39,7 @@ pub fn u256_from_hex(s: &str) -> U256 {
}
pub fn u256_from_json(json: &Json) -> U256 {
u256_from_hex(json.as_string().unwrap_or(""))
u256_from_str(json.as_string().unwrap_or(""))
}
pub fn usize_from_json(json: &Json) -> usize {