0.3.11 • Published 3 months ago

@substreams/sink-entity-changes v0.3.11

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Substreams Sink Entity Changes

Buf Protobuf codegen & TypeBox for EntityChanges.

Quickstart

$ npm install @substreams/sink-entity-changes
import { typebox, zod } from "@substreams/sink-entity-changes"

Protobuf

message EntityChanges {
  repeated EntityChange entity_changes = 5;
}

message EntityChange {
  string entity = 1;
  string id = 2;
  Operation operation = 4;
  repeated Field fields = 5;
}

Using TypeBox Static Type Resolution

import { EntityChanges } from "@substreams/sink-entity-changes/typebox"
...

const emitter = new BlockEmitter(transport, request, registry);

emitter.on("anyMessage", (message: EntityChanges) => {
  for ( const entityChange of message.entityChanges ?? []) {
    console.log(entityChange);
  }
});

Using Zod Static Type Resolution

import { EntityChanges, getValuesInEntityChange } from "@substreams/sink-entity-changes/zod"
...

const emitter = new BlockEmitter(transport, request, registry);

emitter.on("anyMessage", (message: EntityChanges) => {
  for ( const entityChange of message.entityChanges ?? []) {
    console.log(entityChange);
    const values = getValuesInEntityChange(entityChange);
    const address = values["address"];
  }
});

getValuesInEntityChange

import { getValuesInEntityChange } from "@substreams/sink-entity-changes/zod"
...

for ( const entityChange of message.entityChanges ?? []) {
  const values = getValuesInEntityChange(entityChange);
  const address = values["address"];
}

Using Buf Protobuf codegen

import { EntityChanges } from "@substreams/sink-entity-changes/entity_pb"
...

const emitter = new BlockEmitter(transport, request, registry);

// Stream EntityChanges
emitter.on("output", (output: EntityChanges) => {
  for ( const entityChange of output?.entityChanges ?? []) {
    console.log(entityChange);
  }
});
0.3.11

3 months ago

0.3.10

3 months ago

0.3.9

3 months ago

0.3.6

3 months ago

0.3.8

3 months ago

0.3.7

3 months ago

0.3.5

3 months ago

0.3.4

7 months ago

0.3.3

7 months ago

0.3.2

7 months ago

0.3.1

7 months ago

0.3.0

7 months ago

0.2.0

8 months ago

0.1.0

8 months ago