From 0d0bdb1a11f8ba3b96c6aa5ebc70381c97e8b8e7 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 20 Mar 2024 18:46:03 +0000 Subject: [PATCH] don't need that anymore --- .../query-cache/createStorageAdapter.test.ts | 3 +- .../store-sync/src/query-cache/getTables.ts | 28 ------------------- .../src/query-cache/syncToQueryCache.ts | 3 +- .../query-cache/test/createHydratedStore.ts | 3 +- 4 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 packages/store-sync/src/query-cache/getTables.ts diff --git a/packages/store-sync/src/query-cache/createStorageAdapter.test.ts b/packages/store-sync/src/query-cache/createStorageAdapter.test.ts index 28da190311..3b89245c55 100644 --- a/packages/store-sync/src/query-cache/createStorageAdapter.test.ts +++ b/packages/store-sync/src/query-cache/createStorageAdapter.test.ts @@ -7,7 +7,6 @@ import { fetchAndStoreLogs } from "../fetchAndStoreLogs"; import { testClient } from "../../test/common"; import { getBlockNumber } from "viem/actions"; import { Address } from "viem"; -import { getTables } from "./getTables"; describe("createStorageAdapter", async () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -17,7 +16,7 @@ describe("createStorageAdapter", async () => { }); it("sets component values from logs", async () => { - const useStore = createStore({ tables: getTables(config) }); + const useStore = createStore({ tables: config.tables }); const storageAdapter = createStorageAdapter({ store: useStore }); console.log("fetching blocks"); diff --git a/packages/store-sync/src/query-cache/getTables.ts b/packages/store-sync/src/query-cache/getTables.ts deleted file mode 100644 index e9cf6fb888..0000000000 --- a/packages/store-sync/src/query-cache/getTables.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { resourceToHex } from "@latticexyz/common"; -import { Store } from "@latticexyz/store/config/v2"; - -// TODO(alvrs): table resolver doesn't yet provide `tableId` so we'll use this helper to inject it for now - -export function getTables(config: config): config["tables"] { - const tables = Object.fromEntries( - Object.entries(config.tables).map(([tableName, table]) => [ - tableName, - { - ...table, - tableId: resourceToHex({ - // hardcoded for now because table doesn't have a `type` yet - // TODO: use table type if available before `tableId` - type: "table", - // use config's namespace because table doesn't have `namespace` yet - // TODO: fix `config.namespace` being `string | undefined` - it should always be set in resolved output - // TODO: replace wih `table.namespace` - namespace: config.namespace ?? "", - // TODO: replace with `table.name` if available before `tableId` - name: tableName, - }), - }, - ]), - ); - - return tables; -} diff --git a/packages/store-sync/src/query-cache/syncToQueryCache.ts b/packages/store-sync/src/query-cache/syncToQueryCache.ts index 2fb7ee0b89..e33a6f81bc 100644 --- a/packages/store-sync/src/query-cache/syncToQueryCache.ts +++ b/packages/store-sync/src/query-cache/syncToQueryCache.ts @@ -4,7 +4,6 @@ import { Address } from "viem"; import { Store } from "@latticexyz/store/config/v2"; import { createStore } from "./createStore"; import { createStorageAdapter } from "./createStorageAdapter"; -import { getTables } from "./getTables"; type SyncToQueryCacheOptions = Omit & { // require address for now to keep the data model + retrieval simpler @@ -22,7 +21,7 @@ export async function syncToQueryCache({ startSync = true, ...syncOptions }: SyncToQueryCacheOptions): Promise { - const useStore = createStore({ tables: getTables(config) }); + const useStore = createStore({ tables: config.tables }); const storageAdapter = createStorageAdapter({ store: useStore }); const storeSync = await createStoreSync({ diff --git a/packages/store-sync/src/query-cache/test/createHydratedStore.ts b/packages/store-sync/src/query-cache/test/createHydratedStore.ts index 2b781e2c73..42e7621b51 100644 --- a/packages/store-sync/src/query-cache/test/createHydratedStore.ts +++ b/packages/store-sync/src/query-cache/test/createHydratedStore.ts @@ -6,7 +6,6 @@ import { Address } from "viem"; import { getBlock, getBlockNumber } from "viem/actions"; import { QueryCacheStore, createStore } from "../createStore"; import { createStorageAdapter } from "../createStorageAdapter"; -import { getTables } from "../getTables"; export { config }; @@ -14,7 +13,7 @@ export async function createHydratedStore(worldAddress: Address): Promise<{ store: QueryCacheStore<(typeof config)["tables"]>; fetchLatestLogs: () => Promise; }> { - const store = createStore({ tables: getTables(config) }); + const store = createStore({ tables: config.tables }); const storageAdapter = createStorageAdapter({ store }); let lastBlockProcessed = (await getBlock(testClient, { blockTag: "earliest" })).number - 1n;