Page MenuHomePhabricator

[Cashtab] Do not airdrop XEC to agora scripts
Needs ReviewPublic

Authored by bytesofman on Mon, Dec 16, 00:10.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

The "holders" of the token qty offered in an Agora offer are the p2pkh addresses of the creating pk.

Make sure the airdrop function takes this into account. Otherwise we will airdrop XEC to Agora scripts.

We convert airdrop functions and tests to typescript to support this.

We also clean up the airdrop calculation functions. Behavior confirmed with existing tests.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
no-p2sh-airdrops
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 31704
Build 62904: Build Diffcashtab-tests
Build 62903: arc lint + arc unit

Event Timeline

Tail of the build log:

  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
 src/transactions                       |   98.79 |     92.3 |     100 |   98.79 |                                                                                                                                                                                                                                                 
  index.js                              |   98.79 |     92.3 |     100 |   98.79 | 175                                                                                                                                                                                                                                             
 src/transactions/fixtures              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  mocks.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
 src/utils                              |   94.93 |    94.59 |     100 |   94.93 |                                                                                                                                                                                                                                                 
  cashMethods.js                        |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  formatting.ts                         |   94.44 |    93.93 |     100 |   94.44 | 24,54-56                                                                                                                                                                                                                                        
 src/utils/fixtures                     |       0 |        0 |       0 |       0 |                                                                                                                                                                                                                                                 
  vectors.js                            |       0 |        0 |       0 |       0 |                                                                                                                                                                                                                                                 
 src/validation                         |   97.06 |    95.67 |     100 |   97.29 |                                                                                                                                                                                                                                                 
  index.ts                              |   97.06 |    95.67 |     100 |   97.29 | 116-117,282,317,337,384,585,692-693,997,1002                                                                                                                                                                                                    
 src/validation/fixtures                |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  mocks.js                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
 src/wallet                             |   94.96 |    87.78 |   89.06 |   95.12 |                                                                                                                                                                                                                                                 
  context.tsx                           |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  index.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  useWallet.ts                          |    91.3 |    79.22 |   79.41 |   91.61 | 140,222-223,604-610,649,654,717-718,729,790,816,859-860,872-887,901,951,979,988-991,1062,1132-1133,1161                                                                                                                                         
 src/wallet/fixtures                    |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  mocks.js                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
----------------------------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='5046']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='5941']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='2808']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='3487']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='962']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1204']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='4952']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='5829']
##teamcity[blockClosed name='Code Coverage Summary']

Summary of all failing tests
FAIL src/airdrop/__tests__/index.test.js
  ● Test suite failed to run

    Cannot find module '../../../../modules/mock-chronik-client/dist' from 'src/airdrop/__tests__/index.test.js'

       6 | import vectors from 'airdrop/fixtures/vectors';
       7 | import { initWasm } from 'ecash-lib';
    >  8 | import { MockAgora } from '../../../../modules/mock-chronik-client/dist';
         | ^
       9 |
      10 | describe('Cashtab airdrop methods', () => {
      11 |     beforeAll(async () => {

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/airdrop/__tests__/index.test.js:8:1)


Test Suites: 1 failed, 41 passed, 42 total
Tests:       1103 passed, 1103 total
Snapshots:   0 total
Time:        48.747 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

Tail of the build log:

Run `npm audit` for details.

> ecash-lib@1.1.0 build
> tsc && tsc -p ./tsconfig.build.json && cp -r ./src/ffi ./dist

Installing ecash-agora dependencies...
/work/modules/ecash-agora /work/modules/ecash-lib /work/modules/ecash-lib-wasm /work/modules/ecash-script /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/cashtab-tests

added 364 packages, and audited 367 packages in 1s

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

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> ecash-agora@0.2.0 build
> tsc && tsc -p ./tsconfig.build.json

/work/cashtab /work/modules/ecash-agora /work/modules/ecash-lib /work/modules/ecash-lib-wasm /work/modules/ecash-script /work/modules/chronik-client /work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated eslint@8.56.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 1489 packages, and audited 3335 packages in 23s

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

8 vulnerabilities (6 moderate, 2 high)

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

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

Run `npm audit` for details.

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

Creating an optimized production build...

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

[eslint] 
src/airdrop/index.ts
  Line 7:25:   'TokenIdUtxos' is defined but never used                    @typescript-eslint/no-unused-vars
  Line 12:10:  'MAX_MINT_AMOUNT_TOKEN_SATOSHIS' is defined but never used  @typescript-eslint/no-unused-vars


Build cashtab-tests failed with exit code 1

Tail of the build log:

 src/wallet                             |   94.96 |    87.78 |   89.06 |   95.12 |                                                                                                                                                                                                                                                 
  context.tsx                           |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  index.ts                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  useWallet.ts                          |    91.3 |    79.22 |   79.41 |   91.61 | 140,222-223,604-610,649,654,717-718,729,790,816,859-860,872-887,901,951,979,988-991,1062,1132-1133,1161                                                                                                                                         
 src/wallet/fixtures                    |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  mocks.js                              |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
  vectors.js                            |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                 
----------------------------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='5015']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='6073']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='2764']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='3527']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='928']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1211']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='4928']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='5962']
##teamcity[blockClosed name='Code Coverage Summary']

Summary of all failing tests
FAIL src/components/Airdrop/__tests__/Airdrop.test.js
  ● Test suite failed to run

    Cannot find module '../../../../../modules/mock-chronik-client/dist' from 'src/components/Airdrop/__tests__/Airdrop.test.js'

      27 | } from 'components/App/fixtures/helpers';
      28 | import CashtabTestWrapper from 'components/App/fixtures/CashtabTestWrapper';
    > 29 | import { MockAgora } from '../../../../../modules/mock-chronik-client/dist';
         | ^
      30 | import {
      31 |     agoraOfferCachetAlphaOne,
      32 |     cachetCacheMocks,

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/components/Airdrop/__tests__/Airdrop.test.js:29:1)

FAIL src/airdrop/__tests__/index.test.ts
  ● Test suite failed to run

    Cannot find module '../../../../modules/mock-chronik-client/dist' from 'src/airdrop/__tests__/index.test.ts'

      12 | import vectors from 'airdrop/fixtures/vectors';
      13 | import { initWasm } from 'ecash-lib';
    > 14 | import {
         | ^
      15 |     MockAgora,
      16 |     MockChronikClient,
      17 | } from '../../../../modules/mock-chronik-client/dist';

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/airdrop/__tests__/index.test.ts:14:1)


Test Suites: 2 failed, 40 passed, 42 total
Tests:       1123 passed, 1123 total
Snapshots:   0 total
Time:        49.74 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

build mock-chronik-client for cashtab tests

Tail of the build log:

npm warn deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.

> ecashaddrjs@1.6.2 prepublish
> npm run build


> ecashaddrjs@1.6.2 build
> tsc


added 579 packages, and audited 580 packages in 4s

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

4 vulnerabilities (3 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> ecashaddrjs@1.6.2 build
> tsc

Installing mock-chronik-client dependencies...
/work/modules/mock-chronik-client /work/modules/ecashaddrjs /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 349 packages, and audited 352 packages in 2s

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

1 high severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> mock-chronik-client@2.0.1 build
> tsc

../chronik-client/proto/chronik.ts(2,18): error TS2307: Cannot find module 'long' or its corresponding type declarations.
../chronik-client/proto/chronik.ts(3,17): error TS2307: Cannot find module 'protobufjs/minimal' or its corresponding type declarations.
../chronik-client/src/ChronikClient.ts(5,22): error TS2307: Cannot find module 'ecashaddrjs' or its corresponding type declarations.
../chronik-client/src/ChronikClient.ts(6,23): error TS2307: Cannot find module 'isomorphic-ws' or its corresponding type declarations.
../chronik-client/src/ChronikClient.ts(7,21): error TS2307: Cannot find module 'ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(5,38): error TS2307: Cannot find module 'axios' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(6,23): error TS2307: Cannot find module 'isomorphic-ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(7,21): error TS2307: Cannot find module 'ws' or its corresponding type declarations.
../chronik-client/src/failoverProxy.ts(186,35): error TS7006: Parameter 'x' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(270,32): error TS7006: Parameter 'e' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(276,30): error TS7006: Parameter 'e' implicitly has an 'any' type.
../chronik-client/src/failoverProxy.ts(294,33): error TS7006: Parameter 'msg' implicitly has an 'any' type.
Build cashtab-tests failed with exit code 2

build chronik-client before mock-chronik-client