Skip to content

Commit 7bc46c1

Browse files
MoonBoi9001claude
andcommitted
refactor(actions): rename COLLECT action type to PRESENT_POI
Rename the COLLECT action type to PRESENT_POI to better reflect its purpose and avoid confusion with TAP receipt collection. The action posts a POI on-chain to collect indexing rewards without closing the allocation. Changes: - Rename ActionType.COLLECT to ActionType.PRESENT_POI (value: 'present_poi') - Rename CollectAllocationResult to PresentPOIResult - Rename AllocationManager methods (prepareCollect -> preparePresentPOI, etc.) - Rename GraphQL resolver from collectAllocation to presentPOI - Update CLI help text and command usage - Update all related tests Note: Uses underscore (present_poi) instead of hyphen for GraphQL compatibility since GraphQL enum values cannot contain hyphens. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 51e4ca8 commit 7bc46c1

File tree

11 files changed

+79
-79
lines changed

11 files changed

+79
-79
lines changed

packages/indexer-cli/src/__tests__/actions.unit.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { ActionStatus, ActionType } from '@graphprotocol/indexer-common'
22
import { buildActionInput, validateActionInput } from '../actions'
33

44
describe('buildActionInput', () => {
5-
test('builds COLLECT action input with correct structure', async () => {
5+
test('builds PRESENT_POI action input with correct structure', async () => {
66
const result = await buildActionInput(
7-
ActionType.COLLECT,
7+
ActionType.PRESENT_POI,
88
{
99
targetDeployment: 'QmTest123',
1010
param1: '0xallocationId',
@@ -20,15 +20,15 @@ describe('buildActionInput', () => {
2020
0,
2121
'arbitrum-sepolia',
2222
)
23-
expect(result.type).toBe(ActionType.COLLECT)
23+
expect(result.type).toBe(ActionType.PRESENT_POI)
2424
expect(result.deploymentID).toBe('QmTest123')
2525
expect(result.allocationID).toBe('0xallocationId')
2626
expect(result.poiBlockNumber).toBe(12345)
2727
})
2828

29-
test('normalizes zero POI values for COLLECT', async () => {
29+
test('normalizes zero POI values for PRESENT_POI', async () => {
3030
const result = await buildActionInput(
31-
ActionType.COLLECT,
31+
ActionType.PRESENT_POI,
3232
{
3333
targetDeployment: 'QmTest123',
3434
param1: '0xallocationId',
@@ -54,9 +54,9 @@ describe('buildActionInput', () => {
5454
})
5555

5656
describe('validateActionInput', () => {
57-
test('validates COLLECT with required fields', async () => {
57+
test('validates PRESENT_POI with required fields', async () => {
5858
await expect(
59-
validateActionInput(ActionType.COLLECT, {
59+
validateActionInput(ActionType.PRESENT_POI, {
6060
targetDeployment: 'QmTest123',
6161
param1: '0xallocationId',
6262
param2: undefined,
@@ -68,10 +68,10 @@ describe('validateActionInput', () => {
6868
).resolves.not.toThrow()
6969
})
7070

71-
test('rejects COLLECT with invalid block number', async () => {
71+
test('rejects PRESENT_POI with invalid block number', async () => {
7272
await expect(
7373
buildActionInput(
74-
ActionType.COLLECT,
74+
ActionType.PRESENT_POI,
7575
{
7676
targetDeployment: 'QmTest123',
7777
param1: '0xallocationId',
@@ -90,9 +90,9 @@ describe('validateActionInput', () => {
9090
).rejects.toThrow('Invalid block number: not-a-number')
9191
})
9292

93-
test('rejects COLLECT missing allocationID', async () => {
93+
test('rejects PRESENT_POI missing allocationID', async () => {
9494
await expect(
95-
validateActionInput(ActionType.COLLECT, {
95+
validateActionInput(ActionType.PRESENT_POI, {
9696
targetDeployment: 'QmTest123',
9797
param1: undefined, // missing allocationID
9898
param2: undefined,

packages/indexer-cli/src/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export async function buildActionInput(
143143
isLegacy,
144144
}
145145
}
146-
case ActionType.COLLECT: {
147-
// collect <deploymentID> <allocationID> <poi> <force> <blockNumber> <publicPOI>
146+
case ActionType.PRESENT_POI: {
147+
// present_poi <deploymentID> <allocationID> <poi> <force> <blockNumber> <publicPOI>
148148
const { poi, publicPOI, poiBlockNumber } = normalizePOIParams(
149149
actionParams.param2,
150150
actionParams.param5,
@@ -184,7 +184,7 @@ export async function validateActionInput(
184184
case ActionType.REALLOCATE:
185185
requiredFields = requiredFields.concat(['targetDeployment', 'param1', 'param2'])
186186
break
187-
case ActionType.COLLECT:
187+
case ActionType.PRESENT_POI:
188188
requiredFields = requiredFields.concat(['targetDeployment', 'param1'])
189189
break
190190
}

packages/indexer-cli/src/commands/indexer/actions/queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ${chalk.bold(
2727
)} [options] reallocate <deploymentID> <allocationID> <amount> <poi> <force> <blockNumber> <publicPOI>
2828
${chalk.bold(
2929
'graph indexer actions queue',
30-
)} [options] collect <deploymentID> <allocationID> <poi> <force> <blockNumber> <publicPOI>
30+
)} [options] present_poi <deploymentID> <allocationID> <poi> <force> <blockNumber> <publicPOI>
3131
3232
${chalk.dim('Options:')}
3333

packages/indexer-common/src/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export enum ActionType {
227227
ALLOCATE = 'allocate',
228228
UNALLOCATE = 'unallocate',
229229
REALLOCATE = 'reallocate',
230-
COLLECT = 'collect',
230+
PRESENT_POI = 'present_poi',
231231
}
232232

233233
export enum ActionStatus {

packages/indexer-common/src/indexer-management/__tests__/helpers.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ describe('Actions', () => {
296296
).resolves.toHaveLength(1)
297297
})
298298

299-
test('Insert and fetch COLLECT action', async () => {
299+
test('Insert and fetch PRESENT_POI action', async () => {
300300
const action = {
301301
status: ActionStatus.QUEUED,
302-
type: ActionType.COLLECT,
302+
type: ActionType.PRESENT_POI,
303303
deploymentID: 'QmQ44hgrWWt3Qf2X9XEX2fPyTbmQbChxwNm5c1t4mhKpGt',
304304
allocationID: '0x1234567890123456789012345678901234567890',
305305
force: false,
@@ -311,17 +311,17 @@ describe('Actions', () => {
311311
}
312312
await models.Action.upsert(action)
313313
await expect(
314-
ActionManager.fetchActions(models, null, { type: ActionType.COLLECT }),
314+
ActionManager.fetchActions(models, null, { type: ActionType.PRESENT_POI }),
315315
).resolves.toHaveLength(1)
316316
})
317317

318-
test('Generate where options for COLLECT', () => {
318+
test('Generate where options for PRESENT_POI', () => {
319319
const filter = {
320320
status: ActionStatus.QUEUED,
321-
type: ActionType.COLLECT,
321+
type: ActionType.PRESENT_POI,
322322
}
323323
expect(actionFilterToWhereOptions(filter)).toEqual({
324-
[Op.and]: [{ status: 'queued' }, { type: 'collect' }],
324+
[Op.and]: [{ status: 'queued' }, { type: 'present_poi' }],
325325
})
326326
})
327327
})

packages/indexer-common/src/indexer-management/allocations.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
preprocessRules,
3030
Network,
3131
ReallocateAllocationResult,
32-
CollectAllocationResult,
32+
PresentPOIResult,
3333
SubgraphIdentifierType,
3434
SubgraphStatus,
3535
uniqueAllocationID,
@@ -89,7 +89,7 @@ export interface UnallocateTransactionParams {
8989
protocolNetwork: string
9090
}
9191

92-
export interface CollectTransactionParams {
92+
export interface PresentPOITransactionParams {
9393
allocationID: string
9494
poi: POIData
9595
indexer: string
@@ -559,14 +559,14 @@ export class AllocationManager {
559559
action.allocationID!,
560560
receipts,
561561
)
562-
case ActionType.COLLECT:
562+
case ActionType.PRESENT_POI:
563563
if (receipts.length !== 1) {
564-
this.logger.error('Invalid number of receipts for collect action', {
564+
this.logger.error('Invalid number of receipts for present-poi action', {
565565
receipts,
566566
})
567-
throw new Error('Invalid number of receipts for collect action')
567+
throw new Error('Invalid number of receipts for present-poi action')
568568
}
569-
return await this.confirmCollect(
569+
return await this.confirmPresentPOI(
570570
action.id,
571571
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
572572
action.allocationID!,
@@ -649,8 +649,8 @@ export class AllocationManager {
649649
action.id,
650650
action.protocolNetwork,
651651
)
652-
case ActionType.COLLECT:
653-
return await this.prepareCollect(
652+
case ActionType.PRESENT_POI:
653+
return await this.preparePresentPOI(
654654
logger,
655655
context,
656656
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -1000,9 +1000,9 @@ export class AllocationManager {
10001000

10011001
const allocation = await this.network.networkMonitor.allocation(allocationID)
10021002

1003-
// For Horizon allocations, reuse prepareCollectParams logic
1003+
// For Horizon allocations, reuse preparePresentPOIParams logic
10041004
if (!allocation.isLegacy) {
1005-
const collectParams = await this.prepareCollectParams(
1005+
const presentPOIParams = await this.preparePresentPOIParams(
10061006
logger,
10071007
context,
10081008
allocationID,
@@ -1014,7 +1014,7 @@ export class AllocationManager {
10141014
protocolNetwork,
10151015
)
10161016
return {
1017-
...collectParams,
1017+
...presentPOIParams,
10181018
isLegacy: false,
10191019
}
10201020
}
@@ -1199,12 +1199,12 @@ export class AllocationManager {
11991199
})
12001200

12011201
if (isOverAllocated) {
1202-
// Reuse populateCollectTransaction - collect will auto-close the allocation
1202+
// Reuse populatePresentPOITransaction - collect will auto-close the allocation
12031203
logger.info(
12041204
'Indexer is over-allocated, using collect-only transaction (allocation will auto-close)',
12051205
{ allocationID: params.allocationID },
12061206
)
1207-
return await this.populateCollectTransaction(logger, params)
1207+
return await this.populatePresentPOITransaction(logger, params)
12081208
}
12091209

12101210
// Normal path: multicall collect + stopService
@@ -1257,9 +1257,9 @@ export class AllocationManager {
12571257
return await this.populateUnallocateTransaction(logger, params)
12581258
}
12591259

1260-
// ---- COLLECT (rewards only, no close) ----
1260+
// ---- PRESENT_POI (rewards only, no close) ----
12611261

1262-
async prepareCollectParams(
1262+
async preparePresentPOIParams(
12631263
logger: Logger,
12641264
context: TransactionPreparationContext,
12651265
allocationID: string,
@@ -1269,8 +1269,8 @@ export class AllocationManager {
12691269
publicPOI: string | undefined,
12701270
actionID: number,
12711271
protocolNetwork: string,
1272-
): Promise<CollectTransactionParams> {
1273-
logger.info('Preparing to collect indexing rewards (without closing)', {
1272+
): Promise<PresentPOITransactionParams> {
1273+
logger.info('Preparing to present POI (collect indexing rewards without closing)', {
12741274
allocationID: allocationID,
12751275
poi: poi || 'none provided',
12761276
publicPOI: publicPOI || 'none provided',
@@ -1279,11 +1279,11 @@ export class AllocationManager {
12791279

12801280
const allocation = await this.network.networkMonitor.allocation(allocationID)
12811281

1282-
// Collect without closing only works for Horizon allocations
1282+
// Present POI without closing only works for Horizon allocations
12831283
if (allocation.isLegacy) {
12841284
throw indexerError(
12851285
IndexerErrorCode.IE061,
1286-
`Cannot collect rewards without closing for legacy allocations. Use unallocate instead.`,
1286+
`Cannot present POI (collect rewards) without closing for legacy allocations. Use unallocate instead.`,
12871287
)
12881288
}
12891289

@@ -1311,16 +1311,16 @@ export class AllocationManager {
13111311
}
13121312
}
13131313

1314-
async populateCollectTransaction(
1314+
async populatePresentPOITransaction(
13151315
logger: Logger,
1316-
params: CollectTransactionParams,
1316+
params: PresentPOITransactionParams,
13171317
): Promise<ActionTransactionRequest> {
1318-
logger.debug(`Populating collect transaction (rewards only)`, {
1318+
logger.debug(`Populating present-poi transaction (rewards only)`, {
13191319
allocationID: params.allocationID,
13201320
poiData: params.poi,
13211321
})
13221322

1323-
// Collect indexing rewards without closing the allocation
1323+
// Present POI and collect indexing rewards without closing the allocation
13241324
const collectData = encodeCollectData(params.allocationID, params.poi)
13251325

13261326
const tx = await this.network.contracts.SubgraphService.collect.populateTransaction(
@@ -1336,7 +1336,7 @@ export class AllocationManager {
13361336
}
13371337
}
13381338

1339-
async prepareCollect(
1339+
async preparePresentPOI(
13401340
logger: Logger,
13411341
context: TransactionPreparationContext,
13421342
allocationID: string,
@@ -1347,7 +1347,7 @@ export class AllocationManager {
13471347
actionID: number,
13481348
protocolNetwork: string,
13491349
): Promise<ActionTransactionRequest> {
1350-
const params = await this.prepareCollectParams(
1350+
const params = await this.preparePresentPOIParams(
13511351
logger,
13521352
context,
13531353
allocationID,
@@ -1358,24 +1358,24 @@ export class AllocationManager {
13581358
actionID,
13591359
protocolNetwork,
13601360
)
1361-
return await this.populateCollectTransaction(logger, params)
1361+
return await this.populatePresentPOITransaction(logger, params)
13621362
}
13631363

1364-
async confirmCollect(
1364+
async confirmPresentPOI(
13651365
actionID: number,
13661366
allocationID: string,
13671367
receipt: TransactionReceipt | 'paused' | 'unauthorized',
1368-
): Promise<CollectAllocationResult> {
1368+
): Promise<PresentPOIResult> {
13691369
const logger = this.logger.child({ action: actionID })
13701370

1371-
logger.info(`Confirming collect transaction (rewards only)`, {
1371+
logger.info(`Confirming present-poi transaction (rewards only)`, {
13721372
allocationID,
13731373
})
13741374

13751375
if (receipt === 'paused' || receipt === 'unauthorized') {
13761376
throw indexerError(
13771377
IndexerErrorCode.IE062,
1378-
`Collect for allocation '${allocationID}' failed: ${receipt}`,
1378+
`Present POI for allocation '${allocationID}' failed: ${receipt}`,
13791379
)
13801380
}
13811381

@@ -1391,21 +1391,21 @@ export class AllocationManager {
13911391
if (!collectEventLogs) {
13921392
throw indexerError(
13931393
IndexerErrorCode.IE015,
1394-
`Collect transaction was never successfully mined`,
1394+
`Present POI transaction was never successfully mined`,
13951395
)
13961396
}
13971397

13981398
const rewardsCollected = collectEventLogs.tokens ?? 0n
13991399

1400-
logger.info(`Successfully collected indexing rewards`, {
1400+
logger.info(`Successfully presented POI and collected indexing rewards`, {
14011401
allocation: allocationID,
14021402
indexingRewards: formatGRT(rewardsCollected),
14031403
transaction: receipt.hash,
14041404
})
14051405

14061406
return {
14071407
actionID,
1408-
type: 'collect',
1408+
type: 'present_poi',
14091409
transactionID: receipt.hash,
14101410
allocation: allocationID,
14111411
indexingRewardsCollected: formatGRT(rewardsCollected),

packages/indexer-common/src/indexer-management/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const SCHEMA_SDL = gql`
106106
protocolNetwork: String!
107107
}
108108
109-
type CollectAllocationResult {
109+
type PresentPOIResult {
110110
actionID: Int!
111111
type: String!
112112
transactionID: String
@@ -129,7 +129,7 @@ const SCHEMA_SDL = gql`
129129
allocate
130130
unallocate
131131
reallocate
132-
collect
132+
present_poi
133133
}
134134
135135
type Action {
@@ -519,14 +519,14 @@ const SCHEMA_SDL = gql`
519519
force: Boolean
520520
protocolNetwork: String!
521521
): ReallocateAllocationResult!
522-
collectAllocation(
522+
presentPOI(
523523
allocation: String!
524524
poi: String
525525
blockNumber: Int
526526
publicPOI: String
527527
force: Boolean
528528
protocolNetwork: String!
529-
): CollectAllocationResult!
529+
): PresentPOIResult!
530530
submitCollectReceiptsJob(allocation: String!, protocolNetwork: String!): Boolean!
531531
532532
updateAction(action: ActionInput!): Action!

0 commit comments

Comments
 (0)