Skip to content

Commit

Permalink
Merge pull request #1586 from zmcNotafraid/snapshot-erc721token
Browse files Browse the repository at this point in the history
 feat: snapshot erc721 token and return owner address
  • Loading branch information
zmcNotafraid authored Mar 21, 2024
2 parents 8517427 + f0cbb95 commit cd5a3e3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/godwoken_explorer/token_transfer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,21 @@ defmodule GodwokenExplorer.TokenTransfer do
end
end

def snapshot_erc721_token(token_contract_address_hash, start_block_number, end_block_number) do
from(tt in TokenTransfer,
where:
tt.token_contract_address_hash == ^token_contract_address_hash and
tt.block_number >= ^start_block_number and tt.block_number <= ^end_block_number,
select: %{
address_hash: fragment("'0x' || encode(?, 'hex')", tt.to_address_hash),
token_id: tt.token_id
},
distinct: tt.token_id,
order_by: [desc: tt.block_number]
)
|> Repo.all()
end

defp parse_json_result(paginate_result, init_query) do
if paginate_result.total_entries != 0 do
query =
Expand Down

0 comments on commit cd5a3e3

Please sign in to comment.