Page MenuHomePhabricator

[Cashtab] Improve and simplify fiat API
ClosedPublic

Authored by bytesofman on Mar 14 2024, 16:37.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC6a4ccfdd0098: [Cashtab] Improve and simplify fiat API
Summary

We should always throw an error if we do not get a good price. The "double" try...catch is not necessary.

Part of the codebase that has not been changed for years, implementing better practices. Also bumping the interval as 60s was resulting in rate limits.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
patch-forex
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27872
Build 55296: Build Diffcashtab-tests
Build 55295: arc lint + arc unit

Event Timeline

bytesofman added inline comments.
cashtab/src/hooks/useWallet.js
759

Before this diff, if a user had currency set to something other than usd, fiat interval would get usd -- then cashtabLoaded would complete -- then interval would clear and set to their selected currency.

This double-ping also caused rate limit issues.

PiRK added a subscriber: PiRK.
PiRK added inline comments.
cashtab/src/hooks/useWallet.js
674–697

style nit. I'm assuming that JS is like other languages in this regard, if we return in the try branch the rest of the code is unreachable. So if we reach the end we know that we didn't get a number in the API response or that we got an error.

This revision is now accepted and ready to land.Mar 14 2024, 17:19
This revision was automatically updated to reflect the committed changes.
bytesofman marked an inline comment as done.
cashtab/src/hooks/useWallet.js
674–697

nice -- yes, this is a better pattern, thanks