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

Commit

Permalink
fix events call with continuation token (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana authored Jan 4, 2024
1 parent a3eb94d commit 36d4029
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
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

0 comments on commit 36d4029

Please sign in to comment.