From 8d95690e2ca7393619561ae69c0146e1630b5e4c Mon Sep 17 00:00:00 2001 From: lupin012 <58134934+lupin012@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:48:11 +0200 Subject: [PATCH] rpcdaemon: fix serialization of "to" field as JSON null in Receipt (#1443) --- silkworm/silkrpc/json/receipt.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/silkworm/silkrpc/json/receipt.cpp b/silkworm/silkrpc/json/receipt.cpp index a4e74fae4f..a220e26d77 100644 --- a/silkworm/silkrpc/json/receipt.cpp +++ b/silkworm/silkrpc/json/receipt.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include "types.hpp" @@ -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);