Page MenuHomePhabricator

[ecash-herald] display amounts in fiat if prices are available
ClosedPublic

Authored by bytesofman on Jun 19 2023, 22:11.

Details

Summary

T2972

Add new function satsToFormattedFiat that accepts satoshis and coingeckoPrices and returns a formatted string. Returns amount in XEC if dollar amount is less than 1.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
sats-to-formatted-fiat
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24096
Build 47802: Build Diffecash-herald-tests
Build 47801: arc lint + arc unit

Event Timeline

apps/ecash-herald/test/utilsTests.js
35 ↗(On Diff #40871)

it's weird that these unrelated MockAdapter lines got this treatment

I tried going back to master and prettier --write test/utilsTests.js but no effect. So, these changes are somehow related to this file getting longer with other unit tests.

Weirder still that this didn't happen in D14079

emack requested changes to this revision.Jun 19 2023, 23:24
emack added a subscriber: emack.
emack added inline comments.
apps/ecash-herald/src/utils.js
173

since you already worked out xecAmount above then just use that instead of calling satsToformattedXec

apps/ecash-herald/test/utilsTests.js
261

can use another test for a fiat amount that is close to $999,999.99 and see if there are any rounding errors that would result in the M descriptor being incorrectly assigned as opposed to K.
also should test whether the 1 trillion amount will actually be returned as 1000B

This revision now requires changes to proceed.Jun 19 2023, 23:24
bytesofman marked an inline comment as done.

Modify functions and names to fit their implementation; add recommended unit test

This revision is now accepted and ready to land.Jun 20 2023, 00:06