Page MenuHomePhabricator

[Cashtab] [utxo handling p2] Sort etoken and non-etoken utxos
AbandonedPublic

Authored by bytesofman on Aug 5 2022, 17:07.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

T2447

Depends on D11818

Add a function to get eToken info to utxo set using chronik instead of bch-api

This diff converts raw chronik utxo data, introduced in D11818, into the same data structure used by Cashtab pulling info from bch-api.

utxos are split between non-eToken and eToken, and eToken information is added.

Test Plan

npm start and note that bchApislpBalancesAndUtxos and chronikslpBalancesAndUtxos printed in the console display same quantity of slp and non-slpUtxos, same token info

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-utxo-handling
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 19792
Build 39298: Build Diffcashtab-tests
Build 39297: arc lint + arc unit

Event Timeline

There are some optimizations available here compared to the way it was done as a proof of concept in D11385

Tail of the build log:

npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-preset-env@7.4.3',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'postcss-pseudo-class-any-link@7.1.1',
npm WARN EBADENGINE   required: { node: '^12 || ^14 || >=16' },
npm WARN EBADENGINE   current: { node: 'v15.14.0', npm: '7.7.6' }
npm WARN EBADENGINE }
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated text-encoding@0.6.4: no longer maintained
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm WARN deprecated ts-custom-error@2.2.2: npm package tarball contains useless codeclimate-reporter binary, please update to version 3.1.1. See https://github.com/adriengibrat/ts-custom-error/issues/32

> cashtab@1.0.0 prepare
> cd ../.. && husky install web/cashtab/.husky

husky - Git hooks installed

added 1810 packages, and audited 1811 packages in 27s

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

22 vulnerabilities (10 moderate, 11 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm notice 
npm notice New major version of npm available! 7.7.6 -> 8.16.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.16.0>
npm notice Run `npm install -g npm@8.16.0` to update!
npm notice 

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

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

src/utils/chronik.js
  Line 73:7:   'getSlpBalancesAndUtxosFromChronik' is assigned a value but never used  no-unused-vars
  Line 139:9:  'getTxDetailsChronik' is not defined                                    no-undef
  Line 153:7:  'addTokenInfo' is assigned a value but never used                       no-unused-vars

Search for the keywords to learn more about each error.


Build cashtab-tests failed with exit code 1

Adding functionality, unit test

In implementing a unit test for the token method, discovered that earlier mock of chronik.script('p2pkh', hash160).utxos(); was not actually mocking anything. Updated mocked chronik client URL to be fake as a way to catch future failed mocks.

Still need to fix the original unit test.

Refactoring utxo storage and the discovery that the chronik.script('p2pkh', hash160).utxos(); is not readily mockable in jest means a slightly different approach will be used

Superseded by D11928 stack