Page MenuHomePhabricator

[token-server] Add function to check eligibility for token reward
AbandonedPublicDraft

Authored by bytesofman on Mar 1 2024, 01:19.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Depends on D15586

Add a function to check if a given address is eligible for a token reward

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
token-server-next-steps
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27566
Build 54695: Build Diff
Build 54694: arc lint + arc unit

Event Timeline

more functions, tests, vectors, solve smaller problems

good stopping point. need to define a tx history fetching function that iterates over pages

Tail of the build log:

  npm audit fix --force

Run `npm audit` for details.

> ecash-herald@1.0.0 test
> mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/ecash-herald-junit.xml --reporter-options testsuitesTitle=Ecash Herald Unit Tests --reporter-options rootSuiteTitle=Ecash Herald


Error: Cannot find module 'ecashaddrjs'
Require stack:
- /work/apps/mock-chronik-client/index.js
- /work/apps/ecash-herald/test/chronik.test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/mock-chronik-client/index.js:5:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/ecash-herald/test/chronik.test.js:6:31)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15)
    at async formattedImport (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async exports.requireOrImport (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async exports.loadFilesAsync (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async exports.handler (/work/apps/ecash-herald/node_modules/mocha/lib/cli/run.js:370:5)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='0']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-herald-junit.xml': No such file or directory
Build ecash-herald-tests failed with exit code 1

Tail of the build log:

- /work/apps/examples/test/sendXec.test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/mock-chronik-client/index.js:5:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/examples/test/sendXec.test.js:20:31)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15)
    at async formattedImport (/work/apps/examples/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async exports.requireOrImport (/work/apps/examples/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async exports.loadFilesAsync (/work/apps/examples/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/apps/examples/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async exports.handler (/work/apps/examples/node_modules/mocha/lib/cli/run.js:370:5)
-----------------------------|---------|----------|---------|---------|-------------------
File                         | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-----------------------------|---------|----------|---------|---------|-------------------
All files                    |   49.26 |    11.11 |   44.44 |    49.5 |                   
 mocks                       |    3.22 |        0 |       0 |    3.22 |                   
  chronikMock.js             |    1.63 |        0 |       0 |    1.63 | 11-160            
  chronikResponses.js        |     100 |      100 |     100 |     100 |                   
 scripts                     |    69.5 |       25 |   88.88 |      70 |                   
  createWallet.js            |     100 |      100 |     100 |     100 |                   
  getDetailsFromTxid.js      |      80 |      100 |     100 |      80 | 20,35             
  getTokenDetails.js         |      80 |      100 |     100 |      80 | 20,34             
  getTxHistoryFromAddress.js |   73.33 |      100 |     100 |   73.33 | 29-36,58          
  getUtxosFromAddress.js     |      75 |      100 |     100 |      75 | 30-32,47          
  listenForConfirmation.js   |      50 |        0 |      50 |      50 | 18-45             
  sendXec.js                 |      60 |     37.5 |     100 |   61.11 | 69-146,205,233    
-----------------------------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='100']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='203']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='3']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='27']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='16']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='36']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='100']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='202']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/examples-junit.xml': No such file or directory
Build app-dev-examples failed with exit code 1

Tail of the build log:

- /work/apps/mock-chronik-client/index.js
- /work/apps/alias-server/test/chronik.test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/mock-chronik-client/index.js:5:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/work/apps/alias-server/test/chronik.test.js:16:31)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15)
    at async formattedImport (/work/apps/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
    at async exports.requireOrImport (/work/apps/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
    at async exports.loadFilesAsync (/work/apps/alias-server/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/apps/alias-server/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async exports.handler (/work/apps/alias-server/node_modules/mocha/lib/cli/run.js:370:5)
------------------------|---------|----------|---------|---------|-------------------
File                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------------|---------|----------|---------|---------|-------------------
All files               |    7.77 |        0 |       0 |    7.98 |                   
 alias-server           |     100 |      100 |     100 |     100 |                   
  config.js             |     100 |      100 |     100 |     100 |                   
 alias-server/constants |     100 |      100 |     100 |     100 |                   
  alias.js              |     100 |      100 |     100 |     100 |                   
 alias-server/src       |    7.27 |        0 |       0 |    7.47 |                   
  alias.js              |    5.88 |        0 |       0 |    6.06 | 23-369            
  app.js                |   16.66 |        0 |       0 |   16.66 | 23-183            
  chronik.js            |    4.47 |        0 |       0 |    4.76 | 12-196            
  db.js                 |    6.09 |        0 |       0 |    6.09 | 17-308            
  utils.js              |       5 |        0 |       0 |    5.26 | 12-160            
------------------------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='29']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='373']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='140']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='40']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='29']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='363']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/alias-server-junit.xml': No such file or directory
Build alias-server-tests failed with exit code 1

Tail of the build log:

      8 |     MockChronikClient: class {

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (../apps/mock-chronik-client/index.js:5:19)
      at Object.require (src/components/fixtures/helpers.js:1:1)
      at Object.require (src/components/Etokens/__tests__/CreateToken.test.js:6:1)

FAIL src/hooks/__tests__/useWallet.test.js
  โ— Test suite failed to run

    Cannot find module 'ecashaddrjs' from '../apps/mock-chronik-client/index.js'

    Require stack:
      /work/apps/mock-chronik-client/index.js
      src/components/fixtures/helpers.js
      src/hooks/__tests__/useWallet.test.js

      3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php.
      4 | 'use strict';
    > 5 | const ecashaddr = require('ecashaddrjs');
        |                   ^
      6 |
      7 | module.exports = {
      8 |     MockChronikClient: class {

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (../apps/mock-chronik-client/index.js:5:19)
      at Object.require (src/components/fixtures/helpers.js:1:1)
      at Object.require (src/hooks/__tests__/useWallet.test.js:14:1)

FAIL src/components/fixtures/__tests__/CashtabTestWrapper.test.js
  โ— Test suite failed to run

    Cannot find module 'ecashaddrjs' from '../apps/mock-chronik-client/index.js'

    Require stack:
      /work/apps/mock-chronik-client/index.js
      src/components/fixtures/helpers.js
      src/components/fixtures/__tests__/CashtabTestWrapper.test.js

      3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php.
      4 | 'use strict';
    > 5 | const ecashaddr = require('ecashaddrjs');
        |                   ^
      6 |
      7 | module.exports = {
      8 |     MockChronikClient: class {

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (../apps/mock-chronik-client/index.js:5:19)
      at Object.require (src/components/fixtures/helpers.js:1:1)
      at Object.require (src/components/fixtures/__tests__/CashtabTestWrapper.test.js:9:1)


Test Suites: 15 failed, 14 passed, 29 total
Tests:       459 passed, 459 total
Snapshots:   0 total
Time:        12.191 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

we can determine if an address is eligible for token rewards

Add endpoint for eligibility status

add route to return eligibility by address

remove unrelated mock-cc changes, convert script to ts