Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

fix events call with continuation token #394

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ npm-debug.log
# Ignore docker volumes
.volumes

# Ignore .env
.env

# Ignore juno files
juno_files

Expand Down
24 changes: 12 additions & 12 deletions lib/starknet_explorer/events.ex
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@ defmodule StarknetExplorer.Events do
Enum.flat_map_reduce(1..1000, nil, fn _, acc ->
if acc == "last_page_reached" do
{:halt, acc}
end

case try_fetch_next_page(block_hash, network, acc) do
{:ok, %{"events" => events, "continuation_token" => continuation_token}} ->
{events, continuation_token}

# when no continuation token is present, this means that we reached the end of the events.
{:ok, %{"events" => events}} ->
{events, "last_page_reached"}

_err ->
{:halt, acc}
else
case try_fetch_next_page(block_hash, network, acc) do
{:ok, %{"events" => events, "continuation_token" => continuation_token}} ->
{events, continuation_token}

# when no continuation token is present, this means that we reached the end of the events.
{:ok, %{"events" => events}} ->
{events, "last_page_reached"}

_err ->
{:halt, acc}
end
end
end)

Expand Down
Loading