Skip to content

feat: private balance#4

Open
Dodecahedr0x wants to merge 5 commits intomainfrom
dode/private-balance
Open

feat: private balance#4
Dodecahedr0x wants to merge 5 commits intomainfrom
dode/private-balance

Conversation

@Dodecahedr0x
Copy link
Copy Markdown

@Dodecahedr0x Dodecahedr0x commented Mar 30, 2026

Authenticate to the PER when getting private balances

Summary by CodeRabbit

  • New Features

    • Wallet message signing is now required to authenticate and view private SPL balances; UI shows an “Authenticate” overlay when connected but unauthenticated and detects wallets without signing support.
    • Net worth panel displays dynamic per-token balances (replaces hardcoded rows) with per-token loading (“…”) and missing-data (“—”) states.
    • Auth tokens are persisted per wallet; balances refresh after payments and via a global refresh event.
  • Bug Fixes

    • Token is cleared and re-authentication prompted on balance-load or auth failures.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pay Ready Ready Preview, Comment Apr 17, 2026 4:19pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Replaced wallet-modal connect with wallet message-signature authentication for private SPL balances; added client helpers for challenge/login/balance fetch and storage, an event-based refresh helper, a payment-card refresh trigger, and added bs58 dependency.

Changes

Cohort / File(s) Summary
NetWorth Panel
components/one/net-worth-panel.tsx
Replaced wallet-modal connect flow with SPL message-signature auth: load/store per-owner auth token, fetch+sign challenge and login to obtain token, persist/clear token on owner change/errors, fetch private balances in parallel for configured mints, show loading () / missing () states, handle balanceError, and listen for PRIVATE_BALANCE_REFRESH_EVENT.
SPL Private Balance Library
lib/spl-private-balance.ts
New module: get/set/clear localStorage helpers for per-pubkey auth tokens, fetchSplChallenge, loginSplPrivate, fetchPrivateBalance (Bearer auth + cluster), formatBaseUnits, and PrivateBalanceRow type with robust error handling and safe window checks.
Private Balance Refresh
lib/private-balance-refresh.ts
New module exporting PRIVATE_BALANCE_REFRESH_EVENT and dispatchPrivateBalanceRefresh() which dispatches a browser CustomEvent (no-op on server) to prompt refetch.
Payment Card
components/one/payment-card.tsx
Invoke dispatchPrivateBalanceRefresh() immediately after a payment transitions to "confirmed" to trigger private-balance listeners to refresh.
Dependencies / Manifest
package.json
Added dependency bs58 (^6.0.0).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dode/private-balance

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant