Page MenuHomePhabricator

[Cashtab] Convert calculated fiat amount string to locale string

Authored by emack on Oct 13 2021, 23:42.



Linked to T1710:

  • Created new formatFiatBalance function in validation.js which takes in the fiatBalance and an optional locale parameter. A locale formatted string is then returned accordingly.
  • Created unit tests for formatFiatBalance in validation.test.js
  • Updated Send.js to pass in fiatPriceString to the formatFiatBalance function
  • Updated UI snapshots for Send
Test Plan
  • npm start
  • navigate to the Send UI
  • Ensure it is displaying zero fiat currency by default
  • Input 500000000 as the XEC amount and ensure the calculated fiat figure is displayed in locale format
  • npm run extension
  • Repeat above in browser extension mode

Diff Detail

rABC Bitcoin ABC
Lint Passed
No Test Coverage
Build Status
Buildable 17039
Build 33911: Build Diffcashtab-tests
Build 33910: arc lint + arc unit

Event Timeline

emack requested review of this revision.Oct 13 2021, 23:43
bytesofman added inline comments.
254 ↗(On Diff #30505)

need to do a diff with new version of prettier run on whole web/ folder before we use that version

143 ↗(On Diff #30505)

let's call fBalance fiatBalance to fit better with the name of the function

This revision now requires changes to proceed.Oct 14 2021, 22:49
emack marked 2 inline comments as done.
  • Removal of whitespaces was due to local IDE rather than Prettier. This has since been disabled in my IDE and whitespace removal reverted.
  • fBalance variable changed to fiatBalance.
bytesofman added inline comments.

This code block (inside this if() {} statement) needs to handle the case where cashtabSettings is false, similar to the code block it is replacing.

If cashtabSettings is false, assume currency is USD.

It's an edge case for wallets that haven't been loaded since this feature was pushed, but no reason not to preserve it.


Remove else {} ; redundant since using return


remove else {}; redundant since using return

This revision now requires changes to proceed.Oct 21 2021, 20:43
  • Added check for cashtabSettings edge case in Send.js
  • Removed the two redundant else{} blocks in Validation.js
  • Updated Send UI snapshots
This revision is now accepted and ready to land.Oct 28 2021, 21:04