Skip to content

Commit 7b9061f

Browse files
committed
fix: only mark as paid if really paid
1 parent f74d18b commit 7b9061f

File tree

1 file changed

+13
-21
lines changed
  • packages/indexer-common/src/indexing-fees

1 file changed

+13
-21
lines changed

packages/indexer-common/src/indexing-fees/dips.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@ export class DipsManager {
9797
},
9898
})
9999
for (const agreement of outstandingAgreements) {
100-
if (agreement.last_allocation_id) {
101-
await this.tryCollectPayment(agreement)
102-
} else {
103-
// This should never happen as we check for this in the query
104-
this.logger.error(`Agreement ${agreement.id} has no last allocation id`)
105-
}
100+
await this.tryCollectPayment(agreement)
106101
}
107102
}
108103
async tryCollectPayment(agreement: IndexingAgreement) {
@@ -145,28 +140,25 @@ export class DipsManager {
145140
)
146141
}
147142
await this.network.queryFeeModels.scalarTapReceipts.create(tapReceipt)
143+
// Mark the agreement as having had a payment collected
144+
await this.models.IndexingAgreement.update(
145+
{
146+
last_payment_collected_at: new Date(),
147+
},
148+
{
149+
where: {
150+
id: agreement.id,
151+
},
152+
},
153+
)
148154
} else {
149-
this.logger.error(`Error collecting payment for agreement ${agreement.id}`, {
150-
error: response.status,
151-
})
155+
throw new Error(`Payment request not accepted: ${response.status}`)
152156
}
153157
} catch (error) {
154158
this.logger.error(`Error collecting payment for agreement ${agreement.id}`, {
155159
error,
156160
})
157161
}
158-
159-
// Mark the agreement as having had a payment collected
160-
await this.models.IndexingAgreement.update(
161-
{
162-
last_payment_collected_at: new Date(),
163-
},
164-
{
165-
where: {
166-
id: agreement.id,
167-
},
168-
},
169-
)
170162
}
171163
async ensureAgreementRules() {
172164
if (!this.parent) {

0 commit comments

Comments
 (0)