diff --git a/packages/indexer-common/src/allocations/query-fees.ts b/packages/indexer-common/src/allocations/query-fees.ts index 30cdfe319..5f9b96ffb 100644 --- a/packages/indexer-common/src/allocations/query-fees.ts +++ b/packages/indexer-common/src/allocations/query-fees.ts @@ -431,31 +431,33 @@ export class AllocationReceiptCollector implements ReceiptCollector { } startRAVProcessing() { + const notifyAndMapEligible = (signedRavs: ValidRavs) => { + if (signedRavs.belowThreshold.length > 0) { + const logger = this.logger.child({ function: 'startRAVProcessing()' }) + const totalValueGRT = formatGRT( + signedRavs.belowThreshold.reduce( + (total, signedRav) => + total.add(BigNumber.from(signedRav.rav.rav.valueAggregate)), + BigNumber.from(0), + ), + ) + logger.info(`Query RAVs below the redemption threshold`, { + hint: 'If you would like to redeem vouchers like this, reduce the voucher redemption threshold', + voucherRedemptionThreshold: formatGRT(this.voucherRedemptionThreshold), + belowThresholdCount: signedRavs.belowThreshold.length, + totalValueGRT, + allocations: signedRavs.belowThreshold.map( + (signedRav) => signedRav.rav.rav.allocationId, + ), + }) + } + return signedRavs.eligible + } + const pendingRAVs = this.getPendingRAVs() const signedRAVs = this.getSignedRAVsEventual(pendingRAVs) const eligibleRAVs = signedRAVs - .map((signedRavs: ValidRavs) => { - if (signedRavs.belowThreshold.length > 0) { - const logger = this.logger.child({ function: 'startRAVProcessing()' }) - const totalValueGRT = formatGRT( - signedRavs.belowThreshold.reduce( - (total, signedRav) => - total.add(BigNumber.from(signedRav.rav.rav.valueAggregate)), - BigNumber.from(0), - ), - ) - logger.info(`Query RAVs below the redemption threshold`, { - hint: 'If you would like to redeem vouchers like this, reduce the voucher redemption threshold', - voucherRedemptionThreshold: formatGRT(this.voucherRedemptionThreshold), - belowThresholdCount: signedRavs.belowThreshold.length, - totalValueGRT, - allocations: signedRavs.belowThreshold.map( - (signedRav) => signedRav.rav.rav.allocationId, - ), - }) - } - return signedRavs.eligible - }) + .map(notifyAndMapEligible) .filter((signedRavs) => signedRavs.length > 0) eligibleRAVs.pipe(async (ravs) => await this.submitRAVs(ravs)) }