@latticexyz/world 2.0.0-alpha.1.62 → 2.0.0-alpha.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import{f as o}from"./chunk-XSZNAEUO.js";import"@latticexyz/store/register";import{mudConfig as c,mudCoreConfig as C,resolveTableId as g}from"@latticexyz/store/register";import{extendMUDCoreConfig as t,fromZodErrorCustom as i}from"@latticexyz/config";import{ZodError as n}from"zod";t(r=>{try{return o.parse(r)}catch(e){throw e instanceof n?i(e,"WorldConfig Validation Error"):e}});import"@latticexyz/store/register";export{c as a,C as b,g as c};
2
+ //# sourceMappingURL=chunk-KXMVYZUU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts","../ts/register/typeExtensions.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin, followed by world)\n\n// For convenience register and reexport store (which does the same for core config),\n// to reduce the number of needed imports for users\nimport \"@latticexyz/store/register\";\nexport { mudConfig, mudCoreConfig, resolveTableId } from \"@latticexyz/store/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../library\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginWorldConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"WorldConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n","import { OrDefaults } from \"@latticexyz/common/type-utils\";\nimport { MUDCoreUserConfig } from \"@latticexyz/config\";\nimport { ExpandSystemsConfig, WorldConfig, WorldUserConfig, WORLD_DEFAULTS } from \"../library\";\n\nimport \"@latticexyz/store/register\";\n\n// Inject the plugin options into the core config.\n// Re-exporting an interface of an existing module merges them, adding new options to the interface.\n// (typescript has no way to override types)\ndeclare module \"@latticexyz/config\" {\n // Extend the user config type, which represents the config as written by the users.\n // Most things are optional here.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreUserConfig extends WorldUserConfig {}\n\n // Also extend the config type, which represents the configuration after it has been resolved.\n // It should not have any optional properties, with the default values applied instead.\n // Other plugins may receive this resolved config as their input.\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface MUDCoreConfig extends WorldConfig {}\n}\n\ndeclare module \"@latticexyz/store/register\" {\n export interface ExpandMUDUserConfig<T extends MUDCoreUserConfig>\n extends OrDefaults<\n T,\n {\n worldContractName: typeof WORLD_DEFAULTS.worldContractName;\n worldInterfaceName: typeof WORLD_DEFAULTS.worldInterfaceName;\n excludeSystems: typeof WORLD_DEFAULTS.excludeSystems;\n postDeployScript: typeof WORLD_DEFAULTS.postDeployScript;\n deploysDirectory: typeof WORLD_DEFAULTS.deploysDirectory;\n worldgenDirectory: typeof WORLD_DEFAULTS.worldgenDirectory;\n worldImportPath: typeof WORLD_DEFAULTS.worldImportPath;\n modules: typeof WORLD_DEFAULTS.modules;\n }\n > {\n overrideSystems: ExpandSystemsConfig<\n T[\"overrideSystems\"] extends Record<string, unknown> ? T[\"overrideSystems\"] : Record<string, never>\n >;\n }\n}\n"],"mappings":"wCAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,EAAe,kBAAAC,MAAsB,6BCPzD,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,qBACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC,ECbD,MAAO","names":["mudConfig","mudCoreConfig","resolveTableId","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}
@@ -0,0 +1,30 @@
1
+ var S={registerFunctionSelector:!0,openAccess:!0,accessList:[]},l={worldContractName:void 0,worldInterfaceName:"IWorld",overrideSystems:{},excludeSystems:[],postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/",modules:[]};import{getDuplicates as j,MUDError as T,STORE_SELECTOR_MAX_LENGTH as z,UnrecognizedSystemErrorFactory as I}from"@latticexyz/config";function b(r,o){let c=o?.filter(e=>e.endsWith("System")&&e!=="System"&&!e.match(/^I[A-Z]/))??[],n=Object.keys(r.overrideSystems);if(o){for(let e of n)if(!o.includes(e)||e==="World")throw I(["overrideSystems",e],e)}let m=[...new Set([...c,...n])].filter(e=>!r.excludeSystems.includes(e)).reduce((e,p)=>({...e,[p]:O(p,r.overrideSystems[p],o)}),{}),s=Object.values(r.tables).map(({name:e})=>e),a=Object.values(m).map(({name:e})=>e),d=j([...s,...a]);if(d.length>0)throw new T(`Table and system names must be unique: ${d.join(", ")}`);return{systems:m}}function O(r,o,c){let n=o?.name??r.slice(0,z),i=o?.registerFunctionSelectors??!0,m=o?.openAccess??!0,s=[],a=[],d=o&&!o.openAccess?o.accessList:[];for(let e of d)if(e.startsWith("0x"))s.push(e);else{if(c&&!c.includes(e))throw I(["overrideSystems",r,"accessList"],e);a.push(e)}return{name:n,registerFunctionSelectors:i,openAccess:m,accessListAddresses:s,accessListSystems:a}}import{z as t}from"zod";import{DynamicResolutionType as E,zEthereumAddress as F,zObjectName as w,zSelector as _}from"@latticexyz/config";var g=w,U=w,M=t.array(g.or(F)).default(S.accessList),B=t.intersection(t.object({name:_,registerFunctionSelectors:t.boolean().default(S.registerFunctionSelector)}),t.discriminatedUnion("openAccess",[t.object({openAccess:t.literal(!0).default(S.openAccess)}),t.object({openAccess:t.literal(!1),accessList:M})])),G=t.object({value:t.union([t.string(),t.number(),t.instanceof(Uint8Array)]),type:t.string()}),H=t.object({type:t.nativeEnum(E),input:t.string()}),k=t.object({name:U,root:t.boolean().default(!1),args:t.array(t.union([G,H])).default([])}),K=t.object({worldContractName:t.string().optional(),worldInterfaceName:t.string().default(l.worldInterfaceName),overrideSystems:t.record(g,B).default(l.overrideSystems),excludeSystems:t.array(g).default(l.excludeSystems),postDeployScript:t.string().default(l.postDeployScript),deploysDirectory:t.string().default(l.deploysDirectory),worldgenDirectory:t.string().default(l.worldgenDirectory),worldImportPath:t.string().default(l.worldImportPath),modules:t.array(k).default(l.modules)}),me=K.catchall(t.any());import{renderArguments as h,renderList as W,renderedSolidityHeader as Y,renderImports as q}from"@latticexyz/common/codegen";function $(r){let{imports:o,name:c,functionPrefix:n,functions:i,errors:m}=r;return`${Y}
2
+
3
+ ${q(o)}
4
+
5
+ interface ${c} {
6
+ ${W(m,({name:s,parameters:a})=>`error ${s}(${h(a)});`)}
7
+
8
+ ${W(i,({name:s,parameters:a,stateMutability:d,returnParameters:e})=>`
9
+ function ${n}${s}(
10
+ ${h(a)}
11
+ ) external ${d} ${V(e)};
12
+ `)}
13
+ }
14
+
15
+ `}function V(r){return r.length>0?`returns (${h(r)})`:""}import{renderArguments as X,renderedSolidityHeader as Z,renderAbsoluteImports as J,renderRelativeImports as Q}from"@latticexyz/common/codegen";function v(r){let{interfaceName:o,storeImportPath:c,worldImportPath:n,imports:i}=r,m=o==="IBaseWorld"?[{symbol:"IStore",path:`${c}IStore.sol`},{symbol:"IWorldKernel",path:`${n}interfaces/IWorldKernel.sol`}]:[{symbol:"IBaseWorld",path:`${n}interfaces/IBaseWorld.sol`}],s=[...m,...i].map(({symbol:a})=>a);return`${Z}
16
+
17
+ ${J(m)}
18
+
19
+ ${Q(i)}
20
+
21
+ /**
22
+ * The ${o} interface includes all systems dynamically added to the World
23
+ * during the deploy process.
24
+ */
25
+ interface ${o} is ${X(s)} {
26
+
27
+ }
28
+
29
+ `}import{readFileSync as ee}from"fs";import u from"path";import{formatAndWriteSolidity as D,contractToInterface as te}from"@latticexyz/common/codegen";async function xe(r,o,c){let n=b(r,o.map(({basename:e})=>e)),i=u.join(c,r.worldgenDirectory),m=o.filter(({basename:e})=>Object.keys(n.systems).includes(e)),s=[];for(let e of m){let p=ee(e.path,"utf8"),{functions:x,errors:A,symbolImports:C}=te(p,e.basename),R=C.map(f=>f.path[0]==="."?{symbol:f.symbol,fromPath:u.join(u.dirname(e.path),f.path),usedInPath:i}:{symbol:f.symbol,path:f.path}),y=`I${e.basename}`,{name:L}=n.systems[e.basename],N=$({name:y,functionPrefix:r.namespace===""?"":`${r.namespace}_${L}_`,functions:x,errors:A,imports:R}),P=u.join(i,y+".sol");await D(N,P,"Generated system interface"),s.push({symbol:y,fromPath:`${y}.sol`,usedInPath:"./"})}let a=v({interfaceName:r.worldInterfaceName,imports:s,storeImportPath:r.storeImportPath,worldImportPath:r.worldImportPath}),d=u.join(i,r.worldInterfaceName+".sol");await D(a,d,"Generated system interface")}export{S as a,l as b,b as c,O as d,K as e,me as f,$ as g,v as h,xe as i};
30
+ //# sourceMappingURL=chunk-XSZNAEUO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../ts/library/config/defaults.ts","../ts/library/config/resolveWorldConfig.ts","../ts/library/config/worldConfig.ts","../ts/library/render-solidity/renderSystemInterface.ts","../ts/library/render-solidity/renderWorld.ts","../ts/library/render-solidity/worldgen.ts"],"sourcesContent":["export const SYSTEM_DEFAULTS = {\n registerFunctionSelector: true,\n openAccess: true,\n accessList: [] as string[],\n} as const;\n\nexport const WORLD_DEFAULTS = {\n worldContractName: undefined,\n worldInterfaceName: \"IWorld\",\n overrideSystems: {} as Record<string, never>,\n excludeSystems: [] as string[],\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n modules: [] as [],\n} as const;\n","import { getDuplicates, MUDError, STORE_SELECTOR_MAX_LENGTH, UnrecognizedSystemErrorFactory } from \"@latticexyz/config\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { SystemConfig, WorldConfig } from \"./types\";\n\nexport type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;\n\nexport type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;\n\n/**\n * Resolves the world config by combining the default and overridden system configs,\n * filtering out excluded systems, validate system names refer to existing contracts, and\n * splitting the access list into addresses and system names.\n */\nexport function resolveWorldConfig(config: StoreConfig & WorldConfig, existingContracts?: string[]) {\n // Include contract names ending in \"System\", but not the base \"System\" contract, and not Interfaces\n const defaultSystemNames =\n existingContracts?.filter((name) => name.endsWith(\"System\") && name !== \"System\" && !name.match(/^I[A-Z]/)) ?? [];\n const overriddenSystemNames = Object.keys(config.overrideSystems);\n\n // Validate every key in overrideSystems refers to an existing system contract (and is not called \"World\")\n if (existingContracts) {\n for (const systemName of overriddenSystemNames) {\n if (!existingContracts.includes(systemName) || systemName === \"World\") {\n throw UnrecognizedSystemErrorFactory([\"overrideSystems\", systemName], systemName);\n }\n }\n }\n\n // Combine the default and overridden system names and filter out excluded systems\n const systemNames = [...new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(\n (name) => !config.excludeSystems.includes(name)\n );\n\n // Resolve the config\n const resolvedSystems: Record<string, ResolvedSystemConfig> = systemNames.reduce((acc, systemName) => {\n return {\n ...acc,\n [systemName]: resolveSystemConfig(systemName, config.overrideSystems[systemName], existingContracts),\n };\n }, {});\n\n // Table and system names must be unique (because they're both used for world selectors)\n const tableNames = Object.values(config.tables).map(({ name }) => name);\n const configuredSystemNames = Object.values(resolvedSystems).map(({ name }) => name);\n const duplicateNames = getDuplicates([...tableNames, ...configuredSystemNames]);\n if (duplicateNames.length > 0) {\n throw new MUDError(`Table and system names must be unique: ${duplicateNames.join(\", \")}`);\n }\n\n return { systems: resolvedSystems };\n}\n\n/**\n * Resolves the system config by combining the default and overridden system configs,\n * @param systemName name of the system\n * @param config optional SystemConfig object, if none is provided the default config is used\n * @param existingContracts optional list of existing contract names, used to validate system names in the access list. If not provided, no validation is performed.\n * @returns ResolvedSystemConfig object\n * Default value for name is `systemName`\n * Default value for registerFunctionSelectors is true\n * Default value for openAccess is true\n * Default value for accessListAddresses is []\n * Default value for accessListSystems is []\n */\nexport function resolveSystemConfig(systemName: string, config?: SystemConfig, existingContracts?: string[]) {\n const name = config?.name ?? systemName.slice(0, STORE_SELECTOR_MAX_LENGTH);\n const registerFunctionSelectors = config?.registerFunctionSelectors ?? true;\n const openAccess = config?.openAccess ?? true;\n const accessListAddresses: string[] = [];\n const accessListSystems: string[] = [];\n const accessList = config && !config.openAccess ? config.accessList : [];\n\n // Split the access list into addresses and system names\n for (const accessListItem of accessList) {\n if (accessListItem.startsWith(\"0x\")) {\n accessListAddresses.push(accessListItem);\n } else {\n // Validate every system refers to an existing system contract\n if (existingContracts && !existingContracts.includes(accessListItem)) {\n throw UnrecognizedSystemErrorFactory([\"overrideSystems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n","import { z } from \"zod\";\nimport { DynamicResolutionType, zEthereumAddress, zObjectName, zSelector } from \"@latticexyz/config\";\nimport { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from \"./defaults\";\n\nconst zSystemName = zObjectName;\nconst zModuleName = zObjectName;\nconst zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).default(SYSTEM_DEFAULTS.accessList);\n\n// The system config is a combination of a name config and access config\nconst zSystemConfig = z.intersection(\n z.object({\n name: zSelector,\n registerFunctionSelectors: z.boolean().default(SYSTEM_DEFAULTS.registerFunctionSelector),\n }),\n z.discriminatedUnion(\"openAccess\", [\n z.object({\n openAccess: z.literal(true).default(SYSTEM_DEFAULTS.openAccess),\n }),\n z.object({\n openAccess: z.literal(false),\n accessList: zSystemAccessList,\n }),\n ])\n);\n\nconst zValueWithType = z.object({\n value: z.union([z.string(), z.number(), z.instanceof(Uint8Array)]),\n type: z.string(),\n});\nconst zDynamicResolution = z.object({ type: z.nativeEnum(DynamicResolutionType), input: z.string() });\n\nconst zModuleConfig = z.object({\n name: zModuleName,\n root: z.boolean().default(false),\n args: z.array(z.union([zValueWithType, zDynamicResolution])).default([]),\n});\n\n// The parsed world config is the result of parsing the user config\nexport const zWorldConfig = z.object({\n worldContractName: z.string().optional(),\n worldInterfaceName: z.string().default(WORLD_DEFAULTS.worldInterfaceName),\n overrideSystems: z.record(zSystemName, zSystemConfig).default(WORLD_DEFAULTS.overrideSystems),\n excludeSystems: z.array(zSystemName).default(WORLD_DEFAULTS.excludeSystems),\n postDeployScript: z.string().default(WORLD_DEFAULTS.postDeployScript),\n deploysDirectory: z.string().default(WORLD_DEFAULTS.deploysDirectory),\n worldgenDirectory: z.string().default(WORLD_DEFAULTS.worldgenDirectory),\n worldImportPath: z.string().default(WORLD_DEFAULTS.worldImportPath),\n modules: z.array(zModuleConfig).default(WORLD_DEFAULTS.modules),\n});\n\n// Catchall preserves other plugins' options\nexport const zPluginWorldConfig = zWorldConfig.catchall(z.any());\n","import { renderArguments, renderList, renderedSolidityHeader, renderImports } from \"@latticexyz/common/codegen\";\nimport { RenderSystemInterfaceOptions } from \"./types\";\n\nexport function renderSystemInterface(options: RenderSystemInterfaceOptions) {\n const { imports, name, functionPrefix, functions, errors } = options;\n\n return `${renderedSolidityHeader}\n\n${renderImports(imports)}\n\ninterface ${name} {\n ${renderList(errors, ({ name, parameters }) => `error ${name}(${renderArguments(parameters)});`)}\n\n ${renderList(\n functions,\n ({ name, parameters, stateMutability, returnParameters }) => `\n function ${functionPrefix}${name}(\n ${renderArguments(parameters)}\n ) external ${stateMutability} ${renderReturnParameters(returnParameters)};\n `\n )}\n}\n\n`;\n}\n\nfunction renderReturnParameters(returnParameters: string[]) {\n if (returnParameters.length > 0) {\n return `returns (${renderArguments(returnParameters)})`;\n } else {\n return \"\";\n }\n}\n","import {\n renderArguments,\n renderedSolidityHeader,\n renderAbsoluteImports,\n renderRelativeImports,\n type AbsoluteImportDatum,\n} from \"@latticexyz/common/codegen\";\nimport type { RenderWorldOptions } from \"./types\";\n\nexport function renderWorld(options: RenderWorldOptions) {\n const { interfaceName, storeImportPath, worldImportPath, imports } = options;\n const baseImports: AbsoluteImportDatum[] =\n interfaceName === \"IBaseWorld\"\n ? [\n { symbol: \"IStore\", path: `${storeImportPath}IStore.sol` },\n { symbol: \"IWorldKernel\", path: `${worldImportPath}interfaces/IWorldKernel.sol` },\n ]\n : [\n {\n symbol: \"IBaseWorld\",\n path: `${worldImportPath}interfaces/IBaseWorld.sol`,\n },\n ];\n const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol);\n\n return `${renderedSolidityHeader}\n\n${renderAbsoluteImports(baseImports)}\n\n${renderRelativeImports(imports)}\n\n/**\n * The ${interfaceName} interface includes all systems dynamically added to the World\n * during the deploy process.\n */\ninterface ${interfaceName} is ${renderArguments(importSymbols)} {\n\n}\n\n`;\n}\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from \"@latticexyz/common/codegen\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { renderSystemInterface } from \"./renderSystemInterface\";\nimport { renderWorld } from \"./renderWorld\";\nimport { resolveWorldConfig, WorldConfig } from \"../config\";\n\nexport async function worldgen(\n config: StoreConfig & WorldConfig,\n existingContracts: { path: string; basename: string }[],\n outputBaseDirectory: string\n) {\n const resolvedConfig = resolveWorldConfig(\n config,\n existingContracts.map(({ basename }) => basename)\n );\n\n const worldgenBaseDirectory = path.join(outputBaseDirectory, config.worldgenDirectory);\n const systems = existingContracts.filter(({ basename }) => Object.keys(resolvedConfig.systems).includes(basename));\n\n const systemInterfaceImports: RelativeImportDatum[] = [];\n for (const system of systems) {\n const data = readFileSync(system.path, \"utf8\");\n // get external funcions from a contract\n const { functions, errors, symbolImports } = contractToInterface(data, system.basename);\n const imports = symbolImports.map((symbolImport) => {\n if (symbolImport.path[0] === \".\") {\n // relative import\n return {\n symbol: symbolImport.symbol,\n fromPath: path.join(path.dirname(system.path), symbolImport.path),\n usedInPath: worldgenBaseDirectory,\n };\n } else {\n // absolute import\n return {\n symbol: symbolImport.symbol,\n path: symbolImport.path,\n };\n }\n });\n const systemInterfaceName = `I${system.basename}`;\n // create an interface using the external functions and imports\n const { name } = resolvedConfig.systems[system.basename];\n const output = renderSystemInterface({\n name: systemInterfaceName,\n functionPrefix: config.namespace === \"\" ? \"\" : `${config.namespace}_${name}_`,\n functions,\n errors,\n imports,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, systemInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n\n // prepare imports for IWorld\n systemInterfaceImports.push({\n symbol: systemInterfaceName,\n fromPath: `${systemInterfaceName}.sol`,\n usedInPath: \"./\",\n });\n }\n\n // render IWorld\n const output = renderWorld({\n interfaceName: config.worldInterfaceName,\n imports: systemInterfaceImports,\n storeImportPath: config.storeImportPath,\n worldImportPath: config.worldImportPath,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, config.worldInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n}\n"],"mappings":"AAAO,IAAMA,EAAkB,CAC7B,yBAA0B,GAC1B,WAAY,GACZ,WAAY,CAAC,CACf,EAEaC,EAAiB,CAC5B,kBAAmB,OACnB,mBAAoB,SACpB,gBAAiB,CAAC,EAClB,eAAgB,CAAC,EACjB,iBAAkB,aAClB,iBAAkB,YAClB,kBAAmB,QACnB,gBAAiB,yBACjB,QAAS,CAAC,CACZ,EChBA,OAAS,iBAAAC,EAAe,YAAAC,EAAU,6BAAAC,EAA2B,kCAAAC,MAAsC,qBAa5F,SAASC,EAAmBC,EAAmCC,EAA8B,CAElG,IAAMC,EACJD,GAAmB,OAAQE,GAASA,EAAK,SAAS,QAAQ,GAAKA,IAAS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CAAE,UAAAG,EAAW,OAAAC,EAAQ,cAAAC,CAAc,EAAIC,GAAoBL,EAAMD,EAAO,QAAQ,EAChFO,EAAUF,EAAc,IAAKG,GAC7BA,EAAa,KAAK,CAAC,IAAM,IAEpB,CACL,OAAQA,EAAa,OACrB,SAAUX,EAAK,KAAKA,EAAK,QAAQG,EAAO,IAAI,EAAGQ,EAAa,IAAI,EAChE,WAAYZ,CACd,EAGO,CACL,OAAQY,EAAa,OACrB,KAAMA,EAAa,IACrB,CAEH,EACKC,EAAsB,IAAIT,EAAO,WAEjC,CAAE,KAAAU,CAAK,EAAIjB,EAAe,QAAQO,EAAO,QAAQ,EACjDW,EAASC,EAAsB,CACnC,KAAMH,EACN,eAAgBnB,EAAO,YAAc,GAAK,GAAK,GAAGA,EAAO,aAAaoB,KACtE,UAAAP,EACA,OAAAC,EACA,QAAAG,CACF,CAAC,EAEKM,EAAiBhB,EAAK,KAAKD,EAAuBa,EAAsB,MAAM,EACpF,MAAMK,EAAuBH,EAAQE,EAAgB,4BAA4B,EAGjFd,EAAuB,KAAK,CAC1B,OAAQU,EACR,SAAU,GAAGA,QACb,WAAY,IACd,CAAC,EAIH,IAAME,EAASI,EAAY,CACzB,cAAezB,EAAO,mBACtB,QAASS,EACT,gBAAiBT,EAAO,gBACxB,gBAAiBA,EAAO,eAC1B,CAAC,EAEKuB,EAAiBhB,EAAK,KAAKD,EAAuBN,EAAO,mBAAqB,MAAM,EAC1F,MAAMwB,EAAuBH,EAAQE,EAAgB,4BAA4B,CACnF","names":["SYSTEM_DEFAULTS","WORLD_DEFAULTS","getDuplicates","MUDError","STORE_SELECTOR_MAX_LENGTH","UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","resolvedSystems","acc","resolveSystemConfig","tableNames","configuredSystemNames","duplicateNames","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem","z","DynamicResolutionType","zEthereumAddress","zObjectName","zSelector","zSystemName","zObjectName","zModuleName","zSystemAccessList","z","zEthereumAddress","SYSTEM_DEFAULTS","zSystemConfig","zSelector","zValueWithType","zDynamicResolution","DynamicResolutionType","zModuleConfig","zWorldConfig","WORLD_DEFAULTS","zPluginWorldConfig","renderArguments","renderList","renderedSolidityHeader","renderImports","renderSystemInterface","options","imports","name","functionPrefix","functions","errors","parameters","stateMutability","returnParameters","renderReturnParameters","renderArguments","renderedSolidityHeader","renderAbsoluteImports","renderRelativeImports","renderWorld","options","interfaceName","storeImportPath","worldImportPath","imports","baseImports","importSymbols","symbol","readFileSync","path","formatAndWriteSolidity","contractToInterface","worldgen","config","existingContracts","outputBaseDirectory","resolvedConfig","resolveWorldConfig","basename","worldgenBaseDirectory","path","systems","systemInterfaceImports","system","data","readFileSync","functions","errors","symbolImports","contractToInterface","imports","symbolImport","systemInterfaceName","name","output","renderSystemInterface","fullOutputPath","formatAndWriteSolidity","renderWorld"]}
@@ -1,2 +1,2 @@
1
- import{a as e}from"./chunk-OSMORYKU.js";import"./chunk-QFDRX7VZ.js";var r=e({worldImportPath:"../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld",codegenDirectory:"",tables:{NamespaceOwner:{primaryKeys:{namespace:"bytes16"},schema:{owner:"address"}},ResourceAccess:{primaryKeys:{resourceSelector:"bytes32",caller:"address"},schema:{access:"bool"}},InstalledModules:{primaryKeys:{moduleName:"bytes16",argumentsHash:"bytes32"},schema:{moduleAddress:"address"},dataStruct:!0},Systems:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{system:"address",publicAccess:"bool"},dataStruct:!1},SystemRegistry:{directory:"modules/core/tables",primaryKeys:{system:"address"},schema:{resourceSelector:"bytes32"}},ResourceType:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{resourceType:"Resource"}},FunctionSelectors:{directory:"modules/core/tables",primaryKeys:{functionSelector:"bytes4"},schema:{namespace:"bytes16",name:"bytes16",systemFunctionSelector:"bytes4"},dataStruct:!1},KeysWithValue:{directory:"modules/keyswithvalue/tables",primaryKeys:{valueHash:"bytes32"},schema:{keysWithValue:"bytes32[]"},tableIdArgument:!0},KeysInTable:{directory:"modules/keysintable/tables",primaryKeys:{sourceTable:"bytes32"},schema:{length:"uint32",keys:"bytes32[]"}},UsedKeysIndex:{directory:"modules/keysintable/tables",primaryKeys:{sourceTable:"bytes32",keysHash:"bytes32"},schema:{has:"bool",index:"uint32"},dataStruct:!1},UniqueEntity:{directory:"modules/uniqueentity/tables",primaryKeys:{},schema:"uint256",tableIdArgument:!0,storeArgument:!0},Bool:{directory:"../test/tables",primaryKeys:{},schema:{value:"bool"},tableIdArgument:!0},AddressArray:{directory:"../test/tables",schema:"address[]",tableIdArgument:!0}},enums:{Resource:["NONE","NAMESPACE","TABLE","SYSTEM"]},excludeSystems:["UniqueEntitySystem","StoreRegistrationSystem"]});export{r as default};
1
+ import{a as e}from"./chunk-KXMVYZUU.js";import"./chunk-XSZNAEUO.js";var r=e({worldImportPath:"../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld",codegenDirectory:"",tables:{NamespaceOwner:{primaryKeys:{namespace:"bytes16"},schema:{owner:"address"}},ResourceAccess:{primaryKeys:{resourceSelector:"bytes32",caller:"address"},schema:{access:"bool"}},InstalledModules:{primaryKeys:{moduleName:"bytes16",argumentsHash:"bytes32"},schema:{moduleAddress:"address"},dataStruct:!0},Systems:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{system:"address",publicAccess:"bool"},dataStruct:!1},SystemRegistry:{directory:"modules/core/tables",primaryKeys:{system:"address"},schema:{resourceSelector:"bytes32"}},ResourceType:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{resourceType:"Resource"}},FunctionSelectors:{directory:"modules/core/tables",primaryKeys:{functionSelector:"bytes4"},schema:{namespace:"bytes16",name:"bytes16",systemFunctionSelector:"bytes4"},dataStruct:!1},KeysWithValue:{directory:"modules/keyswithvalue/tables",primaryKeys:{valueHash:"bytes32"},schema:{keysWithValue:"bytes32[]"},tableIdArgument:!0},KeysInTable:{directory:"modules/keysintable/tables",primaryKeys:{sourceTable:"bytes32"},schema:{length:"uint32",keys:"bytes32[]"}},UsedKeysIndex:{directory:"modules/keysintable/tables",primaryKeys:{sourceTable:"bytes32",keysHash:"bytes32"},schema:{has:"bool",index:"uint32"},dataStruct:!1},UniqueEntity:{directory:"modules/uniqueentity/tables",primaryKeys:{},schema:"uint256",tableIdArgument:!0,storeArgument:!0},Bool:{directory:"../test/tables",primaryKeys:{},schema:{value:"bool"},tableIdArgument:!0},AddressArray:{directory:"../test/tables",schema:"address[]",tableIdArgument:!0}},enums:{Resource:["NONE","NAMESPACE","TABLE","SYSTEM"]},excludeSystems:["UniqueEntitySystem","StoreRegistrationSystem"]});export{r as default};
2
2
  //# sourceMappingURL=mud.config.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"../../chunk-QFDRX7VZ.js";export{e as renderSystemInterface,f as renderWorld,b as resolveSystemConfig,a as resolveWorldConfig,g as worldgen,d as zPluginWorldConfig,c as zWorldConfig};
1
+ import{a,b,c,d,e,f,g,h,i}from"../../chunk-XSZNAEUO.js";export{a as SYSTEM_DEFAULTS,b as WORLD_DEFAULTS,g as renderSystemInterface,h as renderWorld,d as resolveSystemConfig,c as resolveWorldConfig,i as worldgen,f as zPluginWorldConfig,e as zWorldConfig};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c}from"../../chunk-OSMORYKU.js";import"../../chunk-QFDRX7VZ.js";export{a as mudConfig,b as mudCoreConfig,c as resolveTableId};
1
+ import{a,b,c}from"../../chunk-KXMVYZUU.js";import"../../chunk-XSZNAEUO.js";export{a as mudConfig,b as mudCoreConfig,c as resolveTableId};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/world",
3
- "version": "2.0.0-alpha.1.62+37cbf72c",
3
+ "version": "2.0.0-alpha.1.63+158de9e8",
4
4
  "description": "World framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,10 +46,10 @@
46
46
  "dependencies": {
47
47
  "@ethersproject/abi": "^5.7.0",
48
48
  "@ethersproject/providers": "^5.7.2",
49
- "@latticexyz/common": "2.0.0-alpha.1.62+37cbf72c",
50
- "@latticexyz/config": "2.0.0-alpha.1.62+37cbf72c",
51
- "@latticexyz/schema-type": "2.0.0-alpha.1.62+37cbf72c",
52
- "@latticexyz/store": "2.0.0-alpha.1.62+37cbf72c",
49
+ "@latticexyz/common": "2.0.0-alpha.1.63+158de9e8",
50
+ "@latticexyz/config": "2.0.0-alpha.1.63+158de9e8",
51
+ "@latticexyz/schema-type": "2.0.0-alpha.1.63+158de9e8",
52
+ "@latticexyz/store": "2.0.0-alpha.1.63+158de9e8",
53
53
  "ethers": "^5.7.2",
54
54
  "zod": "^3.21.4"
55
55
  },
@@ -74,5 +74,5 @@
74
74
  "typescript": "^4.9.5",
75
75
  "vitest": "0.30.1"
76
76
  },
77
- "gitHead": "37cbf72c4025a26774120fdbe03286a2af5a7ca4"
77
+ "gitHead": "158de9e83ff4212e34c79b166d8336377972922f"
78
78
  }
@@ -0,0 +1,17 @@
1
+ export const SYSTEM_DEFAULTS = {
2
+ registerFunctionSelector: true,
3
+ openAccess: true,
4
+ accessList: [] as string[],
5
+ } as const;
6
+
7
+ export const WORLD_DEFAULTS = {
8
+ worldContractName: undefined,
9
+ worldInterfaceName: "IWorld",
10
+ overrideSystems: {} as Record<string, never>,
11
+ excludeSystems: [] as string[],
12
+ postDeployScript: "PostDeploy",
13
+ deploysDirectory: "./deploys",
14
+ worldgenDirectory: "world",
15
+ worldImportPath: "@latticexyz/world/src/",
16
+ modules: [] as [],
17
+ } as const;
@@ -1,3 +1,4 @@
1
+ export * from "./defaults";
1
2
  export * from "./resolveWorldConfig";
2
3
  export * from "./types";
3
4
  export * from "./worldConfig";
@@ -1,6 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { DynamicResolution, ValueWithType } from "@latticexyz/config";
3
+ import { OrDefaults } from "@latticexyz/common/type-utils";
3
4
  import { zWorldConfig } from "./worldConfig";
5
+ import { SYSTEM_DEFAULTS } from "./defaults";
4
6
 
5
7
  // zod doesn't preserve doc comments
6
8
  export type SystemUserConfig =
@@ -18,7 +20,7 @@ export type SystemUserConfig =
18
20
  } & (
19
21
  | {
20
22
  /** If openAccess is true, any address can call the system */
21
- openAccess: true;
23
+ openAccess?: true;
22
24
  }
23
25
  | {
24
26
  /** If openAccess is false, only the addresses or systems in `access` can call the system */
@@ -28,6 +30,24 @@ export type SystemUserConfig =
28
30
  }
29
31
  );
30
32
 
33
+ export interface ExpandSystemConfig<T extends SystemUserConfig, SystemName extends string>
34
+ extends OrDefaults<
35
+ T,
36
+ {
37
+ name: SystemName;
38
+ registerFunctionSelectors: typeof SYSTEM_DEFAULTS.registerFunctionSelector;
39
+ openAccess: typeof SYSTEM_DEFAULTS.openAccess;
40
+ }
41
+ > {
42
+ accessList: T extends { accessList: string[] } ? T["accessList"] : typeof SYSTEM_DEFAULTS.accessList;
43
+ }
44
+
45
+ export type SystemsUserConfig = Record<string, SystemUserConfig>;
46
+
47
+ export type ExpandSystemsConfig<T extends SystemsUserConfig> = {
48
+ [SystemName in keyof T]: ExpandSystemConfig<T[SystemName], SystemName extends string ? SystemName : never>;
49
+ };
50
+
31
51
  export type ModuleConfig = {
32
52
  /** The name of the module */
33
53
  name: string;
@@ -39,8 +59,6 @@ export type ModuleConfig = {
39
59
 
40
60
  // zod doesn't preserve doc comments
41
61
  export interface WorldUserConfig {
42
- /** The namespace to register tables and systems at. Defaults to the root namespace (empty string) */
43
- namespace?: string;
44
62
  /** The name of the World contract to deploy. If no name is provided, a vanilla World is deployed */
45
63
  worldContractName?: string;
46
64
  /** The name of the World interface to generate. (Default `IWorld`) */
@@ -52,7 +70,7 @@ export interface WorldUserConfig {
52
70
  * The key is the system name (capitalized).
53
71
  * The value is a SystemConfig object.
54
72
  */
55
- overrideSystems?: Record<string, SystemUserConfig>;
73
+ overrideSystems?: SystemsUserConfig;
56
74
  /** Systems to exclude from automatic deployment */
57
75
  excludeSystems?: string[];
58
76
  /**
@@ -1,19 +1,20 @@
1
1
  import { z } from "zod";
2
2
  import { DynamicResolutionType, zEthereumAddress, zObjectName, zSelector } from "@latticexyz/config";
3
+ import { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from "./defaults";
3
4
 
4
5
  const zSystemName = zObjectName;
5
6
  const zModuleName = zObjectName;
6
- const zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).default([]);
7
+ const zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).default(SYSTEM_DEFAULTS.accessList);
7
8
 
8
9
  // The system config is a combination of a name config and access config
9
10
  const zSystemConfig = z.intersection(
10
11
  z.object({
11
12
  name: zSelector,
12
- registerFunctionSelectors: z.boolean().default(true),
13
+ registerFunctionSelectors: z.boolean().default(SYSTEM_DEFAULTS.registerFunctionSelector),
13
14
  }),
14
15
  z.discriminatedUnion("openAccess", [
15
16
  z.object({
16
- openAccess: z.literal(true),
17
+ openAccess: z.literal(true).default(SYSTEM_DEFAULTS.openAccess),
17
18
  }),
18
19
  z.object({
19
20
  openAccess: z.literal(false),
@@ -36,16 +37,15 @@ const zModuleConfig = z.object({
36
37
 
37
38
  // The parsed world config is the result of parsing the user config
38
39
  export const zWorldConfig = z.object({
39
- namespace: zSelector.default(""),
40
40
  worldContractName: z.string().optional(),
41
- worldInterfaceName: z.string().default("IWorld"),
42
- overrideSystems: z.record(zSystemName, zSystemConfig).default({}),
43
- excludeSystems: z.array(zSystemName).default([]),
44
- postDeployScript: z.string().default("PostDeploy"),
45
- deploysDirectory: z.string().default("./deploys"),
46
- worldgenDirectory: z.string().default("world"),
47
- worldImportPath: z.string().default("@latticexyz/world/src/"),
48
- modules: z.array(zModuleConfig).default([]),
41
+ worldInterfaceName: z.string().default(WORLD_DEFAULTS.worldInterfaceName),
42
+ overrideSystems: z.record(zSystemName, zSystemConfig).default(WORLD_DEFAULTS.overrideSystems),
43
+ excludeSystems: z.array(zSystemName).default(WORLD_DEFAULTS.excludeSystems),
44
+ postDeployScript: z.string().default(WORLD_DEFAULTS.postDeployScript),
45
+ deploysDirectory: z.string().default(WORLD_DEFAULTS.deploysDirectory),
46
+ worldgenDirectory: z.string().default(WORLD_DEFAULTS.worldgenDirectory),
47
+ worldImportPath: z.string().default(WORLD_DEFAULTS.worldImportPath),
48
+ modules: z.array(zModuleConfig).default(WORLD_DEFAULTS.modules),
49
49
  });
50
50
 
51
51
  // Catchall preserves other plugins' options
@@ -1,4 +1,8 @@
1
- import { WorldConfig, WorldUserConfig } from "../library";
1
+ import { OrDefaults } from "@latticexyz/common/type-utils";
2
+ import { MUDCoreUserConfig } from "@latticexyz/config";
3
+ import { ExpandSystemsConfig, WorldConfig, WorldUserConfig, WORLD_DEFAULTS } from "../library";
4
+
5
+ import "@latticexyz/store/register";
2
6
 
3
7
  // Inject the plugin options into the core config.
4
8
  // Re-exporting an interface of an existing module merges them, adding new options to the interface.
@@ -15,3 +19,24 @@ declare module "@latticexyz/config" {
15
19
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
16
20
  export interface MUDCoreConfig extends WorldConfig {}
17
21
  }
22
+
23
+ declare module "@latticexyz/store/register" {
24
+ export interface ExpandMUDUserConfig<T extends MUDCoreUserConfig>
25
+ extends OrDefaults<
26
+ T,
27
+ {
28
+ worldContractName: typeof WORLD_DEFAULTS.worldContractName;
29
+ worldInterfaceName: typeof WORLD_DEFAULTS.worldInterfaceName;
30
+ excludeSystems: typeof WORLD_DEFAULTS.excludeSystems;
31
+ postDeployScript: typeof WORLD_DEFAULTS.postDeployScript;
32
+ deploysDirectory: typeof WORLD_DEFAULTS.deploysDirectory;
33
+ worldgenDirectory: typeof WORLD_DEFAULTS.worldgenDirectory;
34
+ worldImportPath: typeof WORLD_DEFAULTS.worldImportPath;
35
+ modules: typeof WORLD_DEFAULTS.modules;
36
+ }
37
+ > {
38
+ overrideSystems: ExpandSystemsConfig<
39
+ T["overrideSystems"] extends Record<string, unknown> ? T["overrideSystems"] : Record<string, never>
40
+ >;
41
+ }
42
+ }
@@ -1,2 +0,0 @@
1
- import{d as o}from"./chunk-QFDRX7VZ.js";import"@latticexyz/store/register";import{mudConfig as g,mudCoreConfig as s,resolveTableId as u}from"@latticexyz/store/register";import{extendMUDCoreConfig as t,fromZodErrorCustom as e}from"@latticexyz/config";import{ZodError as m}from"zod";t(i=>{try{return o.parse(i)}catch(r){throw r instanceof m?e(r,"WorldConfig Validation Error"):r}});export{g as a,s as b,u as c};
2
- //# sourceMappingURL=chunk-OSMORYKU.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/register/index.ts","../ts/register/configExtensions.ts"],"sourcesContent":["// Importing this file has side-effects for MUD config,\n// and the order of imports is important in relation to other plugins\n// (store should usually be the first plugin, followed by world)\n\n// For convenience register and reexport store (which does the same for core config),\n// to reduce the number of needed imports for users\nimport \"@latticexyz/store/register\";\nexport { mudConfig, mudCoreConfig, resolveTableId } from \"@latticexyz/store/register\";\n// Extend core config and types\nimport \"./configExtensions\";\nimport \"./typeExtensions\";\n","import { extendMUDCoreConfig, fromZodErrorCustom } from \"@latticexyz/config\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../library\";\n\nextendMUDCoreConfig((config) => {\n // This function gets called within mudConfig.\n // The call order of config extenders depends on the order of their imports.\n // Any config validation and transformation should be placed here.\n try {\n return zPluginWorldConfig.parse(config);\n } catch (error) {\n if (error instanceof ZodError) {\n throw fromZodErrorCustom(error, \"WorldConfig Validation Error\");\n } else {\n throw error;\n }\n }\n});\n"],"mappings":"wCAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,EAAe,kBAAAC,MAAsB,6BCPzD,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,qBACxD,OAAS,YAAAC,MAAgB,MAGzBC,EAAqBC,GAAW,CAI9B,GAAI,CACF,OAAOC,EAAmB,MAAMD,CAAM,CACxC,OAASE,EAAP,CACA,MAAIA,aAAiBC,EACbC,EAAmBF,EAAO,8BAA8B,EAExDA,CAEV,CACF,CAAC","names":["mudConfig","mudCoreConfig","resolveTableId","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}
@@ -1,30 +0,0 @@
1
- import{getDuplicates as z,MUDError as D,STORE_SELECTOR_MAX_LENGTH as O,UnrecognizedSystemErrorFactory as h}from"@latticexyz/config";function g(r,o){let l=o?.filter(e=>e.endsWith("System")&&e!=="System"&&!e.match(/^I[A-Z]/))??[],n=Object.keys(r.overrideSystems);if(o){for(let e of n)if(!o.includes(e)||e==="World")throw h(["overrideSystems",e],e)}let i=[...new Set([...l,...n])].filter(e=>!r.excludeSystems.includes(e)).reduce((e,d)=>({...e,[d]:L(d,r.overrideSystems[d],o)}),{}),s=Object.values(r.tables).map(({name:e})=>e),a=Object.values(i).map(({name:e})=>e),c=z([...s,...a]);if(c.length>0)throw new D(`Table and system names must be unique: ${c.join(", ")}`);return{systems:i}}function L(r,o,l){let n=o?.name??r.slice(0,O),m=o?.registerFunctionSelectors??!0,i=o?.openAccess??!0,s=[],a=[],c=o&&!o.openAccess?o.accessList:[];for(let e of c)if(e.startsWith("0x"))s.push(e);else{if(l&&!l.includes(e))throw h(["overrideSystems",r,"accessList"],e);a.push(e)}return{name:n,registerFunctionSelectors:m,openAccess:i,accessListAddresses:s,accessListSystems:a}}import{z as t}from"zod";import{DynamicResolutionType as T,zEthereumAddress as E,zObjectName as I,zSelector as b}from"@latticexyz/config";var y=I,F=I,_=t.array(y.or(E)).default([]),B=t.intersection(t.object({name:b,registerFunctionSelectors:t.boolean().default(!0)}),t.discriminatedUnion("openAccess",[t.object({openAccess:t.literal(!0)}),t.object({openAccess:t.literal(!1),accessList:_})])),M=t.object({value:t.union([t.string(),t.number(),t.instanceof(Uint8Array)]),type:t.string()}),U=t.object({type:t.nativeEnum(T),input:t.string()}),G=t.object({name:F,root:t.boolean().default(!1),args:t.array(t.union([M,U])).default([])}),H=t.object({namespace:b.default(""),worldContractName:t.string().optional(),worldInterfaceName:t.string().default("IWorld"),overrideSystems:t.record(y,B).default({}),excludeSystems:t.array(y).default([]),postDeployScript:t.string().default("PostDeploy"),deploysDirectory:t.string().default("./deploys"),worldgenDirectory:t.string().default("world"),worldImportPath:t.string().default("@latticexyz/world/src/"),modules:t.array(G).default([])}),se=H.catchall(t.any());import{renderArguments as S,renderList as $,renderedSolidityHeader as k,renderImports as K}from"@latticexyz/common/codegen";function W(r){let{imports:o,name:l,functionPrefix:n,functions:m,errors:i}=r;return`${k}
2
-
3
- ${K(o)}
4
-
5
- interface ${l} {
6
- ${$(i,({name:s,parameters:a})=>`error ${s}(${S(a)});`)}
7
-
8
- ${$(m,({name:s,parameters:a,stateMutability:c,returnParameters:e})=>`
9
- function ${n}${s}(
10
- ${S(a)}
11
- ) external ${c} ${q(e)};
12
- `)}
13
- }
14
-
15
- `}function q(r){return r.length>0?`returns (${S(r)})`:""}import{renderArguments as V,renderedSolidityHeader as X,renderAbsoluteImports as Z,renderRelativeImports as J}from"@latticexyz/common/codegen";function v(r){let{interfaceName:o,storeImportPath:l,worldImportPath:n,imports:m}=r,i=o==="IBaseWorld"?[{symbol:"IStore",path:`${l}IStore.sol`},{symbol:"IWorldKernel",path:`${n}interfaces/IWorldKernel.sol`}]:[{symbol:"IBaseWorld",path:`${n}interfaces/IBaseWorld.sol`}],s=[...i,...m].map(({symbol:a})=>a);return`${X}
16
-
17
- ${Z(i)}
18
-
19
- ${J(m)}
20
-
21
- /**
22
- * The ${o} interface includes all systems dynamically added to the World
23
- * during the deploy process.
24
- */
25
- interface ${o} is ${V(s)} {
26
-
27
- }
28
-
29
- `}import{readFileSync as Q}from"fs";import f from"path";import{formatAndWriteSolidity as w,contractToInterface as Y}from"@latticexyz/common/codegen";async function $e(r,o,l){let n=g(r,o.map(({basename:e})=>e)),m=f.join(l,r.worldgenDirectory),i=o.filter(({basename:e})=>Object.keys(n.systems).includes(e)),s=[];for(let e of i){let d=Q(e.path,"utf8"),{functions:x,errors:C,symbolImports:A}=Y(d,e.basename),R=A.map(p=>p.path[0]==="."?{symbol:p.symbol,fromPath:f.join(f.dirname(e.path),p.path),usedInPath:m}:{symbol:p.symbol,path:p.path}),u=`I${e.basename}`,{name:j}=n.systems[e.basename],P=W({name:u,functionPrefix:r.namespace===""?"":`${r.namespace}_${j}_`,functions:x,errors:C,imports:R}),N=f.join(m,u+".sol");await w(P,N,"Generated system interface"),s.push({symbol:u,fromPath:`${u}.sol`,usedInPath:"./"})}let a=v({interfaceName:r.worldInterfaceName,imports:s,storeImportPath:r.storeImportPath,worldImportPath:r.worldImportPath}),c=f.join(m,r.worldInterfaceName+".sol");await w(a,c,"Generated system interface")}export{g as a,L as b,H as c,se as d,W as e,v as f,$e as g};
30
- //# sourceMappingURL=chunk-QFDRX7VZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/library/config/resolveWorldConfig.ts","../ts/library/config/worldConfig.ts","../ts/library/render-solidity/renderSystemInterface.ts","../ts/library/render-solidity/renderWorld.ts","../ts/library/render-solidity/worldgen.ts"],"sourcesContent":["import { getDuplicates, MUDError, STORE_SELECTOR_MAX_LENGTH, UnrecognizedSystemErrorFactory } from \"@latticexyz/config\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { SystemConfig, WorldConfig } from \"./types\";\n\nexport type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;\n\nexport type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;\n\n/**\n * Resolves the world config by combining the default and overridden system configs,\n * filtering out excluded systems, validate system names refer to existing contracts, and\n * splitting the access list into addresses and system names.\n */\nexport function resolveWorldConfig(config: StoreConfig & WorldConfig, existingContracts?: string[]) {\n // Include contract names ending in \"System\", but not the base \"System\" contract, and not Interfaces\n const defaultSystemNames =\n existingContracts?.filter((name) => name.endsWith(\"System\") && name !== \"System\" && !name.match(/^I[A-Z]/)) ?? [];\n const overriddenSystemNames = Object.keys(config.overrideSystems);\n\n // Validate every key in overrideSystems refers to an existing system contract (and is not called \"World\")\n if (existingContracts) {\n for (const systemName of overriddenSystemNames) {\n if (!existingContracts.includes(systemName) || systemName === \"World\") {\n throw UnrecognizedSystemErrorFactory([\"overrideSystems\", systemName], systemName);\n }\n }\n }\n\n // Combine the default and overridden system names and filter out excluded systems\n const systemNames = [...new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(\n (name) => !config.excludeSystems.includes(name)\n );\n\n // Resolve the config\n const resolvedSystems: Record<string, ResolvedSystemConfig> = systemNames.reduce((acc, systemName) => {\n return {\n ...acc,\n [systemName]: resolveSystemConfig(systemName, config.overrideSystems[systemName], existingContracts),\n };\n }, {});\n\n // Table and system names must be unique (because they're both used for world selectors)\n const tableNames = Object.values(config.tables).map(({ name }) => name);\n const configuredSystemNames = Object.values(resolvedSystems).map(({ name }) => name);\n const duplicateNames = getDuplicates([...tableNames, ...configuredSystemNames]);\n if (duplicateNames.length > 0) {\n throw new MUDError(`Table and system names must be unique: ${duplicateNames.join(\", \")}`);\n }\n\n return { systems: resolvedSystems };\n}\n\n/**\n * Resolves the system config by combining the default and overridden system configs,\n * @param systemName name of the system\n * @param config optional SystemConfig object, if none is provided the default config is used\n * @param existingContracts optional list of existing contract names, used to validate system names in the access list. If not provided, no validation is performed.\n * @returns ResolvedSystemConfig object\n * Default value for name is `systemName`\n * Default value for registerFunctionSelectors is true\n * Default value for openAccess is true\n * Default value for accessListAddresses is []\n * Default value for accessListSystems is []\n */\nexport function resolveSystemConfig(systemName: string, config?: SystemConfig, existingContracts?: string[]) {\n const name = config?.name ?? systemName.slice(0, STORE_SELECTOR_MAX_LENGTH);\n const registerFunctionSelectors = config?.registerFunctionSelectors ?? true;\n const openAccess = config?.openAccess ?? true;\n const accessListAddresses: string[] = [];\n const accessListSystems: string[] = [];\n const accessList = config && !config.openAccess ? config.accessList : [];\n\n // Split the access list into addresses and system names\n for (const accessListItem of accessList) {\n if (accessListItem.startsWith(\"0x\")) {\n accessListAddresses.push(accessListItem);\n } else {\n // Validate every system refers to an existing system contract\n if (existingContracts && !existingContracts.includes(accessListItem)) {\n throw UnrecognizedSystemErrorFactory([\"overrideSystems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n","import { z } from \"zod\";\nimport { DynamicResolutionType, zEthereumAddress, zObjectName, zSelector } from \"@latticexyz/config\";\n\nconst zSystemName = zObjectName;\nconst zModuleName = zObjectName;\nconst zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).default([]);\n\n// The system config is a combination of a name config and access config\nconst zSystemConfig = z.intersection(\n z.object({\n name: zSelector,\n registerFunctionSelectors: z.boolean().default(true),\n }),\n z.discriminatedUnion(\"openAccess\", [\n z.object({\n openAccess: z.literal(true),\n }),\n z.object({\n openAccess: z.literal(false),\n accessList: zSystemAccessList,\n }),\n ])\n);\n\nconst zValueWithType = z.object({\n value: z.union([z.string(), z.number(), z.instanceof(Uint8Array)]),\n type: z.string(),\n});\nconst zDynamicResolution = z.object({ type: z.nativeEnum(DynamicResolutionType), input: z.string() });\n\nconst zModuleConfig = z.object({\n name: zModuleName,\n root: z.boolean().default(false),\n args: z.array(z.union([zValueWithType, zDynamicResolution])).default([]),\n});\n\n// The parsed world config is the result of parsing the user config\nexport const zWorldConfig = z.object({\n namespace: zSelector.default(\"\"),\n worldContractName: z.string().optional(),\n worldInterfaceName: z.string().default(\"IWorld\"),\n overrideSystems: z.record(zSystemName, zSystemConfig).default({}),\n excludeSystems: z.array(zSystemName).default([]),\n postDeployScript: z.string().default(\"PostDeploy\"),\n deploysDirectory: z.string().default(\"./deploys\"),\n worldgenDirectory: z.string().default(\"world\"),\n worldImportPath: z.string().default(\"@latticexyz/world/src/\"),\n modules: z.array(zModuleConfig).default([]),\n});\n\n// Catchall preserves other plugins' options\nexport const zPluginWorldConfig = zWorldConfig.catchall(z.any());\n","import { renderArguments, renderList, renderedSolidityHeader, renderImports } from \"@latticexyz/common/codegen\";\nimport { RenderSystemInterfaceOptions } from \"./types\";\n\nexport function renderSystemInterface(options: RenderSystemInterfaceOptions) {\n const { imports, name, functionPrefix, functions, errors } = options;\n\n return `${renderedSolidityHeader}\n\n${renderImports(imports)}\n\ninterface ${name} {\n ${renderList(errors, ({ name, parameters }) => `error ${name}(${renderArguments(parameters)});`)}\n\n ${renderList(\n functions,\n ({ name, parameters, stateMutability, returnParameters }) => `\n function ${functionPrefix}${name}(\n ${renderArguments(parameters)}\n ) external ${stateMutability} ${renderReturnParameters(returnParameters)};\n `\n )}\n}\n\n`;\n}\n\nfunction renderReturnParameters(returnParameters: string[]) {\n if (returnParameters.length > 0) {\n return `returns (${renderArguments(returnParameters)})`;\n } else {\n return \"\";\n }\n}\n","import {\n renderArguments,\n renderedSolidityHeader,\n renderAbsoluteImports,\n renderRelativeImports,\n type AbsoluteImportDatum,\n} from \"@latticexyz/common/codegen\";\nimport type { RenderWorldOptions } from \"./types\";\n\nexport function renderWorld(options: RenderWorldOptions) {\n const { interfaceName, storeImportPath, worldImportPath, imports } = options;\n const baseImports: AbsoluteImportDatum[] =\n interfaceName === \"IBaseWorld\"\n ? [\n { symbol: \"IStore\", path: `${storeImportPath}IStore.sol` },\n { symbol: \"IWorldKernel\", path: `${worldImportPath}interfaces/IWorldKernel.sol` },\n ]\n : [\n {\n symbol: \"IBaseWorld\",\n path: `${worldImportPath}interfaces/IBaseWorld.sol`,\n },\n ];\n const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol);\n\n return `${renderedSolidityHeader}\n\n${renderAbsoluteImports(baseImports)}\n\n${renderRelativeImports(imports)}\n\n/**\n * The ${interfaceName} interface includes all systems dynamically added to the World\n * during the deploy process.\n */\ninterface ${interfaceName} is ${renderArguments(importSymbols)} {\n\n}\n\n`;\n}\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from \"@latticexyz/common/codegen\";\nimport { StoreConfig } from \"@latticexyz/store\";\nimport { renderSystemInterface } from \"./renderSystemInterface\";\nimport { renderWorld } from \"./renderWorld\";\nimport { resolveWorldConfig, WorldConfig } from \"../config\";\n\nexport async function worldgen(\n config: StoreConfig & WorldConfig,\n existingContracts: { path: string; basename: string }[],\n outputBaseDirectory: string\n) {\n const resolvedConfig = resolveWorldConfig(\n config,\n existingContracts.map(({ basename }) => basename)\n );\n\n const worldgenBaseDirectory = path.join(outputBaseDirectory, config.worldgenDirectory);\n const systems = existingContracts.filter(({ basename }) => Object.keys(resolvedConfig.systems).includes(basename));\n\n const systemInterfaceImports: RelativeImportDatum[] = [];\n for (const system of systems) {\n const data = readFileSync(system.path, \"utf8\");\n // get external funcions from a contract\n const { functions, errors, symbolImports } = contractToInterface(data, system.basename);\n const imports = symbolImports.map((symbolImport) => {\n if (symbolImport.path[0] === \".\") {\n // relative import\n return {\n symbol: symbolImport.symbol,\n fromPath: path.join(path.dirname(system.path), symbolImport.path),\n usedInPath: worldgenBaseDirectory,\n };\n } else {\n // absolute import\n return {\n symbol: symbolImport.symbol,\n path: symbolImport.path,\n };\n }\n });\n const systemInterfaceName = `I${system.basename}`;\n // create an interface using the external functions and imports\n const { name } = resolvedConfig.systems[system.basename];\n const output = renderSystemInterface({\n name: systemInterfaceName,\n functionPrefix: config.namespace === \"\" ? \"\" : `${config.namespace}_${name}_`,\n functions,\n errors,\n imports,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, systemInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n\n // prepare imports for IWorld\n systemInterfaceImports.push({\n symbol: systemInterfaceName,\n fromPath: `${systemInterfaceName}.sol`,\n usedInPath: \"./\",\n });\n }\n\n // render IWorld\n const output = renderWorld({\n interfaceName: config.worldInterfaceName,\n imports: systemInterfaceImports,\n storeImportPath: config.storeImportPath,\n worldImportPath: config.worldImportPath,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, config.worldInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n}\n"],"mappings":"AAAA,OAAS,iBAAAA,EAAe,YAAAC,EAAU,6BAAAC,EAA2B,kCAAAC,MAAsC,qBAa5F,SAASC,EAAmBC,EAAmCC,EAA8B,CAElG,IAAMC,EACJD,GAAmB,OAAQE,GAASA,EAAK,SAAS,QAAQ,GAAKA,IAAS,UAAY,CAACA,EAAK,MAAM,SAAS,CAAC,GAAK,CAAC,EAC5GC,EAAwB,OAAO,KAAKJ,EAAO,eAAe,EAGhE,GAAIC,GACF,QAAWI,KAAcD,EACvB,GAAI,CAACH,EAAkB,SAASI,CAAU,GAAKA,IAAe,QAC5D,MAAMP,EAA+B,CAAC,kBAAmBO,CAAU,EAAGA,CAAU,EAWtF,IAAMC,EALc,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGJ,EAAoB,GAAGE,CAAqB,CAAC,CAAC,EAAE,OACjFD,GAAS,CAACH,EAAO,eAAe,SAASG,CAAI,CAChD,EAG0E,OAAO,CAACI,EAAKF,KAC9E,CACL,GAAGE,EACH,CAACF,CAAU,EAAGG,EAAoBH,EAAYL,EAAO,gBAAgBK,CAAU,EAAGJ,CAAiB,CACrG,GACC,CAAC,CAAC,EAGCQ,EAAa,OAAO,OAAOT,EAAO,MAAM,EAAE,IAAI,CAAC,CAAE,KAAAG,CAAK,IAAMA,CAAI,EAChEO,EAAwB,OAAO,OAAOJ,CAAe,EAAE,IAAI,CAAC,CAAE,KAAAH,CAAK,IAAMA,CAAI,EAC7EQ,EAAiBhB,EAAc,CAAC,GAAGc,EAAY,GAAGC,CAAqB,CAAC,EAC9E,GAAIC,EAAe,OAAS,EAC1B,MAAM,IAAIf,EAAS,0CAA0Ce,EAAe,KAAK,IAAI,GAAG,EAG1F,MAAO,CAAE,QAASL,CAAgB,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AAgB,4BAA4B,CACnF","names":["getDuplicates","MUDError","STORE_SELECTOR_MAX_LENGTH","UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","resolvedSystems","acc","resolveSystemConfig","tableNames","configuredSystemNames","duplicateNames","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem","z","DynamicResolutionType","zEthereumAddress","zObjectName","zSelector","zSystemName","zModuleName","zSystemAccessList","zSystemConfig","zValueWithType","zDynamicResolution","zModuleConfig","zWorldConfig","zPluginWorldConfig","renderArguments","renderList","renderedSolidityHeader","renderImports","renderSystemInterface","options","imports","name","functionPrefix","functions","errors","parameters","stateMutability","returnParameters","renderReturnParameters","renderArguments","renderedSolidityHeader","renderAbsoluteImports","renderRelativeImports","renderWorld","options","interfaceName","storeImportPath","worldImportPath","imports","baseImports","importSymbols","symbol","readFileSync","path","formatAndWriteSolidity","contractToInterface","worldgen","config","existingContracts","outputBaseDirectory","resolvedConfig","resolveWorldConfig","basename","worldgenBaseDirectory","path","systems","systemInterfaceImports","system","data","readFileSync","functions","errors","symbolImports","contractToInterface","imports","symbolImport","systemInterfaceName","name","output","renderSystemInterface","fullOutputPath","formatAndWriteSolidity","renderWorld"]}