diff --git a/.changeset/pretty-hotels-drop.md b/.changeset/pretty-hotels-drop.md new file mode 100644 index 0000000000..bf2bc965f2 --- /dev/null +++ b/.changeset/pretty-hotels-drop.md @@ -0,0 +1,26 @@ +--- +"@latticexyz/cli": major +"@latticexyz/std-client": major +"@latticexyz/store-sync": major +"@latticexyz/store": patch +"@latticexyz/world": patch +"create-mud": major +--- + +RECS components are now dynamically created and inferred from your MUD config when using `syncToRecs`. + +To migrate existing projects after upgrading to this MUD version: + +1. Remove `contractComponents.ts` from `client/src/mud` +2. Remove `components` argument from `syncToRecs` +3. Update `build:mud` and `dev` scripts in `contracts/package.json` to remove tsgen + + ```diff + - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client/src/mud", + + "build:mud": "mud tablegen && mud worldgen", + ``` + + ```diff + - "dev": "pnpm mud dev-contracts --tsgenOutput ../client/src/mud", + + "dev": "pnpm mud dev-contracts", + ``` diff --git a/e2e/packages/client-vanilla/src/mud/contractComponents.ts b/e2e/packages/client-vanilla/src/mud/contractComponents.ts deleted file mode 100644 index f343bfe2f9..0000000000 --- a/e2e/packages/client-vanilla/src/mud/contractComponents.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Number: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x000000000000000000000000000000004e756d62657200000000000000000000", - metadata: { - componentName: "Number", - tableName: ":Number", - keySchema: { key: "uint32" }, - valueSchema: { value: "uint32" }, - }, - } as const - ), - Vector: defineComponent( - world, - { - x: RecsType.Number, - y: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000566563746f7200000000000000000000", - metadata: { - componentName: "Vector", - tableName: ":Vector", - keySchema: { key: "uint32" }, - valueSchema: { x: "int32", y: "int32" }, - }, - } as const - ), - NumberList: defineComponent( - world, - { - value: RecsType.NumberArray, - }, - { - id: "0x000000000000000000000000000000004e756d6265724c697374000000000000", - metadata: { - componentName: "NumberList", - tableName: ":NumberList", - keySchema: {}, - valueSchema: { value: "uint32[]" }, - }, - } as const - ), - Multi: defineComponent( - world, - { - num: RecsType.BigInt, - value: RecsType.Boolean, - }, - { - id: "0x000000000000000000000000000000004d756c74690000000000000000000000", - metadata: { - componentName: "Multi", - tableName: ":Multi", - keySchema: { a: "uint32", b: "bool", c: "uint256", d: "int120" }, - valueSchema: { num: "int256", value: "bool" }, - }, - } as const - ), - }; -} diff --git a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts index 02cdaed644..85708917a0 100644 --- a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, http, createWalletClient, Hex, parseEther, ClientCo import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -42,7 +40,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), indexerUrl: networkConfig.indexerUrl ?? undefined, }); diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index efdac86e28..02124532eb 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -6,15 +6,14 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge build --extra-output-files abi --out abi --skip test script", - "build:mud": "mud tablegen && mud worldgen && pnpm run tsgen", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "typechain --target=ethers-v5 abi/IWorld.sol/IWorld.json", "clean": "pnpm run clean:abi && pnpm run clean:mud && pnpm run clean:typechain", "clean:abi": "rimraf abi", "clean:mud": "rimraf src/codegen", "clean:typechain": "rimraf types", "deploy:local": "mud deploy", - "test": "mud test", - "tsgen": "mud tsgen --configPath mud.config.ts --out ../client-vanilla/src/mud" + "test": "mud test" }, "devDependencies": { "@latticexyz/cli": "link:../../../packages/cli", diff --git a/examples/minimal/packages/client-phaser/src/mud/contractComponents.ts b/examples/minimal/packages/client-phaser/src/mud/contractComponents.ts deleted file mode 100644 index 116694f6f3..0000000000 --- a/examples/minimal/packages/client-phaser/src/mud/contractComponents.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - CounterTable: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e7465725461626c6500000000", - metadata: { - componentName: "CounterTable", - tableName: ":CounterTable", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - MessageTable: defineComponent( - world, - { - value: RecsType.String, - }, - { - id: "0x000000000000000000000000000000004d6573736167655461626c6500000000", - metadata: { - componentName: "MessageTable", - tableName: ":MessageTable", - keySchema: {}, - valueSchema: { value: "string" }, - }, - } as const - ), - Inventory: defineComponent( - world, - { - amount: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000496e76656e746f727900000000000000", - metadata: { - componentName: "Inventory", - tableName: ":Inventory", - keySchema: { - owner: "address", - item: "uint32", - itemVariant: "uint32", - }, - valueSchema: { amount: "uint32" }, - }, - } as const - ), - }; -} diff --git a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/examples/minimal/packages/client-react/src/mud/contractComponents.ts b/examples/minimal/packages/client-react/src/mud/contractComponents.ts deleted file mode 100644 index 116694f6f3..0000000000 --- a/examples/minimal/packages/client-react/src/mud/contractComponents.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - CounterTable: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e7465725461626c6500000000", - metadata: { - componentName: "CounterTable", - tableName: ":CounterTable", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - MessageTable: defineComponent( - world, - { - value: RecsType.String, - }, - { - id: "0x000000000000000000000000000000004d6573736167655461626c6500000000", - metadata: { - componentName: "MessageTable", - tableName: ":MessageTable", - keySchema: {}, - valueSchema: { value: "string" }, - }, - } as const - ), - Inventory: defineComponent( - world, - { - amount: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000496e76656e746f727900000000000000", - metadata: { - componentName: "Inventory", - tableName: ":Inventory", - keySchema: { - owner: "address", - item: "uint32", - itemVariant: "uint32", - }, - valueSchema: { amount: "uint32" }, - }, - } as const - ), - }; -} diff --git a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts index 6906769259..54b0103087 100644 --- a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -33,7 +31,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/examples/minimal/packages/client-vanilla/src/mud/contractComponents.ts b/examples/minimal/packages/client-vanilla/src/mud/contractComponents.ts deleted file mode 100644 index 116694f6f3..0000000000 --- a/examples/minimal/packages/client-vanilla/src/mud/contractComponents.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - CounterTable: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e7465725461626c6500000000", - metadata: { - componentName: "CounterTable", - tableName: ":CounterTable", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - MessageTable: defineComponent( - world, - { - value: RecsType.String, - }, - { - id: "0x000000000000000000000000000000004d6573736167655461626c6500000000", - metadata: { - componentName: "MessageTable", - tableName: ":MessageTable", - keySchema: {}, - valueSchema: { value: "string" }, - }, - } as const - ), - Inventory: defineComponent( - world, - { - amount: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000496e76656e746f727900000000000000", - metadata: { - componentName: "Inventory", - tableName: ":Inventory", - keySchema: { - owner: "address", - item: "uint32", - itemVariant: "uint32", - }, - valueSchema: { amount: "uint32" }, - }, - } as const - ), - }; -} diff --git a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json index 6aec4866a5..10b95c71d8 100644 --- a/examples/minimal/packages/contracts/package.json +++ b/examples/minimal/packages/contracts/package.json @@ -6,13 +6,11 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge clean && forge build", - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client-vanilla/src/mud && mud tsgen --configPath mud.config.ts --out ../client-react/src/mud && mud tsgen --configPath mud.config.ts --out ../client-phaser/src/mud", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "rimraf types && typechain --target=ethers-v5 out/IWorld.sol/IWorld.json", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", - "dev": "pnpm mud dev-contracts --tsgenOutput ../client-react/src/mud", - "dev:phaser": "pnpm mud dev-contracts --tsgenOutput ../client-phaser/src/mud", - "dev:vanilla": "pnpm mud dev-contracts --tsgenOutput ../client-vanilla/src/mud", + "dev": "pnpm mud dev-contracts", "lint": "pnpm run prettier && pnpm run solhint", "prettier": "prettier --write 'src/**/*.sol'", "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix", diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts index 3e243b2f8b..0ff145d7ef 100644 --- a/packages/cli/src/commands/dev-contracts.ts +++ b/packages/cli/src/commands/dev-contracts.ts @@ -6,7 +6,6 @@ import { loadConfig, resolveConfigPath } from "@latticexyz/config/node"; import { StoreConfig } from "@latticexyz/store"; import { tablegen } from "@latticexyz/store/codegen"; import path from "path"; -import { tsgen } from "../render-ts"; import { debounce } from "throttle-debounce"; import { worldgenHandler } from "./worldgen"; import { WorldConfig } from "@latticexyz/world"; @@ -17,7 +16,6 @@ import { rmSync } from "fs"; type Options = { rpc?: string; configPath?: string; - tsgenOutput: string; }; const commandModule: CommandModule = { @@ -35,15 +33,10 @@ const commandModule: CommandModule = { type: "string", decs: "Path to MUD config", }, - tsgenOutput: { type: "string", demandOption: true, desc: "Directory to output MUD typescript definition files" }, }); }, async handler(args) { - if (!args.tsgenOutputDir) { - console.error("No output provided"); - } - // Initial cleanup await forge(["clean"]); @@ -137,9 +130,6 @@ const commandModule: CommandModule = { // Run tablegen to generate tables based on the config const outPath = path.join(srcDirectory, config.codegenDirectory); await tablegen(config, outPath); - - // Run tsgen to regenerate recs types based on the mud config - await tsgen(config, args.tsgenOutput); } /** Codegen to run if contracts changed */ diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index ef7c853983..9021b85f52 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -6,7 +6,6 @@ import devnode from "./devnode"; import faucet from "./faucet"; import hello from "./hello"; import tablegen from "./tablegen"; -import tsgen from "./tsgen"; import deploy from "./deploy"; import worldgen from "./worldgen"; import setVersion from "./set-version"; @@ -22,7 +21,6 @@ export const commands: CommandModule[] = [ gasReport as CommandModule, hello, tablegen, - tsgen, worldgen, setVersion, test, diff --git a/packages/cli/src/commands/tsgen.ts b/packages/cli/src/commands/tsgen.ts deleted file mode 100644 index 1ba2f9000f..0000000000 --- a/packages/cli/src/commands/tsgen.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { CommandModule } from "yargs"; -import { loadConfig } from "@latticexyz/config/node"; -import { StoreConfig } from "@latticexyz/store"; -import { tsgen } from "../render-ts/tsgen"; - -type Options = { - configPath: string; - out: string; -}; - -const commandModule: CommandModule = { - command: "tsgen", - - describe: "Autogenerate MUD typescript definitions based on the config file", - - builder(yargs) { - return yargs.options({ - configPath: { type: "string", demandOption: true, desc: "Path to the config file" }, - out: { type: "string", demandOption: true, desc: "Directory to output MUD typescript definition files" }, - }); - }, - - async handler(args) { - const { configPath, out } = args; - - const config = (await loadConfig(configPath)) as StoreConfig; - - await tsgen(config, out); - - process.exit(0); - }, -}; - -export default commandModule; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index cd24ba8518..15d828e935 100755 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,2 +1 @@ -export * from "./render-ts"; export * from "./utils/deployHandler"; diff --git a/packages/cli/src/render-ts/index.ts b/packages/cli/src/render-ts/index.ts deleted file mode 100644 index c8604ea8a1..0000000000 --- a/packages/cli/src/render-ts/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./recsV1TableOptions.js"; -export * from "./renderRecsV1Tables.js"; -export * from "./schemaTypesToRecsTypeStrings.js"; -export * from "./tsgen.js"; -export * from "./types.js"; diff --git a/packages/cli/src/render-ts/recsV1TableOptions.ts b/packages/cli/src/render-ts/recsV1TableOptions.ts deleted file mode 100644 index c15d4e8f43..0000000000 --- a/packages/cli/src/render-ts/recsV1TableOptions.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { StoreConfig } from "@latticexyz/store"; -import { resolveAbiOrUserType } from "@latticexyz/store/codegen"; -import { schemaTypesToRecsTypeStrings } from "./schemaTypesToRecsTypeStrings"; -import { RecsV1TableOptions } from "./types"; -import { SchemaTypeToAbiType } from "@latticexyz/schema-type/deprecated"; -import { StaticAbiType } from "@latticexyz/schema-type"; - -export function getRecsV1TableOptions(config: StoreConfig): RecsV1TableOptions { - const tableOptions = []; - for (const tableName of Object.keys(config.tables)) { - const tableData = config.tables[tableName]; - - const fields = Object.keys(tableData.schema).map((name) => { - const abiOrUserType = tableData.schema[name]; - const { schemaType } = resolveAbiOrUserType(abiOrUserType, config); - - const recsTypeString = schemaTypesToRecsTypeStrings[schemaType]; - - return { - recsTypeString, - name, - }; - }); - - // WARNING: skip tables without a static tableId - if (tableData.tableIdArgument) continue; - const staticResourceData = { - namespace: config.namespace, - name: tableData.name, - }; - - // TODO: move user type -> abi type into our config expanding step rather than sprinkled everywhere (https://github.com/latticexyz/mud/issues/1201) - const keySchema = Object.fromEntries( - Object.entries(tableData.keySchema).map(([name, type]) => [ - name, - SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType] as StaticAbiType, - ]) - ); - const valueSchema = Object.fromEntries( - Object.entries(tableData.schema).map(([name, type]) => [ - name, - SchemaTypeToAbiType[resolveAbiOrUserType(type, config).schemaType], - ]) - ); - - tableOptions.push({ - tableName, - keySchema, - valueSchema, - fields, - staticResourceData, - }); - } - return { - tables: tableOptions, - }; -} diff --git a/packages/cli/src/render-ts/renderRecsV1Tables.ts b/packages/cli/src/render-ts/renderRecsV1Tables.ts deleted file mode 100644 index 6df1a7fa36..0000000000 --- a/packages/cli/src/render-ts/renderRecsV1Tables.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { TableId } from "@latticexyz/common/deprecated"; -import { RecsV1TableOptions } from "./types"; - -export function renderRecsV1Tables(options: RecsV1TableOptions) { - const { tables } = options; - - return `/* Autogenerated file. Do not edit manually. */ - -import { defineComponent, Type as RecsType, type World } from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - ${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join("")} - } -} -`; -} - -function renderDefineComponent(table: RecsV1TableOptions["tables"][number]) { - const { namespace, name } = table.staticResourceData; - const tableId = new TableId(namespace, name); - return ` - defineComponent(world, { - ${table.fields.map(({ name, recsTypeString }) => `${name}: ${recsTypeString}`).join(",")} - }, { - id: ${JSON.stringify(tableId.toHex())}, - metadata: { - componentName: ${JSON.stringify(name)}, - tableName: ${JSON.stringify([namespace, name].join(":"))}, - keySchema: ${JSON.stringify(table.keySchema)}, - valueSchema: ${JSON.stringify(table.valueSchema)}, - }, - } as const) - `; -} diff --git a/packages/cli/src/render-ts/schemaTypesToRecsTypeStrings.ts b/packages/cli/src/render-ts/schemaTypesToRecsTypeStrings.ts deleted file mode 100644 index a2ea83d85e..0000000000 --- a/packages/cli/src/render-ts/schemaTypesToRecsTypeStrings.ts +++ /dev/null @@ -1,202 +0,0 @@ -import { SchemaType } from "@latticexyz/schema-type/deprecated"; - -export const schemaTypesToRecsTypeStrings: Record = { - [SchemaType.UINT8]: "RecsType.Number", - [SchemaType.UINT16]: "RecsType.Number", - [SchemaType.UINT24]: "RecsType.Number", - [SchemaType.UINT32]: "RecsType.Number", - [SchemaType.UINT40]: "RecsType.Number", - [SchemaType.UINT48]: "RecsType.Number", - [SchemaType.UINT56]: "RecsType.BigInt", - [SchemaType.UINT64]: "RecsType.BigInt", - [SchemaType.UINT72]: "RecsType.BigInt", - [SchemaType.UINT80]: "RecsType.BigInt", - [SchemaType.UINT88]: "RecsType.BigInt", - [SchemaType.UINT96]: "RecsType.BigInt", - [SchemaType.UINT104]: "RecsType.BigInt", - [SchemaType.UINT112]: "RecsType.BigInt", - [SchemaType.UINT120]: "RecsType.BigInt", - [SchemaType.UINT128]: "RecsType.BigInt", - [SchemaType.UINT136]: "RecsType.BigInt", - [SchemaType.UINT144]: "RecsType.BigInt", - [SchemaType.UINT152]: "RecsType.BigInt", - [SchemaType.UINT160]: "RecsType.BigInt", - [SchemaType.UINT168]: "RecsType.BigInt", - [SchemaType.UINT176]: "RecsType.BigInt", - [SchemaType.UINT184]: "RecsType.BigInt", - [SchemaType.UINT192]: "RecsType.BigInt", - [SchemaType.UINT200]: "RecsType.BigInt", - [SchemaType.UINT208]: "RecsType.BigInt", - [SchemaType.UINT216]: "RecsType.BigInt", - [SchemaType.UINT224]: "RecsType.BigInt", - [SchemaType.UINT232]: "RecsType.BigInt", - [SchemaType.UINT240]: "RecsType.BigInt", - [SchemaType.UINT248]: "RecsType.BigInt", - [SchemaType.UINT256]: "RecsType.BigInt", - [SchemaType.INT8]: "RecsType.Number", - [SchemaType.INT16]: "RecsType.Number", - [SchemaType.INT24]: "RecsType.Number", - [SchemaType.INT32]: "RecsType.Number", - [SchemaType.INT40]: "RecsType.Number", - [SchemaType.INT48]: "RecsType.Number", - [SchemaType.INT56]: "RecsType.BigInt", - [SchemaType.INT64]: "RecsType.BigInt", - [SchemaType.INT72]: "RecsType.BigInt", - [SchemaType.INT80]: "RecsType.BigInt", - [SchemaType.INT88]: "RecsType.BigInt", - [SchemaType.INT96]: "RecsType.BigInt", - [SchemaType.INT104]: "RecsType.BigInt", - [SchemaType.INT112]: "RecsType.BigInt", - [SchemaType.INT120]: "RecsType.BigInt", - [SchemaType.INT128]: "RecsType.BigInt", - [SchemaType.INT136]: "RecsType.BigInt", - [SchemaType.INT144]: "RecsType.BigInt", - [SchemaType.INT152]: "RecsType.BigInt", - [SchemaType.INT160]: "RecsType.BigInt", - [SchemaType.INT168]: "RecsType.BigInt", - [SchemaType.INT176]: "RecsType.BigInt", - [SchemaType.INT184]: "RecsType.BigInt", - [SchemaType.INT192]: "RecsType.BigInt", - [SchemaType.INT200]: "RecsType.BigInt", - [SchemaType.INT208]: "RecsType.BigInt", - [SchemaType.INT216]: "RecsType.BigInt", - [SchemaType.INT224]: "RecsType.BigInt", - [SchemaType.INT232]: "RecsType.BigInt", - [SchemaType.INT240]: "RecsType.BigInt", - [SchemaType.INT248]: "RecsType.BigInt", - [SchemaType.INT256]: "RecsType.BigInt", - [SchemaType.BYTES1]: "RecsType.String", - [SchemaType.BYTES2]: "RecsType.String", - [SchemaType.BYTES3]: "RecsType.String", - [SchemaType.BYTES4]: "RecsType.String", - [SchemaType.BYTES5]: "RecsType.String", - [SchemaType.BYTES6]: "RecsType.String", - [SchemaType.BYTES7]: "RecsType.String", - [SchemaType.BYTES8]: "RecsType.String", - [SchemaType.BYTES9]: "RecsType.String", - [SchemaType.BYTES10]: "RecsType.String", - [SchemaType.BYTES11]: "RecsType.String", - [SchemaType.BYTES12]: "RecsType.String", - [SchemaType.BYTES13]: "RecsType.String", - [SchemaType.BYTES14]: "RecsType.String", - [SchemaType.BYTES15]: "RecsType.String", - [SchemaType.BYTES16]: "RecsType.String", - [SchemaType.BYTES17]: "RecsType.String", - [SchemaType.BYTES18]: "RecsType.String", - [SchemaType.BYTES19]: "RecsType.String", - [SchemaType.BYTES20]: "RecsType.String", - [SchemaType.BYTES21]: "RecsType.String", - [SchemaType.BYTES22]: "RecsType.String", - [SchemaType.BYTES23]: "RecsType.String", - [SchemaType.BYTES24]: "RecsType.String", - [SchemaType.BYTES25]: "RecsType.String", - [SchemaType.BYTES26]: "RecsType.String", - [SchemaType.BYTES27]: "RecsType.String", - [SchemaType.BYTES28]: "RecsType.String", - [SchemaType.BYTES29]: "RecsType.String", - [SchemaType.BYTES30]: "RecsType.String", - [SchemaType.BYTES31]: "RecsType.String", - [SchemaType.BYTES32]: "RecsType.String", - [SchemaType.BOOL]: "RecsType.Boolean", - [SchemaType.ADDRESS]: "RecsType.String", - [SchemaType.UINT8_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT16_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT24_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT32_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT40_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT48_ARRAY]: "RecsType.NumberArray", - [SchemaType.UINT56_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT64_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT72_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT80_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT88_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT96_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT104_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT112_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT120_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT128_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT136_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT144_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT152_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT160_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT168_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT176_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT184_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT192_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT200_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT208_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT216_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT224_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT232_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT240_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT248_ARRAY]: "RecsType.BigIntArray", - [SchemaType.UINT256_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT8_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT16_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT24_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT32_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT40_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT48_ARRAY]: "RecsType.NumberArray", - [SchemaType.INT56_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT64_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT72_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT80_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT88_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT96_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT104_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT112_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT120_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT128_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT136_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT144_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT152_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT160_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT168_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT176_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT184_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT192_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT200_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT208_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT216_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT224_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT232_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT240_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT248_ARRAY]: "RecsType.BigIntArray", - [SchemaType.INT256_ARRAY]: "RecsType.BigIntArray", - [SchemaType.BYTES1_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES2_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES3_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES4_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES5_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES6_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES7_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES8_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES9_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES10_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES11_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES12_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES13_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES14_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES15_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES16_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES17_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES18_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES19_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES20_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES21_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES22_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES23_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES24_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES25_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES26_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES27_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES28_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES29_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES30_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES31_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES32_ARRAY]: "RecsType.StringArray", - [SchemaType.BOOL_ARRAY]: "RecsType.T", // no boolean array - [SchemaType.ADDRESS_ARRAY]: "RecsType.StringArray", - [SchemaType.BYTES]: "RecsType.String", - [SchemaType.STRING]: "RecsType.String", -}; diff --git a/packages/cli/src/render-ts/tsgen.ts b/packages/cli/src/render-ts/tsgen.ts deleted file mode 100644 index 15e70108eb..0000000000 --- a/packages/cli/src/render-ts/tsgen.ts +++ /dev/null @@ -1,12 +0,0 @@ -import path from "path"; -import { StoreConfig } from "@latticexyz/store"; -import { formatAndWriteTypescript } from "@latticexyz/common/codegen"; -import { getRecsV1TableOptions } from "../render-ts/recsV1TableOptions"; -import { renderRecsV1Tables } from "../render-ts/renderRecsV1Tables"; - -export async function tsgen(config: StoreConfig, outDirectory: string) { - const fullOutputPath = path.join(outDirectory, `contractComponents.ts`); - const options = getRecsV1TableOptions(config); - const output = renderRecsV1Tables(options); - formatAndWriteTypescript(output, fullOutputPath, "Generated ts definition files"); -} diff --git a/packages/cli/src/render-ts/types.ts b/packages/cli/src/render-ts/types.ts deleted file mode 100644 index b5c0e1cb15..0000000000 --- a/packages/cli/src/render-ts/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { SchemaAbiType, StaticAbiType } from "@latticexyz/schema-type"; - -export interface RecsV1TableOptions { - tables: { - tableName: string; - keySchema: Record; - valueSchema: Record; - fields: { - recsTypeString: string; - name: string; - }[]; - staticResourceData: { - namespace: string; - name: string; - }; - }[]; -} diff --git a/packages/std-client/package.json b/packages/std-client/package.json index 888c75f3bb..025cb9ddac 100644 --- a/packages/std-client/package.json +++ b/packages/std-client/package.json @@ -24,14 +24,12 @@ } }, "scripts": { - "build": "pnpm run build:mud && pnpm run build:js", + "build": "pnpm run build:js", "build:js": "tsup", - "build:mud": "tsx ./scripts/tsgen.ts", - "clean": "pnpm run clean:mud && pnpm run clean:js", + "clean": "pnpm run clean:js", "clean:js": "rimraf dist", - "clean:mud": "rimraf src/mud-definitions", "dev": "tsup --watch", - "test": "pnpm run build:mud && vitest typecheck --run" + "test": "vitest typecheck --run --passWithNoTests" }, "dependencies": { "@ethersproject/providers": "^5.7.2", diff --git a/packages/std-client/scripts/tsgen.ts b/packages/std-client/scripts/tsgen.ts deleted file mode 100644 index caf715ee61..0000000000 --- a/packages/std-client/scripts/tsgen.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { tsgen } from "@latticexyz/cli"; - -import storeMudConfig from "@latticexyz/store/mud.config.js"; -import worldMudConfig from "@latticexyz/world/mud.config.js"; - -await tsgen(storeMudConfig, "src/mud-definitions/store"); -await tsgen(worldMudConfig, "src/mud-definitions/world"); diff --git a/packages/std-client/src/contractComponents.test-d.ts b/packages/std-client/src/contractComponents.test-d.ts deleted file mode 100644 index 0b030d5103..0000000000 --- a/packages/std-client/src/contractComponents.test-d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, Type as RecsType } from "@latticexyz/recs"; -import { describe, expectTypeOf } from "vitest"; -import { defineContractComponents } from "./mud-definitions/store/contractComponents"; - -type StoreContractComponents = ReturnType; - -describe("store/contractComponents", () => { - expectTypeOf().toEqualTypeOf< - Component< - { - x: RecsType.Number; - y: RecsType.Number; - }, - { - readonly componentName: "Vector2"; - readonly tableName: "mudstore:Vector2"; - readonly keySchema: { key: "bytes32" }; - readonly valueSchema: { x: "uint32"; y: "uint32" }; - } - > - >(); -}); diff --git a/packages/std-client/src/mud-definitions/store/contractComponents.ts b/packages/std-client/src/mud-definitions/store/contractComponents.ts deleted file mode 100644 index 772431c4c3..0000000000 --- a/packages/std-client/src/mud-definitions/store/contractComponents.ts +++ /dev/null @@ -1,119 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Hooks: defineComponent( - world, - { - value: RecsType.StringArray, - }, - { - id: "0x6d756473746f72650000000000000000486f6f6b730000000000000000000000", - metadata: { - componentName: "Hooks", - tableName: "mudstore:Hooks", - keySchema: { key: "bytes32" }, - valueSchema: { value: "address[]" }, - }, - } as const - ), - Callbacks: defineComponent( - world, - { - value: RecsType.StringArray, - }, - { - id: "0x6d756473746f7265000000000000000043616c6c6261636b7300000000000000", - metadata: { - componentName: "Callbacks", - tableName: "mudstore:Callbacks", - keySchema: { key: "bytes32" }, - valueSchema: { value: "bytes24[]" }, - }, - } as const - ), - StoreMetadata: defineComponent( - world, - { - tableName: RecsType.String, - abiEncodedFieldNames: RecsType.String, - }, - { - id: "0x6d756473746f7265000000000000000053746f72654d65746164617461000000", - metadata: { - componentName: "StoreMetadata", - tableName: "mudstore:StoreMetadata", - keySchema: { tableId: "bytes32" }, - valueSchema: { tableName: "string", abiEncodedFieldNames: "bytes" }, - }, - } as const - ), - Mixed: defineComponent( - world, - { - u32: RecsType.Number, - u128: RecsType.BigInt, - a32: RecsType.NumberArray, - s: RecsType.String, - }, - { - id: "0x6d756473746f726500000000000000004d697865640000000000000000000000", - metadata: { - componentName: "Mixed", - tableName: "mudstore:Mixed", - keySchema: { key: "bytes32" }, - valueSchema: { - u32: "uint32", - u128: "uint128", - a32: "uint32[]", - s: "string", - }, - }, - } as const - ), - Vector2: defineComponent( - world, - { - x: RecsType.Number, - y: RecsType.Number, - }, - { - id: "0x6d756473746f72650000000000000000566563746f7232000000000000000000", - metadata: { - componentName: "Vector2", - tableName: "mudstore:Vector2", - keySchema: { key: "bytes32" }, - valueSchema: { x: "uint32", y: "uint32" }, - }, - } as const - ), - KeyEncoding: defineComponent( - world, - { - value: RecsType.Boolean, - }, - { - id: "0x6d756473746f726500000000000000004b6579456e636f64696e670000000000", - metadata: { - componentName: "KeyEncoding", - tableName: "mudstore:KeyEncoding", - keySchema: { - k1: "uint256", - k2: "int32", - k3: "bytes16", - k4: "address", - k5: "bool", - k6: "uint8", - }, - valueSchema: { value: "bool" }, - }, - } as const - ), - }; -} diff --git a/packages/std-client/src/mud-definitions/world/contractComponents.ts b/packages/std-client/src/mud-definitions/world/contractComponents.ts deleted file mode 100644 index fd171f4cd3..0000000000 --- a/packages/std-client/src/mud-definitions/world/contractComponents.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - NamespaceOwner: defineComponent( - world, - { - owner: RecsType.String, - }, - { - id: "0x000000000000000000000000000000004e616d6573706163654f776e65720000", - metadata: { - componentName: "NamespaceOwner", - tableName: ":NamespaceOwner", - keySchema: { namespace: "bytes16" }, - valueSchema: { owner: "address" }, - }, - } as const - ), - ResourceAccess: defineComponent( - world, - { - access: RecsType.Boolean, - }, - { - id: "0x000000000000000000000000000000005265736f757263654163636573730000", - metadata: { - componentName: "ResourceAccess", - tableName: ":ResourceAccess", - keySchema: { resourceSelector: "bytes32", caller: "address" }, - valueSchema: { access: "bool" }, - }, - } as const - ), - InstalledModules: defineComponent( - world, - { - moduleAddress: RecsType.String, - }, - { - id: "0x00000000000000000000000000000000496e7374616c6c65644d6f64756c6573", - metadata: { - componentName: "InstalledModules", - tableName: ":InstalledModules", - keySchema: { moduleName: "bytes16", argumentsHash: "bytes32" }, - valueSchema: { moduleAddress: "address" }, - }, - } as const - ), - Systems: defineComponent( - world, - { - system: RecsType.String, - publicAccess: RecsType.Boolean, - }, - { - id: "0x0000000000000000000000000000000053797374656d73000000000000000000", - metadata: { - componentName: "Systems", - tableName: ":Systems", - keySchema: { resourceSelector: "bytes32" }, - valueSchema: { system: "address", publicAccess: "bool" }, - }, - } as const - ), - SystemRegistry: defineComponent( - world, - { - resourceSelector: RecsType.String, - }, - { - id: "0x0000000000000000000000000000000053797374656d52656769737472790000", - metadata: { - componentName: "SystemRegistry", - tableName: ":SystemRegistry", - keySchema: { system: "address" }, - valueSchema: { resourceSelector: "bytes32" }, - }, - } as const - ), - SystemHooks: defineComponent( - world, - { - value: RecsType.StringArray, - }, - { - id: "0x0000000000000000000000000000000053797374656d486f6f6b730000000000", - metadata: { - componentName: "SystemHooks", - tableName: ":SystemHooks", - keySchema: { resourceSelector: "bytes32" }, - valueSchema: { value: "address[]" }, - }, - } as const - ), - ResourceType: defineComponent( - world, - { - resourceType: RecsType.Number, - }, - { - id: "0x000000000000000000000000000000005265736f757263655479706500000000", - metadata: { - componentName: "ResourceType", - tableName: ":ResourceType", - keySchema: { resourceSelector: "bytes32" }, - valueSchema: { resourceType: "uint8" }, - }, - } as const - ), - FunctionSelectors: defineComponent( - world, - { - namespace: RecsType.String, - name: RecsType.String, - systemFunctionSelector: RecsType.String, - }, - { - id: "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72", - metadata: { - componentName: "FunctionSelector", - tableName: ":FunctionSelector", - keySchema: { functionSelector: "bytes4" }, - valueSchema: { - namespace: "bytes16", - name: "bytes16", - systemFunctionSelector: "bytes4", - }, - }, - } as const - ), - KeysInTable: defineComponent( - world, - { - keys0: RecsType.StringArray, - keys1: RecsType.StringArray, - keys2: RecsType.StringArray, - keys3: RecsType.StringArray, - keys4: RecsType.StringArray, - }, - { - id: "0x000000000000000000000000000000004b657973496e5461626c650000000000", - metadata: { - componentName: "KeysInTable", - tableName: ":KeysInTable", - keySchema: { sourceTable: "bytes32" }, - valueSchema: { - keys0: "bytes32[]", - keys1: "bytes32[]", - keys2: "bytes32[]", - keys3: "bytes32[]", - keys4: "bytes32[]", - }, - }, - } as const - ), - UsedKeysIndex: defineComponent( - world, - { - has: RecsType.Boolean, - index: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000557365644b657973496e646578000000", - metadata: { - componentName: "UsedKeysIndex", - tableName: ":UsedKeysIndex", - keySchema: { sourceTable: "bytes32", keysHash: "bytes32" }, - valueSchema: { has: "bool", index: "uint40" }, - }, - } as const - ), - }; -} diff --git a/packages/std-client/src/setup/setupMUDV2Network.ts b/packages/std-client/src/setup/setupMUDV2Network.ts index ac2fc2f842..ef21773859 100644 --- a/packages/std-client/src/setup/setupMUDV2Network.ts +++ b/packages/std-client/src/setup/setupMUDV2Network.ts @@ -20,8 +20,6 @@ import { IWorldKernel__factory } from "@latticexyz/world/types/ethers-contracts/ import { defineStringComponent } from "../components"; import { ContractComponent, ContractComponents, SetupContractConfig } from "./types"; import { applyNetworkUpdates, createEncoders } from "./utils"; -import { defineContractComponents as defineStoreComponents } from "../mud-definitions/store/contractComponents"; -import { defineContractComponents as defineWorldComponents } from "../mud-definitions/world/contractComponents"; import * as devObservables from "../dev/observables"; import { Abi } from "abitype"; import { createDatabase, createDatabaseClient } from "@latticexyz/store-cache"; @@ -87,14 +85,9 @@ export async function setupMUDV2Network { + expectTypeOf["StoreMetadata"]>().toEqualTypeOf< + Component< + { + tableName: RecsType.String; + abiEncodedFieldNames: RecsType.String; + }, + { + componentName: "StoreMetadata"; + // TODO: fix config namespace so it comes back as a const + tableName: `${string}:StoreMetadata`; + keySchema: { tableId: "bytes32" }; + valueSchema: { tableName: "string"; abiEncodedFieldNames: "bytes" }; + } + > + >(); +}); diff --git a/packages/store-sync/src/recs/common.ts b/packages/store-sync/src/recs/common.ts index 77327bc997..017d0f5bf1 100644 --- a/packages/store-sync/src/recs/common.ts +++ b/packages/store-sync/src/recs/common.ts @@ -1,4 +1,7 @@ -import { KeySchema, ValueSchema } from "@latticexyz/store"; +import { KeySchema, StoreConfig, ValueSchema } from "@latticexyz/store"; +import { Component as RecsComponent, Type as RecsType } from "@latticexyz/recs"; +import { SchemaAbiTypeToRecsType } from "./schemaAbiTypeToRecsType"; +import { SchemaAbiType } from "@latticexyz/schema-type"; export type StoreComponentMetadata = { keySchema: KeySchema; @@ -11,3 +14,18 @@ export enum SyncStep { RPC = "rpc", LIVE = "live", } + +export type ConfigToRecsComponents = { + [tableName in keyof TConfig["tables"] & string]: RecsComponent< + { + [fieldName in keyof TConfig["tables"][tableName]["schema"] & string]: RecsType & + SchemaAbiTypeToRecsType; + }, + StoreComponentMetadata & { + componentName: tableName; + tableName: `${TConfig["namespace"]}:${tableName}`; + keySchema: TConfig["tables"][tableName]["keySchema"]; + valueSchema: TConfig["tables"][tableName]["schema"]; + } + >; +}; diff --git a/packages/store-sync/src/recs/configToRecsComponents.ts b/packages/store-sync/src/recs/configToRecsComponents.ts new file mode 100644 index 0000000000..f1b2e617e5 --- /dev/null +++ b/packages/store-sync/src/recs/configToRecsComponents.ts @@ -0,0 +1,35 @@ +import { StoreConfig } from "@latticexyz/store"; +import { SchemaAbiType } from "@latticexyz/schema-type"; +import { tableIdToHex } from "@latticexyz/common"; +import { World, defineComponent } from "@latticexyz/recs"; +import { ConfigToRecsComponents } from "./common"; +import { schemaAbiTypeToRecsType } from "./schemaAbiTypeToRecsType"; + +export function configToRecsComponents( + world: World, + config: TConfig +): ConfigToRecsComponents { + return Object.fromEntries( + Object.entries(config.tables).map(([tableName, table]) => [ + tableName, + defineComponent( + world, + Object.fromEntries( + Object.entries(table.schema).map(([fieldName, schemaAbiType]) => [ + fieldName, + schemaAbiTypeToRecsType[schemaAbiType as SchemaAbiType], + ]) + ), + { + id: tableIdToHex(config.namespace, tableName), + metadata: { + componentName: tableName, + tableName: `${config.namespace}:${tableName}`, + keySchema: table.keySchema, + valueSchema: table.schema, + }, + } + ), + ]) + ) as ConfigToRecsComponents; +} diff --git a/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts b/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts new file mode 100644 index 0000000000..4fe56b5f41 --- /dev/null +++ b/packages/store-sync/src/recs/schemaAbiTypeToRecsType.ts @@ -0,0 +1,205 @@ +import { Type as RecsType } from "@latticexyz/recs"; +import { SchemaAbiType } from "@latticexyz/schema-type"; + +export const schemaAbiTypeToRecsType = { + uint8: RecsType.Number, + uint16: RecsType.Number, + uint24: RecsType.Number, + uint32: RecsType.Number, + uint40: RecsType.Number, + uint48: RecsType.Number, + uint56: RecsType.BigInt, + uint64: RecsType.BigInt, + uint72: RecsType.BigInt, + uint80: RecsType.BigInt, + uint88: RecsType.BigInt, + uint96: RecsType.BigInt, + uint104: RecsType.BigInt, + uint112: RecsType.BigInt, + uint120: RecsType.BigInt, + uint128: RecsType.BigInt, + uint136: RecsType.BigInt, + uint144: RecsType.BigInt, + uint152: RecsType.BigInt, + uint160: RecsType.BigInt, + uint168: RecsType.BigInt, + uint176: RecsType.BigInt, + uint184: RecsType.BigInt, + uint192: RecsType.BigInt, + uint200: RecsType.BigInt, + uint208: RecsType.BigInt, + uint216: RecsType.BigInt, + uint224: RecsType.BigInt, + uint232: RecsType.BigInt, + uint240: RecsType.BigInt, + uint248: RecsType.BigInt, + uint256: RecsType.BigInt, + int8: RecsType.Number, + int16: RecsType.Number, + int24: RecsType.Number, + int32: RecsType.Number, + int40: RecsType.Number, + int48: RecsType.Number, + int56: RecsType.BigInt, + int64: RecsType.BigInt, + int72: RecsType.BigInt, + int80: RecsType.BigInt, + int88: RecsType.BigInt, + int96: RecsType.BigInt, + int104: RecsType.BigInt, + int112: RecsType.BigInt, + int120: RecsType.BigInt, + int128: RecsType.BigInt, + int136: RecsType.BigInt, + int144: RecsType.BigInt, + int152: RecsType.BigInt, + int160: RecsType.BigInt, + int168: RecsType.BigInt, + int176: RecsType.BigInt, + int184: RecsType.BigInt, + int192: RecsType.BigInt, + int200: RecsType.BigInt, + int208: RecsType.BigInt, + int216: RecsType.BigInt, + int224: RecsType.BigInt, + int232: RecsType.BigInt, + int240: RecsType.BigInt, + int248: RecsType.BigInt, + int256: RecsType.BigInt, + bytes1: RecsType.String, + bytes2: RecsType.String, + bytes3: RecsType.String, + bytes4: RecsType.String, + bytes5: RecsType.String, + bytes6: RecsType.String, + bytes7: RecsType.String, + bytes8: RecsType.String, + bytes9: RecsType.String, + bytes10: RecsType.String, + bytes11: RecsType.String, + bytes12: RecsType.String, + bytes13: RecsType.String, + bytes14: RecsType.String, + bytes15: RecsType.String, + bytes16: RecsType.String, + bytes17: RecsType.String, + bytes18: RecsType.String, + bytes19: RecsType.String, + bytes20: RecsType.String, + bytes21: RecsType.String, + bytes22: RecsType.String, + bytes23: RecsType.String, + bytes24: RecsType.String, + bytes25: RecsType.String, + bytes26: RecsType.String, + bytes27: RecsType.String, + bytes28: RecsType.String, + bytes29: RecsType.String, + bytes30: RecsType.String, + bytes31: RecsType.String, + bytes32: RecsType.String, + bool: RecsType.Boolean, + address: RecsType.String, + "uint8[]": RecsType.NumberArray, + "uint16[]": RecsType.NumberArray, + "uint24[]": RecsType.NumberArray, + "uint32[]": RecsType.NumberArray, + "uint40[]": RecsType.NumberArray, + "uint48[]": RecsType.NumberArray, + "uint56[]": RecsType.BigIntArray, + "uint64[]": RecsType.BigIntArray, + "uint72[]": RecsType.BigIntArray, + "uint80[]": RecsType.BigIntArray, + "uint88[]": RecsType.BigIntArray, + "uint96[]": RecsType.BigIntArray, + "uint104[]": RecsType.BigIntArray, + "uint112[]": RecsType.BigIntArray, + "uint120[]": RecsType.BigIntArray, + "uint128[]": RecsType.BigIntArray, + "uint136[]": RecsType.BigIntArray, + "uint144[]": RecsType.BigIntArray, + "uint152[]": RecsType.BigIntArray, + "uint160[]": RecsType.BigIntArray, + "uint168[]": RecsType.BigIntArray, + "uint176[]": RecsType.BigIntArray, + "uint184[]": RecsType.BigIntArray, + "uint192[]": RecsType.BigIntArray, + "uint200[]": RecsType.BigIntArray, + "uint208[]": RecsType.BigIntArray, + "uint216[]": RecsType.BigIntArray, + "uint224[]": RecsType.BigIntArray, + "uint232[]": RecsType.BigIntArray, + "uint240[]": RecsType.BigIntArray, + "uint248[]": RecsType.BigIntArray, + "uint256[]": RecsType.BigIntArray, + "int8[]": RecsType.NumberArray, + "int16[]": RecsType.NumberArray, + "int24[]": RecsType.NumberArray, + "int32[]": RecsType.NumberArray, + "int40[]": RecsType.NumberArray, + "int48[]": RecsType.NumberArray, + "int56[]": RecsType.BigIntArray, + "int64[]": RecsType.BigIntArray, + "int72[]": RecsType.BigIntArray, + "int80[]": RecsType.BigIntArray, + "int88[]": RecsType.BigIntArray, + "int96[]": RecsType.BigIntArray, + "int104[]": RecsType.BigIntArray, + "int112[]": RecsType.BigIntArray, + "int120[]": RecsType.BigIntArray, + "int128[]": RecsType.BigIntArray, + "int136[]": RecsType.BigIntArray, + "int144[]": RecsType.BigIntArray, + "int152[]": RecsType.BigIntArray, + "int160[]": RecsType.BigIntArray, + "int168[]": RecsType.BigIntArray, + "int176[]": RecsType.BigIntArray, + "int184[]": RecsType.BigIntArray, + "int192[]": RecsType.BigIntArray, + "int200[]": RecsType.BigIntArray, + "int208[]": RecsType.BigIntArray, + "int216[]": RecsType.BigIntArray, + "int224[]": RecsType.BigIntArray, + "int232[]": RecsType.BigIntArray, + "int240[]": RecsType.BigIntArray, + "int248[]": RecsType.BigIntArray, + "int256[]": RecsType.BigIntArray, + "bytes1[]": RecsType.StringArray, + "bytes2[]": RecsType.StringArray, + "bytes3[]": RecsType.StringArray, + "bytes4[]": RecsType.StringArray, + "bytes5[]": RecsType.StringArray, + "bytes6[]": RecsType.StringArray, + "bytes7[]": RecsType.StringArray, + "bytes8[]": RecsType.StringArray, + "bytes9[]": RecsType.StringArray, + "bytes10[]": RecsType.StringArray, + "bytes11[]": RecsType.StringArray, + "bytes12[]": RecsType.StringArray, + "bytes13[]": RecsType.StringArray, + "bytes14[]": RecsType.StringArray, + "bytes15[]": RecsType.StringArray, + "bytes16[]": RecsType.StringArray, + "bytes17[]": RecsType.StringArray, + "bytes18[]": RecsType.StringArray, + "bytes19[]": RecsType.StringArray, + "bytes20[]": RecsType.StringArray, + "bytes21[]": RecsType.StringArray, + "bytes22[]": RecsType.StringArray, + "bytes23[]": RecsType.StringArray, + "bytes24[]": RecsType.StringArray, + "bytes25[]": RecsType.StringArray, + "bytes26[]": RecsType.StringArray, + "bytes27[]": RecsType.StringArray, + "bytes28[]": RecsType.StringArray, + "bytes29[]": RecsType.StringArray, + "bytes30[]": RecsType.StringArray, + "bytes31[]": RecsType.StringArray, + "bytes32[]": RecsType.StringArray, + "bool[]": RecsType.T, // no boolean arr, + "address[]": RecsType.StringArray, + bytes: RecsType.String, + string: RecsType.String, +} as const satisfies Record; + +export type SchemaAbiTypeToRecsType = (typeof schemaAbiTypeToRecsType)[T]; diff --git a/packages/store-sync/src/recs/syncToRecs.ts b/packages/store-sync/src/recs/syncToRecs.ts index 36b34937cd..2e23bfee58 100644 --- a/packages/store-sync/src/recs/syncToRecs.ts +++ b/packages/store-sync/src/recs/syncToRecs.ts @@ -1,14 +1,6 @@ import { StoreConfig, storeEventsAbi } from "@latticexyz/store"; -import { Address, Block, Chain, Hex, PublicClient, TransactionReceipt, Transport } from "viem"; -import { - ComponentValue, - Entity, - Component as RecsComponent, - Schema as RecsSchema, - World as RecsWorld, - getComponentValue, - setComponent, -} from "@latticexyz/recs"; +import { Address, Block, Hex, PublicClient, TransactionReceipt } from "viem"; +import { ComponentValue, Entity, World as RecsWorld, getComponentValue, setComponent } from "@latticexyz/recs"; import { BlockLogs, Table } from "../common"; import { TableRecord } from "@latticexyz/store"; import { @@ -23,25 +15,20 @@ import { recsStorage } from "./recsStorage"; import { debug } from "./debug"; import { defineInternalComponents } from "./defineInternalComponents"; import { getTableKey } from "./getTableKey"; -import { StoreComponentMetadata, SyncStep } from "./common"; +import { ConfigToRecsComponents, SyncStep } from "./common"; import { encodeEntity } from "./encodeEntity"; import { createIndexerClient } from "../trpc-indexer"; import { singletonEntity } from "./singletonEntity"; +import storeConfig from "@latticexyz/store/mud.config"; +import worldConfig from "@latticexyz/world/mud.config"; +import { configToRecsComponents } from "./configToRecsComponents"; -type SyncToRecsOptions< - TConfig extends StoreConfig = StoreConfig, - TComponents extends Record> = Record< - string, - RecsComponent - > -> = { +type SyncToRecsOptions = { world: RecsWorld; config: TConfig; address: Address; // TODO: make this optional and return one if none provided (but will need chain ID at least) publicClient: PublicClient; - // TODO: generate these from config and return instead? - components: TComponents; startBlock?: bigint; indexerUrl?: string; initialState?: { @@ -50,15 +37,12 @@ type SyncToRecsOptions< }; }; -type SyncToRecsResult< - TConfig extends StoreConfig = StoreConfig, - TComponents extends Record> = Record< - string, - RecsComponent - > -> = { +type SyncToRecsResult = { // TODO: return publicClient? - components: TComponents & ReturnType; + components: ConfigToRecsComponents & + ConfigToRecsComponents & + ConfigToRecsComponents & + ReturnType; latestBlock$: Observable; latestBlockNumber$: Observable; blockLogs$: Observable; @@ -67,24 +51,19 @@ type SyncToRecsResult< destroy: () => void; }; -export async function syncToRecs< - TConfig extends StoreConfig = StoreConfig, - TComponents extends Record> = Record< - string, - RecsComponent - > ->({ +export async function syncToRecs({ world, config, address, publicClient, - components: initialComponents, startBlock = 0n, initialState, indexerUrl, -}: SyncToRecsOptions): Promise> { +}: SyncToRecsOptions): Promise> { const components = { - ...initialComponents, + ...configToRecsComponents(world, config), + ...configToRecsComponents(world, storeConfig), + ...configToRecsComponents(world, worldConfig), ...defineInternalComponents(world), }; diff --git a/packages/store/ts/common.ts b/packages/store/ts/common.ts index 98df7a5240..9d825f35fd 100644 --- a/packages/store/ts/common.ts +++ b/packages/store/ts/common.ts @@ -14,6 +14,12 @@ export type TableRecord; }; +export type ConfigFieldTypeToSchemaAbiType> = T extends SchemaAbiType + ? T + : T extends `${string}[${string}]` + ? "uint8[]" + : "uint8"; + export type ConfigFieldTypeToPrimitiveType> = T extends SchemaAbiType ? SchemaAbiTypeToPrimitiveType : T extends `${string}[${string}]` // field type might include enums and enum arrays, which are mapped to uint8/uint8[] diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 86f26ac32d..f478a84bf6 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -267,7 +267,7 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 87248 + "gasUsed": 87260 }, { "file": "test/World.t.sol", diff --git a/packages/world/package.json b/packages/world/package.json index 165935038f..c76e02063e 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -13,10 +13,10 @@ ".": "./dist/ts/library/index.js", "./register": "./dist/ts/register/index.js", "./node": "./dist/ts/node/index.js", - "./mud.config.js": "./dist/mud.config.js", "./abi/*": "./abi/*", "./types/*": "./types/*", - "./snapsync": "./dist/ts/plugins/snapsync/index.js" + "./snapsync": "./dist/ts/plugins/snapsync/index.js", + "./*": "./dist/*" }, "typesVersions": { "*": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7c8b5e85e..bead10e918 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1131,6 +1131,9 @@ importers: '@latticexyz/store': specifier: workspace:* version: link:../store + '@latticexyz/world': + specifier: workspace:* + version: link:../world '@trpc/client': specifier: 10.34.0 version: 10.34.0(@trpc/server@10.34.0) diff --git a/templates/phaser/packages/client/src/mud/contractComponents.ts b/templates/phaser/packages/client/src/mud/contractComponents.ts deleted file mode 100644 index 97d7c95522..0000000000 --- a/templates/phaser/packages/client/src/mud/contractComponents.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Counter: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e746572000000000000000000", - metadata: { - componentName: "Counter", - tableName: ":Counter", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - }; -} diff --git a/templates/phaser/packages/client/src/mud/setupNetwork.ts b/templates/phaser/packages/client/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/templates/phaser/packages/client/src/mud/setupNetwork.ts +++ b/templates/phaser/packages/client/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/templates/phaser/packages/contracts/package.json b/templates/phaser/packages/contracts/package.json index a828e9c0b3..e850a729d2 100644 --- a/templates/phaser/packages/contracts/package.json +++ b/templates/phaser/packages/contracts/package.json @@ -6,11 +6,11 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge clean && forge build", - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client/src/mud", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "rimraf types && typechain --target=ethers-v5 out/IWorld.sol/IWorld.json", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", - "dev": "pnpm mud dev-contracts --tsgenOutput ../client/src/mud", + "dev": "pnpm mud dev-contracts", "lint": "pnpm run prettier && pnpm run solhint", "prettier": "prettier --write 'src/**/*.sol'", "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix", diff --git a/templates/react/packages/client/src/mud/contractComponents.ts b/templates/react/packages/client/src/mud/contractComponents.ts deleted file mode 100644 index 97d7c95522..0000000000 --- a/templates/react/packages/client/src/mud/contractComponents.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Counter: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e746572000000000000000000", - metadata: { - componentName: "Counter", - tableName: ":Counter", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - }; -} diff --git a/templates/react/packages/client/src/mud/setupNetwork.ts b/templates/react/packages/client/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/templates/react/packages/client/src/mud/setupNetwork.ts +++ b/templates/react/packages/client/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/templates/react/packages/contracts/package.json b/templates/react/packages/contracts/package.json index a828e9c0b3..e850a729d2 100644 --- a/templates/react/packages/contracts/package.json +++ b/templates/react/packages/contracts/package.json @@ -6,11 +6,11 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge clean && forge build", - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client/src/mud", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "rimraf types && typechain --target=ethers-v5 out/IWorld.sol/IWorld.json", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", - "dev": "pnpm mud dev-contracts --tsgenOutput ../client/src/mud", + "dev": "pnpm mud dev-contracts", "lint": "pnpm run prettier && pnpm run solhint", "prettier": "prettier --write 'src/**/*.sol'", "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix", diff --git a/templates/threejs/packages/client/src/mud/contractComponents.ts b/templates/threejs/packages/client/src/mud/contractComponents.ts deleted file mode 100644 index 2121998b99..0000000000 --- a/templates/threejs/packages/client/src/mud/contractComponents.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Position: defineComponent( - world, - { - x: RecsType.Number, - y: RecsType.Number, - z: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000506f736974696f6e0000000000000000", - metadata: { - componentName: "Position", - tableName: ":Position", - keySchema: { key: "bytes32" }, - valueSchema: { x: "int32", y: "int32", z: "int32" }, - }, - } as const - ), - }; -} diff --git a/templates/threejs/packages/client/src/mud/setupNetwork.ts b/templates/threejs/packages/client/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/templates/threejs/packages/client/src/mud/setupNetwork.ts +++ b/templates/threejs/packages/client/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/templates/threejs/packages/contracts/package.json b/templates/threejs/packages/contracts/package.json index a828e9c0b3..e850a729d2 100644 --- a/templates/threejs/packages/contracts/package.json +++ b/templates/threejs/packages/contracts/package.json @@ -6,11 +6,11 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge clean && forge build", - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client/src/mud", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "rimraf types && typechain --target=ethers-v5 out/IWorld.sol/IWorld.json", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", - "dev": "pnpm mud dev-contracts --tsgenOutput ../client/src/mud", + "dev": "pnpm mud dev-contracts", "lint": "pnpm run prettier && pnpm run solhint", "prettier": "prettier --write 'src/**/*.sol'", "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix", diff --git a/templates/vanilla/packages/client/src/mud/contractComponents.ts b/templates/vanilla/packages/client/src/mud/contractComponents.ts deleted file mode 100644 index 97d7c95522..0000000000 --- a/templates/vanilla/packages/client/src/mud/contractComponents.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ - -import { - defineComponent, - Type as RecsType, - type World, -} from "@latticexyz/recs"; - -export function defineContractComponents(world: World) { - return { - Counter: defineComponent( - world, - { - value: RecsType.Number, - }, - { - id: "0x00000000000000000000000000000000436f756e746572000000000000000000", - metadata: { - componentName: "Counter", - tableName: ":Counter", - keySchema: {}, - valueSchema: { value: "uint32" }, - }, - } as const - ), - }; -} diff --git a/templates/vanilla/packages/client/src/mud/setupNetwork.ts b/templates/vanilla/packages/client/src/mud/setupNetwork.ts index 8ec9aee443..6882d73cb1 100644 --- a/templates/vanilla/packages/client/src/mud/setupNetwork.ts +++ b/templates/vanilla/packages/client/src/mud/setupNetwork.ts @@ -2,7 +2,6 @@ import { createPublicClient, fallback, webSocket, http, createWalletClient, Hex, import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; -import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; @@ -11,7 +10,6 @@ import { createBurnerAccount, createContract, transportObserver } from "@lattice export type SetupNetworkResult = Awaited>; export async function setupNetwork() { - const contractComponents = defineContractComponents(world); const networkConfig = await getNetworkConfig(); const clientOptions = { @@ -40,7 +38,6 @@ export async function setupNetwork() { config: storeConfig, address: networkConfig.worldAddress as Hex, publicClient, - components: contractComponents, startBlock: BigInt(networkConfig.initialBlockNumber), }); diff --git a/templates/vanilla/packages/contracts/package.json b/templates/vanilla/packages/contracts/package.json index a828e9c0b3..e850a729d2 100644 --- a/templates/vanilla/packages/contracts/package.json +++ b/templates/vanilla/packages/contracts/package.json @@ -6,11 +6,11 @@ "scripts": { "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:typechain", "build:abi": "forge clean && forge build", - "build:mud": "mud tablegen && mud worldgen && mud tsgen --configPath mud.config.ts --out ../client/src/mud", + "build:mud": "mud tablegen && mud worldgen", "build:typechain": "rimraf types && typechain --target=ethers-v5 out/IWorld.sol/IWorld.json", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", - "dev": "pnpm mud dev-contracts --tsgenOutput ../client/src/mud", + "dev": "pnpm mud dev-contracts", "lint": "pnpm run prettier && pnpm run solhint", "prettier": "prettier --write 'src/**/*.sol'", "solhint": "solhint --config ./.solhint.json 'src/**/*.sol' --fix",