|
|
|
@ -2933,9 +2933,21 @@ defmodule Explorer.Chain do |
|
|
|
|
} = transaction |
|
|
|
|
) do |
|
|
|
|
zero_wei = %Wei{value: Decimal.new(0)} |
|
|
|
|
result = find_token_transfer_type(transaction, input, value) |
|
|
|
|
|
|
|
|
|
if is_nil(result) && Enum.count(transaction.token_transfers) > 0 && value == zero_wei, |
|
|
|
|
do: :token_transfer, |
|
|
|
|
else: result |
|
|
|
|
rescue |
|
|
|
|
_ -> nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def transaction_token_transfer_type(_), do: nil |
|
|
|
|
|
|
|
|
|
defp find_token_transfer_type(transaction, input, value) do |
|
|
|
|
zero_wei = %Wei{value: Decimal.new(0)} |
|
|
|
|
|
|
|
|
|
# https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/ERC721.sol#L35 |
|
|
|
|
result = |
|
|
|
|
case {to_string(input), value} do |
|
|
|
|
# transferFrom(address,address,uint256) |
|
|
|
|
{"0x23b872dd" <> params, ^zero_wei} -> |
|
|
|
@ -2971,20 +2983,11 @@ defmodule Explorer.Chain do |
|
|
|
|
|
|
|
|
|
find_erc721_or_erc20_token_transfer(transaction.token_transfers, {address, decimal_value}) |
|
|
|
|
|
|
|
|
|
{_params, ^zero_wei} -> |
|
|
|
|
if Enum.count(transaction.token_transfers) > 0, do: :token_transfer |
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
|
nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if is_nil(result) && Enum.count(transaction.token_transfers) > 0, do: :token_transfer, else: result |
|
|
|
|
rescue |
|
|
|
|
_ -> nil |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def transaction_token_transfer_type(_), do: nil |
|
|
|
|
|
|
|
|
|
defp find_erc721_token_transfer(token_transfers, {from_address, to_address}) do |
|
|
|
|
token_transfer = |
|
|
|
|
Enum.find(token_transfers, fn token_transfer -> |
|
|
|
|