Merge pull request #3551 from poanetwork/vb-fix-output-of-tuple-type

Fix contract's method's output of tuple type
pull/3557/head
Victor Baranov 4 years ago committed by GitHub
commit 0fa1504563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex

@ -5,6 +5,7 @@
- [#3540](https://github.com/poanetwork/blockscout/pull/3540) - Apply DarkForest custom theme to NFT instances
### Fixes
- [#3551](https://github.com/poanetwork/blockscout/pull/3551) - Fix contract's method's output of tuple type
### Chore
- [#3540](https://github.com/poanetwork/blockscout/pull/3540), [#3545](https://github.com/poanetwork/blockscout/pull/3545) - Support different versions of DarkForest (0.4 - 0.5)

@ -48,12 +48,16 @@ defmodule BlockScoutWeb.SmartContractView do
end
def values(values, type) when is_list(values) and type == "tuple[]" do
array_from_tuple = tupple_to_array(values)
array_from_tuple = tuple_array_to_array(values)
array_from_tuple
|> Enum.join(", ")
end
def values(value, _type) when is_tuple(value) do
tuple_to_array(value)
end
def values(value, type) when type in ["address", "address payable"] do
{:ok, address} = Explorer.Chain.Hash.Address.cast(value)
to_string(address)
@ -62,14 +66,18 @@ defmodule BlockScoutWeb.SmartContractView do
def values(values, _) when is_list(values), do: Enum.join(values, ",")
def values(value, _), do: value
defp tupple_to_array(values) do
defp tuple_array_to_array(values) do
values
|> Enum.map(fn value ->
tuple_to_array(value)
end)
end
defp tuple_to_array(value) do
value
|> Tuple.to_list()
|> Enum.map(&binary_to_utf_string(&1))
|> Enum.join(",")
end)
end
defp binary_to_utf_string(item) do

Loading…
Cancel
Save