Page MenuHomePhabricator

[ChronikClient] Add "UNKNOWN" protocol type
ClosedPublic

Authored by tobias_ruck on May 26 2025, 22:18.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC7b68fb8230a3: [ChronikClient] Add "UNKNOWN" protocol type
Summary

In case we add a new token protocol in the future, this gracefully allows querying the tx without throwing an error.

E.g., if we were to add BLP (Better Ledger Protocol), and were to connect an old ChronikClient version to a Chronik instance that implements BLP, this library (without this diff) would always throw an error for any transactions containing BLP tokens. However, it is better to return that the token protocol is unknown.

A corollary is that app devs are now forced to handle UNKNOWN token protocols, however, this is something that should be handled gracefully. Right now, it's impossible to handle it gracefully.

Test Plan

npm test && npm run integration-tests

Diff Detail

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

Event Timeline

Tail of the build log:

> chronik-client@3.1.1 build
> tsc


added 235 packages, and audited 237 packages in 4s

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

4 vulnerabilities (3 moderate, 1 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.

> chronik-client@3.1.1 build
> tsc

/work/modules/ecash-lib /work/abc-ci-builds/ecash-herald-tests

added 271 packages, and audited 275 packages in 1s

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

6 vulnerabilities (5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

/work/modules/ecash-agora /work/abc-ci-builds/ecash-herald-tests

added 272 packages, and audited 275 packages in 1s

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

6 vulnerabilities (5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

src/ad.ts(75,21): error TS2454: Variable 'opreturnScript' is used before being assigned.
src/agora.ts(967,13): error TS2322: Type '"UNKNOWN" | "SLP" | "ALP"' is not assignable to type '"SLP" | "ALP"'.
  Type '"UNKNOWN"' is not assignable to type '"SLP" | "ALP"'.
Build ecash-herald-tests failed with exit code 2

Tail of the build log:

[555/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/trafficgraphwidget.cpp.o
[556/593] Linking CXX executable src/bench/bitcoin-bench
[557/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/utilitydialog.cpp.o
[558/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/coincontroltreewidget.cpp.o
[559/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/splashscreen.cpp.o
[560/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/createwalletdialog.cpp.o
[561/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/editaddressdialog.cpp.o
[562/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/askpassphrasedialog.cpp.o
[563/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrc_bitcoin_locale.cpp.o
[564/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrimagewidget.cpp.o
[565/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/openuridialog.cpp.o
[566/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/addresstablemodel.cpp.o
[567/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/overviewpage.cpp.o
[568/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactionfilterproxy.cpp.o
[569/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactiondescdialog.cpp.o
[570/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/receiverequestdialog.cpp.o
[571/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/recentrequeststablemodel.cpp.o
[572/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/sendcoinsentry.cpp.o
[573/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/rpcconsole.cpp.o
[574/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/receivecoinsdialog.cpp.o
[575/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/coincontroldialog.cpp.o
[576/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactionrecord.cpp.o
[577/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/paymentserver.cpp.o
[578/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/walletframe.cpp.o
[579/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactionview.cpp.o
[580/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactiondesc.cpp.o
[581/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/walletmodeltransaction.cpp.o
[582/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/transactiontablemodel.cpp.o
[583/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/signverifymessagedialog.cpp.o
[584/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/paymentrequestplus.cpp.o
[585/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/walletcontroller.cpp.o
[586/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/sendcoinsdialog.cpp.o
[587/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/walletview.cpp.o
[588/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/walletmodel.cpp.o
[589/593] Linking CXX static library src/qt/libbitcoin-qt-base.a
[590/593] Automatic MOC for target bitcoin-qt
[591/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/bitcoin-qt_autogen/mocs_compilation.cpp.o
[592/593] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/main.cpp.o
[593/593] Linking CXX executable src/qt/bitcoin-qt
/work/modules/ecash-agora /work/abc-ci-builds/ecash-agora-integration-tests

added 272 packages, and audited 275 packages in 1s

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

6 vulnerabilities (5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

src/ad.ts(75,21): error TS2454: Variable 'opreturnScript' is used before being assigned.
src/agora.ts(967,13): error TS2322: Type '"UNKNOWN" | "SLP" | "ALP"' is not assignable to type '"SLP" | "ALP"'.
  Type '"UNKNOWN"' is not assignable to type '"SLP" | "ALP"'.
Build ecash-agora-integration-tests failed with exit code 2

Tail of the build log:

    at Function.Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.<anonymous> (/work/apps/ecash-herald/src/chronikWsHandler.ts:5:302)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1618:23)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.<anonymous> (/work/apps/ecash-herald/test/chronikWsHandler.test.ts:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1529:14)
    at Module.replacementCompile (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:60:13)
    at Module.m._compile (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1618:23)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/apps/ecash-herald/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1096:12)
    at Module.require (node:internal/modules/cjs/loader:1298:19)
    at require (node:internal/modules/helpers:182:18)
    at Object.exports.requireOrImport (/work/apps/ecash-herald/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.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 Object.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               |   14.84 |     0.91 |       0 |   11.47 |                                  
 ecash-herald           |     100 |      100 |     100 |     100 |                                  
  config.ts             |     100 |      100 |     100 |     100 |                                  
  secrets.ts            |     100 |      100 |     100 |     100 |                                  
 ecash-herald/constants |     100 |      100 |     100 |     100 |                                  
  addresses.ts          |     100 |      100 |     100 |     100 |                                  
 ecash-herald/scripts   |      80 |       50 |     100 |      80 |                                  
  prepSecrets.ts        |      80 |       50 |     100 |      80 | 15                               
 ecash-herald/src       |   12.23 |        0 |       0 |    8.52 |                                  
  chronik.ts            |   11.82 |        0 |       0 |    7.95 | 23-64,82-136,150-177,193-260     
  chronikWsHandler.ts   |    4.76 |        0 |       0 |    5.26 | 11-86                            
  events.ts             |    5.81 |        0 |       0 |    6.09 | 18-394                           
  utils.ts              |   15.66 |        0 |       0 |    10.1 | ...0-410,420-442,462-501,511-525 
------------------------|---------|----------|---------|---------|----------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='64']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='431']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='1']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='109']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='45']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='46']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='401']
##teamcity[blockClosed name='Code Coverage Summary']
Build ecash-herald-tests failed with exit code 1

Tail of the build log:

Run `npm audit` for details.

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

/work/modules/ecash-agora /work/abc-ci-builds/cashtab-tests

added 272 packages, and audited 275 packages in 1s

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

6 vulnerabilities (5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array 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 1393 packages, and audited 2830 packages in 13s

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

11 vulnerabilities (8 moderate, 2 high, 1 critical)

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.25.2 build
> node scripts/build.js

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

TS2322: Type '"SLP" | "ALP" | "UNKNOWN"' is not assignable to type '"SLP" | "ALP" | undefined'.
    208 |     if (cachedInfoLoaded) {
    209 |         ({ tokenType, genesisInfo, genesisSupply } = cachedInfo);
  > 210 |         ({ protocol } = tokenType);
        |            ^^^^^^^^
    211 |         ({ tokenName, tokenTicker, url, hash, decimals } = genesisInfo);
    212 |     }
    213 |


Build cashtab-tests failed with exit code 1

fix ecash-herald and cashtab

Tail of the build log:

Run `npm audit` for details.

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

/work/modules/ecash-agora /work/abc-ci-builds/cashtab-tests

added 272 packages, and audited 275 packages in 1s

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

6 vulnerabilities (5 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

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

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array 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 1393 packages, and audited 2830 packages in 15s

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

11 vulnerabilities (8 moderate, 2 high, 1 critical)

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.25.2 build
> node scripts/build.js

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

TS2322: Type '"SLP" | "ALP" | "UNKNOWN"' is not assignable to type '"SLP" | "ALP" | undefined'.
  Type '"UNKNOWN"' is not assignable to type '"SLP" | "ALP" | undefined'.
    1303 |     if (cachedInfoLoaded && isBip21TokenSend(parsedAddressInput)) {
    1304 |         ({ tokenType, genesisInfo } = cachedInfo);
  > 1305 |         ({ protocol, type } = tokenType);
         |            ^^^^^^^^
    1306 |         ({ tokenName, tokenTicker, decimals } = genesisInfo);
    1307 |         nameAndTicker = `${tokenName}${
    1308 |             tokenTicker !== '' ? ` (${tokenTicker})` : ''


Build cashtab-tests failed with exit code 1

can foresee some potential downstream impacts from this but the main point -- we may have more token types in the future that chronik-client may need to handle -- is valid.

need to add minor version bumps and README / changelog updates to chronik-client and ecash-agora

This revision now requires changes to proceed.May 26 2025, 23:49
This revision is now accepted and ready to land.May 27 2025, 04:11