Skip to content

feat(dashmint-lab): add Tokens tab for DashMint token transfers#90

Merged
thephez merged 4 commits into
mainfrom
feat/dashmint-token-xfers
Jun 9, 2026
Merged

feat(dashmint-lab): add Tokens tab for DashMint token transfers#90
thephez merged 4 commits into
mainfrom
feat/dashmint-token-xfers

Conversation

@thephez

@thephez thephez commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Tokens tab to DashMint Lab for transferring DashMint tokens between identities on testnet
  • New transferDashMintTokens helper wraps sdk.tokens.transfer and uses the identity's TRANSFER-purpose key (key 3); fast-paths a self-transfer check via cached keyManager.identityId before the on-chain identity fetch, with a post-fetch fallback when the cached ID is null
  • New TokenTransferScreen reuses 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 mode
  • Adds a transfer method to setupDashClient-core.d.mts and a getTransfer() accessor to the app-local DashKeyManager type

Test plan

  • npm run test — 21 new tests across TokenTransferScreen.test.tsx, transferDashMintTokens.test.ts, AppTokenTransferNavigation.test.tsx, plus updates to App.test.tsx and dash.test.ts; coverage on transferDashMintTokens.ts is 100% stmt / 91% branch and TokenTransferScreen.tsx 86% / 90%
  • npm run lint and npm run build
  • Manual testnet round-trip: send DashMint tokens to another identity, confirm balance updates on both sides, verify Tokens tab gate appears when not signed in
  • DPNS recipient: type a .dash name, verify resolution + submission to the resolved ID
  • Self-transfer guard: type your own identity ID, confirm rejection before the network call
  • Insufficient balance: type an amount above your DashMint balance, confirm submit stays disabled with the inline hint

Notes:

  • Token transfers use the TRANSFER-purpose key, not AUTHENTICATION — distinct from card document operations (which require AUTH per the SDK's document state-transition rules). The doc comment on transferDashMintTokens.ts notes that token single-transfer transitions accept either critical auth or TRANSFER purpose; this app standardizes on TRANSFER.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new Tokens tab for users to transfer tokens to recipients
    • Transfer form includes validation and balance checks to prevent invalid transactions
  • Tests

    • Expanded test coverage for token transfer functionality
  • Chores

    • Updated ESLint configuration to exclude the coverage directory

thephez and others added 3 commits June 3, 2026 17:00
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>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thephez, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 622717e9-efb2-40f6-8df1-44fa3cedafb8

📥 Commits

Reviewing files that changed from the base of the PR and between 5376671 and f7c5de9.

📒 Files selected for processing (1)
  • example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx
📝 Walkthrough

Walkthrough

This 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 transferDashMintTokens utility function with comprehensive validation; SDK type extensions for token transfer operations; and full test coverage including component, unit, and end-to-end tests.

Changes

Token Transfer Feature

Layer / File(s) Summary
SDK Type Extensions
setupDashClient-core.d.mts, example-apps/dashmint-lab/src/dash/types.ts
DashKeyManager adds getTransfer() method and DashSdk.tokens adds transfer() method to enable token transfers with signer material and identity context.
Transfer Utility Implementation
example-apps/dashmint-lab/src/dash/transferDashMintTokens.ts, example-apps/dashmint-lab/test/transferDashMintTokens.test.ts
transferDashMintTokens function validates recipient (non-empty, trimmed) and amount (positive), prevents self-transfers using both known identity and signer resolution, logs progress, and calls SDK transfer method. Unit tests cover recipient/amount validation, known and unknown self-transfer prevention, and expected SDK invocation.
UI Navigation Foundation
example-apps/dashmint-lab/src/components/Tabs.tsx, example-apps/dashmint-lab/src/components/AppShell.tsx
TopTab type union extends to include "tokens" option; AppShell navigation adds a Tokens button that switches tabs and closes mobile drawer.
TokenTransferScreen Component
example-apps/dashmint-lab/src/components/TokenTransferScreen.tsx, example-apps/dashmint-lab/test/TokenTransferScreen.test.tsx
Form component with recipient classification, DPNS name resolution, amount parsing (whole tokens only), balance validation, and submit eligibility gating. Helper functions handle amount parsing, recipient hints, and transfer target rendering. Tests verify form validation across empty/invalid/unresolved states, successful submission with resolved recipient IDs and input normalization, balance enforcement, error handling with inline alerts, and form reset on session changes.
App Integration
example-apps/dashmint-lab/src/App.tsx, example-apps/dashmint-lab/test/App.test.tsx
App imports TokenTransferScreen and conditionally renders it in the tokens tab when authenticated; balance refresh useEffect now triggers for both mint and tokens tabs; screenTitles extended with tokens title/subtitle. Tests mock TokenTransferScreen, verify login gate behavior when unauthenticated, confirm authenticated screen rendering with balance propagation, and assert balance refresh is called after token transfer completion.
End-to-End Navigation Test
example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx
Complete user flow integration test: navigates to Tokens tab, fills transfer form (amount and recipient), submits, verifies success status appears, switches to Collection tab confirming status clears, and returns to Tokens tab verifying status is not retained.
Config and Maintenance Updates
example-apps/dashmint-lab/test/dash.test.ts, example-apps/dashmint-lab/eslint.config.js
Existing withAuthedCard test cases extended with getTransfer() mock assertions ensuring the method is not called during card authentication. ESLint globalIgnores extended to include coverage directory.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • dashpay/platform-tutorials#89: Both PRs modify the balance-refresh useEffect in example-apps/dashmint-lab/src/App.tsx tied to tab changes, with this PR extending it to the new tokens tab.

Poem

🐰 A token hops from hand to hand,
Through types and screens across the land,
With validation guards and balance checks so true,
The transfer feature works anew!
Minted lab now shines with fresh appeal.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(dashmint-lab): add Tokens tab for DashMint token transfers' accurately and specifically describes the main change—adding a new Tokens tab feature to dashmint-lab for token transfers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dashmint-token-xfers

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx (1)

196-228: ⚡ Quick win

Verify that the transfer function was invoked.

The test waits for a success status but doesn't confirm that mockTransferDashMintTokens was 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

📥 Commits

Reviewing files that changed from the base of the PR and between 662b16b and 5376671.

📒 Files selected for processing (13)
  • example-apps/dashmint-lab/eslint.config.js
  • example-apps/dashmint-lab/src/App.tsx
  • example-apps/dashmint-lab/src/components/AppShell.tsx
  • example-apps/dashmint-lab/src/components/Tabs.tsx
  • example-apps/dashmint-lab/src/components/TokenTransferScreen.tsx
  • example-apps/dashmint-lab/src/dash/transferDashMintTokens.ts
  • example-apps/dashmint-lab/src/dash/types.ts
  • example-apps/dashmint-lab/test/App.test.tsx
  • example-apps/dashmint-lab/test/AppTokenTransferNavigation.test.tsx
  • example-apps/dashmint-lab/test/TokenTransferScreen.test.tsx
  • example-apps/dashmint-lab/test/dash.test.ts
  • example-apps/dashmint-lab/test/transferDashMintTokens.test.ts
  • setupDashClient-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>
@thephez thephez merged commit d4d98b0 into main Jun 9, 2026
3 checks passed
@thephez thephez deleted the feat/dashmint-token-xfers branch June 9, 2026 16:28
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