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