Skip to content

Commit bd19b24

Browse files
committed
fix: remove contract pre-check from DIPs collection
1 parent aae03f5 commit bd19b24

2 files changed

Lines changed: 2 additions & 65 deletions

File tree

packages/indexer-common/src/indexing-fees/__tests__/collect-agreements.test.ts

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,10 @@ const logger = {
1414
const mockQuery = jest.fn()
1515
const mockNetworkSubgraph = { query: mockQuery } as any
1616

17-
const mockGetCollectionInfo = jest.fn()
1817
const mockCollectEstimateGas = jest.fn()
1918
const mockCollect = jest.fn()
20-
const mockGetAgreement = jest.fn()
2119

2220
const mockContracts = {
23-
RecurringCollector: {
24-
getCollectionInfo: mockGetCollectionInfo,
25-
getAgreement: mockGetAgreement,
26-
},
2721
SubgraphService: {
2822
collect: Object.assign(mockCollect, {
2923
estimateGas: mockCollectEstimateGas,
@@ -40,6 +34,7 @@ const mockGraphNode = {
4034
entityCount: jest.fn(),
4135
proofOfIndexing: jest.fn(),
4236
blockHashFromNumber: jest.fn(),
37+
subgraphFeatures: jest.fn().mockResolvedValue({ network: 'mainnet' }),
4338
} as any
4439

4540
const mockNetwork = {
@@ -86,24 +81,6 @@ function makeReadyAgreement(id = '0x00000000000000000000000000000001') {
8681
}
8782
}
8883

89-
function makeAgreementData() {
90-
return {
91-
dataService: '0x0000',
92-
payer: '0x0000',
93-
serviceProvider: '0x0000',
94-
acceptedAt: 1000n,
95-
lastCollectionAt: 0n,
96-
endsAt: 9999999999n,
97-
maxInitialTokens: 1000000n,
98-
maxOngoingTokensPerSecond: 100n,
99-
minSecondsPerCollection: 3600,
100-
maxSecondsPerCollection: 86400,
101-
updateNonce: 0,
102-
canceledAt: 0n,
103-
state: 1,
104-
}
105-
}
106-
10784
describe('DipsManager.collectAgreementPayments', () => {
10885
beforeEach(() => {
10986
jest.clearAllMocks()
@@ -132,32 +109,14 @@ describe('DipsManager.collectAgreementPayments', () => {
132109
const dm = createDipsManager()
133110
await dm.collectAgreementPayments()
134111

135-
// Should not even call getAgreement since tracker skips it
136-
expect(mockGetAgreement).not.toHaveBeenCalled()
137-
expect(mockExecuteTransaction).not.toHaveBeenCalled()
138-
})
139-
140-
test('skips agreement when getCollectionInfo says not collectable', async () => {
141-
mockQuery.mockResolvedValueOnce({
142-
data: { indexingAgreements: [makeReadyAgreement()] },
143-
})
144-
145-
mockGetAgreement.mockResolvedValueOnce(makeAgreementData())
146-
mockGetCollectionInfo.mockResolvedValueOnce([false, 0n, 1])
147-
148-
const dm = createDipsManager()
149-
await dm.collectAgreementPayments()
150-
151112
expect(mockExecuteTransaction).not.toHaveBeenCalled()
152113
})
153114

154-
test('collects payment when agreement is ready and collectable', async () => {
115+
test('collects payment when agreement is ready', async () => {
155116
mockQuery.mockResolvedValueOnce({
156117
data: { indexingAgreements: [makeReadyAgreement()] },
157118
})
158119

159-
mockGetAgreement.mockResolvedValueOnce(makeAgreementData())
160-
mockGetCollectionInfo.mockResolvedValueOnce([true, 7200n, 0])
161120
mockGraphNode.entityCount.mockResolvedValueOnce([500])
162121
mockGraphNode.blockHashFromNumber.mockResolvedValueOnce('0x' + 'ab'.repeat(32))
163122
mockGraphNode.proofOfIndexing.mockResolvedValueOnce('0x' + 'cd'.repeat(32))
@@ -174,8 +133,6 @@ describe('DipsManager.collectAgreementPayments', () => {
174133
.mockResolvedValueOnce({ data: { indexingAgreements: [makeReadyAgreement()] } })
175134
.mockResolvedValueOnce({ data: { indexingAgreements: [makeReadyAgreement()] } })
176135

177-
mockGetAgreement.mockResolvedValue(makeAgreementData())
178-
mockGetCollectionInfo.mockResolvedValue([true, 7200n, 0])
179136
mockGraphNode.entityCount.mockResolvedValue([500])
180137
mockGraphNode.blockHashFromNumber.mockResolvedValue('0x' + 'ab'.repeat(32))
181138
mockGraphNode.proofOfIndexing.mockResolvedValue('0x' + 'cd'.repeat(32))
@@ -198,8 +155,6 @@ describe('DipsManager.collectAgreementPayments', () => {
198155
data: { indexingAgreements: [makeReadyAgreement()] },
199156
})
200157

201-
mockGetAgreement.mockResolvedValueOnce(makeAgreementData())
202-
mockGetCollectionInfo.mockResolvedValueOnce([true, 7200n, 0])
203158
mockGraphNode.entityCount.mockResolvedValueOnce([500])
204159
mockGraphNode.blockHashFromNumber.mockResolvedValueOnce('0x' + 'ab'.repeat(32))
205160
mockGraphNode.proofOfIndexing.mockResolvedValueOnce(null) // POI unavailable
@@ -218,8 +173,6 @@ describe('DipsManager.collectAgreementPayments', () => {
218173
data: { indexingAgreements: [makeReadyAgreement()] },
219174
})
220175

221-
mockGetAgreement.mockResolvedValueOnce(makeAgreementData())
222-
mockGetCollectionInfo.mockResolvedValueOnce([true, 7200n, 0])
223176
mockGraphNode.entityCount.mockResolvedValueOnce([500])
224177
mockGraphNode.blockHashFromNumber.mockResolvedValueOnce('0x' + 'ab'.repeat(32))
225178
mockGraphNode.proofOfIndexing.mockResolvedValueOnce('0x' + 'cd'.repeat(32))

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -552,21 +552,6 @@ export class DipsManager {
552552
blockNumber: number,
553553
logger: Logger,
554554
): Promise<void> {
555-
const agreementData = await this.network.contracts.RecurringCollector.getAgreement(
556-
agreement.id,
557-
)
558-
559-
const [isCollectable, collectionSeconds, reason] =
560-
await this.network.contracts.RecurringCollector.getCollectionInfo(agreementData)
561-
562-
if (!isCollectable) {
563-
logger.debug('Agreement not collectable', {
564-
agreementId: agreement.id,
565-
reason: Number(reason),
566-
})
567-
return
568-
}
569-
570555
const deploymentId = new SubgraphDeploymentID(agreement.subgraphDeploymentId)
571556
const entityCounts = await this.graphNode.entityCount([deploymentId])
572557
const entities = entityCounts[0]
@@ -632,7 +617,6 @@ export class DipsManager {
632617
agreementId: agreement.id,
633618
txHash: receipt.hash,
634619
deployment: deploymentId.ipfsHash,
635-
collectionSeconds: collectionSeconds.toString(),
636620
entities,
637621
})
638622
}

0 commit comments

Comments
 (0)