Add new ChronikClientNode class to support API requests and websocket connections to in-node instances of chronik
Details
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- add-cc-node
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 25738 Build 51056: Build Diff chronik-client-tests Build 51055: arc lint + arc unit
Event Timeline
Sample output console.logging on a subscription to blocks and the ifp address
msg { type: 'Tx', msgType: 'Confirmed', txid: '2d8c59713cc8facd50d19a629e044c8e19b3924ee9b25c0f35f07094f4613e16' } msg { type: 'Block', msgType: 'Connected', blockHash: '000000000000000016c058e79ce4274d798c5dbe62a27d799da86696b22ea6d7', blockHeight: 819479 } msg { type: 'Tx', msgType: 'Finalized', txid: '2d8c59713cc8facd50d19a629e044c8e19b3924ee9b25c0f35f07094f4613e16' } msg { type: 'Block', msgType: 'Finalized', blockHash: '000000000000000016c058e79ce4274d798c5dbe62a27d799da86696b22ea6d7', blockHeight: 819479 } msg { type: 'Block', msgType: 'Connected', blockHash: '000000000000000029728164c167890298f285a7ee83f2973b7efbdb0c63b1a2', blockHeight: 819480 } msg { type: 'Tx', msgType: 'Confirmed', txid: '6e4108edd3857cabd44ee235906e572b7ac6ca465c84714a942b9083d9ffceb9' } msg { type: 'Tx', msgType: 'Finalized', txid: '6e4108edd3857cabd44ee235906e572b7ac6ca465c84714a942b9083d9ffceb9' } msg { type: 'Block', msgType: 'Finalized', blockHash: '000000000000000029728164c167890298f285a7ee83f2973b7efbdb0c63b1a2', blockHeight: 819480 }
remove todo comments, the real todo there is adding features to the in-node chronik instance
There is no way to know if this is correct, this diff does too much things at once.
You can split in parts, like regular endpoints first, then script endpoints, then websockets.
Also the same naming/layout issue repeated along the file, please make a pass to clean this.
modules/chronik-client/src/ChronikClientNode.ts | ||
---|---|---|
16 ↗ | (On Diff #43237) | layout |
63 ↗ | (On Diff #43237) | layout |
102 ↗ | (On Diff #43237) | "_v2" is an horrible name. Especially when there is no v1. And you client isn't named ChronikClient_v2 |
117 ↗ | (On Diff #43237) | layout |
146 ↗ | (On Diff #43237) | dito |
169 ↗ | (On Diff #43237) | dito |
176 ↗ | (On Diff #43237) | dito |
183 ↗ | (On Diff #43237) | Why does it default to false ? |
change _v2 naming convention to Node, layout issues
modules/chronik-client/src/ChronikClientNode.ts | ||
---|---|---|
183 ↗ | (On Diff #43237) | should swap this to true but not really in-scope for this diff. In this case, it defaults to false because the nng client also defaults to false. initial rationale for defaulting to false was that this preserved existing behavior of chronik-client for users who did not "opt in." But, since all of my apps that use chronik-client will have keepAlive: true ... should just be true. |
Tail of the build log:
/work/modules/chronik-client /work/abc-ci-builds/chronik-client-tests > chronik-client@0.9.0 prepublish > npm run build > chronik-client@0.9.0 build > tsc src/failoverProxy.ts(6,10): error TS2305: Module '"./ChronikClientNode"' has no exported member 'WsEndpoint_v2'. src/failoverProxy.ts(285,53): error TS7006: Parameter 'sub' implicitly has an 'any' type. test/testNode.ts(4,5): error TS2305: Module '"../index"' has no exported member 'BlockInfo_v2'. test/testNode.ts(6,5): error TS2305: Module '"../index"' has no exported member 'Tx_v2'. test/testNode.ts(7,5): error TS2305: Module '"../index"' has no exported member 'Utxo_v2'. npm ERR! code 2 npm ERR! path /work/modules/chronik-client npm ERR! command failed npm ERR! command sh -c -- npm run build npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2023-11-24T15_17_27_483Z-debug-0.log Build chronik-client-tests failed with exit code 2
cleaning up var name changes to clean up this diff as a reference. will still be abandoned after spllitting up.