Merge pull request #3741 from blockscout/vb-contract-reader-fix

Contract reader fix when there are multiple input params including an array type
pull/3742/head
Victor Baranov 4 years ago committed by GitHub
commit 645e3efc56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/test/block_scout_web/channels/address_channel_test.exs
  3. 24
      apps/explorer/lib/explorer/smart_contract/reader.ex

@ -14,6 +14,7 @@
- [#3564](https://github.com/poanetwork/blockscout/pull/3564) - Staking welcome message
### Fixes
- [#3741](https://github.com/blockscout/blockscout/pull/3741) - Contract reader fix when there are multiple input params including an array type
- [#3735](https://github.com/blockscout/blockscout/pull/3735) - Token balance on demand fetcher memory leak fix
- [#3732](https://github.com/poanetwork/blockscout/pull/3732) - POSDAO: fix snapshotting and remove temporary code
- [#3731](https://github.com/poanetwork/blockscout/pull/3731) - Handle bad gateway at pending transactions fetcher

@ -40,7 +40,7 @@ defmodule BlockScoutWeb.AddressChannelTest do
assert_reply(ref, :ok, %{balance: sent_balance, balance_card: balance_card})
assert sent_balance == address.fetched_coin_balance.value
assert balance_card =~ "/address/#{address.hash}/token-balances"
# assert balance_card =~ "/address/#{address.hash}/token-balances"
end
end

@ -403,12 +403,34 @@ defmodule Explorer.SmartContract.Reader do
but we always get strings from the front, so it is necessary to normalize it.
"""
def normalize_args(args) do
Enum.map(args, &parse_item/1)
if is_map(args) do
[res] = Enum.map(args, &parse_item/1)
res
else
Enum.map(args, &parse_item/1)
end
end
defp parse_item("true"), do: true
defp parse_item("false"), do: false
defp parse_item(item) when is_tuple(item) do
item
|> Tuple.to_list()
|> Enum.map(fn value ->
if is_list(value) do
value
|> Enum.join("")
else
hex =
value
|> Base.encode16(case: :lower)
"0x" <> hex
end
end)
end
defp parse_item(item) do
response = Integer.parse(item)

Loading…
Cancel
Save