Conversation
There was a problem hiding this comment.
Sorry @Connorbelez, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds the new ENG-29 “mintAndIssue” convenience mutation to the mortgage ownership ledger, providing an atomic single-call flow to mint a mortgage’s total supply and immediately issue shares to initial lender position accounts.
Changes:
- Added
allocationValidatorandmintAndIssueArgsValidatorfor the new mutation’s arguments. - Implemented
mintAndIssueinconvex/ledger/mutations.ts(mint + issue + invariant check in one ledger mutation). - Added a dedicated Vitest suite covering happy paths, validation failures, double-mint protection, and idempotent replay.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| specs/ENG-29/tasks.md | Adds the ENG-29 task checklist for implementing the feature. |
| specs/ENG-29/chunks/manifest.md | Declares a single implementation chunk covering code + tests. |
| specs/ENG-29/chunks/chunk-01-implementation/tasks.md | Chunk-level task breakdown mirroring the main task list. |
| specs/ENG-29/chunks/chunk-01-implementation/context.md | Implementation context/acceptance criteria and expected patterns. |
| convex/ledger/validators.ts | Introduces validators for allocations and the new mutation’s args. |
| convex/ledger/mutations.ts | Implements the mintAndIssue mutation and wires it into ledger mutations. |
| convex/ledger/tests/mintAndIssue.test.ts | Adds tests for mint+issue behavior, validation, and idempotency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR implements Issues found:
Confidence Score: 2/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([mintAndIssue called]) --> B{Sum of allocations\n== 10,000?}
B -- No --> ERR1([ALLOCATIONS_SUM_MISMATCH])
B -- Yes --> C{Each allocation\n>= 1,000?}
C -- No --> ERR2([ALLOCATION_BELOW_MINIMUM])
C -- Yes --> D{Existing entry for\nidempotencyKey?}
D -- Yes --> E{TREASURY exists\nfor mortgageId?}
E -- No --> ERR3([IDEMPOTENT_REPLAY_FAILED])
E -- Yes --> F[Collect ALL entries for mortgage\nfilter SHARES_ISSUED]
F --> G([Return cached result])
D -- No --> H{TREASURY exists\nfor mortgageId?}
H -- Yes --> ERR4([ALREADY_MINTED])
H -- No --> I[initializeWorldAccount]
I --> J[Insert TREASURY account]
J --> K[postEntry MORTGAGE_MINTED\nWORLD → TREASURY 10,000]
K --> L[For each allocation:\ngetOrCreatePositionAccount\npostEntry SHARES_ISSUED\nTREASURY → POSITION]
L --> M{TREASURY\nbalance == 0?}
M -- No --> ERR5([INVARIANT_VIOLATION])
M -- Yes --> N([Return treasuryAccountId\nmintEntry, issueEntries])
style ERR1 fill:#f66,color:#fff
style ERR2 fill:#f66,color:#fff
style ERR3 fill:#f66,color:#fff
style ERR4 fill:#f66,color:#fff
style ERR5 fill:#f66,color:#fff
style G fill:#6a6,color:#fff
style N fill:#6a6,color:#fff
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@convex/ledger/mutations.ts`:
- Around line 246-259: The replay code in mintAndIssue returns all SHARES_ISSUED
entries for the mortgage, which can include unrelated entries; update the
post-query filter to only include entries whose causedBy equals the current mint
entry id (use existingEntry._id) so issueEntries returned are tied to this
specific mint operation (filter the issueEntries array by e.entryType ===
"SHARES_ISSUED" && e.causedBy === existingEntry._id).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b1a41178-5222-43e5-b43b-70de151b8779
📒 Files selected for processing (7)
convex/ledger/__tests__/mintAndIssue.test.tsconvex/ledger/mutations.tsconvex/ledger/validators.tsspecs/ENG-29/chunks/chunk-01-implementation/context.mdspecs/ENG-29/chunks/chunk-01-implementation/tasks.mdspecs/ENG-29/chunks/manifest.mdspecs/ENG-29/tasks.md
Merge activity
|
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * New mint and issue operation supporting single-step share allocation to multiple lenders * Built-in validation ensures allocations meet minimum thresholds and sum correctly * Idempotent operation design—duplicate requests with the same key return consistent results * Double-mint protection prevents accidental duplicate minting for the same mortgage <!-- end of auto-generated comment: release notes by coderabbit.ai -->

Summary by CodeRabbit