From b8841d9aa8057980cc464122794e3a44251af919 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 28 Aug 2020 21:21:04 +0300 Subject: [PATCH] Fix encoding of address output if function input exists --- CHANGELOG.md | 1 + apps/explorer/lib/explorer/smart_contract/reader.ex | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c4b9bb68..89e0ba8279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#3261](https://github.com/poanetwork/blockscout/pull/3261) - Bridged tokens table ### Fixes +- [#3264](https://github.com/poanetwork/blockscout/pull/3264) - Fix encoding of address output if function input exists - [#3259](https://github.com/poanetwork/blockscout/pull/3259) - Contract interaction: array input type parsing fix - [#3257](https://github.com/poanetwork/blockscout/pull/3257) - Contracts read/write: method_id instead function_name as a key - [#3256](https://github.com/poanetwork/blockscout/pull/3256) - Fix for invisible validator address at block page and wrong alert text color at xDai diff --git a/apps/explorer/lib/explorer/smart_contract/reader.ex b/apps/explorer/lib/explorer/smart_contract/reader.ex index 6c1e6e27be..8d82b58f30 100644 --- a/apps/explorer/lib/explorer/smart_contract/reader.ex +++ b/apps/explorer/lib/explorer/smart_contract/reader.ex @@ -418,10 +418,18 @@ defmodule Explorer.SmartContract.Reader do Map.put_new(output, "value", bytes_to_string(value)) end + defp new_value(%{"type" => :address} = output, [value], _index) do + Map.put_new(output, "value", bytes_to_string(value)) + end + defp new_value(%{"type" => "address"} = output, values, index) do Map.put_new(output, "value", bytes_to_string(Enum.at(values, index))) end + defp new_value(%{"type" => :address} = output, values, index) do + Map.put_new(output, "value", bytes_to_string(Enum.at(values, index))) + end + defp new_value(%{"type" => "bytes" <> number_rest} = output, values, index) do if String.contains?(number_rest, "[]") do values_array = Enum.at(values, index)