Skip to content

Commit f381edc

Browse files
authored
Merge branch 'main' into 310-feat-add-per-user-performance-to-indexer
2 parents 8d276a1 + 6c0d07d commit f381edc

8 files changed

Lines changed: 115 additions & 40 deletions

.cursor/agents/pr-explainer.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
name: pr-explainer
3+
description: Drafts high-quality GitHub PR descriptions from git diffs vs origin/main. Use proactively when opening a PR, summarizing a branch, or turning local changes into reviewer-ready context (TL;DR, why, how, testing, risk).
4+
---
5+
6+
You are a **PR explainer**: you turn the current branch’s changes into a clear, reviewer-friendly Pull Request description.
7+
8+
## When invoked
9+
10+
1. **Establish the diff baseline**
11+
- Prefer comparing the **current branch** (or working tree, if explicitly requested) against **`origin/main`**.
12+
- Run `git fetch origin main` if needed so `origin/main` is current, then use `git diff origin/main...HEAD` for commits on the branch, or `git diff origin/main` if the user wants working-tree changes included—**ask once** if ambiguous.
13+
- Summarize **what files and areas** changed (high level); group by concern (e.g. workflows, services, config) rather than listing every line.
14+
15+
2. **Do not invent facts**
16+
- If **ticket/issue links**, **manual test steps**, or **screenshots** are not in the diff or conversation, use placeholders such as `_Add Linear/Jira link_`, `_Manual verification: …_`, `_N/A (no UI)_` rather than guessing.
17+
18+
## Output structure (mandatory sections)
19+
20+
Follow this hierarchy so reviewers get **why** before **what**:
21+
22+
### TL;DR (Summary)
23+
24+
One sentence: outcome + scope (not “small fixes”).
25+
26+
### Context (Why)
27+
28+
- **Problem:** Why this change exists (business or technical).
29+
- **Impact:** What goes wrong if we don’t merge (brief).
30+
31+
If unknown, state assumptions or mark as **TBD** and list one clarifying question.
32+
33+
### Implementation (How)
34+
35+
Explain **architectural or workflow choices**, not a line-by-line narration.
36+
37+
- Prefer bullets: trade-offs, patterns, why this approach vs alternatives (when inferable from the diff).
38+
39+
### Evidence of Quality (Testing)
40+
41+
- **Automated:** Tests added/changed, or note “no test changes in diff.”
42+
- **Manual:** Steps the author should run (infer from change type where reasonable).
43+
- **Visuals:** For UI changes, state that **before/after screenshots or GIFs are required**; if diff has no frontend, say **N/A**.
44+
45+
### Risk & Rollback
46+
47+
- **Risks:** migrations, prod config, workflows, breaking API/schema changes—only if relevant to the diff.
48+
- **Rollback:** how to revert or mitigate (revert PR, flip flag, redeploy previous image, etc.).
49+
50+
### Metadata table
51+
52+
Include a short table:
53+
54+
| Field | Value |
55+
| :--- | :--- |
56+
| Ticket | _link or “none”_ |
57+
| Breaking changes | Yes / No / Unknown |
58+
| Dependencies | New/updated deps from lockfiles or package.json if present |
59+
60+
### Atomic PR note
61+
62+
If the diff is **very large** or mixes unrelated themes, recommend **splitting** into smaller PRs (cite the “atomic PR” principle briefly).
63+
64+
## Tone and quality bar
65+
66+
- Write for **busy reviewers**: scannable headings, concrete nouns, minimal jargon.
67+
- Tie claims to **observable changes** in the diff; flag uncertainty explicitly.
68+
- Mention **CI/automation** only when the diff touches workflows or when reminding that checks should be green before review.
69+
70+
Your deliverable is **paste-ready Markdown** for the GitHub PR body (no generic filler; every section should earn its place).

src/services/CrosschainMessageService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ export class CrosschainMessageService extends Service<typeof CrosschainMessage>
219219
}
220220
const poolIds = Array.from(poolIdSet);
221221
const tokenIds = Array.from(tokenIdSet);
222-
if (poolIds.length > 1) throw new Error("Multiple pools found among messages");
222+
if (poolIds.length > 1) {
223+
serviceError("Multiple pools found among messages");
224+
return [null, null];
225+
}
223226
return [poolIds.pop() ?? null, tokenIds.pop() ?? null];
224227
}
225228

src/services/HoldingService.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ export class HoldingService extends Service<typeof Holding> {
4444
*/
4545
public increase(amount: bigint, increaseValue: bigint) {
4646
const { assetQuantity, totalValue } = this.data;
47-
if (assetQuantity === null || totalValue === null) {
48-
throw new Error("Hub asset amount or value is null");
49-
}
50-
this.data.assetQuantity! += amount;
51-
this.data.totalValue! += increaseValue;
47+
this.data.assetQuantity = assetQuantity ?? 0n + amount;
48+
this.data.totalValue = totalValue ?? 0n + increaseValue;
5249
return this;
5350
}
5451

@@ -63,11 +60,8 @@ export class HoldingService extends Service<typeof Holding> {
6360
*/
6461
public decrease(amount: bigint, decreaseValue: bigint) {
6562
const { assetQuantity, totalValue } = this.data;
66-
if (assetQuantity === null || totalValue === null) {
67-
throw new Error("Hub asset amount or value is null");
68-
}
69-
this.data.assetQuantity! -= amount;
70-
this.data.totalValue! -= decreaseValue;
63+
this.data.assetQuantity = assetQuantity ?? 0n - amount;
64+
this.data.totalValue = totalValue ?? 0n - decreaseValue;
7165
return this;
7266
}
7367

@@ -81,10 +75,7 @@ export class HoldingService extends Service<typeof Holding> {
8175
*/
8276
public update(isPositive: boolean, diffValue: bigint) {
8377
const { totalValue } = this.data;
84-
if (totalValue === null) {
85-
throw new Error("Hub total value is null");
86-
}
87-
this.data.totalValue! += isPositive ? diffValue : -diffValue;
78+
this.data.totalValue = totalValue ?? 0n + (isPositive ? diffValue : -diffValue);
8879
return this;
8980
}
9081

src/services/InvestOrderService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Event } from "ponder:registry";
22
import { Service } from "./Service";
33
import { InvestOrder } from "ponder:schema";
4-
import { serviceLog, addThousandsSeparator } from "../helpers/logger";
4+
import { serviceLog, addThousandsSeparator, serviceError } from "../helpers/logger";
55
import { timestamper } from "../helpers/timestamper";
66

77
/**
@@ -54,8 +54,14 @@ export class InvestOrderService extends Service<typeof InvestOrder> {
5454
serviceLog(
5555
`Issuing shares for investOrder for account ${this.data.account} with navAssetPerShare: ${navAssetPerShare} navPoolPerShare: ${navPoolPerShare}`
5656
);
57-
if (this.data.issuedAt) throw new Error("Shares already issued");
58-
if (this.data.approvedAssetsAmount === null) throw new Error("No assets approved");
57+
if (this.data.issuedAt) {
58+
serviceError("Shares already issued");
59+
return this;
60+
}
61+
if (this.data.approvedAssetsAmount === null) {
62+
serviceError("No assets approved");
63+
return this;
64+
}
5965

6066
this.data = {
6167
...this.data,
@@ -86,7 +92,10 @@ export class InvestOrderService extends Service<typeof InvestOrder> {
8692
serviceLog(
8793
`Claiming deposit for account ${this.data.account} with claimedSharesAmount: ${claimedSharesAmount} on block ${event.block.number} with timestamp ${event.block.timestamp}`
8894
);
89-
if (this.data.claimedAt) throw new Error("Deposit already claimed");
95+
if (this.data.claimedAt) {
96+
serviceError("Deposit already claimed");
97+
return this;
98+
}
9099
if (paymentAssetAmount !== this.data.approvedAssetsAmount)
91100
serviceLog(
92101
`paymentAssetAmount ${addThousandsSeparator(paymentAssetAmount)} !== ${addThousandsSeparator(this.data.approvedAssetsAmount ?? 0n)} approvedAssetsAmount`

src/services/PoolAdapterService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ export class PoolAdapterService extends Service<typeof PoolAdapter> {
221221
for (let i = 0; i < adapterCount; i++) {
222222
const word = hex.slice(offset, offset + 64);
223223
if (word.length !== 64) {
224-
throw new Error(`Invalid adapterList length for adapter index ${i}`);
224+
serviceError(`Invalid adapterList length for adapter index ${i}`);
225+
return [];
225226
}
226227
addresses.push(formatBytes32ToAddress(`0x${word}`));
227228
offset += 64;

src/services/RedeemOrderService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Event } from "ponder:registry";
22
import { Service } from "./Service";
33
import { RedeemOrder } from "ponder:schema";
4-
import { serviceLog, addThousandsSeparator } from "../helpers/logger";
4+
import { serviceLog, addThousandsSeparator, serviceError } from "../helpers/logger";
55
import { timestamper } from "../helpers/timestamper";
66

77
/**
@@ -59,8 +59,14 @@ export class RedeemOrderService extends Service<typeof RedeemOrder> {
5959
`Revoking shares for account ${this.data.account} with navAssetPerShare: ${navAssetPerShare} navPoolPerShare: ${navPoolPerShare} shareDecimals: ${shareDecimals} on block ${event.block.number} and timestamp ${event.block.timestamp}`
6060
);
6161
const poolDecimals = shareDecimals;
62-
if (this.data.revokedAt) throw new Error("Shares already revoked");
63-
if (this.data.approvedSharesAmount === null) throw new Error("No shares approved");
62+
if (this.data.revokedAt) {
63+
serviceError("Shares already revoked");
64+
return this;
65+
}
66+
if (this.data.approvedSharesAmount === null) {
67+
serviceError("No shares approved");
68+
return this;
69+
}
6470
this.data = {
6571
...this.data,
6672
...timestamper("revoked", event),
@@ -97,7 +103,10 @@ export class RedeemOrderService extends Service<typeof RedeemOrder> {
97103
serviceLog(
98104
`Claiming redeem for account ${this.data.account} with claimedAssetsAmount: ${claimedAssetsAmount} on block ${event.block.number} and timestamp ${event.block.timestamp}`
99105
);
100-
if (this.data.claimedAt) throw new Error("Redeem already claimed");
106+
if (this.data.claimedAt) {
107+
serviceError("Redeem already claimed");
108+
return this;
109+
}
101110
if (paymentShareAmount !== this.data.approvedSharesAmount)
102111
serviceLog(
103112
`paymentShareAmount ${addThousandsSeparator(paymentShareAmount)} !== ${addThousandsSeparator(this.data.approvedSharesAmount ?? 0n)} approvedSharesAmount`

src/services/TokenInstanceService.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ export class TokenInstanceService extends Service<typeof TokenInstance> {
7373
* @throws {Error} When total issuance is not set (null)
7474
*/
7575
public increaseTotalIssuance(tokenAmount: bigint) {
76-
if (this.data.totalIssuance === null)
77-
throw new Error(
78-
`Total issuance for token ${this.data.centrifugeId}-${this.data.tokenId} is not set`
79-
);
80-
this.data.totalIssuance += tokenAmount;
76+
const { totalIssuance } = this.data;
77+
this.data.totalIssuance = totalIssuance ?? 0n + tokenAmount;
8178
serviceLog(
8279
`Increased totalIssuance for token ${this.data.centrifugeId}-${this.data.tokenId} by ${tokenAmount} to ${this.data.totalIssuance}`
8380
);
@@ -92,11 +89,8 @@ export class TokenInstanceService extends Service<typeof TokenInstance> {
9289
* @throws {Error} When total issuance is not set (null)
9390
*/
9491
public decreaseTotalIssuance(tokenAmount: bigint) {
95-
if (this.data.totalIssuance === null)
96-
throw new Error(
97-
`Total issuance for token ${this.data.centrifugeId}-${this.data.tokenId} is not set`
98-
);
99-
this.data.totalIssuance -= tokenAmount;
92+
const { totalIssuance } = this.data;
93+
this.data.totalIssuance = totalIssuance ?? 0n - tokenAmount;
10094
serviceLog(
10195
`Decreased totalIssuance for token ${this.data.centrifugeId}-${this.data.tokenId} by ${tokenAmount} to ${this.data.totalIssuance}`
10296
);

src/services/TokenService.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ export class TokenService extends Service<typeof Token> {
113113
* @throws {Error} When totalIssuance is null (not initialized)
114114
*/
115115
public increaseTotalIssuance(tokenAmount: bigint) {
116-
if (this.data.totalIssuance === null)
117-
throw new Error(`totalIssuance for token ${this.data.id} is not set`);
118-
this.data.totalIssuance += tokenAmount;
116+
const { totalIssuance } = this.data;
117+
this.data.totalIssuance = totalIssuance ?? 0n + tokenAmount;
119118
serviceLog(
120119
`Increased totalIssuance for token ${this.data.id} by ${tokenAmount} to ${this.data.totalIssuance}`
121120
);
@@ -130,9 +129,8 @@ export class TokenService extends Service<typeof Token> {
130129
* @throws {Error} When totalIssuance is null (not initialized)
131130
*/
132131
public decreaseTotalIssuance(tokenAmount: bigint) {
133-
if (this.data.totalIssuance === null)
134-
throw new Error(`totalIssuance for token ${this.data.id} is not set`);
135-
this.data.totalIssuance -= tokenAmount;
132+
const { totalIssuance } = this.data;
133+
this.data.totalIssuance = totalIssuance ?? 0n - tokenAmount;
136134
serviceLog(
137135
`Decreased totalIssuance for token ${this.data.id} by ${tokenAmount} to ${this.data.totalIssuance}`
138136
);

0 commit comments

Comments
 (0)