FIRMA header fiat used CoinGecko simple/price?ids=usd, but that
id is an unrelated crypto token (~₹0.11), not the US dollar. A ~$16
FIRMA balance therefore showed ~₹1.75 instead of ~₹1,575. Switch
fetchFirmaPrice to exchange_rates (BTC-indexed fiat table) and pass the
selected fiat code into the fetch/interval. Update Configure/Header
mocks and add an INR regression asserting ₹1,575.17 for 16.029 FIRMA at
98.27 INR/USD.
Details
- Reviewers
Fabien - Group Reviewers
Restricted Project - Commits
- rABCfe571f54cf59: [Cashtab] Fix FIRMA non-USD fiat conversion via CoinGecko exchange_rates
- cd cashtab && npm test -- --testPathPatterns='Header.test|Configure.test' --no-coverage
- With fiat currency INR and a non-zero FIRMA balance, header USD card fiat line matches balance × USD/INR (not ~0.11×balance)
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) I speak fluent stack trace.
────────────────────────────────────────────────────────────────────────
minor [Functional Correctness]
→ ]8;;vscode://file//work/cashtab/src/wallet/useWallet.ts:1176cashtab/src/wallet/useWallet.ts:1176-1186]8;;
Use Number.isFinite() to validate both rates before computing
firmaPrice.
CoinGecko documents /exchange_rates as BTC-to-currency data. The formula
fiatRate / usdRate is correct for USD-to-fiat conversion.
The current guard checks only typeof fiatRate === 'number'. This check
does not reject NaN, Infinity, zero, or negative values. Any of these
can produce an invalid firmaPrice instead of using the existing null
fallback. Use Number.isFinite() to validate both rates and require both
to be positive:
Proposed validation fix
if (
- typeof usdRate === 'number' &&
+ Number.isFinite(usdRate) &&
usdRate > 0 &&
- typeof fiatRate === 'number'
+ Number.isFinite(fiatRate) &&
+ fiatRate > 0
) {────────────────────────────────────────
Review complete
1 finding ✔
Minor 1
4 files reviewed:
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Header/__tests__/Header.test.tsx
- cashtab/src/test/index.tsx
- cashtab/src/wallet/useWallet.ts
────────────────────────────────────────
Print all AI prompts: coderabbit review --show-prompts
Address CodeRabbit: require Number.isFinite and positive fiatRate/usdRate before setting firmaPrice.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) Test state coverage, not code coverage. Identify and test significant program states. Just testing lines of code isn't enough.
────────────────────────────────────────────────────────────────────────
major [Data Integrity & Integration] → ]8;;vscode://file//work/cashtab/src/test/index.tsx:126cashtab/src/test/index.tsx:126-135]8;; Preserve BTC-relative values in the forex fixture. The fixture sets usd.value to 1 and stores fiatPerUsd directly as the fiat rate. Use a non-unit USD rate and scale each fiat rate proportionally to match the CoinGecko /exchange_rates API contract. Add a regression assertion for the ratio and confirm that rates.inr.value is not equal to 98.27.
────────────────────────────────────────
Review complete
1 finding ✔
Major 1
4 files reviewed:
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Header/__tests__/Header.test.tsx
- cashtab/src/test/index.tsx
- cashtab/src/wallet/useWallet.ts
────────────────────────────────────────
Print all AI prompts: coderabbit review --show-prompts
Address CodeRabbit: BTC-index forex fixture (non-unit usd.value) and assert fiat/usd ratio in Header regression.
Build Bitcoin ABC Diffs / Diff Testing (ai-review) passed.
CodeRabbit Review
Diff : committed changes only
Compare : HEAD → master
Directory : work
────────────────────────────────────────
(\(\
(• .•) I bench-press race conditions.
────────────────────────────────────────
Review complete
No findings ✔
4 files reviewed:
- cashtab/src/components/Configure/__tests__/Configure.test.tsx
- cashtab/src/components/Header/__tests__/Header.test.tsx
- cashtab/src/test/index.tsx
- cashtab/src/wallet/useWallet.ts
────────────────────────────────────────
I solved the same issue in Marlin by using USDT, and special casing the USD conversion to a hardcoded 1:1. The forex option seems better