From 295aec763b24b04c0745c95ab17f7c8875c1ef2e Mon Sep 17 00:00:00 2001 From: alvrs Date: Wed, 18 Sep 2024 20:12:04 +0100 Subject: [PATCH] add changeset for syncToStash --- .changeset/lucky-cows-fail.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .changeset/lucky-cows-fail.md diff --git a/.changeset/lucky-cows-fail.md b/.changeset/lucky-cows-fail.md new file mode 100644 index 0000000000..17553e688d --- /dev/null +++ b/.changeset/lucky-cows-fail.md @@ -0,0 +1,24 @@ +--- +"@latticexyz/store-sync": patch +"@latticexyz/world": patch +--- + +Added a `syncToStash` util to hydrate a `stash` client store from MUD contract state. + +```ts +import config from "mud.config"; +import { createStash } from "@latticexyz/stash/internal"; +import { createClient, http } from "viem"; +import { anvil } from "viem/chains"; + +const address = "0x..."; +const stash = createStash(config); +const client = createClient({ + chain: anvil, + transport: http(), +}); + +const sync = await syncToStash({ config, stash, client, address }); +// subscribe to start the sync +sync.storedBlockLogs$.subscribe(); +```