add cash incentives query - #428
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review once |
|
@frankinkfnd syncing this up locally to make sure we have everything. |
There was a problem hiding this comment.
LGTM — straightforward addition of a new read-only indexer query following the established pattern (getXPoints/getPoints).
Extended reasoning...
Overview
This PR adds a new getCashIncentives query method to IndexerBaseClient plus the corresponding client and server types, and a small E2E test. Total surface: one new method that forwards a wallet address to the indexer and maps the x18 string response into BigNumber fields, mirroring the shape used by adjacent methods like getXPoints and getPoints.
Security risks
None. The endpoint is read-only, takes a single Address param, and does no signing, no state mutation, and no privileged operation. Standard removeDecimals/toBigNumber conversions match neighboring queries.
Level of scrutiny
Low. This is a mechanical, self-contained SDK extension: new type declarations plus a query method that follows the existing translation pattern one-to-one. The E2E test asserts the full response shape.
Other factors
The bug hunting pass surfaced one nit: the JSDoc mentions an eventId param that doesn't exist on either the client or server params type. It's a doc-only defect with no runtime impact and has already been posted as an inline comment for the author to drop or wire up as they see fit — not a blocker for approval.
| /** | ||
| * Retrieves cash incentives information (platform volume and unlocked rewards) for a given wallet address. | ||
| * If no `eventId` is provided, the latest event is returned. | ||
| * @param params | ||
| */ |
There was a problem hiding this comment.
🟡 The JSDoc for getCashIncentives says "If no eventId is provided, the latest event is returned," but no eventId field exists on GetIndexerCashIncentivesParams (only address) and IndexerServerCashIncentivesParams only accepts wallet_address. This appears to be stale copy from an earlier design — either drop the sentence or actually wire up eventId support if it was intended.
Extended reasoning...
What the bug is
The JSDoc block added at packages/indexer-client/src/IndexerBaseClient.ts:982-986 documents a parameter that does not exist:
/**
* Retrieves cash incentives information (platform volume and unlocked rewards) for a given wallet address.
* If no `eventId` is provided, the latest event is returned.
* @param params
*/
async getCashIncentives(
params: GetIndexerCashIncentivesParams,
): Promise<GetIndexerCashIncentivesResponse> {Why the docstring is wrong
Tracing the type stack:
- Client param type —
GetIndexerCashIncentivesParams(clientTypes.ts:900-902) is defined as:Noexport interface GetIndexerCashIncentivesParams { address: Address; }
eventIdfield. - Server param type —
IndexerServerCashIncentivesParams(serverTypes.ts:249-251):Noexport interface IndexerServerCashIncentivesParams { wallet_address: string; }
event_idfield. - Implementation — the method only forwards
wallet_address:Nothing accepts or propagates an event ID.const baseResponse = await this.query('cash_incentives', { wallet_address: params.address, });
Step-by-step proof
- A user reads the JSDoc and concludes: "I can call
client.getCashIncentives({ address, eventId: 42 })to filter to a single event, or omiteventIdfor the latest." - They attempt
client.getCashIncentives({ address, eventId: 42 }). TypeScript rejects this at compile time —eventIdis not a property ofGetIndexerCashIncentivesParams(Object literal may only specify known properties). - Even if they cast around the type error, the method's body never reads
params.eventId— onlyparams.addressis forwarded to the server. The server params type has noevent_idfield either, so the request would never carry the filter. - The response always contains the full
eventsarray (seeIndexerCashIncentivesEvent[]), never a single "latest" event — so the docstring's behavioral claim is doubly wrong.
Impact
Purely a documentation defect. It misleads SDK consumers about supported filtering, but no runtime path is affected and TypeScript will reject any attempt to use the phantom parameter. Behavior for the actual code path — { address } → full events list — is correct.
How to fix
Two options — pick whichever matches intent:
- Drop the stale sentence (most likely correct — the method really does return all events):
/** * Retrieves cash incentives information (platform volume and unlocked rewards) for a given wallet address. * @param params */
- Wire up
eventIdsupport if the server actually accepts it: addeventId?: numbertoGetIndexerCashIncentivesParams,event_id?: numbertoIndexerServerCashIncentivesParams, and forward it in the query.
|
Lmk when you think it's good to publish, also take a look at e2e |
e2e looks like an issue with the linked signer account health. |
|
@frankinkfnd We should be good to go here |
|
0.25.0 |
This pull request adds support for retrieving and handling cash incentives (platform volume and unlocked rewards) for a given wallet address in the indexer client. The main changes include implementing the
getCashIncentivesmethod, defining new types for the cash incentives data structures, and updating the server and client type definitions to support the new query.Cash Incentives Feature Implementation:
getCashIncentivestoIndexerBaseClient, which fetches and processes platform volume and unlocked rewards data for a wallet address.clientTypes.tsfor cash incentives parameters, event metadata, platform/wallet data, and the response structure.Server and Query Type Updates:
serverTypes.tsfor cash incentives queries, including request parameters, event structures, and response objects. [1] [2]cash_incentivesquery. [1] [2]Testing:
subaccountQueries.test.tsto verify thatgetCashIncentivesreturns the expected platform volume and rewards data per event and wallet summary.contributes to ENGW-202