|
|
@ -11,30 +11,23 @@ defmodule Indexer.Transform.AddressTokenBalances do |
|
|
|
|
|
|
|
|
|
|
|
defp reducer({:token_transfers_params, token_transfers_params}, initial) when is_list(token_transfers_params) do |
|
|
|
defp reducer({:token_transfers_params, token_transfers_params}, initial) when is_list(token_transfers_params) do |
|
|
|
token_transfers_params |
|
|
|
token_transfers_params |
|
|
|
|> ignore_burn_address_transfers_for_token_erc_721 |
|
|
|
|> ignore_burn_address_transfers_for_token_erc_721() |
|
|
|
|> Enum.reduce(initial, fn %{ |
|
|
|
|> Enum.reduce(initial, fn %{ |
|
|
|
block_number: block_number, |
|
|
|
block_number: block_number, |
|
|
|
from_address_hash: from_address_hash, |
|
|
|
from_address_hash: from_address_hash, |
|
|
|
to_address_hash: to_address_hash, |
|
|
|
to_address_hash: to_address_hash, |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
token_id: token_id, |
|
|
|
token_ids: token_ids, |
|
|
|
token_type: token_type |
|
|
|
token_type: token_type |
|
|
|
} = params, |
|
|
|
}, |
|
|
|
acc |
|
|
|
acc |
|
|
|
when is_integer(block_number) and is_binary(from_address_hash) and |
|
|
|
when is_integer(block_number) and is_binary(from_address_hash) and |
|
|
|
is_binary(to_address_hash) and is_binary(token_contract_address_hash) -> |
|
|
|
is_binary(to_address_hash) and is_binary(token_contract_address_hash) -> |
|
|
|
if params[:token_ids] && token_type == "ERC-1155" do |
|
|
|
Enum.reduce(token_ids || [nil], acc, fn id, sub_acc -> |
|
|
|
params[:token_ids] |
|
|
|
|
|
|
|
|> Enum.reduce(acc, fn id, sub_acc -> |
|
|
|
|
|
|
|
sub_acc |
|
|
|
sub_acc |
|
|
|
|> add_token_balance_address(from_address_hash, token_contract_address_hash, id, token_type, block_number) |
|
|
|
|> add_token_balance_address(from_address_hash, token_contract_address_hash, id, token_type, block_number) |
|
|
|
|> add_token_balance_address(to_address_hash, token_contract_address_hash, id, token_type, block_number) |
|
|
|
|> add_token_balance_address(to_address_hash, token_contract_address_hash, id, token_type, block_number) |
|
|
|
end) |
|
|
|
end) |
|
|
|
else |
|
|
|
|
|
|
|
acc |
|
|
|
|
|
|
|
|> add_token_balance_address(from_address_hash, token_contract_address_hash, token_id, token_type, block_number) |
|
|
|
|
|
|
|
|> add_token_balance_address(to_address_hash, token_contract_address_hash, token_id, token_type, block_number) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
end) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|