2.2.14 • Published 11 months ago

@latticexyz/block-logs-stream v2.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Block logs stream

A set of utilities for efficiently retrieving blockchain event logs. Built on top of viem and RxJS.

Example

import { filter, map, mergeMap } from "rxjs";
import { createPublicClient, parseAbi } from "viem";
import { createBlockStream, groupLogsByBlockNumber, blockRangeToLogs } from "@latticexyz/block-logs-stream";

const publicClient = createPublicClient({
  // your viem public client config here
});

const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest" });
const latestBlockNumber$ = latestBlock$.pipe(map((block) => block.number));

latestBlockNumber$
  .pipe(
    map((latestBlockNumber) => ({ startBlock: 0n, endBlock: latestBlockNumber })),
    blockRangeToLogs({
      publicClient,
      address,
      events: parseAbi([
        "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
        "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)",
        "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)",
        "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)",
      ]),
    }),
    mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
  )
  .subscribe((block) => {
    console.log("got events for block", block);
  });
2.2.14

11 months ago

2.2.13

11 months ago

2.2.12

11 months ago

2.2.11

12 months ago

2.2.10

12 months ago

2.2.9

12 months ago

2.2.8

12 months ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.0-next.18

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-next.17

2 years ago

2.0.0-next.16

2 years ago

2.0.0-next.15

2 years ago

2.0.0-next.14

2 years ago

2.0.0-next.13

2 years ago

2.0.0-next.12

2 years ago

2.0.0-next.11

2 years ago

2.0.0-next.10

2 years ago

2.0.0-next.9

2 years ago

2.0.0-next.8

2 years ago

2.0.0-next.7

2 years ago

2.0.0-next.6

2 years ago

2.0.0-next.5

2 years ago

2.0.0-next.4

2 years ago

2.0.0-next.3

2 years ago

2.0.0-next.2

2 years ago

2.0.0-next.1

2 years ago

2.0.0-next.0

2 years ago