Page MenuHomePhabricator

[Cashtab] replace BCHA decimal unit with a constant
ClosedPublic

Authored by bytesofman on Jan 25 2021, 15:55.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCe06b0ec4e874: [Cashtab] replace BCHA decimal unit with a constant
Summary

BCHA has 8 decimal places, and the value "8" is occasionally used in calculation that convert between BCHA and satoshis. This diff replaces "8" with a constant in Ticker.js to support potential adjustments to this value. Note: this diff does not completely prepare the app to support different decimal places. An additional diff is required that would remove use of the .toSatoshis function from bch-js and replace it with a generalized conversion function.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
bcha-decimals-to-constant
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14977
Build 29906: Build Diffcashtab-tests
Build 29905: arc lint + arc unit

Event Timeline

Replace '8' with currency.cashDecimals in validation error msg

Why did you choose to call it currency.cashDecimals and not just currency.decimals ? Could it be confused with something else ?

web/cashtab/src/utils/validation.js
41

Nit: you should remove this comment, it brings no value and has the hardcoded number of decimals

There is a .decimals parameter for token utxos, which can be between 0 and 9 inclusive depending on the SLPA token. I wanted to avoid duplicating this key, which is used directly on the SendToken.js page.

Removing comment with hardcoded 8

This revision is now accepted and ready to land.Jan 25 2021, 17:27