diff --git a/.changeset/tricky-olives-stare.md b/.changeset/tricky-olives-stare.md new file mode 100644 index 0000000000..ad1fdd711b --- /dev/null +++ b/.changeset/tricky-olives-stare.md @@ -0,0 +1,10 @@ +--- +"@latticexyz/cli": patch +"@latticexyz/common": major +"@latticexyz/dev-tools": patch +"@latticexyz/network": patch +"@latticexyz/std-client": patch +"@latticexyz/store-sync": patch +--- + +Add `tableIdToHex` and `hexToTableId` pure functions and move/deprecate `TableId`. diff --git a/docs/pages/world/modules.mdx b/docs/pages/world/modules.mdx index ebb8177650..cb08ce3126 100644 --- a/docs/pages/world/modules.mdx +++ b/docs/pages/world/modules.mdx @@ -124,7 +124,7 @@ Clients can use snap-sync to get all records on the World, then begin syncing re ```tsx import { getSnapSyncRecords } from "@latticexyz/network"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; ... diff --git a/docs/pages/world/snap-sync.mdx b/docs/pages/world/snap-sync.mdx index 653f0a95fc..70af626248 100644 --- a/docs/pages/world/snap-sync.mdx +++ b/docs/pages/world/snap-sync.mdx @@ -95,7 +95,7 @@ In the client, we fetch all the records at the current block number then begin s ```tsx import { getSnapSyncRecords } from "@latticexyz/network"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; ... diff --git a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/packages/cli/src/commands/trace.ts b/packages/cli/src/commands/trace.ts index 8d6cef9546..ff2b1c210e 100644 --- a/packages/cli/src/commands/trace.ts +++ b/packages/cli/src/commands/trace.ts @@ -5,7 +5,7 @@ import { ethers } from "ethers"; import { loadConfig } from "@latticexyz/config/node"; import { MUDError } from "@latticexyz/common/errors"; import { cast, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { StoreConfig } from "@latticexyz/store"; import { resolveWorldConfig, WorldConfig } from "@latticexyz/world"; import { IBaseWorld } from "@latticexyz/world/types/ethers-contracts/IBaseWorld"; diff --git a/packages/cli/src/render-ts/renderRecsV1Tables.ts b/packages/cli/src/render-ts/renderRecsV1Tables.ts index 7955501208..6df1a7fa36 100644 --- a/packages/cli/src/render-ts/renderRecsV1Tables.ts +++ b/packages/cli/src/render-ts/renderRecsV1Tables.ts @@ -1,4 +1,4 @@ -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { RecsV1TableOptions } from "./types"; export function renderRecsV1Tables(options: RecsV1TableOptions) { diff --git a/packages/common/package.json b/packages/common/package.json index efe6f9432f..244e1f6c36 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -11,21 +11,31 @@ "type": "module", "exports": { ".": "./dist/index.js", + "./chains": "./dist/chains.js", "./codegen": "./dist/codegen.js", + "./deprecated": "./dist/deprecated.js", + "./errors": "./dist/errors.js", "./foundry": "./dist/foundry.js", "./type-utils": "./dist/type-utils.js", - "./utils": "./dist/utils.js", - "./errors": "./dist/errors.js", - "./chains": "./dist/chains.js" + "./utils": "./dist/utils.js" }, "typesVersions": { "*": { "index": [ "./src/index.ts" ], + "chains": [ + "./src/chains/index.ts" + ], "codegen": [ "./src/codegen/index.ts" ], + "deprecated": [ + "./src/deprecated/index.ts" + ], + "errors": [ + "./src/errors/index.ts" + ], "foundry": [ "./src/foundry/index.ts" ], @@ -34,12 +44,6 @@ ], "utils": [ "./src/utils/index.ts" - ], - "errors": [ - "./src/errors/index.ts" - ], - "chains": [ - "./src/chains/index.ts" ] } }, diff --git a/packages/common/src/TableId.test.ts b/packages/common/src/deprecated/TableId.test.ts similarity index 100% rename from packages/common/src/TableId.test.ts rename to packages/common/src/deprecated/TableId.test.ts diff --git a/packages/common/src/TableId.ts b/packages/common/src/deprecated/TableId.ts similarity index 95% rename from packages/common/src/TableId.ts rename to packages/common/src/deprecated/TableId.ts index a664ac7942..9fafd268ae 100644 --- a/packages/common/src/TableId.ts +++ b/packages/common/src/deprecated/TableId.ts @@ -1,5 +1,6 @@ import { Hex, stringToHex, hexToString, sliceHex, concatHex } from "viem"; +/** @deprecated Use `tableIdToHex` and `hexToTableId` instead. */ export class TableId { readonly namespace: string; readonly name: string; diff --git a/packages/common/src/deprecated/getTableIds.ts b/packages/common/src/deprecated/getTableIds.ts new file mode 100644 index 0000000000..3e77c665fa --- /dev/null +++ b/packages/common/src/deprecated/getTableIds.ts @@ -0,0 +1,6 @@ +import { TableId } from "./TableId"; + +/** @deprecated Use `tableIdToHex` and `hexToTableId` instead. */ +export function getTableIds(config: { namespace: string; tables: { [key: string]: unknown } }): TableId[] { + return Object.keys(config.tables).map((table) => new TableId(config.namespace, table)); +} diff --git a/packages/common/src/deprecated/index.ts b/packages/common/src/deprecated/index.ts new file mode 100644 index 0000000000..bf4b7bfeb9 --- /dev/null +++ b/packages/common/src/deprecated/index.ts @@ -0,0 +1,2 @@ +export * from "./getTableIds"; +export * from "./TableId"; diff --git a/packages/common/src/hexToTableId.test.ts b/packages/common/src/hexToTableId.test.ts new file mode 100644 index 0000000000..20a43c95b0 --- /dev/null +++ b/packages/common/src/hexToTableId.test.ts @@ -0,0 +1,10 @@ +import { describe, it, expect } from "vitest"; +import { hexToTableId } from "./hexToTableId"; + +describe("hexToTableId", () => { + it("can convert from hex string", () => { + const tableId = hexToTableId("0x6e616d657370616365000000000000006e616d65000000000000000000000000"); + expect(tableId.namespace).toMatchInlineSnapshot('"namespace"'); + expect(tableId.name).toMatchInlineSnapshot('"name"'); + }); +}); diff --git a/packages/common/src/hexToTableId.ts b/packages/common/src/hexToTableId.ts new file mode 100644 index 0000000000..8782630888 --- /dev/null +++ b/packages/common/src/hexToTableId.ts @@ -0,0 +1,7 @@ +import { Hex, hexToString, sliceHex } from "viem"; + +export function hexToTableId(hex: Hex): { namespace: string; name: string } { + const namespace = hexToString(sliceHex(hex, 0, 16)).replace(/\0+$/, ""); + const name = hexToString(sliceHex(hex, 16, 32)).replace(/\0+$/, ""); + return { namespace, name }; +} diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index ceec57f366..1c5261f42a 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -1,3 +1,4 @@ export * from "./createBurnerAccount"; +export * from "./hexToTableId"; export * from "./mudTransportObserver"; -export * from "./TableId"; +export * from "./tableIdToHex"; diff --git a/packages/common/src/tableIdToHex.test.ts b/packages/common/src/tableIdToHex.test.ts new file mode 100644 index 0000000000..97fdf9476c --- /dev/null +++ b/packages/common/src/tableIdToHex.test.ts @@ -0,0 +1,24 @@ +import { describe, it, expect } from "vitest"; +import { tableIdToHex } from "./tableIdToHex"; +import { hexToTableId } from "./hexToTableId"; + +describe("tableIdToHex", () => { + it("can convert to hex string", () => { + const tableIdHex = tableIdToHex("namespace", "name"); + expect(tableIdHex).toMatchInlineSnapshot('"0x6e616d657370616365000000000000006e616d65000000000000000000000000"'); + }); + + it("truncates namespaces >16 bytes", () => { + const hex = "0x41566572794c6f6e674e616d657370616e616d65000000000000000000000000"; + const tableIdHex = tableIdToHex("AVeryLongNamespace", "name"); + expect(tableIdHex).toEqual(hex); + expect(hexToTableId(tableIdHex).namespace).toMatchInlineSnapshot('"AVeryLongNamespa"'); + }); + + it("truncates names >16 bytes", () => { + const hex = "0x6e616d65737061636500000000000000416e556e6e65636573736172696c794c"; + const tableIdHex = tableIdToHex("namespace", "AnUnnecessarilyLongName"); + expect(tableIdHex).toEqual(hex); + expect(hexToTableId(tableIdHex).name).toMatchInlineSnapshot('"AnUnnecessarilyL"'); + }); +}); diff --git a/packages/common/src/tableIdToHex.ts b/packages/common/src/tableIdToHex.ts new file mode 100644 index 0000000000..00e9143e0a --- /dev/null +++ b/packages/common/src/tableIdToHex.ts @@ -0,0 +1,8 @@ +import { Hex, stringToHex, concatHex } from "viem"; + +export function tableIdToHex(namespace: string, name: string): Hex { + return concatHex([ + stringToHex(namespace.substring(0, 16), { size: 16 }), + stringToHex(name.substring(0, 16), { size: 16 }), + ]); +} diff --git a/packages/common/tsup.config.ts b/packages/common/tsup.config.ts index 4f3c616f78..4b70cf758d 100644 --- a/packages/common/tsup.config.ts +++ b/packages/common/tsup.config.ts @@ -3,12 +3,13 @@ import { defineConfig } from "tsup"; export default defineConfig({ entry: { index: "src/index.ts", + chains: "src/chains/index.ts", codegen: "src/codegen/index.ts", + deprecated: "src/deprecated/index.ts", + errors: "src/errors/index.ts", foundry: "src/foundry/index.ts", "type-utils": "src/type-utils/index.ts", utils: "src/utils/index.ts", - errors: "src/errors/index.ts", - chains: "src/chains/index.ts", }, target: "esnext", format: ["esm"], diff --git a/packages/dev-tools/src/actions/TransactionSummary.tsx b/packages/dev-tools/src/actions/TransactionSummary.tsx index 7e2db21319..7bc5076872 100644 --- a/packages/dev-tools/src/actions/TransactionSummary.tsx +++ b/packages/dev-tools/src/actions/TransactionSummary.tsx @@ -1,7 +1,7 @@ import { decodeEventLog, decodeFunctionData, Hex, AbiEventSignatureNotFoundError } from "viem"; import { twMerge } from "tailwind-merge"; import { isDefined } from "@latticexyz/common/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { keyTupleToEntityID } from "@latticexyz/network/dev"; import { useStore } from "../useStore"; import { PendingIcon } from "../icons/PendingIcon"; diff --git a/packages/dev-tools/src/tables/useTables.ts b/packages/dev-tools/src/tables/useTables.ts index 2f3df9993e..21844de28a 100644 --- a/packages/dev-tools/src/tables/useTables.ts +++ b/packages/dev-tools/src/tables/useTables.ts @@ -1,5 +1,5 @@ import { isDefined } from "@latticexyz/common/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { useStore } from "../useStore"; export function useTables() { diff --git a/packages/network/jest.config.js b/packages/network/jest.config.js index 5f659ae21b..5ad5adee62 100644 --- a/packages/network/jest.config.js +++ b/packages/network/jest.config.js @@ -10,6 +10,7 @@ export default { // jest can't handle esm imports, so we import the typescript source instead "^@latticexyz/common$": "/../common/src/index.ts", "^@latticexyz/common/chains$": "/../common/src/chains/index.ts", + "^@latticexyz/common/deprecated$": "/../common/src/deprecated/index.ts", "^@latticexyz/common/utils$": "/../common/src/utils/index.ts", "^@latticexyz/recs$": "/../recs/src/index.ts", "^@latticexyz/schema-type$": "/../schema-type/src/typescript/index.ts", diff --git a/packages/network/src/dev/observables.ts b/packages/network/src/dev/observables.ts index 716f004c9a..18205b0c35 100644 --- a/packages/network/src/dev/observables.ts +++ b/packages/network/src/dev/observables.ts @@ -1,7 +1,7 @@ import { BehaviorSubject, Subject } from "rxjs"; import type { PublicClient, WalletClient, Chain, Transport } from "viem"; import type { CacheStore } from "../workers"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { StoreEvent, EphemeralEvent } from "../v2/common"; // TODO: connection status? diff --git a/packages/network/src/types.ts b/packages/network/src/types.ts index 4b51ed418f..ccc46adc5d 100644 --- a/packages/network/src/types.ts +++ b/packages/network/src/types.ts @@ -3,7 +3,7 @@ import { ExternalProvider } from "@ethersproject/providers"; import { Components, ComponentValue, Entity, SchemaOf } from "@latticexyz/recs"; import { TxMetadata } from "@latticexyz/services/ecs-stream"; import { Cached } from "@latticexyz/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { BaseContract, BigNumber, ContractInterface } from "ethers"; import { Observable } from "rxjs"; import { SyncState } from "./workers"; diff --git a/packages/network/src/v2/common.ts b/packages/network/src/v2/common.ts index 47622e274a..1f028050ad 100644 --- a/packages/network/src/v2/common.ts +++ b/packages/network/src/v2/common.ts @@ -1,4 +1,4 @@ -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { SchemaType } from "@latticexyz/schema-type/deprecated"; export const schemaTableId = new TableId("mudstore", "schema"); diff --git a/packages/network/src/v2/decodeStoreSetField.ts b/packages/network/src/v2/decodeStoreSetField.ts index 8ad17dbf33..74dc7e4ae1 100644 --- a/packages/network/src/v2/decodeStoreSetField.ts +++ b/packages/network/src/v2/decodeStoreSetField.ts @@ -1,5 +1,5 @@ import { ComponentValue } from "@latticexyz/recs"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Contract } from "ethers"; import { registerSchema } from "./schemas/tableSchemas"; import { registerMetadata } from "./schemas/tableMetadata"; diff --git a/packages/network/src/v2/decodeStoreSetRecord.ts b/packages/network/src/v2/decodeStoreSetRecord.ts index 8344617641..97c09a6dcf 100644 --- a/packages/network/src/v2/decodeStoreSetRecord.ts +++ b/packages/network/src/v2/decodeStoreSetRecord.ts @@ -1,4 +1,4 @@ -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Contract, utils } from "ethers"; import { registerSchema } from "./schemas/tableSchemas"; import { registerMetadata } from "./schemas/tableMetadata"; diff --git a/packages/network/src/v2/ecsEventFromLog.ts b/packages/network/src/v2/ecsEventFromLog.ts index 7862cfebbf..e3b8cdc239 100644 --- a/packages/network/src/v2/ecsEventFromLog.ts +++ b/packages/network/src/v2/ecsEventFromLog.ts @@ -1,7 +1,7 @@ import { Contract, utils } from "ethers"; import { Log } from "@ethersproject/providers"; import { LogDescription } from "@ethersproject/abi"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { NetworkComponentUpdate, NetworkEvents } from "../types"; import { decodeStoreSetRecord } from "./decodeStoreSetRecord"; import { decodeStoreSetField } from "./decodeStoreSetField"; diff --git a/packages/network/src/v2/mode/syncTablesFromMode.ts b/packages/network/src/v2/mode/syncTablesFromMode.ts index a350e98b4e..0caa1a1453 100644 --- a/packages/network/src/v2/mode/syncTablesFromMode.ts +++ b/packages/network/src/v2/mode/syncTablesFromMode.ts @@ -2,7 +2,7 @@ import { ComponentValue } from "@latticexyz/recs"; import { AbiTypeToSchemaType, encodeSchema } from "@latticexyz/schema-type/deprecated"; import { QueryLayerClient } from "@latticexyz/services/mode"; import { arrayToHex } from "@latticexyz/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Contract } from "ethers"; import { NetworkEvents } from "../../types"; diff --git a/packages/network/src/v2/schemas/tableMetadata.ts b/packages/network/src/v2/schemas/tableMetadata.ts index 93c0aca671..23eb55bf6f 100644 --- a/packages/network/src/v2/schemas/tableMetadata.ts +++ b/packages/network/src/v2/schemas/tableMetadata.ts @@ -1,4 +1,4 @@ -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Contract, utils } from "ethers"; import { metadataTableId, schemaTableId, TableMetadata } from "../common"; import { decodeData } from "./decodeData"; diff --git a/packages/network/src/v2/schemas/tableSchemas.ts b/packages/network/src/v2/schemas/tableSchemas.ts index f27ea908c6..fe56942974 100644 --- a/packages/network/src/v2/schemas/tableSchemas.ts +++ b/packages/network/src/v2/schemas/tableSchemas.ts @@ -1,5 +1,5 @@ import { Contract } from "ethers"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { TableSchema } from "../common"; import { decodeSchema } from "./decodeSchema"; import { IStore } from "@latticexyz/store/types/ethers-contracts/IStore.sol/IStore"; diff --git a/packages/network/src/v2/snapSync/getSnapSyncRecords.ts b/packages/network/src/v2/snapSync/getSnapSyncRecords.ts index 9d4f003937..165f6774f0 100644 --- a/packages/network/src/v2/snapSync/getSnapSyncRecords.ts +++ b/packages/network/src/v2/snapSync/getSnapSyncRecords.ts @@ -1,4 +1,4 @@ -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Hex } from "viem"; import snapSyncSystemAbi from "./snapSyncSystemAbi"; import { Contract, Signer, providers } from "ethers"; diff --git a/packages/std-client/src/setup/setupMUDV2Network.ts b/packages/std-client/src/setup/setupMUDV2Network.ts index 50d45b89a4..ac2fc2f842 100644 --- a/packages/std-client/src/setup/setupMUDV2Network.ts +++ b/packages/std-client/src/setup/setupMUDV2Network.ts @@ -14,7 +14,7 @@ import { BehaviorSubject, concatMap, from, Subject } from "rxjs"; import { Components, defineComponent, Type, World } from "@latticexyz/recs"; import { computed } from "mobx"; import { keccak256 } from "@latticexyz/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { World as WorldContract } from "@latticexyz/world/types/ethers-contracts/World"; import { IWorldKernel__factory } from "@latticexyz/world/types/ethers-contracts/factories/IWorldKernel.sol/IWorldKernel__factory"; import { defineStringComponent } from "../components"; diff --git a/packages/store-sync/src/blockLogsToStorage.test.ts b/packages/store-sync/src/blockLogsToStorage.test.ts index ba51546f2d..9e93b24ffe 100644 --- a/packages/store-sync/src/blockLogsToStorage.test.ts +++ b/packages/store-sync/src/blockLogsToStorage.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { BlockLogsToStorageOptions, blockLogsToStorage } from "./blockLogsToStorage"; import storeConfig from "@latticexyz/store/mud.config"; import { isDefined } from "@latticexyz/common/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; const mockedCallbacks = { registerTables: vi.fn< diff --git a/packages/store-sync/src/blockLogsToStorage.ts b/packages/store-sync/src/blockLogsToStorage.ts index 480efb8b46..090dba77a3 100644 --- a/packages/store-sync/src/blockLogsToStorage.ts +++ b/packages/store-sync/src/blockLogsToStorage.ts @@ -7,7 +7,7 @@ import { TableSchema, } from "@latticexyz/protocol-parser"; import { StoreConfig, ConfigToKeyPrimitives as Key, ConfigToValuePrimitives as Value } from "@latticexyz/store"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { Address, Hex, decodeAbiParameters, getAddress, parseAbiParameters } from "viem"; import { debug } from "./debug"; import { isDefined } from "@latticexyz/common/utils"; diff --git a/packages/store-sync/src/recs/recsStorage.ts b/packages/store-sync/src/recs/recsStorage.ts index 2924b4a6d0..42fefdaaa6 100644 --- a/packages/store-sync/src/recs/recsStorage.ts +++ b/packages/store-sync/src/recs/recsStorage.ts @@ -12,7 +12,7 @@ import { updateComponent, } from "@latticexyz/recs"; import { isDefined } from "@latticexyz/common/utils"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { schemaToDefaults } from "../schemaToDefaults"; import { hexKeyTupleToEntity } from "./hexKeyTupleToEntity"; import { defineInternalComponents } from "./defineInternalComponents"; diff --git a/packages/store-sync/src/sqlite/getTables.ts b/packages/store-sync/src/sqlite/getTables.ts index 16d7864d11..6d1a4f4d03 100644 --- a/packages/store-sync/src/sqlite/getTables.ts +++ b/packages/store-sync/src/sqlite/getTables.ts @@ -1,7 +1,7 @@ import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core"; import { inArray } from "drizzle-orm"; import { Table } from "../common"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { getTableName } from "./getTableName"; import { mudStoreTables } from "./internalTables"; diff --git a/packages/store-sync/src/sqlite/sqliteStorage.ts b/packages/store-sync/src/sqlite/sqliteStorage.ts index 1d4c39133e..3c78ba86ee 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.ts @@ -4,7 +4,7 @@ import { and, eq, sql } from "drizzle-orm"; import { sqliteTableToSql } from "./sqliteTableToSql"; import { createSqliteTable } from "./createSqliteTable"; import { schemaToDefaults } from "../schemaToDefaults"; -import { TableId } from "@latticexyz/common"; +import { TableId } from "@latticexyz/common/deprecated"; import { BlockLogsToStorageOptions } from "../blockLogsToStorage"; import { StoreConfig } from "@latticexyz/store"; import { debug } from "./debug"; diff --git a/packages/utils/src/v2/getTableIds.ts b/packages/utils/src/v2/getTableIds.ts deleted file mode 100644 index 6f27957780..0000000000 --- a/packages/utils/src/v2/getTableIds.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { TableId } from "@latticexyz/common"; - -const STORE_SELECTOR_MAX_LENGTH = 16; - -export function getTableIds(config: { namespace: string; tables: { [key: string]: unknown } }) { - return Object.keys(config.tables).map( - (table) => - new TableId(config.namespace.slice(0, STORE_SELECTOR_MAX_LENGTH), table.slice(0, STORE_SELECTOR_MAX_LENGTH)) - ); -} diff --git a/packages/utils/src/v2/index.ts b/packages/utils/src/v2/index.ts index 990dfc62e2..1235f63ec8 100644 --- a/packages/utils/src/v2/index.ts +++ b/packages/utils/src/v2/index.ts @@ -3,4 +3,3 @@ export * from "./bytesToString"; export * from "./hexToArray"; export * from "./isHex"; export * from "./stringToBytes"; -export * from "./getTableIds"; diff --git a/templates/phaser/packages/client/src/mud/setupNetwork.ts b/templates/phaser/packages/client/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/templates/phaser/packages/client/src/mud/setupNetwork.ts +++ b/templates/phaser/packages/client/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/templates/react/packages/client/src/mud/setupNetwork.ts b/templates/react/packages/client/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/templates/react/packages/client/src/mud/setupNetwork.ts +++ b/templates/react/packages/client/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/templates/threejs/packages/client/src/mud/setupNetwork.ts b/templates/threejs/packages/client/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/templates/threejs/packages/client/src/mud/setupNetwork.ts +++ b/templates/threejs/packages/client/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>; diff --git a/templates/vanilla/packages/client/src/mud/setupNetwork.ts b/templates/vanilla/packages/client/src/mud/setupNetwork.ts index 4ad3fb39b7..b8fff495b5 100644 --- a/templates/vanilla/packages/client/src/mud/setupNetwork.ts +++ b/templates/vanilla/packages/client/src/mud/setupNetwork.ts @@ -6,7 +6,7 @@ import { world } from "./world"; import { Contract, Signer, utils } from "ethers"; import { JsonRpcProvider } from "@ethersproject/providers"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; -import { getTableIds } from "@latticexyz/utils"; +import { getTableIds } from "@latticexyz/common/deprecated"; import storeConfig from "contracts/mud.config"; export type SetupNetworkResult = Awaited>;