chore(dashmint-lab): card pricing fixes, buy-screen credit check, and test coverage#91
Conversation
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>
📝 WalkthroughWalkthroughThis 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. ChangesMarketplace Pricing and Purchase Flow
Comprehensive Test Coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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 docstrings
🧪 Generate unit tests (beta)
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
example-apps/dashmint-lab/src/App.tsxESLint 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.tsxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. example-apps/dashmint-lab/src/components/PurchaseModal.tsxESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.
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/DashCardOperations.test.ts (1)
58-189: Revision bump is handled inwithAuthedCard, so the wrapper tests don’t need to re-implement it
transferCard,setPrice, andpurchaseCardall callwithAuthedCard()withpreFetchdefaulting totrue, andwithAuthedCardfetches the card document and bumps it viadoc.revision = BigInt(doc.revision ?? 0) + 1nbefore invokingsdk.documents.transfer/setPrice/purchase.burnCardcorrectly usespreFetch: false(no full fetch needed).- Current tests assert the passed
documentobject but don’t explicitly check the revision value change; adding an assertion ondocument.revisionwould 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
📒 Files selected for processing (14)
example-apps/dashmint-lab/src/App.tsxexample-apps/dashmint-lab/src/components/CardTile.tsxexample-apps/dashmint-lab/src/components/PurchaseModal.tsxexample-apps/dashmint-lab/src/components/SetPriceModal.tsxexample-apps/dashmint-lab/src/dash/queries.tsexample-apps/dashmint-lab/test/App.test.tsxexample-apps/dashmint-lab/test/DashCardOperations.test.tsexample-apps/dashmint-lab/test/PurchaseModal.test.tsxexample-apps/dashmint-lab/test/SetPriceModal.test.tsxexample-apps/dashmint-lab/test/UiPrimitives.test.tsxexample-apps/dashmint-lab/test/logger.test.tsexample-apps/dashmint-lab/test/queries.test.tsexample-apps/dashmint-lab/test/useDpnsName.test.tsxexample-apps/dashmint-lab/test/useResolvedRecipient.test.tsx
Summary
A collection of related improvements to the DashMint Lab example app, centered on card pricing and test coverage.
bigintvalues instead of being coerced throughnumber, avoiding precision loss on large prices.PurchaseModalnow 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.Tests
useDpnsName,useResolvedRecipient), and UI primitives.PurchaseModalcases for the insufficient-credits states and extendsSetPriceModal/Appcoverage.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes