Skip to content

Commit

Permalink
rpcdaemon: fix serialization of "to" field as JSON null in Receipt (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lupin012 authored Aug 11, 2023
1 parent ad13f74 commit 8d95690
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions silkworm/silkrpc/json/receipt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include <silkworm/core/common/util.hpp>
#include <silkworm/infra/common/log.hpp>
#include <silkworm/silkrpc/common/compatibility.hpp>
#include <silkworm/silkrpc/common/util.hpp>

#include "types.hpp"
Expand All @@ -31,15 +30,10 @@ void to_json(nlohmann::json& json, const Receipt& receipt) {
json["transactionHash"] = receipt.tx_hash;
json["transactionIndex"] = to_quantity(receipt.tx_index);
json["from"] = receipt.from.value_or(evmc::address{});
// Erigon currently at 2.48.1 returns zero address if to field is missing
if (compatibility::is_erigon_json_api_compatibility_required()) {
json["to"] = receipt.to.value_or(evmc::address{});
if (receipt.to) {
json["to"] = *receipt.to;
} else {
if (receipt.to) {
json["to"] = *receipt.to;
} else {
json["to"] = nlohmann::json{};
}
json["to"] = nlohmann::json{};
}
json["type"] = to_quantity(receipt.type ? receipt.type.value() : 0);
json["gasUsed"] = to_quantity(receipt.gas_used);
Expand Down

0 comments on commit 8d95690

Please sign in to comment.