Fix 500 response when ABI method was decoded as nil

pull/5051/head
nikitosing 3 years ago
parent 3e56f30056
commit ca53d552de
  1. 2
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 9
      apps/explorer/lib/explorer/smart_contract/reader.ex

@ -18,7 +18,7 @@ lib/phoenix/router.ex:402
lib/block_scout_web/views/layout_view.ex:145: 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:22
lib/explorer/smart_contract/reader.ex:430
lib/explorer/smart_contract/reader.ex:435
lib/indexer/fetcher/token_total_supply_on_demand.ex:16
lib/explorer/exchange_rates/source.ex:110
lib/explorer/exchange_rates/source.ex:113

@ -4,6 +4,7 @@
### Fixes
- [#5025](https://github.com/blockscout/blockscout/pull/5025) - Add standard input JSON files validation
- [#5051](https://github.com/blockscout/blockscout/pull/5051) - Fix 500 response when ABI method was parsed as nil
### Chore

@ -299,8 +299,13 @@ defmodule Explorer.SmartContract.Reader do
abi
|> Enum.map(fn method ->
parsed_method = [method] |> ABI.parse_specification() |> Enum.at(0)
method_id = Map.get(parsed_method, :method_id)
Map.put(method, "method_id", Base.encode16(method_id, case: :lower))
if is_map(parsed_method) do
method_id = Map.get(parsed_method, :method_id)
Map.put(method, "method_id", Base.encode16(method_id, case: :lower))
else
method
end
end)
end

Loading…
Cancel
Save