feat(currency): add INR display support - #274
Conversation
… params. Add Indian Rupee to the currency registry, Windows fallback rates, settings copy/i18n, and India-locale auto-default when no preference is saved. Wire QualityPerDollar and leaderboard cost formatting to useCurrency, and support currency/rate query params on embed and badge SVG endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds INR support across currency data, locale-based defaults, edge SVG embed formatting, dashboard cost displays, and i18n labels, with matching updates to unit and render tests. ChangesINR Currency Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Related Issues: None found Sequence Diagram(s)sequenceDiagram
participant Client
participant tokentracker-badge-svg
participant tokentracker-embed-svg
participant embed-currency helper
Client->>tokentracker-badge-svg: GET ?metric=cost¤cy=INR&rate=83.5
tokentracker-badge-svg->>embed-currency helper: parseEmbedCurrency(searchParams)
embed-currency helper-->>tokentracker-badge-svg: currencyOpts
tokentracker-badge-svg->>embed-currency helper: formatEmbedCost(cost, currencyOpts)
embed-currency helper-->>tokentracker-badge-svg: formatted badge value
tokentracker-badge-svg-->>Client: SVG badge
Client->>tokentracker-embed-svg: GET ?currency=INR&rate=83.5
tokentracker-embed-svg->>embed-currency helper: parseEmbedCurrency(searchParams)
embed-currency helper-->>tokentracker-embed-svg: currencyOpts
tokentracker-embed-svg->>embed-currency helper: formatEmbedCost(estimated_cost_usd, currencyOpts)
embed-currency helper-->>tokentracker-embed-svg: formatted profile cost
tokentracker-embed-svg-->>Client: profile card SVG
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
dashboard/src/components/leaderboard/LeaderboardProfileModal.jsx (1)
22-30: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winSub-cent threshold uses raw USD value, not the converted amount.
nis the raw USD cost, butsymbolreflects the target currency. For INR (rate ≈83.5), a value like$0.005(rawn < 0.01) actually converts to ~₹0.42 — well above ₹0.01 — yet this still renders"<₹0.01", understating the true cost. The threshold should be compared against the converted amount for non-USD currencies.🐛 Proposed fix
function formatCost(value, currency, rate) { const n = Number(value); if (!Number.isFinite(n) || n < 0) return "—"; const symbol = getCurrencySymbol(currency); - if (n > 0 && n < 0.01) { + const converted = currency === "USD" || !rate ? n : n * rate; + if (converted > 0 && converted < 0.01) { return `<${symbol}0.01`; } return formatUsdCurrency(n, { decimals: 2, currency, rate }); }🤖 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 `@dashboard/src/components/leaderboard/LeaderboardProfileModal.jsx` around lines 22 - 30, The sub-cent check in formatCost uses the raw USD value instead of the target-currency amount, so small USD values can be mislabeled for non-USD currencies. Update formatCost to base the “< 0.01” threshold on the converted value (using the currency/rate inputs and the existing getCurrencySymbol/formatUsdCurrency flow), while keeping the raw-value formatting path for USD or when conversion is not needed.
🤖 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.
Inline comments:
In `@dashboard/src/ui/dashboard/components/QualityPerDollarCard.jsx`:
- Around line 9-13: The decimal precision in formatMoney is being chosen from
the pre-conversion USD value, which causes overly precise output after currency
conversion. Update formatMoney (and any related logic in QualityPerDollarCard
that uses it) so the decimals decision is based on the converted amount returned
by formatUsdCurrency for the target currency, not on n before conversion. Keep
the null/zero handling intact, but make the precision selection happen after
applying the currency multiplier so INR and similar currencies format
consistently.
---
Outside diff comments:
In `@dashboard/src/components/leaderboard/LeaderboardProfileModal.jsx`:
- Around line 22-30: The sub-cent check in formatCost uses the raw USD value
instead of the target-currency amount, so small USD values can be mislabeled for
non-USD currencies. Update formatCost to base the “< 0.01” threshold on the
converted value (using the currency/rate inputs and the existing
getCurrencySymbol/formatUsdCurrency flow), while keeping the raw-value
formatting path for USD or when conversion is not needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0db9a72e-056b-4930-8f63-4fab44a1e2d1
⛔ Files ignored due to path filters (1)
dashboard/src/content/copy.csvis excluded by!**/*.csv
📒 Files selected for processing (17)
TokenTrackerWin/Currency.csdashboard/edge-patches/embed-currency.tsdashboard/edge-patches/tokentracker-badge-svg.tsdashboard/edge-patches/tokentracker-embed-svg.tsdashboard/src/components/leaderboard/LeaderboardProfileModal.jsxdashboard/src/content/i18n/de/core.jsondashboard/src/content/i18n/ja/core.jsondashboard/src/content/i18n/ko/core.jsondashboard/src/content/i18n/zh-TW/core.jsondashboard/src/content/i18n/zh/core.jsondashboard/src/lib/currency.test.tsdashboard/src/lib/currency.tsdashboard/src/lib/exchange-rate.test.tsdashboard/src/lib/format.test.tsdashboard/src/ui/dashboard/components/QualityPerDollarCard.jsxtest/badge-svg-render.test.jstest/embed-currency.test.js
Pick decimal precision and sub-cent labels from the target-currency value so non-USD displays like INR stay consistent after conversion. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed both CodeRabbit findings in
Tests: |
|
Great contribution! All 1,215 local tests passed successfully. However, we found a few issues that need to be addressed before merging. Most importantly, Issue #1 will cause runtime errors on the deployed Deno Edge environment because InsForge deploys edge patches as individual self-contained files and does not resolve local relative imports. Code reviewFound 3 issues:
https://github.com/mm7894215/TokenTracker/blob/6d14c7f1611e7e60addb159a5109e41913db760c/dashboard/edge-patches/tokentracker-badge-svg.ts#L21-L25
|
|
This PR has been inactive for 14 days and is now marked as stale. It will be closed in 7 days if there are no updates. |
Summary
Adds Indian Rupee (INR, ₹) as a first-class display currency across the dashboard, native tray/pet sync, and public embed/badge SVGs. Costs remain stored in USD; conversion happens at display time via existing exchange-rate flow.
Changes
INRincurrency.tswith bundled default rate (83.5 USD→INR) and live fetch via open.er-api.comen-IN,hi-IN, …) auto-select INR when no saved preference existsCurrency.csfallback map includes INRQualityPerDollarCardand leaderboard profile cost formatting respectuseCurrency()(fixes hardcoded$)currency+ optionalratequery params ontokentracker-embed-svgandtokentracker-badge-svg; profile embed snippet passes user's current currencyTest plan
cd dashboard && npm test -- currency format exchange-ratenode --test test/embed-currency.test.js test/badge-svg-render.test.jsnpm run validate:copynpm run validate:ui-hardcodeen-IN+ clearedtokentracker-currency→ defaults to INR?currency=INR&rate=83.5shows converted cost in SVGMade with Cursor
Summary by CodeRabbit
costin a chosen currency usingcurrencyand optionalrate.currency/rateparameters.