pinax-network / substreams

Substreams built by Pinax
Apache License 2.0
5 stars 2 forks source link

Adding support for Substreams JSON formatted responses #7

Closed DenisCarriere closed 1 year ago

DenisCarriere commented 1 year ago

There's very little reason for the Substream Client side to need to parse serialized protobuf

StreamingFast team is future, will save a lot of headaches.

This should remove for the Protobuf requirements, all the data would be served by the Substream .spkg package on the server-side.

Usage

const block = substreams.parseBlockData(response);
if (!block) return;

for ( const output of block.outputs ) {
    console.log(JSON.stringify(output));
}

Current data

{
  "name": "store_tokens",
  "data": {
    "oneofKind": "storeDeltas",
    "storeDeltas": {
      "deltas": [
        {
          "operation": 1,
          "ordinal": "1",
          "key": "EOS,4@eosio.token",
          "oldValue": {},
          "newValue": {
            "type": "Buffer",
            "data": [
              8,186,1,18,6,8,202,129,239,216,5,26,11,101,111,115,105,111,46,116,111,107,101,110,34,3,69,79,83,40,4,48,128,128,233,131,177,222,22,58,5,101,111,115,105,111
            ]
          }
        }
      ]
    }
  },
  "logs": [
    "storing new token EOS,4@eosio.token from block 186 at 2018-06-09T11:58:02Z"
  ],
  "logsTruncated": false
}
DenisCarriere commented 1 year ago

Not an issue