File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,13 @@ export type GetLogsPaginatedParameters<
3030 pageSize : bigint ;
3131} ;
3232
33+ /**
34+ * Get logs in pages, to avoid rate limiting
35+ * Must be used with client that has batching enabled
36+ * @param client
37+ * @param params
38+ * @returns
39+ */
3340export async function getLogsPaginated <
3441 chain extends Chain | undefined ,
3542 const abiEvent extends AbiEvent | undefined = undefined ,
@@ -79,7 +86,14 @@ export async function getLogsPaginated<
7986 ) ,
8087 ) ,
8188 ) ;
82- const events = responses . flat ( ) ;
8389
84- return events ;
90+ return responses . flat ( ) . sort ( ( a , b ) => {
91+ if ( a . blockNumber === b . blockNumber ) {
92+ return a . logIndex - b . logIndex ;
93+ } else if ( a . blockNumber < b . blockNumber ) {
94+ return - 1 ;
95+ } else {
96+ return 1 ;
97+ }
98+ } ) ;
8599}
You can’t perform that action at this time.
0 commit comments