Skip to content

Commit

Permalink
fix: handle case where contract is not verified
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Nov 20, 2018
1 parent c85e9e9 commit ee3c1b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
</tr>
<% end %>
</table>
<% _ -> %>
<%= nil %>
<% end %>

</dd>
Expand Down
6 changes: 3 additions & 3 deletions apps/explorer/lib/explorer/chain/log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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} <-
Expand Down

0 comments on commit ee3c1b3

Please sign in to comment.