@ -2954,6 +2954,29 @@ defmodule Explorer.Chain do
Repo . stream_reduce ( query , initial , reducer )
end
def token_transfers_without_instances ( token_transfers ) do
token_contract_address_hashes =
token_transfers
|> Enum . map ( fn token_transfer -> token_transfer . token_contract_address_hash end )
|> Enum . uniq ( )
query =
from (
token_transfer in TokenTransfer ,
inner_join : token in Token ,
on : token . contract_address_hash == token_transfer . token_contract_address_hash ,
left_join : instance in Instance ,
on : token_transfer . token_id == instance . token_id ,
where :
token . type == ^ " ERC-721 " and is_nil ( instance . token_id ) and
token_transfer . token_contract_address_hash in ^ token_contract_address_hashes ,
distinct : [ token_transfer . token_contract_address_hash , token_transfer . token_id ] ,
select : %{ contract_address_hash : token_transfer . token_contract_address_hash , token_id : token_transfer . token_id }
)
Repo . all ( query )
end
@doc """
Streams a list of token contract addresses that have been cataloged .
"""