fix: handle case where contract is not verified

pull/1119/head
zachdaniel 6 years ago
parent c85e9e9e91
commit ee3c1b3d34
  1. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
  2. 6
      apps/explorer/lib/explorer/chain/log.ex

@ -71,6 +71,8 @@
</tr>
<% end %>
</table>
<% _ -> %>
<%= nil %>
<% end %>
</dd>

@ -104,14 +104,14 @@ defmodule Explorer.Chain.Log do
@doc """
Decode transaction log data.
"""
def decode(log, transaction) do
abi = transaction.to_address.smart_contract.abi
def decode(log, %Transaction{to_address: nil}), do: {:error, :no_to_address}
def decode(log, %Transaction{to_address: %{smart_contract: %{abi: abi}}}) when not is_nil(abi) do
with {:ok, selector, mapping} <- find_and_decode(abi, log),
identifier <- Base.encode16(selector.method_id, case: :lower),
text <- function_call(selector.function, mapping),
do: {:ok, identifier, text, mapping}
end
def decode(_log, _transaction), do: {:error, :contract_not_verified}
defp find_and_decode(abi, log) do
with {selector, mapping} <-

Loading…
Cancel
Save