Skip to content

Commit

Permalink
chore: use updated cursor pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Jul 11, 2024
1 parent 85a737f commit 80fdbf4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,15 @@ async function getGatewayAddressRegistry(arIO: any): Promise<void> {
*/
const fetchAllGateways = async (): Promise<Record<WalletAddress, AoGateway>> => {
const gateways: Record<WalletAddress, AoGateway> = {};
let hasNextPage = true;
let page = 1;
while (hasNextPage) {
const response = await arIO.getGateways({ page });
let cursor;
do {
const response = await arIO.getGateways({ cursor });
for (const gateway of response.items) {
const { gatewayAddress, ...gatewayData } = gateway;
gateways[gatewayAddress] = gatewayData;
}
hasNextPage = response.hasNextPage;
page++;
}
cursor = response.nextCursor;
} while (cursor)
return gateways;
}

Expand Down

0 comments on commit 80fdbf4

Please sign in to comment.