MCPcopy
hub / github.com/embarklabs/embark / parseAndRespond

Function parseAndRespond

packages/core/utils/src/check.js:7–22  ·  view source on GitHub ↗
(data, cb)

Source from the content-addressed store, hash-verified

5const LIVENESS_CHECK=`{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":42}`;
6
7const parseAndRespond = (data, cb) => {
8 let resp;
9 try {
10 resp = JSON.parse(data);
11 if (resp.error) {
12 return cb(resp.error);
13 }
14 } catch (e) {
15 return cb('Version data is not valid JSON');
16 }
17 if (!resp || !resp.result) {
18 return cb('No version returned');
19 }
20 const [_, version, __] = resp.result.split('/');
21 cb(null, version);
22};
23
24const testRpcWithEndpoint = (endpoint, cb) => {
25 const options = {

Callers 2

testRpcWithEndpointFunction · 0.70
testWsEndpointFunction · 0.70

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected