|
|
|
@ -51,9 +51,9 @@ defmodule Indexer.Fetcher.TokenInstance do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@impl BufferedTask |
|
|
|
|
def run([%{contract_address_hash: hash, token_ids: token_ids}], _json_rpc_named_arguments) do |
|
|
|
|
Enum.each(token_ids, &fetch_instance(hash, &1)) |
|
|
|
|
update_current_token_balances(hash, token_ids) |
|
|
|
|
def run([%{contract_address_hash: hash, token_id: token_id}], _json_rpc_named_arguments) do |
|
|
|
|
fetch_instance(hash, token_id) |
|
|
|
|
update_current_token_balances(hash, token_id) |
|
|
|
|
|
|
|
|
|
:ok |
|
|
|
|
end |
|
|
|
@ -92,16 +92,17 @@ defmodule Indexer.Fetcher.TokenInstance do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp update_current_token_balances(token_contract_address_hash, token_ids) do |
|
|
|
|
token_ids |
|
|
|
|
|> Enum.map(&instance_owner_request(token_contract_address_hash, &1)) |
|
|
|
|
defp update_current_token_balances(token_contract_address_hash, token_id) do |
|
|
|
|
token_id |
|
|
|
|
|> instance_owner_request(token_contract_address_hash) |
|
|
|
|
|> List.wrap() |
|
|
|
|
|> InstanceOwnerReader.get_owner_of() |
|
|
|
|
|> Enum.map(¤t_token_balances_import_params/1) |
|
|
|
|
|> all_import_params() |
|
|
|
|
|> Chain.import() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp instance_owner_request(token_contract_address_hash, token_id) do |
|
|
|
|
defp instance_owner_request(token_id, token_contract_address_hash) do |
|
|
|
|
%{ |
|
|
|
|
token_contract_address_hash: to_string(token_contract_address_hash), |
|
|
|
|
token_id: Decimal.to_integer(token_id) |
|
|
|
@ -157,11 +158,14 @@ defmodule Indexer.Fetcher.TokenInstance do |
|
|
|
|
token_transfers |
|
|
|
|
|> Enum.reject(fn token_transfer -> is_nil(token_transfer.token_ids) end) |
|
|
|
|
|> Enum.map(fn token_transfer -> |
|
|
|
|
Enum.map(token_transfer.token_ids, fn token_id -> |
|
|
|
|
%{ |
|
|
|
|
contract_address_hash: token_transfer.token_contract_address_hash, |
|
|
|
|
token_ids: token_transfer.token_ids |
|
|
|
|
token_id: token_id |
|
|
|
|
} |
|
|
|
|
end) |
|
|
|
|
end) |
|
|
|
|
|> List.flatten() |
|
|
|
|
|> Enum.uniq() |
|
|
|
|
|
|
|
|
|
BufferedTask.buffer(__MODULE__, data) |
|
|
|
|