Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 49fda9d

Browse files
authored
[poap] fix: Add 'first' parameter to subgraph queries for complete batch processing (#1782)
* fix(poap): Add 'first' parameter to subgraph queries for complete batch processing - Fix incomplete results when processing large address batches - Add 'first: addresses.length' parameter to GraphQL queries - Create fresh query objects per batch to avoid mutation issues - Remove unused query object after implementing per-batch queries This resolves voting power calculation discrepancies where batch processing would return incomplete subgraph results, causing incorrect vote tallies in delegation scenarios. * remove stright forward comments
1 parent 3ec847a commit 49fda9d

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

src/strategies/poap/index.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,33 @@ export async function strategy(
5959
lowercaseAddressBatches.push(slice);
6060
}
6161

62-
const query = {
63-
accounts: {
64-
__args: {
65-
where: {
66-
id_in: [] as string[]
67-
}
68-
},
69-
id: true,
70-
tokens: {
71-
__args: {
72-
where: {
73-
event_in: options.eventIds
74-
}
75-
},
76-
id: true
77-
}
78-
}
79-
};
80-
if (snapshot !== 'latest') {
81-
query.accounts.__args['block'] = { number: snapshot };
82-
}
83-
8462
const results = await Promise.allSettled<{
8563
accounts: { id: string; tokens?: { id: string }[] }[];
8664
}>(
8765
lowercaseAddressBatches.map((addresses) => {
88-
query.accounts.__args.where.id_in = addresses;
89-
return subgraphRequest(POAP_API_ENDPOINT_URL[network], query);
66+
const batchQuery = {
67+
accounts: {
68+
__args: {
69+
first: addresses.length,
70+
where: {
71+
id_in: addresses
72+
}
73+
},
74+
id: true,
75+
tokens: {
76+
__args: {
77+
where: {
78+
event_in: options.eventIds
79+
}
80+
},
81+
id: true
82+
}
83+
}
84+
};
85+
if (snapshot !== 'latest') {
86+
batchQuery.accounts.__args['block'] = { number: snapshot };
87+
}
88+
return subgraphRequest(POAP_API_ENDPOINT_URL[network], batchQuery);
9089
})
9190
);
9291

0 commit comments

Comments
 (0)