Skip to content

Commit

Permalink
fix: only mark as paid if really paid
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranzav committed Feb 14, 2025
1 parent f74d18b commit 7b9061f
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions packages/indexer-common/src/indexing-fees/dips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,7 @@ export class DipsManager {
},
})
for (const agreement of outstandingAgreements) {
if (agreement.last_allocation_id) {
await this.tryCollectPayment(agreement)
} else {
// This should never happen as we check for this in the query
this.logger.error(`Agreement ${agreement.id} has no last allocation id`)
}
await this.tryCollectPayment(agreement)
}
}
async tryCollectPayment(agreement: IndexingAgreement) {
Expand Down Expand Up @@ -145,28 +140,25 @@ export class DipsManager {
)
}
await this.network.queryFeeModels.scalarTapReceipts.create(tapReceipt)
// Mark the agreement as having had a payment collected
await this.models.IndexingAgreement.update(
{
last_payment_collected_at: new Date(),
},
{
where: {
id: agreement.id,
},
},
)
} else {
this.logger.error(`Error collecting payment for agreement ${agreement.id}`, {
error: response.status,
})
throw new Error(`Payment request not accepted: ${response.status}`)
}
} catch (error) {
this.logger.error(`Error collecting payment for agreement ${agreement.id}`, {
error,
})
}

// Mark the agreement as having had a payment collected
await this.models.IndexingAgreement.update(
{
last_payment_collected_at: new Date(),
},
{
where: {
id: agreement.id,
},
},
)
}
async ensureAgreementRules() {
if (!this.parent) {
Expand Down

0 comments on commit 7b9061f

Please sign in to comment.