refactor: earn flow + remove xstate/store#551
Conversation
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
Key validators by address and subnet so selection keeps distinct validator options. Scope balance and init token options to the selected dashboard category.
| {t("dashboard.borrow.success_page.view_transaction")} | ||
| </Text> | ||
| </Box> | ||
| ) : null |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: MEDIUM
submission.link is opened via window.open(..., "_blank") without noopener,noreferrer. If this URL is attacker-influenced (e.g., via upstream API data), the opened page can access window.opener and navigate the original tab (reverse-tabnabbing).
Impact: A user can be redirected from the trusted widget host tab to a phishing or malicious page after clicking a transaction link.
Reviewed by Cursor Security Reviewer for commit 6cf3187. Configure here.
6cf3187 to
5dac944
Compare
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, Cursor Security Agent left an unresolved medium-severity finding, and required checks did not finish on the latest commit (Bugbot cancelled; Security Agent still running). Assigned jdomingos and dnehl for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Split earn intent and view atoms so route and wallet state changes update the resolved view. Keep dispatch separate from view reads and add wallet resolution handling. Cover dashboard tab selection and patch Effect parent tracking.
Use the native TypeScript 7 compiler across the widget and examples. Keep TypeScript 6 API compatibility for Next.js tooling.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Replace legacy context, query, and state-machine integrations with Effect services and atom-backed wallet, API, and workflow state. Split Vitest projects and add AST rules to validate the new architecture.
16d2bb4 to
67eb76f
Compare
Replace the global identity and phase model with a runtime intake store and route-scoped facade. Align review, workflow, and cleanup lifetimes with one Flow Session generation.
Scope intake cleanup to application runtime replacement and enforce KYC in every Continue path. Deepen intake snapshots and cover wallet, workflow, and stale-session lifetimes.
Reacquire review and steps lifecycle atoms for every router entry. This keeps host and browser navigation normalization reliable without adding a stored flow phase.
Scope Session state to a keyed route boundary. Create fresh Review and Execution capabilities per route mount. Keep only the reviewed action handoff in the parent Session.
Construct action commands through their schemas and reject requests when required subnet IDs are unavailable. Keep completion effects mounted for the workflow scope, refresh generated API clients, and replace brittle architecture checks with documented review constraints.
Split classic and borrow journeys into feature-owned flow sessions. Move shared execution mechanics into a scoped transaction workflow module. Make lifecycle, routing, and completion ownership explicit while preserving isolated attempts.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Move cacheable remote reads into app-scoped resource modules so features share one typed source of truth. Separate read capabilities from operations and enforce the new dependency boundaries.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Make Earn state own selection reconciliation, readiness, and targeted failures. Decode consumed mechanic arguments at the API boundary and verify resource behavior.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Stale comment
🔒 Agentic Security Review
1 finding met reporting thresholds after deduplication and triage.
- HIGH in
.github/workflows/release.yml(added canary publish job): the workflow runscurl https://mise.run | ... shin a privileged CI context (id-token: write+ npm publish path), introducing remote-script execution risk in the release pipeline.Sent by Cursor Security Agent: Security Reviewer
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding on
complete.tsx. jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Add an internal canary channel for branch-specific QA. Keep the stable Release Please flow unchanged. Derive immutable versions from npm latest and the workflow run number. Publish under the canary dist-tag and document retry and QA usage.
04b95f6 to
768b66c
Compare
There was a problem hiding this comment.
Stale comment
🔒 Agentic Security Review
One net-new security finding was validated on the current PR head:
- MEDIUM: The newly added canary release workflow executes
curl https://mise.run | ... shin.github/workflows/release.yml, introducing remote script execution without integrity verification in a publish-capable CI path.No duplicate comment was reposted for the existing borrow-link
_blankthread because that finding is already present in an open automation thread on this same head.Sent by Cursor Security Agent: Security Reviewer
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent reported unresolved findings (medium tabnabbing on
complete.tsxand medium remote-script execution inrelease.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Replace native Date and date-fns usage with Effect DateTime, Duration, and Clock. Apply one time model across API schemas, domain logic, tests, and presentation. Add tolerant timestamp decoding, a shared ticker, Activity expiry guards, and AST lint rules. Prevent loading CTAs from accepting clicks before their action is ready.
Enable the Biome rule and replace existing nested ternaries. Use immutable resolvers, focused Effect Match usage, and clearer JSX branches. Document the value-selection convention for future changes.
Scope collateral balances to their markets and use position-specific risk data. Keep debt, collateral, health, and APY values accurate across borrow positions. Centralize financial formatting and remove misleading capacity and collateral APY labels.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has an unresolved medium-severity tabnabbing finding. jdomingos and dnehl are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver
Enable ast-grep rules for Effect, Atom, React Query, storage, and serialization boundaries. Remove obsolete memoization and native error rules. Migrate affected wallet and translation code to scoped Effect runtimes and typed failures.
63c6f2c to
ae0dc50
Compare
|
|
||
| - name: Install mise | ||
| run: | | ||
| curl https://mise.run | MISE_VERSION=v2026.5.6 sh |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
The canary publish job executes curl https://mise.run | ... sh directly, which runs mutable remote script content in a publish-capable CI path. This creates a trust-boundary break where compromise of the remote script source or transit path can execute arbitrary commands during release.
Impact: An attacker controlling that install script path could tamper with build/publish steps and ship malicious package artifacts under a trusted namespace.
Reviewed by Cursor Security Reviewer for commit ae0dc50. Configure here.
There was a problem hiding this comment.
Stale comment
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has unresolved findings (medium tabnabbing on
complete.tsxand high remote-script execution inrelease.yml). jdomingos and dnehl are already assigned for human review.Sent by Cursor Approval Agent: Pull Request Router and Approver
Replace the callback-rich React page models with capability facades that publish read-only views and writable commands, so projections, tracking, navigation, and resource lifetimes live in Effect and Atom instead of hooks. Application navigation moves into the runtime: a scoped ApplicationRouter owns the memory router for a runtime generation, WidgetNavigation executes workflow destinations, and the root route configuration is assembled at the top-level React composition seam rather than imported by runtime construction. Validator selection memory becomes a command-time write instead of a write during a derived read, which previously destabilised the Earn machine view and suppressed validator searches.
There was a problem hiding this comment.
Risk: high. Not approving: this large earn/borrow refactor exceeds the low-risk approval threshold, and Cursor Security Agent has unresolved findings (medium tabnabbing and high remote-script execution in release.yml). jdomingos and dnehl are already assigned for human review.
Sent by Cursor Approval Agent: Pull Request Router and Approver




Note
High Risk
Large new DeFi borrow path with wallet signing, transaction submission, and LTV validation touches money-moving flows; earn routing/state refactor could regress staking if mis-wired.
Overview
Adds a feature-flagged borrow experience in the dashboard (form → review → steps → complete, plus borrow position management), backed by a new
borrowmodule: Effect Schema domain models, OpenAPI-generatedBorrowApiclient, and@effect/atom-reactatoms for markets/positions, form state, action execution (sign/submit/confirm), and post-tx cache refresh.Earn flow cleanup: drops
EarnPageStateUsageBoundaryProvider/@xstate/store, removescommon/get-token-balances.tsandgetInitialTokenfrom stake types, and tightens validator handling via a compositeValidator.key(address + optional subnet) used in select-validator and position balance keys.Tooling/config: OpenAPI generator gains
BorrowApi(fullhttpclient+ spec prep), optional CLI spec selection,VITE_BORROW_API_URL/VITE_FORCE_BORROW, and rootpnpm.patchedDependenciesremoved; adds skeleton line/circle loaders for borrow UI loading states.Reviewed by Cursor Bugbot for commit 6cf3187. Configure here.