From 63fc3cb4ac65b6f4260e71810e6b95b6f238bdc1 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 11 Mar 2015 08:58:47 +0100 Subject: [PATCH] fixed #763, changes in CommonJS --- libdevcore/CommonJS.h | 22 ++++------------------ libweb3jsonrpc/WebThreeStubServerBase.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h index 567572afd..81a0ac86e 100644 --- a/libdevcore/CommonJS.h +++ b/libdevcore/CommonJS.h @@ -41,9 +41,11 @@ template std::string toJS(boost::multiprecision::number(n.size(), _padding)); + return "0x" + toHex(n); } template< typename T >std::string toJS( T const& i ) @@ -109,20 +111,4 @@ inline std::string jsToDecimal(std::string const& _s) return toString(jsToU256(_s)); } -inline std::string jsFromBinary(bytes _s, unsigned _padding = 32) -{ - _s.resize(std::max(_s.size(), _padding)); - return "0x" + toHex(_s); -} - -inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) -{ - return jsFromBinary(asBytes(_s), _padding); -} - -inline double jsFromFixed(std::string const& _s) -{ - return (double)jsToU256(_s) / (double)(u256(1) << 128); -} - } diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index 75c480850..25f92f3b9 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -60,7 +60,7 @@ static Json::Value toJson(dev::eth::BlockInfo const& _bi) res["number"] = toJS(_bi.number); res["gasLimit"] = toJS(_bi.gasLimit); res["timestamp"] = toJS(_bi.timestamp); - res["extraData"] = jsFromBinary(_bi.extraData); + res["extraData"] = toJS(_bi.extraData); res["nonce"] = toJS(_bi.nonce); return res; } @@ -69,7 +69,7 @@ static Json::Value toJson(dev::eth::Transaction const& _t) { Json::Value res; res["hash"] = toJS(_t.sha3()); - res["input"] = jsFromBinary(_t.data()); + res["input"] = toJS(_t.data()); res["to"] = toJS(_t.receiveAddress()); res["from"] = toJS(_t.safeSender()); res["gas"] = toJS(_t.gas()); @@ -105,7 +105,7 @@ static Json::Value toJson(dev::eth::TransactionSkeleton const& _t) res["gas"] = toJS(_t.gas); res["gasPrice"] = toJS(_t.gasPrice); res["value"] = toJS(_t.value); - res["data"] = jsFromBinary(_t.data); + res["data"] = toJS(_t.data, 32); return res; } @@ -113,7 +113,7 @@ static Json::Value toJson(dev::eth::LocalisedLogEntry const& _e) { Json::Value res; - res["data"] = jsFromBinary(_e.data); + res["data"] = toJS(_e.data); res["address"] = toJS(_e.address); res["topics"] = Json::Value(Json::arrayValue); for (auto const& t: _e.topics) @@ -461,7 +461,7 @@ string WebThreeStubServerBase::eth_getData(string const& _address, string const& BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS)); } - return jsFromBinary(client()->codeAt(address, number)); + return toJS(client()->codeAt(address, number)); } static TransactionSkeleton toTransaction(Json::Value const& _json)