|
|
|
@ -3,6 +3,8 @@ defmodule Indexer.Address.TokenBalances do |
|
|
|
|
Extracts `Explorer.Address.TokenBalance` params from other schema's params. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
@burn_address "0x0000000000000000000000000000000000000000" |
|
|
|
|
|
|
|
|
|
def params_set(%{} = import_options) do |
|
|
|
|
Enum.reduce(import_options, MapSet.new(), &reducer/2) |
|
|
|
|
end |
|
|
|
@ -20,16 +22,8 @@ defmodule Indexer.Address.TokenBalances do |
|
|
|
|
when is_integer(block_number) and is_binary(from_address_hash) and |
|
|
|
|
is_binary(to_address_hash) and is_binary(token_contract_address_hash) -> |
|
|
|
|
acc |
|
|
|
|
|> MapSet.put(%{ |
|
|
|
|
address_hash: from_address_hash, |
|
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
|
block_number: block_number |
|
|
|
|
}) |
|
|
|
|
|> MapSet.put(%{ |
|
|
|
|
address_hash: to_address_hash, |
|
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
|
block_number: block_number |
|
|
|
|
}) |
|
|
|
|
|> add_token_balance_address(from_address_hash, token_contract_address_hash, block_number) |
|
|
|
|
|> add_token_balance_address(to_address_hash, token_contract_address_hash, block_number) |
|
|
|
|
end) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -37,7 +31,17 @@ defmodule Indexer.Address.TokenBalances do |
|
|
|
|
Enum.filter(token_transfers_params, &do_filter_burn_address/1) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def do_filter_burn_address(%{to_address_hash: "0x0000000000000000000000000000000000000000", token_type: "ERC-721"}) do |
|
|
|
|
defp add_token_balance_address(map_set, unquote(@burn_address), _, _), do: map_set |
|
|
|
|
|
|
|
|
|
defp add_token_balance_address(map_set, address, token_contract_address, block_number) do |
|
|
|
|
MapSet.put(map_set, %{ |
|
|
|
|
address_hash: address, |
|
|
|
|
token_contract_address_hash: token_contract_address, |
|
|
|
|
block_number: block_number |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def do_filter_burn_address(%{to_address_hash: unquote(@burn_address), token_type: "ERC-721"}) do |
|
|
|
|
false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|