Page MenuHomePhabricator

[Cashtab] replace legacy DUST param with constant
ClosedPublic

Authored by bytesofman on Jan 28 2021, 14:04.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC3152367fe3e8: [Cashtab] replace legacy DUST param with constant
Summary

Cashtab has an artefact parameter DUST leftover from mint.bitcoin.com days. This diff removes the parameter and replaces it with the constant currency.dust. A unit test is added to ensure this new variable is parsed the same way as the previous one.

This improvement is a step toward refactoring all functions that deal with the smallest base unit to use the BigNumber.js library. This will prepare the app to accept arbitrary base units.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
remove-separate-dust-var
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15041
Build 30033: Build Diffcashtab-tests
Build 30032: arc lint + arc unit

Event Timeline

Fabien requested changes to this revision.Jan 28 2021, 15:23
Fabien added a subscriber: Fabien.
Fabien added inline comments.
web/cashtab/src/hooks/__tests__/migrations.test.js
7

Are you testing that currency.dust is 0.00000546 ? That doesn't seem very useful

This revision now requires changes to proceed.Jan 28 2021, 15:23

Eventually, the remainder parameter and all similar parameters in the sendBch function will need to be a BigNumber, and compare operations will need to use BigNumber methods like .gte instead of >=. For now, this change only replaces the one-off DUST variable with the now-established app-wide constant currency.dust. Because this diff does not apply any BigNumber methods, it is only replacing DUST with currency.dust; the test makes sure that we are still getting a number of the same type.

Technically, we are also changing DUST from 0.000005 to 0.00000546. This diff does not test whether or not this change is an issue. However the original intent of the DUST parameter was to prevent outputs smaller than backend minimum, which is 0.00000546.

I don't think the test adds a great deal of value but it does illustrate no syntax error in converting the currency.dust string to the same number type as the previous DUST variable.

This revision is now accepted and ready to land.Jan 29 2021, 19:14