Skip to content

chore(dashmint-lab): card pricing fixes, buy-screen credit check, and test coverage#91

Merged
thephez merged 5 commits into
mainfrom
fix/dashmint-random
Jun 9, 2026
Merged

chore(dashmint-lab): card pricing fixes, buy-screen credit check, and test coverage#91
thephez merged 5 commits into
mainfrom
fix/dashmint-random

Conversation

@thephez

@thephez thephez commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

A collection of related improvements to the DashMint Lab example app, centered on card pricing and test coverage.

  • Exact bigint prices — card prices are read and submitted as exact bigint values instead of being coerced through number, avoiding precision loss on large prices.
  • Price cap below the SDK serialization limit — listing a card caps the price below the value where SDK serialization fails, instead of letting the write be rejected on-chain.
  • Insufficient-credits indicator on the Buy screenPurchaseModal now shows the buyer's balance, warns when it's below the card price, and disables the Buy button (relabeled "Insufficient credits") up front, instead of failing only with a raw SDK error after the click.
  • Card row alignment — the price chip reserves its height so card rows stay aligned whether or not a card is listed.

Tests

  • Adds unit coverage across dash ops, queries, logger, hooks (useDpnsName, useResolvedRecipient), and UI primitives.
  • Adds PurchaseModal cases for the insufficient-credits states and extends SetPriceModal / App coverage.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Purchase modal now displays your current credit balance and prevents purchases when insufficient credits are available.
    • Price setting enforces a maximum price cap.
  • Bug Fixes

    • Improved price sorting accuracy for large values.
    • Fixed card header alignment for better visual consistency.
    • Corrected zero-price handling in marketplace listings.

thephez and others added 5 commits June 9, 2026 12:29
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The SDK fails to safely serialize document prices above Number.MAX_SAFE_INTEGER (dashpay/platform#3786). Cap the SetPrice modal at 1,000,000,000,000,000 credits and reject larger values with an inline error, until the SDK fix lands.

Also tighten the parse to require digits-only (Number() accepts hex, exponents, whitespace) and set noValidate on the form so the app-level error path runs instead of the browser's native validation popover.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nd UI primitives

Cover the src/dash card operation wrappers (transfer, setPrice, purchase, burn), the card query helpers, the errorMessage logger helper, the useDpnsName and useResolvedRecipient hooks, and the AppShell/SubTabs/CardGrid/HowItWorks UI primitives. These units were previously exercised only indirectly through mocked modal and app tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Validate the price input as a string and convert with BigInt so values are never rounded through Number before the serialization-limit check, and submit the bigint to setPrice.

Sort the collection by exact bigint price value so prices above Number.MAX_SAFE_INTEGER order correctly, and filter the marketplace with an explicit sale-price check instead of relying on falsy coercion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The purchase modal previously always enabled the Buy button, so an
under-funded buyer only learned they could not afford a card from the
raw SDK error after clicking. Mirror the MintForm pattern: show the
buyer's credit balance, warn when it is below the card price, and
disable the Buy button (relabeled "Insufficient credits") up front.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR enhances the DashMint marketplace application with bigint-based card pricing, purchase credit validation, maximum price enforcement, and comprehensive test coverage. Core pricing logic is normalized to bigint for precision; purchase flow adds balance checks to prevent insufficient-credit transactions; SetPriceModal validates prices against an application-defined maximum; and marketplace filtering explicitly checks for non-zero sale prices.

Changes

Marketplace Pricing and Purchase Flow

Layer / File(s) Summary
BigInt price normalization and sorting
src/App.tsx, test/App.test.tsx
cardPriceValue(card) helper converts card prices to bigint, handling undefined and zero as null. Price sort comparator uses exact bigint comparison with explicit null-last ordering instead of number subtraction.
SetPrice modal: BigInt validation and max price cap
src/components/SetPriceModal.tsx, test/SetPriceModal.test.tsx
Exports MAX_PRICE_CREDITS constant and error message. handleSubmit validates input as digits-only, parses as bigint, rejects values <1 or >max. Form uses noValidate, input includes max attribute, submission passes bigint instead of number.
Purchase flow: Credit balance validation
src/components/PurchaseModal.tsx, test/PurchaseModal.test.tsx
Derives insufficientCredits from session balance and card price. Modal displays balance (or if null), shows insufficient-credits warning when balance < price, disables Buy button and changes label accordingly.
Marketplace filtering: Sale price detection
src/dash/queries.ts, test/queries.test.ts
Introduces hasSalePrice(card) helper to classify cards as "for sale" only when $price is present and non-zero. Updates listMarketplaceCards filter and tests normalizeCards, listMyCards, listAllCards, and marketplace filtering behavior.
CardTile header alignment
src/components/CardTile.tsx
Adds min-h-[22px] constraint to header wrapper to maintain consistent vertical spacing across listed and unlisted card states.

Comprehensive Test Coverage

Layer / File(s) Summary
Card operations: Wrapper function tests
test/DashCardOperations.test.ts
Test suite for transferCard, setPrice, purchaseCard, and burnCard wrappers, verifying input validation, SDK parameter plumbing, bigint price conversion, zero-price removal logging, and document deletion with prefetch disabling.
Hook behaviors: DPNS and recipient resolution
test/useDpnsName.test.tsx, test/useResolvedRecipient.test.tsx
Tests for useDpnsName and useResolvedRecipient hooks covering control flow, name parsing (stripping .dash), module-level caching, in-flight deduplication across sibling instances, and error handling with cache invalidation.
UI components and logger utility tests
test/UiPrimitives.test.tsx, test/logger.test.ts
Test suite for AppShell, SubTabs, CardGrid, HowItWorks UI components (navigation, tab ordering, empty states, card rendering) and errorMessage utility (Error extraction, string passthrough, object message reading, JSON fallback).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Bigints now safely store each price with care,
Cards sorted true by values large and rare,
Credit checks guard against the balance fall,
Max caps enforce what merchants ask for all,
Tests bloom like carrots across the whole affair! 🥕

🚥 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 PR title directly and accurately summarizes the main changes: card pricing fixes (bigint handling), buy-screen credit check (PurchaseModal balance display and validation), and test coverage (multiple new test files added).
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashmint-random

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

example-apps/dashmint-lab/src/App.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

example-apps/dashmint-lab/src/components/CardTile.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

example-apps/dashmint-lab/src/components/PurchaseModal.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 11 others

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/DashCardOperations.test.ts (1)

58-189: Revision bump is handled in withAuthedCard, so the wrapper tests don’t need to re-implement it

  • transferCard, setPrice, and purchaseCard all call withAuthedCard() with preFetch defaulting to true, and withAuthedCard fetches the card document and bumps it via doc.revision = BigInt(doc.revision ?? 0) + 1n before invoking sdk.documents.transfer/setPrice/purchase.
  • burnCard correctly uses preFetch: false (no full fetch needed).
  • Current tests assert the passed document object but don’t explicitly check the revision value change; adding an assertion on document.revision would make the guideline intent more explicit.
🤖 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/DashCardOperations.test.ts` around lines 58 -
189, Update the tests for transferCard, setPrice, and purchaseCard to assert
that the document passed into sdk.documents.transfer/setPrice/purchase has its
revision bumped by withAuthedCard (i.e., document.revision ===
BigInt(originalRevision ?? 0) + 1n); locate the call sites in the tests where
mockWithAuthedCard and baseParams.sdk.documents.* are asserted and add a check
for the revision on the same document object, referencing the transferCard,
setPrice, purchaseCard wrappers and withAuthedCard behavior.

Source: Coding guidelines

🤖 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/DashCardOperations.test.ts`:
- Around line 58-189: Update the tests for transferCard, setPrice, and
purchaseCard to assert that the document passed into
sdk.documents.transfer/setPrice/purchase has its revision bumped by
withAuthedCard (i.e., document.revision === BigInt(originalRevision ?? 0) + 1n);
locate the call sites in the tests where mockWithAuthedCard and
baseParams.sdk.documents.* are asserted and add a check for the revision on the
same document object, referencing the transferCard, setPrice, purchaseCard
wrappers and withAuthedCard behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f861a567-7d3e-4ae4-acbb-7b748d187f40

📥 Commits

Reviewing files that changed from the base of the PR and between d4d98b0 and 7b52f7a.

📒 Files selected for processing (14)
  • example-apps/dashmint-lab/src/App.tsx
  • example-apps/dashmint-lab/src/components/CardTile.tsx
  • example-apps/dashmint-lab/src/components/PurchaseModal.tsx
  • example-apps/dashmint-lab/src/components/SetPriceModal.tsx
  • example-apps/dashmint-lab/src/dash/queries.ts
  • example-apps/dashmint-lab/test/App.test.tsx
  • example-apps/dashmint-lab/test/DashCardOperations.test.ts
  • example-apps/dashmint-lab/test/PurchaseModal.test.tsx
  • example-apps/dashmint-lab/test/SetPriceModal.test.tsx
  • example-apps/dashmint-lab/test/UiPrimitives.test.tsx
  • example-apps/dashmint-lab/test/logger.test.ts
  • example-apps/dashmint-lab/test/queries.test.ts
  • example-apps/dashmint-lab/test/useDpnsName.test.tsx
  • example-apps/dashmint-lab/test/useResolvedRecipient.test.tsx

@thephez thephez merged commit 98c7e65 into main Jun 9, 2026
3 checks passed
@thephez thephez deleted the fix/dashmint-random branch June 9, 2026 19:32
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