Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions packages/indexer-api/src/dtos/deposits.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const DepositsParams = s.object({
integratorId: s.optional(s.string()),
status: s.optional(s.enums(Object.values(entities.RelayStatus))),
depositType: s.optional(DepositType), // Filter by deposit type: "across" (V3FundsDeposited), "cctp" (DepositForBurn), or "oft" (OFTSent)
startBlock: s.optional(stringToInt),
endBlock: s.optional(stringToInt),
// some kind of pagination options, skip could be the start point
skip: s.optional(stringToInt),
// pagination limit, how many to return after the start, note we convert string to number
Expand Down
33 changes: 33 additions & 0 deletions packages/indexer-api/src/services/deposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,39 @@ export class DepositsService {
oftSentQueryBuilder.andWhere("1 = 0");
}

if (params.startBlock) {
fundsDepositedQueryBuilder.andWhere(
"deposit.blockNumber >= :startBlock",
{
startBlock: params.startBlock,
},
);
depositForBurnQueryBuilder.andWhere(
"depositForBurn.blockNumber >= :startBlock",
{
startBlock: params.startBlock,
},
);
oftSentQueryBuilder.andWhere("oftSent.blockNumber >= :startBlock", {
startBlock: params.startBlock,
});
}

if (params.endBlock) {
fundsDepositedQueryBuilder.andWhere("deposit.blockNumber <= :endBlock", {
endBlock: params.endBlock,
});
depositForBurnQueryBuilder.andWhere(
"depositForBurn.blockNumber <= :endBlock",
{
endBlock: params.endBlock,
},
);
oftSentQueryBuilder.andWhere("oftSent.blockNumber <= :endBlock", {
endBlock: params.endBlock,
});
}

// Calculate upper bound for fetching records from each query
// We fetch more than needed to ensure we have enough after sorting
const skip = params.skip || 0;
Expand Down