feat(dashmint-lab): add Tokens tab for DashMint token transfers#90
Conversation
Adds a new Tokens screen with a transfer flow, wires up sdk.tokens.transfer + keyManager.getTransfer in shared types, and refreshes the token balance when the tab activates. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the stale-balance precheck (UI already gates submit, Platform is authoritative), fast-path self-transfer via keyManager.identityId before resolving the signer, and reset the transfer form across session and contract changes. Tests now exercise the recipient classifier directly, pin amount-format edge cases (1e3, -1, 0x10, 1.5, 0), and add an App-level Tokens-tab navigation suite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Split the bundled disabled-submit test into separate amount and DPNS cases, rewrite the session-reset test to seed stale state via a rejected transfer so it actually exercises the reset effect, and rename two tests whose names overpromised their assertions. Add coverage for insufficient local balance, missing key manager, dismiss-on-edit, and the Clear button. Switch the invalid-amount table to it.each for per-case failure messages, and drop a redundant clearAllMocks in the nav test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 36 minutes and 35 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a complete token transfer feature to the DashMint lab example app. It introduces a new "tokens" UI screen with form validation, recipient resolution, and balance checking; a ChangesToken Transfer Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx (1)
196-228: ⚡ Quick winVerify that the transfer function was invoked.
The test waits for a success status but doesn't confirm that
mockTransferDashMintTokenswas actually called. Adding a verification would strengthen the test and ensure the transfer logic is properly exercised.✨ Suggested verification
After line 218, add:
expect(screen.getByRole("status").textContent).toContain( "DashMint tokens transferred successfully.", ); + expect(mockTransferDashMintTokens).toHaveBeenCalledWith({ + sdk: sessionValue.sdk, + keyManager: sessionValue.keyManager, + contractId: "contract-1", + recipientId: SAMPLE_ID, + amount: 2n, + log: sessionValue.log, + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx` around lines 196 - 228, After confirming the success status appears in the "App token transfer navigation" test, add a verification that mockTransferDashMintTokens was invoked (and optionally assert specific call args) before navigating away to the Collection tab; locate the assertion near the block that awaits screen.findByRole("status") and add an expect/assert on mockTransferDashMintTokens to ensure the transfer function was actually called.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx`:
- Around line 196-228: After confirming the success status appears in the "App
token transfer navigation" test, add a verification that
mockTransferDashMintTokens was invoked (and optionally assert specific call
args) before navigating away to the Collection tab; locate the assertion near
the block that awaits screen.findByRole("status") and add an expect/assert on
mockTransferDashMintTokens to ensure the transfer function was actually called.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f420eee8-90c0-419f-8eeb-fa5c50b25bb1
📒 Files selected for processing (13)
example-apps/dashmint-lab/eslint.config.jsexample-apps/dashmint-lab/src/App.tsxexample-apps/dashmint-lab/src/components/AppShell.tsxexample-apps/dashmint-lab/src/components/Tabs.tsxexample-apps/dashmint-lab/src/components/TokenTransferScreen.tsxexample-apps/dashmint-lab/src/dash/transferDashMintTokens.tsexample-apps/dashmint-lab/src/dash/types.tsexample-apps/dashmint-lab/test/App.test.tsxexample-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsxexample-apps/dashmint-lab/test/TokenTransferScreen.test.tsxexample-apps/dashmint-lab/test/dash.test.tsexample-apps/dashmint-lab/test/transferDashMintTokens.test.tssetupDashClient-core.d.mts
The token-transfer navigation test confirmed the success notice appeared after submit but never verified what was actually sent. Pin contractId, recipientId, and amount on the mock invocation so a regression in App-to-screen wiring (wrong contract, dropped recipient) can't slip past as long as the notice still renders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
transferDashMintTokenshelper wrapssdk.tokens.transferand uses the identity's TRANSFER-purpose key (key 3); fast-paths a self-transfer check via cachedkeyManager.identityIdbefore the on-chain identity fetch, with a post-fetch fallback when the cached ID is nullTokenTransferScreenreuses the DPNS classifier/resolver hooks from card transfers, validates whole-token amounts, and resets form + result state across session changes; gate overlay matches the existing Mint tab pattern for unauthenticated browse modetransfermethod tosetupDashClient-core.d.mtsand agetTransfer()accessor to the app-localDashKeyManagertypeTest plan
npm run test— 21 new tests acrossTokenTransferScreen.test.tsx,transferDashMintTokens.test.ts,AppTokenTransferNavigation.test.tsx, plus updates toApp.test.tsxanddash.test.ts; coverage ontransferDashMintTokens.tsis 100% stmt / 91% branch andTokenTransferScreen.tsx86% / 90%npm run lintandnpm run build.dashname, verify resolution + submission to the resolved IDNotes:
transferDashMintTokens.tsnotes that token single-transfer transitions accept either critical auth or TRANSFER purpose; this app standardizes on TRANSFER.Summary by CodeRabbit
Release Notes
New Features
Tests
Chores