Merge pull request #3359 from poanetwork/vb-address-output-fix

Contract reader: Address output fix
pull/3365/head
Victor Baranov 4 years ago committed by GitHub
commit f66e21691b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 8
      apps/explorer/lib/explorer/smart_contract/reader.ex
  3. 3
      apps/explorer/test/explorer/smart_contract/reader_test.exs

@ -1,7 +1,7 @@
## Current ## Current
### Features ### Features
- [#2292](https://github.com/poanetwork/blockscout/pull/2292), [#3356](https://github.com/poanetwork/blockscout/pull/3356), [#3360](https://github.com/poanetwork/blockscout/pull/3360) - Add Web UI for POSDAO Staking DApp - [#2292](https://github.com/poanetwork/blockscout/pull/2292), [#3356](https://github.com/poanetwork/blockscout/pull/3356), [#3359](https://github.com/poanetwork/blockscout/pull/3359), [#3360](https://github.com/poanetwork/blockscout/pull/3360) - Add Web UI for POSDAO Staking DApp
- [#3354](https://github.com/poanetwork/blockscout/pull/3354) - Tx hash in EOA coin balance history - [#3354](https://github.com/poanetwork/blockscout/pull/3354) - Tx hash in EOA coin balance history
- [#3333](https://github.com/poanetwork/blockscout/pull/3333), [#3337](https://github.com/poanetwork/blockscout/pull/3337) - Dark forest contract custom theme - [#3333](https://github.com/poanetwork/blockscout/pull/3333), [#3337](https://github.com/poanetwork/blockscout/pull/3337) - Dark forest contract custom theme
- [#3330](https://github.com/poanetwork/blockscout/pull/3330) - Caching of address transactions counter, remove query 10_000 rows limit - [#3330](https://github.com/poanetwork/blockscout/pull/3330) - Caching of address transactions counter, remove query 10_000 rows limit

@ -415,19 +415,19 @@ defmodule Explorer.SmartContract.Reader do
end end
defp new_value(%{"type" => "address"} = output, [value], _index) do defp new_value(%{"type" => "address"} = output, [value], _index) do
Map.put_new(output, "value", bytes_to_string(value)) Map.put_new(output, "value", value)
end end
defp new_value(%{"type" => :address} = output, [value], _index) do defp new_value(%{"type" => :address} = output, [value], _index) do
Map.put_new(output, "value", bytes_to_string(value)) Map.put_new(output, "value", value)
end end
defp new_value(%{"type" => "address"} = output, values, index) do defp new_value(%{"type" => "address"} = output, values, index) do
Map.put_new(output, "value", bytes_to_string(Enum.at(values, index))) Map.put_new(output, "value", Enum.at(values, index))
end end
defp new_value(%{"type" => :address} = output, values, index) do defp new_value(%{"type" => :address} = output, values, index) do
Map.put_new(output, "value", bytes_to_string(Enum.at(values, index))) Map.put_new(output, "value", Enum.at(values, index))
end end
defp new_value(%{"type" => "bytes" <> number_rest} = output, values, index) do defp new_value(%{"type" => "bytes" <> number_rest} = output, values, index) do

@ -302,8 +302,7 @@ defmodule Explorer.SmartContract.ReaderTest do
describe "link_outputs_and_values/2" do describe "link_outputs_and_values/2" do
test "links the ABI outputs with the values retrieved from the blockchain" do test "links the ABI outputs with the values retrieved from the blockchain" do
blockchain_values = %{ blockchain_values = %{
"getOwner" => "getOwner" => {:ok, "0x6937cb25eb54bc013b9c13c47ab38eb63edd1493"}
{:ok, <<105, 55, 203, 37, 235, 84, 188, 1, 59, 156, 19, 196, 122, 179, 142, 182, 62, 221, 20, 147>>}
} }
outputs = [%{"name" => "", "type" => "address"}] outputs = [%{"name" => "", "type" => "address"}]

Loading…
Cancel
Save