Skip to content

Commit

Permalink
add getValuesInEntityChange example
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 27, 2024
1 parent 7b1eda0 commit db8d011
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,32 @@ emitter.on("anyMessage", (message: EntityChanges) => {
### Using [Zod](https://github.com/colinhacks/zod) Static Type Resolution

```typescript
import { EntityChanges } from "@substreams/sink-entity-changes/zod"
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**

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

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

### Using [Buf](https://github.com/bufbuild/protobuf-es) Protobuf codegen

```typescript
Expand Down

0 comments on commit db8d011

Please sign in to comment.