Merge pull request #3422 from poanetwork/vb-contract-tuple-reader

Fix contract reader: tuple type
pull/3424/head
Victor Baranov 4 years ago committed by GitHub
commit 14a0c32fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 17
      apps/explorer/lib/explorer/smart_contract/reader.ex

@ -18,7 +18,7 @@ lib/block_scout_web/views/layout_view.ex:145: The call 'Elixir.Poison.Parser':'p
lib/block_scout_web/views/layout_view.ex:237: The call 'Elixir.Poison.Parser':'parse!' lib/block_scout_web/views/layout_view.ex:237: The call 'Elixir.Poison.Parser':'parse!'
lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:21 lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:21
lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:22 lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:22
lib/explorer/smart_contract/reader.ex:330 lib/explorer/smart_contract/reader.ex:347
lib/indexer/fetcher/token_total_supply_on_demand.ex:16 lib/indexer/fetcher/token_total_supply_on_demand.ex:16
lib/explorer/exchange_rates/source.ex:104 lib/explorer/exchange_rates/source.ex:104
lib/explorer/exchange_rates/source.ex:107 lib/explorer/exchange_rates/source.ex:107

@ -15,6 +15,7 @@
### Fixes ### Fixes
- [#3422](https://github.com/poanetwork/blockscout/pull/3422) - Fix contract reader: tuple type
- [#3408](https://github.com/poanetwork/blockscout/pull/3408) - Fix (total) difficulty display - [#3408](https://github.com/poanetwork/blockscout/pull/3408) - Fix (total) difficulty display
- [#3401](https://github.com/poanetwork/blockscout/pull/3401) - Fix procedure of marking internal transactions as failed - [#3401](https://github.com/poanetwork/blockscout/pull/3401) - Fix procedure of marking internal transactions as failed
- [#3400](https://github.com/poanetwork/blockscout/pull/3400) - Add :last_block_number realtime chain event - [#3400](https://github.com/poanetwork/blockscout/pull/3400) - Add :last_block_number realtime chain event

@ -272,6 +272,9 @@ defmodule Explorer.SmartContract.Reader do
{:array, type} -> {:array, type} ->
format_input_type(type) <> "[]" format_input_type(type) <> "[]"
{:tuple, tuple} ->
format_tuple_type(tuple)
{type, size} -> {type, size} ->
Atom.to_string(type) <> Integer.to_string(size) Atom.to_string(type) <> Integer.to_string(size)
@ -280,6 +283,20 @@ defmodule Explorer.SmartContract.Reader do
end end
end end
defp format_tuple_type(tuple) do
tuple_types =
tuple
|> Enum.reduce(nil, fn tuple_item, acc ->
if acc do
acc <> "," <> format_input_type(tuple_item)
else
format_input_type(tuple_item)
end
end)
"tuple[#{tuple_types}]"
end
def fetch_current_value_from_blockchain(function, abi, contract_address_hash) do def fetch_current_value_from_blockchain(function, abi, contract_address_hash) do
values = values =
case function do case function do

Loading…
Cancel
Save