Page MenuHomePhabricator

[Cashtab] Add circulating supply to token stats
ClosedPublic

Authored by bytesofman on Apr 2 2024, 05:24.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCa51459af3376: [Cashtab] Add circulating supply to token stats
Summary

Add routine to get current circulating supply and mint batons of a token.

Display supply and mint baton based on current on-chain state instead of genesis supply.

Note: I looked at also showing totalMinted and totalBurned. We should add this, but it needs to be in a separate diff. These quantities need to come from parsing tx history, which can be much larger. For example as of today GRUMPY has over 28,000 txs (about 150 megabytes to get them all from chronik).

The approach there will be along the lines of:

  • Calculate totalBurned and totalMinted through a certain numTxs/numPages of history
  • Cache this (change shape of token cache, though we will not need to migrate for this, will add a key that may be undefined)
  • on send token page load, check cache for these values up to page number and numTxs, then check tx history and update and re-cache them
Test Plan

npm test

Loads instantly for pretty much every token except for GRP at the moment. Can look into improving the "Loading..." ux later, right now there isn't really any impact available.

image.png (744×719 px, 113 KB)

image.png (744×719 px, 143 KB)

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Unit tested helper function to get circulating supply
Unit tested helper function to get (net) burn or mint
Implement functions
Clean up rendering (spinner instead of "Loading..." ?)

Update: this diff is ok for implementing just circulating supply. Functions need to be designed with cache updates, but I think it's worth showing circulating supply before we get to that.

remove burn calc, needs to be in another diff

Tail of the build log:

Installing mock-chronik-client dependencies...
/work/modules/mock-chronik-client /work/abc-ci-builds/cashtab-tests

added 236 packages, and audited 237 packages in 2s

35 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
/work/cashtab /work/modules/mock-chronik-client /work/abc-ci-builds/cashtab-tests

added 1718 packages, and audited 1719 packages in 29s

262 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> cashtab@2.15.1 build
> node scripts/build.js

Creating an optimized production build...
Failed to compile.

[eslint] 
src/components/Send/SendToken.js
  Line 43:5:  'undecimalizeTokenAmount' is defined but never used  no-unused-vars

Search for the keywords to learn more about each error.


Build cashtab-tests failed with exit code 1
bytesofman published this revision for review.Apr 2 2024, 17:01
bytesofman edited the summary of this revision. (Show Details)
bytesofman edited the test plan for this revision. (Show Details)
  • Unit tested helper function to get circulating supply
  • Unit tested helper function to get (net) burn or mint
  • Implement functions
  • Clean up rendering (spinner instead of "Loading..." ?)

Are these coming into this diff or separately?

  • Unit tested helper function to get circulating supply
  • Unit tested helper function to get (net) burn or mint
  • Implement functions
  • Clean up rendering (spinner instead of "Loading..." ?)

Are these coming into this diff or separately?

oops

I think they should come separately. It will be a decent-sized refactor to get this working with the cache, and I won't know what that function should look like until I get into it.

This revision is now accepted and ready to land.Apr 3 2024, 00:00