From 6a9675e0a91fe2780ee9ec148d643af2e68ca000 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 4 Jul 2023 11:59:59 +0000 Subject: [PATCH] Version Packages (next) --- .changeset/pre.json | 33 +++++++++++++++++ packages/block-logs-stream/CHANGELOG.md | 48 +++++++++++++++++++++++++ packages/block-logs-stream/package.json | 2 +- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .changeset/pre.json create mode 100644 packages/block-logs-stream/CHANGELOG.md diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 00000000000..623a2bff830 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,33 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "@latticexyz/block-logs-stream": "1.42.0", + "@latticexyz/cli": "1.42.0", + "@latticexyz/common": "1.42.0", + "@latticexyz/config": "1.42.0", + "create-mud": "1.42.0", + "@latticexyz/dev-tools": "1.42.0", + "@latticexyz/ecs-browser": "1.42.0", + "@latticexyz/network": "1.42.0", + "@latticexyz/noise": "1.42.0", + "@latticexyz/phaserx": "1.42.0", + "@latticexyz/protocol-parser": "1.42.0", + "@latticexyz/react": "1.42.0", + "@latticexyz/recs": "1.42.0", + "@latticexyz/schema-type": "1.42.0", + "@latticexyz/services": "1.42.0", + "@latticexyz/solecs": "1.42.0", + "solhint-config-mud": "1.42.0", + "solhint-plugin-mud": "1.42.0", + "@latticexyz/std-client": "1.42.0", + "@latticexyz/std-contracts": "1.42.0", + "@latticexyz/store": "1.42.0", + "@latticexyz/store-cache": "1.42.0", + "@latticexyz/utils": "1.42.0", + "@latticexyz/world": "1.42.0" + }, + "changesets": [ + "nasty-waves-divide" + ] +} diff --git a/packages/block-logs-stream/CHANGELOG.md b/packages/block-logs-stream/CHANGELOG.md new file mode 100644 index 00000000000..38af4d4a901 --- /dev/null +++ b/packages/block-logs-stream/CHANGELOG.md @@ -0,0 +1,48 @@ +# @latticexyz/block-logs-stream + +## 1.43.0-next.0 + +### Minor Changes + +- [#1070](https://github.com/latticexyz/mud/pull/1070) [`72b80697`](https://github.com/latticexyz/mud/commit/72b806979db6eb2880772193898351d657b94f75) Thanks [@holic](https://github.com/holic)! - Add block logs stream package + + ```ts + import { filter, map, mergeMap } from "rxjs"; + import { createPublicClient, parseAbi } from "viem"; + import { + createBlockStream, + isNonPendingBlock, + 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( + filter(isNonPendingBlock), + map((block) => block.number) + ); + + latestBlockNumber$ + .pipe( + map((latestBlockNumber) => ({ startBlock: 0n, endBlock: latestBlockNumber })), + blockRangeToLogs({ + publicClient, + address, + events: parseAbi([ + "event StoreDeleteRecord(bytes32 table, bytes32[] key)", + "event StoreSetField(bytes32 table, bytes32[] key, uint8 schemaIndex, bytes data)", + "event StoreSetRecord(bytes32 table, bytes32[] key, bytes data)", + "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", + ]), + }), + mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) + ) + .subscribe((block) => { + console.log("got events for block", block); + }); + ``` diff --git a/packages/block-logs-stream/package.json b/packages/block-logs-stream/package.json index 15efcc768e6..d2f16151a2f 100644 --- a/packages/block-logs-stream/package.json +++ b/packages/block-logs-stream/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/block-logs-stream", - "version": "1.42.0", + "version": "1.43.0-next.0", "description": "Create a stream of EVM block logs for events", "repository": { "type": "git",