diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index 806df6b30..cea1750ac 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -57,7 +57,7 @@ const unsigned dev::SensibleHttpPort = 8080; static Json::Value toJson(dev::eth::BlockInfo const& _bi) { Json::Value res; - res["hash"] = boost::lexical_cast(_bi.hash); + res["hash"] = toJS(_bi.hash); res["parentHash"] = toJS(_bi.parentHash); res["sha3Uncles"] = toJS(_bi.sha3Uncles); res["miner"] = toJS(_bi.coinbaseAddress); @@ -65,10 +65,12 @@ static Json::Value toJson(dev::eth::BlockInfo const& _bi) res["transactionsRoot"] = toJS(_bi.transactionsRoot); res["difficulty"] = toJS(_bi.difficulty); res["number"] = toJS(_bi.number); + res["gasUsed"] = toJS(_bi.gasUsed); res["gasLimit"] = toJS(_bi.gasLimit); res["timestamp"] = toJS(_bi.timestamp); res["extraData"] = toJS(_bi.extraData); res["nonce"] = toJS(_bi.nonce); + res["logsBloom"] = toJS(_bi.logBloom); return res; } @@ -86,18 +88,24 @@ static Json::Value toJson(dev::eth::Transaction const& _t) return res; } -static Json::Value toJson(dev::eth::BlockInfo const& _bi, Transactions const& _ts) +static Json::Value toJson(dev::eth::BlockInfo const& _bi, UncleHashes const& _us, Transactions const& _ts) { Json::Value res = toJson(_bi); + res["uncles"] = Json::Value(Json::arrayValue); + for (h256 h: _us) + res["uncles"].append(toJS(h)); res["transactions"] = Json::Value(Json::arrayValue); for (Transaction const& t: _ts) res["transactions"].append(toJson(t)); return res; } -static Json::Value toJson(dev::eth::BlockInfo const& _bi, TransactionHashes const& _ts) +static Json::Value toJson(dev::eth::BlockInfo const& _bi, UncleHashes const& _us, TransactionHashes const& _ts) { Json::Value res = toJson(_bi); + res["uncles"] = Json::Value(Json::arrayValue); + for (h256 h: _us) + res["uncles"].append(toJS(h)); res["transactions"] = Json::Value(Json::arrayValue); for (h256 const& t: _ts) res["transactions"].append(toJS(t)); @@ -394,7 +402,7 @@ string WebThreeStubServerBase::eth_getCode(string const& _address, string const& { try { - return toJS(client()->codeAt(jsToAddress(_address), toBlockNumber(_blockNumber))); + return toJS(client()->codeAt(jsToAddress(_address), toBlockNumber(_blockNumber)), 1); } catch (...) { @@ -505,9 +513,9 @@ Json::Value WebThreeStubServerBase::eth_getBlockByHash(string const& _blockHash, { auto h = jsToFixed<32>(_blockHash); if (_includeTransactions) - return toJson(client()->blockInfo(h), client()->transactions(h)); + return toJson(client()->blockInfo(h), client()->uncleHashes(h), client()->transactions(h)); else - return toJson(client()->blockInfo(h), client()->transactionHashes(h)); + return toJson(client()->blockInfo(h), client()->uncleHashes(h), client()->transactionHashes(h)); } catch (...) { @@ -521,9 +529,9 @@ Json::Value WebThreeStubServerBase::eth_getBlockByNumber(string const& _blockNum { auto h = client()->hashFromNumber(jsToInt(_blockNumber)); if (_includeTransactions) - return toJson(client()->blockInfo(h), client()->transactions(h)); + return toJson(client()->blockInfo(h), client()->uncleHashes(h), client()->transactions(h)); else - return toJson(client()->blockInfo(h), client()->transactionHashes(h)); + return toJson(client()->blockInfo(h), client()->uncleHashes(h), client()->transactionHashes(h)); } catch (...) {