HomePhabricator

[Cashtab] Improve bignumber parsing for token agora

Description

[Cashtab] Improve bignumber parsing for token agora

Summary:
Handle big token quantities in agora offers

We have updated all of the math to use bigint in the OrderBook component. However, I did not realize we are still limited by the html slider field. This field only accepts string values, which are then automatically converted to Number for math operations. Since values there are outside of Number.MAX_SAFE_INTEGER, we are getting bad calculations for takeTokenSatoshis (out of line with calculated tokenSatoshisStep). agora throws errors trying to calculate price with invalid values.

I went down a rabbit hole improving the capability of string-based big number helpers in Cashtab. This was (somewhat) fruitless, but the functions are "better", so why not. We do need toBigInt as JS will not convert stringified scientific notation to bigint.

The fix is in preparing all values that come in from the slider. Going forward, we may find it important to build our own slider and have it accept bigint.

Test Plan:
npm test, visit https://cashtab-local-dev.netlify.app/, make sure version is 2.49.0, nav to agora screen, ctrl+f "rocash", use the slider, we do not see white screen of death app crash

image.png (400×473 px, 57 KB)

Reviewers: #bitcoin_abc, emack

Reviewed By: #bitcoin_abc, emack

Subscribers: emack

Differential Revision: https://reviews.bitcoinabc.org/D17044

Details

Provenance
bytesofmanAuthored on Wed, Oct 30, 04:00
bytesofmanPushed on Thu, Oct 31, 03:07
Reviewer
Restricted Project
Differential Revision
D17044: [Cashtab] Improve bignumber parsing for token agora
Parents
rABCb91f480f976f: [token-server] Link token blacklist with icon approval actions
Branches
Unknown
Tags
Unknown