adds pearls a receipt recording app - #144
Conversation
Code Review — PR #144: Pearl (receipt recording app)OverviewPearl adds a new mini-app that lets users compose a digital receipt (merchant, line items, taxes, payment method, notes, tags), preview it as a thermal-tape image, and permanently mint it on Arweave as a PNG + structured metadata. The architecture is clean — schema, constants, hooks, pure utilities, and UI components are all well-separated under That said, there are several issues worth addressing before merging. Bugs / Correctness1. Floating-point arithmetic for financial totals (high priority)
// useComputedTotals.ts
const bundle = i.children.reduce((s, c) => s + c.quantity * c.unitPrice, 0);
const taxes = receipt.taxLines.map(t => ({ amount: subtotal * t.ratePercent / 100 }));
// LineItemRow.tsx (inline, not going through the hook)
{(child.quantity * child.unitPrice).toFixed(2)}JS floats produce the classic 2. Sub-item removal restores // LineItemRow.tsx ~363
if (item.children.length === 1) {
setFieldValue(`${namePrefix}.unitPrice`, 0);
}The schema defaults 3. Navigation guard wires to wrong state flags // PearlPage.tsx ~1961
const { uploading, minting, transaction, minted } = useAppSelector(s => s.pinax);
useNavigationGuard({ uploading, minting, transaction, minted });
4. Missing file size validation
Code Quality5.
6. } catch (e: any) {
const msg = e?.message ?? "Failed to render receipt image";This suppresses TypeScript's unknown-catch safety. Prefer 7. Stale comment: "html2canvas" in The function-level JSDoc says "html2canvas" but the implementation uses 8. Unused
UX / Minor Issues9. "Cancel" button label on the success screen is misleading <Button variant="outline" scale="sm" onClick={onStartOver}>
Cancel
</Button>
10. Content filter doesn't distinguish Pearls from NFTs The comment in 11. Missing
Test CoverageNo tests were added. Two pure functions here are trivial to unit-test and would catch the float-arithmetic and tag-building edge cases:
Summary
The foundation is strong. The float arithmetic issue is the most important fix before mint — a stored grand total of |
No description provided.