Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: snapshot erc721 token and return owner address #1586

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading