@latticexyz/world 2.0.0-main-252a1852 → 2.0.0-main-9e343907
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.
- package/dist/{chunk-IOPGO3X3.js → chunk-IXQANJBW.js} +2 -2
- package/dist/chunk-IXQANJBW.js.map +1 -0
- package/dist/chunk-SOQR4IUL.js +2 -0
- package/dist/chunk-SOQR4IUL.js.map +1 -0
- package/dist/{chunk-GDMJNROL.js → chunk-YMY7QWFU.js} +1 -1
- package/dist/chunk-YMY7QWFU.js.map +1 -0
- package/dist/config/v2.d.ts +40 -0
- package/dist/config/v2.js +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/{ts/index.d.ts → internal.d.ts} +5 -8
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -0
- package/dist/mud.config.js +1 -1
- package/dist/{ts/node/index.d.ts → node.d.ts} +2 -2
- package/dist/{ts/node/index.js → node.js} +2 -2
- package/dist/node.js.map +1 -0
- package/dist/{output-6d21492a.d.ts → output-993b3634.d.ts} +1 -1
- package/dist/{ts/register/index.d.ts → register.d.ts} +2 -2
- package/dist/register.js +2 -0
- package/dist/register.js.map +1 -0
- package/dist/{ts/config/v2/index.d.ts → world-ab20f7e4.d.ts} +8 -37
- package/package.json +16 -12
- package/ts/config/resolveWorldConfig.ts +1 -1
- package/ts/config/v2/compat.ts +2 -1
- package/ts/config/v2/output.ts +1 -1
- package/ts/config/v2/world.test.ts +12 -1
- package/ts/config/v2/world.ts +9 -1
- package/ts/exports/index.ts +10 -0
- package/ts/exports/internal.ts +9 -0
- package/ts/scripts/tablegen.ts +1 -1
- package/dist/chunk-APK5Q6HQ.js +0 -2
- package/dist/chunk-APK5Q6HQ.js.map +0 -1
- package/dist/chunk-GDMJNROL.js.map +0 -1
- package/dist/chunk-IOPGO3X3.js.map +0 -1
- package/dist/ts/config/v2/index.js +0 -2
- package/dist/ts/index.js +0 -2
- package/dist/ts/index.js.map +0 -1
- package/dist/ts/node/index.js.map +0 -1
- package/dist/ts/register/index.js +0 -2
- package/dist/ts/register/index.js.map +0 -1
- package/ts/index.ts +0 -10
- package/dist/{ts/config/v2/index.js.map → config/v2.js.map} +0 -0
- package/dist/{types-0e530577.d.ts → types-b088e935.d.ts} +6 -6
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{storeToV1 as s}from"@latticexyz/store/config/v2";function r(e){return e.map(o=>({name:o.name,root:o.root??!1,args:o.args??[]}))}function
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{storeToV1 as s}from"@latticexyz/store/config/v2";function r(e){return e.map(o=>({name:o.name,root:o.root??!1,args:o.args??[]}))}function l(e){let o={systems:e.systems,excludeSystems:e.excludeSystems,modules:r(e.modules),worldContractName:e.deploy.customWorldContract,postDeployScript:e.deploy.postDeployScript,deploysDirectory:e.deploy.deploysDirectory,worldsFile:e.deploy.worldsFile,worldInterfaceName:e.codegen.worldInterfaceName,worldgenDirectory:e.codegen.worldgenDirectory,worldImportPath:e.codegen.worldImportPath};return{...s(e),...o,v2:e}}export{l as a};
|
|
2
|
+
//# sourceMappingURL=chunk-IXQANJBW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/config/v2/compat.ts"],"sourcesContent":["import { conform, mutable } from \"@arktype/util\";\nimport { Module, World, Systems } from \"./output\";\nimport { Store } from \"@latticexyz/store\";\nimport { storeToV1 } from \"@latticexyz/store/config/v2\";\n\ntype modulesToV1<modules extends readonly Module[]> = mutable<{\n [key in keyof modules]: Required<modules[key]>;\n}>;\n\nfunction modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules> {\n return modules.map((module) => ({\n name: module.name,\n root: module.root ?? false,\n args: module.args ?? [],\n })) as modulesToV1<modules>;\n}\n\ntype systemsToV1<systems extends Systems> = {\n [key in keyof systems]: {\n name?: systems[key][\"name\"];\n registerFunctionSelectors: systems[key][\"registerFunctionSelectors\"];\n } & ({ openAccess: true } | { openAccess: false; accessList: systems[key][\"accessList\"] });\n};\n\nfunction systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems> {\n return systems;\n}\n\nexport type worldToV1<world> = world extends World\n ? Omit<storeToV1<world>, \"v2\"> & {\n systems: systemsToV1<world[\"systems\"]>;\n excludeSystems: mutable<world[\"excludeSystems\"]>;\n modules: modulesToV1<world[\"modules\"]>;\n worldContractName: world[\"deploy\"][\"customWorldContract\"];\n postDeployScript: world[\"deploy\"][\"postDeployScript\"];\n deploysDirectory: world[\"deploy\"][\"deploysDirectory\"];\n worldsFile: world[\"deploy\"][\"worldsFile\"];\n worldInterfaceName: world[\"codegen\"][\"worldInterfaceName\"];\n worldgenDirectory: world[\"codegen\"][\"worldgenDirectory\"];\n worldImportPath: world[\"codegen\"][\"worldImportPath\"];\n v2: world;\n }\n : never;\n\nexport function worldToV1<world>(world: conform<world, World>): worldToV1<world> {\n const v1WorldConfig = {\n systems: systemsToV1(world.systems),\n excludeSystems: world.excludeSystems,\n modules: modulesToV1(world.modules),\n worldContractName: world.deploy.customWorldContract,\n postDeployScript: world.deploy.postDeployScript,\n deploysDirectory: world.deploy.deploysDirectory,\n worldsFile: world.deploy.worldsFile,\n worldInterfaceName: world.codegen.worldInterfaceName,\n worldgenDirectory: world.codegen.worldgenDirectory,\n worldImportPath: world.codegen.worldImportPath,\n };\n\n return { ...storeToV1(world as Store), ...v1WorldConfig, v2: world } as worldToV1<world>;\n}\n"],"mappings":"AAGA,OAAS,aAAAA,MAAiB,8BAM1B,SAASC,EAA+CC,EAAwC,CAC9F,OAAOA,EAAQ,IAAKC,IAAY,CAC9B,KAAMA,EAAO,KACb,KAAMA,EAAO,MAAQ,GACrB,KAAMA,EAAO,MAAQ,CAAC,CACxB,EAAE,CACJ,CA6BO,SAASC,EAAiBC,EAAgD,CAC/E,IAAMC,EAAgB,CACpB,QAAqBD,EAAM,QAC3B,eAAgBA,EAAM,eACtB,QAASE,EAAYF,EAAM,OAAO,EAClC,kBAAmBA,EAAM,OAAO,oBAChC,iBAAkBA,EAAM,OAAO,iBAC/B,iBAAkBA,EAAM,OAAO,iBAC/B,WAAYA,EAAM,OAAO,WACzB,mBAAoBA,EAAM,QAAQ,mBAClC,kBAAmBA,EAAM,QAAQ,kBACjC,gBAAiBA,EAAM,QAAQ,eACjC,EAEA,MAAO,CAAE,GAAGG,EAAUH,CAAc,EAAG,GAAGC,EAAe,GAAID,CAAM,CACrE","names":["storeToV1","modulesToV1","modules","module","worldToV1","world","v1WorldConfig","modulesToV1","storeToV1"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as y}from"./chunk-RF4HOV37.js";import{extendedScope as u,get as U,resolveTable as O,validateTable as W,mergeIfUndefined as d,validateTables as F,resolveStore as L,hasOwnKey as v,validateStore as N,isObject as _}from"@latticexyz/store/config/v2";var r={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},t={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json"},l={systems:{},tables:{},excludeSystems:[],modules:[],codegen:r,deploy:t};import{mapObject as E}from"@latticexyz/common/utils";import{mergeIfUndefined as g}from"@latticexyz/store/config/v2";function c(e){return E(e,o=>g(o,y))}import{isObject as k,mergeIfUndefined as T}from"@latticexyz/store/config/v2";function i(e){return k(e)?T(e,r):r}import{mergeIfUndefined as b,isObject as I}from"@latticexyz/store/config/v2";function f(e){return I(e)?b(e,t):t}function S(e){let o=u(e);if(N(e),v(e,"namespaces")){if(!_(e.namespaces))throw new Error(`Expected namespaces, received ${JSON.stringify(e.namespaces)}`);for(let s of Object.values(e.namespaces))v(s,"tables")&&F(s.tables,o)}}function x(e){let o=u(e),s=e.namespaces??{},w=Object.fromEntries(Object.entries(s).map(([a,D])=>Object.entries(D.tables??{}).map(([p,m])=>(W(m,o),[`${a}__${p}`,O(d(m,{namespace:a,name:p}),o)]))).flat()),n=L(e);return d({...n,tables:{...n.tables,...w},codegen:d(n.codegen,i(e.codegen)),deploy:f(e.deploy),systems:c(e.systems??l.systems),excludeSystems:U(e,"excludeSystems"),modules:e.modules},l)}function Z(e){return S(e),x(e)}function K(e){return S(e),x(e)}export{S as a,x as b,Z as c,K as d};
|
|
2
|
+
//# sourceMappingURL=chunk-SOQR4IUL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/defaults.ts","../ts/config/v2/systems.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { conform, evaluate, narrow } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n isObject,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store/internal\";\nimport { resolveSystems } from \"./systems\";\nimport { resolveNamespacedTables, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"namespaces\"\n ? validateNamespaces<world[key], extendedScope<world>>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : world[key];\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"namespaces\")) {\n if (!isObject(world.namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(world.namespaces)}`);\n }\n for (const namespace of Object.values(world.namespaces)) {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n }\n }\n}\n\nexport type resolveWorld<world> = evaluate<\n resolveStore<world> &\n mergeIfUndefined<\n { tables: resolveNamespacedTables<world> } & Omit<\n {\n [key in keyof world]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n \"namespaces\" | keyof Store\n >,\n typeof CONFIG_DEFAULTS\n >\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const namespaces = world.namespaces ?? {};\n\n const resolvedNamespacedTables = Object.fromEntries(\n Object.entries(namespaces)\n .map(([namespaceKey, namespace]) =>\n Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {\n validateTable(table, scope);\n return [\n `${namespaceKey}__${tableKey}`,\n resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope),\n ];\n }),\n )\n .flat(),\n ) as Tables;\n\n const resolvedStore = resolveStore(world);\n\n return mergeIfUndefined(\n {\n ...resolvedStore,\n tables: { ...resolvedStore.tables, ...resolvedNamespacedTables },\n codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)),\n deploy: resolveDeploy(world.deploy),\n systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems),\n excludeSystems: get(world, \"excludeSystems\"),\n modules: world.modules,\n },\n CONFIG_DEFAULTS,\n ) as unknown as resolveWorld<world>;\n}\n\nexport function defineWorld<const world>(world: validateWorld<world>): resolveWorld<world> {\n validateWorld(world);\n return resolveWorld(world) as unknown as resolveWorld<world>;\n}\n\n// Temporary external export of defineWorld with namespaces disabled\nexport function defineWorldWithoutNamespaces<const world>(\n world: validateWorld<world> & { namespaces: `Namespaces will be enabled soon` },\n): resolveWorld<world> {\n validateWorld(world);\n return resolveWorld(world) as unknown as resolveWorld<world>;\n}\n","export const SYSTEM_DEFAULTS = {\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [] as string[],\n} as const;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n} as const;\n\nexport const DEPLOY_DEFAULTS = {\n customWorldContract: undefined,\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n} as const;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [] as string[],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const;\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { SYSTEM_DEFAULTS } from \"../defaults\";\nimport { SystemsInput } from \"./input\";\nimport { mergeIfUndefined } from \"@latticexyz/store/config/v2\";\n\nexport type resolveSystems<systems extends SystemsInput> = {\n [system in keyof systems]: mergeIfUndefined<systems[system], typeof SYSTEM_DEFAULTS>;\n};\n\nexport function resolveSystems<systems extends SystemsInput>(systems: systems): resolveSystems<systems> {\n return mapObject(systems, (system) => mergeIfUndefined(system, SYSTEM_DEFAULTS));\n}\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, typeof CODEGEN_DEFAULTS>\n : typeof CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (\n isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS\n ) as resolveCodegen<codegen>;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {}\n ? mergeIfUndefined<deploy, typeof DEPLOY_DEFAULTS>\n : typeof DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as resolveDeploy<deploy>;\n}\n"],"mappings":"wCACA,OAEE,iBAAAA,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,gBAAAC,EAEA,aAAAC,EACA,iBAAAC,EACA,YAAAC,MACK,8BCRA,IAAMC,EAAmB,CAC9B,mBAAoB,SACpB,kBAAmB,QACnB,gBAAiB,wBACnB,EAEaC,EAAkB,CAC7B,oBAAqB,OACrB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,eACd,EAEaC,EAAkB,CAC7B,QAAS,CAAC,EACV,OAAQ,CAAC,EACT,eAAgB,CAAC,EACjB,QAAS,CAAC,EACV,QAASF,EACT,OAAQC,CACV,EC1BA,OAAS,aAAAE,MAAiB,2BAG1B,OAAS,oBAAAC,MAAwB,8BAM1B,SAASC,EAA6CC,EAA2C,CACtG,OAAOC,EAAUD,EAAUE,GAAWJ,EAAiBI,EAAQC,CAAe,CAAC,CACjF,CCXA,OAAS,YAAAC,EAAU,oBAAAC,MAAwB,8BAOpC,SAASC,EAAwBC,EAA2C,CACjF,OACEC,EAASD,CAAO,EAAIE,EAAiBF,EAASG,CAAgB,EAAIA,CAEtE,CCXA,OAAS,oBAAAC,EAAkB,YAAAC,MAAgB,8BAOpC,SAASC,EAAsBC,EAAuC,CAC3E,OAAQC,EAASD,CAAM,EAAIE,EAAiBF,EAAQG,CAAe,EAAIA,CACzE,CJ4BO,SAASC,EAAcC,EAA6C,CACzE,IAAMC,EAAQC,EAAcF,CAAK,EAGjC,GAFAG,EAAcH,CAAK,EAEfI,EAAUJ,EAAO,YAAY,EAAG,CAClC,GAAI,CAACK,EAASL,EAAM,UAAU,EAC5B,MAAM,IAAI,MAAM,iCAAiC,KAAK,UAAUA,EAAM,UAAU,GAAG,EAErF,QAAWM,KAAa,OAAO,OAAON,EAAM,UAAU,EAChDI,EAAUE,EAAW,QAAQ,GAC/BC,EAAeD,EAAU,OAAQL,CAAK,EAI9C,CAqBO,SAASO,EAA6CR,EAAmC,CAC9F,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAAaT,EAAM,YAAc,CAAC,EAElCU,EAA2B,OAAO,YACtC,OAAO,QAAQD,CAAU,EACtB,IAAI,CAAC,CAACE,EAAcL,CAAS,IAC5B,OAAO,QAAQA,EAAU,QAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAACM,EAAUC,CAAK,KAC1DC,EAAcD,EAAOZ,CAAK,EACnB,CACL,GAAGU,MAAiBC,IACpBG,EAAaC,EAAiBH,EAAO,CAAE,UAAWF,EAAc,KAAMC,CAAS,CAAC,EAAGX,CAAK,CAC1F,EACD,CACH,EACC,KAAK,CACV,EAEMgB,EAAgBC,EAAalB,CAAK,EAExC,OAAOgB,EACL,CACE,GAAGC,EACH,OAAQ,CAAE,GAAGA,EAAc,OAAQ,GAAGP,CAAyB,EAC/D,QAASM,EAAiBC,EAAc,QAASE,EAAenB,EAAM,OAAO,CAAC,EAC9E,OAAQoB,EAAcpB,EAAM,MAAM,EAClC,QAASqB,EAAerB,EAAM,SAAWsB,EAAgB,OAAO,EAChE,eAAgBC,EAAIvB,EAAO,gBAAgB,EAC3C,QAASA,EAAM,OACjB,EACAsB,CACF,CACF,CAEO,SAASE,EAAyBxB,EAAkD,CACzF,OAAAD,EAAcC,CAAK,EACZQ,EAAaR,CAAK,CAC3B,CAGO,SAASyB,EACdzB,EACqB,CACrB,OAAAD,EAAcC,CAAK,EACZQ,EAAaR,CAAK,CAC3B","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","validateTables","resolveStore","hasOwnKey","validateStore","isObject","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS","mapObject","mergeIfUndefined","resolveSystems","systems","mapObject","system","SYSTEM_DEFAULTS","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","isObject","namespace","validateTables","resolveWorld","namespaces","resolvedNamespacedTables","namespaceKey","tableKey","table","validateTable","resolveTable","mergeIfUndefined","resolvedStore","resolveStore","resolveCodegen","resolveDeploy","resolveSystems","CONFIG_DEFAULTS","get","defineWorld","defineWorldWithoutNamespaces"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{UnrecognizedSystemErrorFactory as y}from"@latticexyz/config/library";function S(t,s){let n=s?.filter(e=>e.endsWith("System")&&e!=="System"&&!e.match(/^I[A-Z]/))??[],c=Object.keys(t.systems);if(s){for(let e of c)if(!s.includes(e)||e==="World")throw y(["systems",e],e)}return{systems:[...new Set([...n,...c])].filter(e=>!t.excludeSystems.includes(e)).reduce((e,o)=>({...e,[o]:d(o,t.systems[o],s)}),{})}}function d(t,s,n){let c=s?.name??t,i=s?.registerFunctionSelectors??!0,m=s?.openAccess??!0,e=[],o=[],l=s&&!s.openAccess?s.accessList:[];for(let r of l)if(r.startsWith("0x"))e.push(r);else{if(n&&!n.includes(r))throw y(["systems",t,"accessList"],r);o.push(r)}return{name:c,registerFunctionSelectors:i,openAccess:m,accessListAddresses:e,accessListSystems:o}}export{S as a,d as b};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-YMY7QWFU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/config/resolveWorldConfig.ts"],"sourcesContent":["import { UnrecognizedSystemErrorFactory } from \"@latticexyz/config/library\";\nimport { StoreConfig } from \"@latticexyz/store/internal\";\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.systems);\n\n // Validate every key in systems 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([\"systems\", 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.systems[systemName], existingContracts),\n };\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;\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([\"systems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n"],"mappings":"AAAA,OAAS,kCAAAA,MAAsC,6BAaxC,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,OAAO,EAGxD,GAAIC,GACF,QAAWI,KAAcD,EACvB,GAAI,CAACH,EAAkB,SAASI,CAAU,GAAKA,IAAe,QAC5D,MAAMP,EAA+B,CAAC,UAAWO,CAAU,EAAGA,CAAU,EAkB9E,MAAO,CAAE,QAZW,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGH,EAAoB,GAAGE,CAAqB,CAAC,CAAC,EAAE,OACjFD,GAAS,CAACH,EAAO,eAAe,SAASG,CAAI,CAChD,EAG0E,OAAO,CAACG,EAAKD,KAC9E,CACL,GAAGC,EACH,CAACD,CAAU,EAAGE,EAAoBF,EAAYL,EAAO,QAAQK,CAAU,EAAGJ,CAAiB,CAC7F,GACC,CAAC,CAAC,CAE6B,CACpC,CAcO,SAASM,EAAoBF,EAAoBL,EAAuBC,EAA8B,CAC3G,IAAME,EAAOH,GAAQ,MAAQK,EACvBG,EAA4BR,GAAQ,2BAA6B,GACjES,EAAaT,GAAQ,YAAc,GACnCU,EAAgC,CAAC,EACjCC,EAA8B,CAAC,EAC/BC,EAAaZ,GAAU,CAACA,EAAO,WAAaA,EAAO,WAAa,CAAC,EAGvE,QAAWa,KAAkBD,EAC3B,GAAIC,EAAe,WAAW,IAAI,EAChCH,EAAoB,KAAKG,CAAc,MAClC,CAEL,GAAIZ,GAAqB,CAACA,EAAkB,SAASY,CAAc,EACjE,MAAMf,EAA+B,CAAC,UAAWO,EAAY,YAAY,EAAGQ,CAAc,EAE5FF,EAAkB,KAAKE,CAAc,EAIzC,MAAO,CAAE,KAAAV,EAAM,0BAAAK,EAA2B,WAAAC,EAAY,oBAAAC,EAAqB,kBAAAC,CAAkB,CAC/F","names":["UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","acc","resolveSystemConfig","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export { a as defineWorld, d as defineWorldWithoutNamespaces, r as resolveWorld, v as validateWorld } from '../world-ab20f7e4.js';
|
|
2
|
+
import { W as World, M as Module, S as Systems } from '../output-993b3634.js';
|
|
3
|
+
export { C as Codegen, D as Deploy, a as System } from '../output-993b3634.js';
|
|
4
|
+
import { mutable, conform } from '@arktype/util';
|
|
5
|
+
import { storeToV1 } from '@latticexyz/store/config/v2';
|
|
6
|
+
import '../defaults-87a942d7.js';
|
|
7
|
+
import '@latticexyz/store';
|
|
8
|
+
|
|
9
|
+
type modulesToV1<modules extends readonly Module[]> = mutable<{
|
|
10
|
+
[key in keyof modules]: Required<modules[key]>;
|
|
11
|
+
}>;
|
|
12
|
+
declare function modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules>;
|
|
13
|
+
type systemsToV1<systems extends Systems> = {
|
|
14
|
+
[key in keyof systems]: {
|
|
15
|
+
name?: systems[key]["name"];
|
|
16
|
+
registerFunctionSelectors: systems[key]["registerFunctionSelectors"];
|
|
17
|
+
} & ({
|
|
18
|
+
openAccess: true;
|
|
19
|
+
} | {
|
|
20
|
+
openAccess: false;
|
|
21
|
+
accessList: systems[key]["accessList"];
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
declare function systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems>;
|
|
25
|
+
type worldToV1<world> = world extends World ? Omit<storeToV1<world>, "v2"> & {
|
|
26
|
+
systems: systemsToV1<world["systems"]>;
|
|
27
|
+
excludeSystems: mutable<world["excludeSystems"]>;
|
|
28
|
+
modules: modulesToV1<world["modules"]>;
|
|
29
|
+
worldContractName: world["deploy"]["customWorldContract"];
|
|
30
|
+
postDeployScript: world["deploy"]["postDeployScript"];
|
|
31
|
+
deploysDirectory: world["deploy"]["deploysDirectory"];
|
|
32
|
+
worldsFile: world["deploy"]["worldsFile"];
|
|
33
|
+
worldInterfaceName: world["codegen"]["worldInterfaceName"];
|
|
34
|
+
worldgenDirectory: world["codegen"]["worldgenDirectory"];
|
|
35
|
+
worldImportPath: world["codegen"]["worldImportPath"];
|
|
36
|
+
v2: world;
|
|
37
|
+
} : never;
|
|
38
|
+
declare function worldToV1<world>(world: conform<world, World>): worldToV1<world>;
|
|
39
|
+
|
|
40
|
+
export { Module, Systems, World, worldToV1 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { d as defineWorld } from './world-ab20f7e4.js';
|
|
2
|
+
export { W as World } from './output-993b3634.js';
|
|
3
|
+
import '@arktype/util';
|
|
4
|
+
import '@latticexyz/store/config/v2';
|
|
5
|
+
import './defaults-87a942d7.js';
|
|
6
|
+
import '@latticexyz/store';
|
|
7
|
+
|
|
8
|
+
declare const worldDeployedEvent = "event WorldDeployed(address indexed newContract, uint256 salt)";
|
|
9
|
+
declare const helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
|
|
10
|
+
|
|
11
|
+
export { helloWorldEvent, worldDeployedEvent };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as e}from"./chunk-SOQR4IUL.js";import"./chunk-RF4HOV37.js";var o="event WorldDeployed(address indexed newContract, uint256 salt)",t="event HelloWorld(bytes32 indexed worldVersion)";export{e as defineWorld,t as helloWorldEvent,o as worldDeployedEvent};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/worldEvents.ts"],"sourcesContent":["// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n"],"mappings":"oEACO,IAAMA,EAAqB,iEAGrBC,EAAkB","names":["worldDeployedEvent","helloWorldEvent"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { S as SYSTEM_DEFAULTS, W as WORLD_DEFAULTS } from '
|
|
2
|
-
import { StoreConfig } from '@latticexyz/store';
|
|
3
|
-
import { W as WorldConfig, S as SystemConfig } from '
|
|
4
|
-
export { E as ExpandSystemConfig, c as ExpandSystemsConfig, M as ModuleConfig, a as SystemUserConfig, b as SystemsUserConfig, d as WorldUserConfig, e as zPluginWorldConfig, z as zWorldConfig } from '
|
|
1
|
+
export { S as SYSTEM_DEFAULTS, W as WORLD_DEFAULTS } from './defaults-87a942d7.js';
|
|
2
|
+
import { StoreConfig } from '@latticexyz/store/internal';
|
|
3
|
+
import { W as WorldConfig, S as SystemConfig } from './types-b088e935.js';
|
|
4
|
+
export { E as ExpandSystemConfig, c as ExpandSystemsConfig, M as ModuleConfig, a as SystemUserConfig, b as SystemsUserConfig, d as WorldUserConfig, e as zPluginWorldConfig, z as zWorldConfig } from './types-b088e935.js';
|
|
5
5
|
import { Abi, ContractFunctionName, EncodeFunctionDataParameters, Hex, Address } from 'viem';
|
|
6
6
|
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from 'abitype';
|
|
7
7
|
import 'zod';
|
|
@@ -118,7 +118,4 @@ declare function encodeSystemCalls<abi extends Abi, functionName extends Contrac
|
|
|
118
118
|
/** Encode system calls to be passed as arguments into `World.batchCallFrom` */
|
|
119
119
|
declare function encodeSystemCallsFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>(abi: abi, from: Address, systemCalls: readonly Omit<SystemCallFrom<abi, functionName>, "abi" | "from">[]): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof abi, "callFrom">["inputs"]>[];
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
declare const helloWorldEvent = "event HelloWorld(bytes32 indexed worldVersion)";
|
|
123
|
-
|
|
124
|
-
export { ResolvedSystemConfig, ResolvedWorldConfig, SystemCall, SystemCallFrom, SystemConfig, WorldConfig, encodeSystemCall, encodeSystemCallFrom, encodeSystemCalls, encodeSystemCallsFrom, helloWorldEvent, resolveSystemConfig, resolveWorldConfig, worldDeployedEvent };
|
|
121
|
+
export { ResolvedSystemConfig, ResolvedWorldConfig, SystemCall, SystemCallFrom, SystemConfig, WorldConfig, encodeSystemCall, encodeSystemCallFrom, encodeSystemCalls, encodeSystemCallsFrom, resolveSystemConfig, resolveWorldConfig };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as u,b as f}from"./chunk-AGPG4DQJ.js";import{a as s,b as l}from"./chunk-RF4HOV37.js";import{a as b,b as p}from"./chunk-YMY7QWFU.js";import{encodeFunctionData as m}from"viem";function i({abi:t,systemId:e,functionName:a,args:o}){return[e,m({abi:t,functionName:a,args:o})]}import{encodeFunctionData as c}from"viem";function n({abi:t,from:e,systemId:a,functionName:o,args:r}){return[e,a,c({abi:t,functionName:o,args:r})]}function v(t,e){return e.map(a=>i({...a,abi:t}))}function w(t,e,a){return a.map(o=>n({...o,abi:t,from:e}))}export{s as SYSTEM_DEFAULTS,l as WORLD_DEFAULTS,i as encodeSystemCall,n as encodeSystemCallFrom,v as encodeSystemCalls,w as encodeSystemCallsFrom,p as resolveSystemConfig,b as resolveWorldConfig,f as zPluginWorldConfig,u as zWorldConfig};
|
|
2
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/encodeSystemCall.ts","../ts/encodeSystemCallFrom.ts","../ts/encodeSystemCalls.ts","../ts/encodeSystemCallsFrom.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = EncodeFunctionDataParameters<\n abi,\n functionName\n> & {\n readonly systemId: Hex;\n};\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]\n> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall } from \"./encodeSystemCall\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall, encodeSystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n systemCalls: readonly Omit<SystemCall<abi, functionName>, \"abi\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall<abi, functionName>));\n}\n","import { Abi, Address, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCallFrom, encodeSystemCallFrom } from \"./encodeSystemCallFrom\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n from: Address,\n systemCalls: readonly Omit<SystemCallFrom<abi, functionName>, \"abi\" | \"from\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) =>\n encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom<abi, functionName>),\n );\n}\n"],"mappings":"6IAAA,OAAiD,sBAAAA,MAAqD,OAY/F,SAASC,EAAkF,CAChG,IAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLF,EACAH,EAAsC,CACpC,IAAAE,EACA,aAAAE,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CC5BA,OAA4C,sBAAAC,MAA8D,OAanG,SAASC,EAAsF,CACpG,IAAAC,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLH,EACAC,EACAJ,EAAsC,CACpC,IAAAE,EACA,aAAAG,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CCzBO,SAASC,EACdC,EACAC,EAC6F,CAC7F,OAAOA,EAAY,IAAKC,GAAeC,EAAiB,CAAE,GAAGD,EAAY,IAAAF,CAAI,CAAkC,CAAC,CAClH,CCLO,SAASI,EACdC,EACAC,EACAC,EACiG,CACjG,OAAOA,EAAY,IAAKC,GACtBC,EAAqB,CAAE,GAAGD,EAAY,IAAAH,EAAK,KAAAC,CAAK,CAAsC,CACxF,CACF","names":["encodeFunctionData","encodeSystemCall","abi","systemId","functionName","args","encodeFunctionData","encodeSystemCallFrom","abi","from","systemId","functionName","args","encodeSystemCalls","abi","systemCalls","systemCall","encodeSystemCall","encodeSystemCallsFrom","abi","from","systemCalls","systemCall","encodeSystemCallFrom"]}
|
package/dist/mud.config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e}from"./chunk-
|
|
1
|
+
import{c as e}from"./chunk-SOQR4IUL.js";import"./chunk-RF4HOV37.js";var a=e({codegen:{worldImportPath:"../../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld"},namespace:"world",userTypes:{ResourceId:{filePath:"@latticexyz/store/src/ResourceId.sol",type:"bytes32"}},tables:{NamespaceOwner:{schema:{namespaceId:"ResourceId",owner:"address"},key:["namespaceId"]},ResourceAccess:{schema:{resourceId:"ResourceId",caller:"address",access:"bool"},key:["resourceId","caller"]},InstalledModules:{schema:{moduleAddress:"address",argumentsHash:"bytes32",isInstalled:"bool"},key:["moduleAddress","argumentsHash"]},UserDelegationControl:{schema:{delegator:"address",delegatee:"address",delegationControlId:"ResourceId"},key:["delegator","delegatee"]},NamespaceDelegationControl:{schema:{namespaceId:"ResourceId",delegationControlId:"ResourceId"},key:["namespaceId"]},Balances:{schema:{namespaceId:"ResourceId",balance:"uint256"},key:["namespaceId"]},Systems:{schema:{systemId:"ResourceId",system:"address",publicAccess:"bool"},key:["systemId"],codegen:{dataStruct:!1}},SystemRegistry:{schema:{system:"address",systemId:"ResourceId"},key:["system"]},SystemHooks:{schema:{systemId:"ResourceId",value:"bytes21[]"},key:["systemId"]},FunctionSelectors:{schema:{worldFunctionSelector:"bytes4",systemId:"ResourceId",systemFunctionSelector:"bytes4"},key:["worldFunctionSelector"],codegen:{dataStruct:!1}},FunctionSignatures:{type:"offchainTable",schema:{functionSelector:"bytes4",functionSignature:"string"},key:["functionSelector"]},InitModuleAddress:{schema:{value:"address"},key:[]}},excludeSystems:["StoreRegistrationSystem"]});export{a as default};
|
|
2
2
|
//# sourceMappingURL=mud.config.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ImportDatum, ContractInterfaceFunction, ContractInterfaceError, RelativeImportDatum } from '@latticexyz/common/codegen';
|
|
2
|
-
import { W as World } from '
|
|
3
|
-
import '@latticexyz/store
|
|
2
|
+
import { W as World } from './output-993b3634.js';
|
|
3
|
+
import '@latticexyz/store';
|
|
4
4
|
|
|
5
5
|
interface RenderSystemInterfaceOptions {
|
|
6
6
|
/** List of symbols to import, and their file paths */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as y}from"
|
|
1
|
+
import{a as y}from"./chunk-YMY7QWFU.js";import{a as h}from"./chunk-IXQANJBW.js";import{renderArguments as u,renderList as I,renderedSolidityHeader as R,renderImports as O}from"@latticexyz/common/codegen";function $(t){let{imports:r,name:i,functionPrefix:e,functions:m,errors:o}=t;return`
|
|
2
2
|
${R}
|
|
3
3
|
|
|
4
4
|
${O(r)}
|
|
@@ -34,4 +34,4 @@ import{a as y}from"../../chunk-GDMJNROL.js";import{a as h}from"../../chunk-IOPGO
|
|
|
34
34
|
interface ${r} is ${j(a)} {
|
|
35
35
|
}
|
|
36
36
|
`}import{readFileSync as C}from"fs";import l from"path";import{formatAndWriteSolidity as b,contractToInterface as L}from"@latticexyz/common/codegen";async function E(t,r,i){let e=h(t),m=y(e,r.map(({basename:s})=>s)),o=l.join(i,e.worldgenDirectory),a=r.filter(({basename:s})=>Object.keys(m.systems).includes(s)),n=[];for(let s of a){let W=C(s.path,"utf8"),{functions:P,errors:w,symbolImports:x}=L(W,s.basename),S=x.map(d=>d.path[0]==="."?{symbol:d.symbol,fromPath:l.join(l.dirname(s.path),d.path),usedInPath:o}:{symbol:d.symbol,path:d.path}),p=`I${s.basename}`,v=$({name:p,functionPrefix:e.namespace===""?"":`${e.namespace}__`,functions:P,errors:w,imports:S}),D=l.join(o,p+".sol");await b(v,D,"Generated system interface"),n.push({symbol:p,fromPath:`${p}.sol`,usedInPath:"./"})}let c=g({interfaceName:e.worldInterfaceName,imports:n,storeImportPath:e.storeImportPath,worldImportPath:e.worldImportPath}),f=l.join(o,e.worldInterfaceName+".sol");await b(c,f,"Generated world interface")}export{$ as renderSystemInterface,g as renderWorldInterface,E as worldgen};
|
|
37
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../ts/node/render-solidity/renderSystemInterface.ts","../ts/node/render-solidity/renderWorldInterface.ts","../ts/node/render-solidity/worldgen.ts"],"sourcesContent":["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 `\n ${renderedSolidityHeader}\n\n ${renderImports(imports)}\n\n /**\n * @title ${name} \n * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)\n * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.\n */\n interface ${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\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 renderWorldInterface(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}IWorldKernel.sol` },\n ]\n : [\n {\n symbol: \"IBaseWorld\",\n path: `${worldImportPath}codegen/interfaces/IBaseWorld.sol`,\n },\n ];\n const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol);\n\n return `\n ${renderedSolidityHeader}\n\n ${renderAbsoluteImports(baseImports)}\n\n ${renderRelativeImports(imports)}\n\n /**\n * @title ${interfaceName} \n * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)\n * @notice This interface integrates all systems and associated function selectors \n * that are dynamically registered in the World during deployment.\n * @dev This is an autogenerated file; do not edit manually.\n */\n interface ${interfaceName} is ${renderArguments(importSymbols)} {\n }\n `;\n}\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from \"@latticexyz/common/codegen\";\nimport { renderSystemInterface } from \"./renderSystemInterface\";\nimport { renderWorldInterface } from \"./renderWorldInterface\";\nimport { resolveWorldConfig } from \"../../config/resolveWorldConfig\";\nimport { World as WorldConfig } from \"../../config/v2/output\";\nimport { worldToV1 } from \"../../config/v2/compat\";\n\nexport async function worldgen(\n configV2: WorldConfig,\n existingContracts: { path: string; basename: string }[],\n outputBaseDirectory: string,\n) {\n const config = worldToV1(configV2);\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 const output = renderSystemInterface({\n name: systemInterfaceName,\n functionPrefix: config.namespace === \"\" ? \"\" : `${config.namespace}__`,\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 = renderWorldInterface({\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 world interface\");\n}\n"],"mappings":"gFAAA,OAAS,mBAAAA,EAAiB,cAAAC,EAAY,0BAAAC,EAAwB,iBAAAC,MAAqB,6BAG5E,SAASC,EAAsBC,EAAuC,CAC3E,GAAM,CAAE,QAAAC,EAAS,KAAAC,EAAM,eAAAC,EAAgB,UAAAC,EAAW,OAAAC,CAAO,EAAIL,EAE7D,MAAO;AAAA,MACHH;AAAA;AAAA,MAEAC,EAAcG,CAAO;AAAA;AAAA;AAAA,gBAGXC;AAAA;AAAA;AAAA;AAAA,gBAIAA;AAAA,QACRN,EAAWS,EAAQ,CAAC,CAAE,KAAAH,EAAM,WAAAI,CAAW,IAAM,SAASJ,KAAQP,EAAgBW,CAAU,KAAK;AAAA;AAAA,QAE7FV,EACAQ,EACA,CAAC,CAAE,KAAAF,EAAM,WAAAI,EAAY,gBAAAC,EAAiB,iBAAAC,CAAiB,IAAM;AAAA,qBAChDL,IAAiBD;AAAA,cACxBP,EAAgBW,CAAU;AAAA,uBACjBC,KAAmBE,EAAuBD,CAAgB;AAAA,SAE3E;AAAA;AAAA,GAGN,CAEA,SAASC,EAAuBD,EAA4B,CAC1D,OAAIA,EAAiB,OAAS,EACrB,YAAYb,EAAgBa,CAAgB,KAE5C,EAEX,CCrCA,OACE,mBAAAE,EACA,0BAAAC,EACA,yBAAAC,EACA,yBAAAC,MAEK,6BAGA,SAASC,EAAqBC,EAA6B,CAChE,GAAM,CAAE,cAAAC,EAAe,gBAAAC,EAAiB,gBAAAC,EAAiB,QAAAC,CAAQ,EAAIJ,EAC/DK,EACJJ,IAAkB,aACd,CACE,CAAE,OAAQ,SAAU,KAAM,GAAGC,aAA4B,EACzD,CAAE,OAAQ,eAAgB,KAAM,GAAGC,mBAAkC,CACvE,EACA,CACE,CACE,OAAQ,aACR,KAAM,GAAGA,oCACX,CACF,EACAG,EAAgB,CAAC,GAAGD,EAAa,GAAGD,CAAO,EAAE,IAAI,CAAC,CAAE,OAAAG,CAAO,IAAMA,CAAM,EAE7E,MAAO;AAAA,MACHX;AAAA;AAAA,MAEAC,EAAsBQ,CAAW;AAAA;AAAA,MAEjCP,EAAsBM,CAAO;AAAA;AAAA;AAAA,gBAGnBH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAMAA,QAAoBN,EAAgBW,CAAa;AAAA;AAAA,GAGjE,CC1CA,OAAS,gBAAAE,MAAoB,KAC7B,OAAOC,MAAU,OACjB,OAAS,0BAAAC,EAAwB,uBAAAC,MAAqD,6BAOtF,eAAsBC,EACpBC,EACAC,EACAC,EACA,CACA,IAAMC,EAASC,EAAUJ,CAAQ,EAC3BK,EAAiBC,EACrBH,EACAF,EAAkB,IAAI,CAAC,CAAE,SAAAM,CAAS,IAAMA,CAAQ,CAClD,EAEMC,EAAwBC,EAAK,KAAKP,EAAqBC,EAAO,iBAAiB,EAC/EO,EAAUT,EAAkB,OAAO,CAAC,CAAE,SAAAM,CAAS,IAAM,OAAO,KAAKF,EAAe,OAAO,EAAE,SAASE,CAAQ,CAAC,EAE3GI,EAAgD,CAAC,EACvD,QAAWC,KAAUF,EAAS,CAC5B,IAAMG,EAAOC,EAAaF,EAAO,KAAM,MAAM,EAEvC,CAAE,UAAAG,EAAW,OAAAC,EAAQ,cAAAC,CAAc,EAAIC,EAAoBL,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,WACjCU,EAASC,EAAsB,CACnC,KAAMF,EACN,eAAgBlB,EAAO,YAAc,GAAK,GAAK,GAAGA,EAAO,cACzD,UAAAY,EACA,OAAAC,EACA,QAAAG,CACF,CAAC,EAEKK,EAAiBf,EAAK,KAAKD,EAAuBa,EAAsB,MAAM,EACpF,MAAMI,EAAuBH,EAAQE,EAAgB,4BAA4B,EAGjFb,EAAuB,KAAK,CAC1B,OAAQU,EACR,SAAU,GAAGA,QACb,WAAY,IACd,CAAC,EAIH,IAAMC,EAASI,EAAqB,CAClC,cAAevB,EAAO,mBACtB,QAASQ,EACT,gBAAiBR,EAAO,gBACxB,gBAAiBA,EAAO,eAC1B,CAAC,EAEKqB,EAAiBf,EAAK,KAAKD,EAAuBL,EAAO,mBAAqB,MAAM,EAC1F,MAAMsB,EAAuBH,EAAQE,EAAgB,2BAA2B,CAClF","names":["renderArguments","renderList","renderedSolidityHeader","renderImports","renderSystemInterface","options","imports","name","functionPrefix","functions","errors","parameters","stateMutability","returnParameters","renderReturnParameters","renderArguments","renderedSolidityHeader","renderAbsoluteImports","renderRelativeImports","renderWorldInterface","options","interfaceName","storeImportPath","worldImportPath","imports","baseImports","importSymbols","symbol","readFileSync","path","formatAndWriteSolidity","contractToInterface","worldgen","configV2","existingContracts","outputBaseDirectory","config","worldToV1","resolvedConfig","resolveWorldConfig","basename","worldgenBaseDirectory","path","systems","systemInterfaceImports","system","data","readFileSync","functions","errors","symbolImports","contractToInterface","imports","symbolImport","systemInterfaceName","output","renderSystemInterface","fullOutputPath","formatAndWriteSolidity","renderWorldInterface"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { mudConfig, mudCoreConfig, resolveTableId } from '@latticexyz/store/register';
|
|
2
2
|
import { OrDefaults } from '@latticexyz/common/type-utils';
|
|
3
3
|
import { MUDCoreUserConfig } from '@latticexyz/config/library';
|
|
4
|
-
import { W as WORLD_DEFAULTS } from '
|
|
5
|
-
import { d as WorldUserConfig, W as WorldConfig, c as ExpandSystemsConfig } from '
|
|
4
|
+
import { W as WORLD_DEFAULTS } from './defaults-87a942d7.js';
|
|
5
|
+
import { d as WorldUserConfig, W as WorldConfig, c as ExpandSystemsConfig } from './types-b088e935.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
8
8
|
declare module "@latticexyz/config/library" {
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as r}from"./chunk-AGPG4DQJ.js";import"./chunk-RF4HOV37.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/library";import{ZodError as s}from"zod";t(e=>{try{return r.parse(e)}catch(o){throw o instanceof s?i(o,"WorldConfig Validation Error"):o}});import"@latticexyz/store/register";export{c as mudConfig,C as mudCoreConfig,g as resolveTableId};
|
|
2
|
+
//# sourceMappingURL=register.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/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../config/worldConfig\";\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/library\";\n\nimport \"@latticexyz/store/register\";\nimport { WORLD_DEFAULTS } from \"../config/defaults\";\nimport { WorldUserConfig, WorldConfig, ExpandSystemsConfig } from \"../config/types\";\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/library\" {\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 worldsFile: typeof WORLD_DEFAULTS.worldsFile;\n worldgenDirectory: typeof WORLD_DEFAULTS.worldgenDirectory;\n worldImportPath: typeof WORLD_DEFAULTS.worldImportPath;\n modules: typeof WORLD_DEFAULTS.modules;\n }\n > {\n systems: ExpandSystemsConfig<T[\"systems\"] extends Record<string, unknown> ? T[\"systems\"] : Record<string, never>>;\n }\n}\n"],"mappings":"oEAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,EAAe,kBAAAC,MAAsB,6BCPzD,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,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,ECdD,MAAO","names":["mudConfig","mudCoreConfig","resolveTableId","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { evaluate, narrow, conform
|
|
2
|
-
import { StoreInput, mergeIfUndefined, Scope, AbiTypeScope, validateTables, resolveTable, get, extendedScope, UserTypes, resolveStore, Store
|
|
3
|
-
import { M as Module
|
|
4
|
-
|
|
5
|
-
import { S as SYSTEM_DEFAULTS } from '../../../defaults-87a942d7.js';
|
|
1
|
+
import { evaluate, narrow, conform } from '@arktype/util';
|
|
2
|
+
import { StoreInput, mergeIfUndefined, Scope, AbiTypeScope, validateTables, resolveTable, get, extendedScope, UserTypes, resolveStore, Store } from '@latticexyz/store/config/v2';
|
|
3
|
+
import { M as Module } from './output-993b3634.js';
|
|
4
|
+
import { S as SYSTEM_DEFAULTS } from './defaults-87a942d7.js';
|
|
6
5
|
|
|
7
6
|
type SystemInput = {
|
|
8
7
|
/** The full resource selector consists of namespace and name */
|
|
@@ -131,36 +130,8 @@ type resolveWorld<world> = evaluate<resolveStore<world> & mergeIfUndefined<{
|
|
|
131
130
|
}, "namespaces" | keyof Store>, typeof CONFIG_DEFAULTS>>;
|
|
132
131
|
declare function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world>;
|
|
133
132
|
declare function defineWorld<const world>(world: validateWorld<world>): resolveWorld<world>;
|
|
133
|
+
declare function defineWorldWithoutNamespaces<const world>(world: validateWorld<world> & {
|
|
134
|
+
namespaces: `Namespaces will be enabled soon`;
|
|
135
|
+
}): resolveWorld<world>;
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
[key in keyof modules]: Required<modules[key]>;
|
|
137
|
-
}>;
|
|
138
|
-
declare function modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules>;
|
|
139
|
-
type systemsToV1<systems extends Systems> = {
|
|
140
|
-
[key in keyof systems]: {
|
|
141
|
-
name?: systems[key]["name"];
|
|
142
|
-
registerFunctionSelectors: systems[key]["registerFunctionSelectors"];
|
|
143
|
-
} & ({
|
|
144
|
-
openAccess: true;
|
|
145
|
-
} | {
|
|
146
|
-
openAccess: false;
|
|
147
|
-
accessList: systems[key]["accessList"];
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
declare function systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems>;
|
|
151
|
-
type worldToV1<world> = world extends World ? Omit<storeToV1<world>, "v2"> & {
|
|
152
|
-
systems: systemsToV1<world["systems"]>;
|
|
153
|
-
excludeSystems: mutable<world["excludeSystems"]>;
|
|
154
|
-
modules: modulesToV1<world["modules"]>;
|
|
155
|
-
worldContractName: world["deploy"]["customWorldContract"];
|
|
156
|
-
postDeployScript: world["deploy"]["postDeployScript"];
|
|
157
|
-
deploysDirectory: world["deploy"]["deploysDirectory"];
|
|
158
|
-
worldsFile: world["deploy"]["worldsFile"];
|
|
159
|
-
worldInterfaceName: world["codegen"]["worldInterfaceName"];
|
|
160
|
-
worldgenDirectory: world["codegen"]["worldgenDirectory"];
|
|
161
|
-
worldImportPath: world["codegen"]["worldImportPath"];
|
|
162
|
-
v2: world;
|
|
163
|
-
} : never;
|
|
164
|
-
declare function worldToV1<world>(world: conform<world, World>): worldToV1<world>;
|
|
165
|
-
|
|
166
|
-
export { Module, Systems, World, defineWorld, resolveWorld, validateWorld, worldToV1 };
|
|
137
|
+
export { defineWorld as a, defineWorldWithoutNamespaces as d, resolveWorld as r, validateWorld as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/world",
|
|
3
|
-
"version": "2.0.0-main-
|
|
3
|
+
"version": "2.0.0-main-9e343907",
|
|
4
4
|
"description": "World framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,17 +10,21 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
|
-
".": "./dist/
|
|
13
|
+
".": "./dist/index.js",
|
|
14
|
+
"./internal": "./dist/internal.js",
|
|
14
15
|
"./mud.config": "./dist/mud.config.js",
|
|
15
|
-
"./config/v2": "./dist/
|
|
16
|
-
"./register": "./dist/
|
|
17
|
-
"./node": "./dist/
|
|
16
|
+
"./config/v2": "./dist/config/v2.js",
|
|
17
|
+
"./register": "./dist/register.js",
|
|
18
|
+
"./node": "./dist/node.js",
|
|
18
19
|
"./out/*": "./out/*"
|
|
19
20
|
},
|
|
20
21
|
"typesVersions": {
|
|
21
22
|
"*": {
|
|
22
23
|
"index": [
|
|
23
|
-
"./ts/index.ts"
|
|
24
|
+
"./ts/exports/index.ts"
|
|
25
|
+
],
|
|
26
|
+
"internal": [
|
|
27
|
+
"./ts/exports/internal.ts"
|
|
24
28
|
],
|
|
25
29
|
"config/v2": [
|
|
26
30
|
"./ts/config/v2/index.ts"
|
|
@@ -39,10 +43,10 @@
|
|
|
39
43
|
"arktype": "1.0.29-alpha",
|
|
40
44
|
"viem": "2.7.12",
|
|
41
45
|
"zod": "^3.21.4",
|
|
42
|
-
"@latticexyz/common": "2.0.0-main-
|
|
43
|
-
"@latticexyz/config": "2.0.0-main-
|
|
44
|
-
"@latticexyz/schema-type": "2.0.0-main-
|
|
45
|
-
"@latticexyz/store": "2.0.0-main-
|
|
46
|
+
"@latticexyz/common": "2.0.0-main-9e343907",
|
|
47
|
+
"@latticexyz/config": "2.0.0-main-9e343907",
|
|
48
|
+
"@latticexyz/schema-type": "2.0.0-main-9e343907",
|
|
49
|
+
"@latticexyz/store": "2.0.0-main-9e343907"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"@types/ejs": "^3.1.1",
|
|
@@ -57,8 +61,8 @@
|
|
|
57
61
|
"tsup": "^6.7.0",
|
|
58
62
|
"tsx": "^3.12.6",
|
|
59
63
|
"vitest": "0.34.6",
|
|
60
|
-
"@latticexyz/abi-ts": "2.0.0-main-
|
|
61
|
-
"@latticexyz/gas-report": "2.0.0-main-
|
|
64
|
+
"@latticexyz/abi-ts": "2.0.0-main-9e343907",
|
|
65
|
+
"@latticexyz/gas-report": "2.0.0-main-9e343907"
|
|
62
66
|
},
|
|
63
67
|
"scripts": {
|
|
64
68
|
"build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts && pnpm run build:js",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnrecognizedSystemErrorFactory } from "@latticexyz/config/library";
|
|
2
|
-
import { StoreConfig } from "@latticexyz/store";
|
|
2
|
+
import { StoreConfig } from "@latticexyz/store/internal";
|
|
3
3
|
import { SystemConfig, WorldConfig } from "./types";
|
|
4
4
|
|
|
5
5
|
export type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;
|
package/ts/config/v2/compat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { conform, mutable } from "@arktype/util";
|
|
2
2
|
import { Module, World, Systems } from "./output";
|
|
3
|
-
import {
|
|
3
|
+
import { Store } from "@latticexyz/store";
|
|
4
|
+
import { storeToV1 } from "@latticexyz/store/config/v2";
|
|
4
5
|
|
|
5
6
|
type modulesToV1<modules extends readonly Module[]> = mutable<{
|
|
6
7
|
[key in keyof modules]: Required<modules[key]>;
|
package/ts/config/v2/output.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it } from "vitest";
|
|
2
|
-
import { defineWorld } from "./world";
|
|
2
|
+
import { defineWorld, defineWorldWithoutNamespaces } from "./world";
|
|
3
3
|
import { attest } from "@arktype/attest";
|
|
4
4
|
import { resourceToHex } from "@latticexyz/common";
|
|
5
5
|
import {
|
|
@@ -715,3 +715,14 @@ describe("defineWorld", () => {
|
|
|
715
715
|
).throwsAndHasTypeError("Overrides of `name` and `namespace` are not allowed for tables in a store config");
|
|
716
716
|
});
|
|
717
717
|
});
|
|
718
|
+
|
|
719
|
+
describe("defineWorldWithoutNamespaces", () => {
|
|
720
|
+
it("should throw if namespaces are defined", () => {
|
|
721
|
+
attest(() =>
|
|
722
|
+
defineWorldWithoutNamespaces({
|
|
723
|
+
// @ts-expect-error Namespaces will be enabled soon
|
|
724
|
+
namespaces: {},
|
|
725
|
+
}),
|
|
726
|
+
).type.errors("Namespaces will be enabled soon");
|
|
727
|
+
});
|
|
728
|
+
});
|
package/ts/config/v2/world.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "@latticexyz/store/config/v2";
|
|
16
16
|
import { SystemsInput, WorldInput } from "./input";
|
|
17
17
|
import { CONFIG_DEFAULTS } from "./defaults";
|
|
18
|
-
import { Tables } from "@latticexyz/store";
|
|
18
|
+
import { Tables } from "@latticexyz/store/internal";
|
|
19
19
|
import { resolveSystems } from "./systems";
|
|
20
20
|
import { resolveNamespacedTables, validateNamespaces } from "./namespaces";
|
|
21
21
|
import { resolveCodegen } from "./codegen";
|
|
@@ -108,3 +108,11 @@ export function defineWorld<const world>(world: validateWorld<world>): resolveWo
|
|
|
108
108
|
validateWorld(world);
|
|
109
109
|
return resolveWorld(world) as unknown as resolveWorld<world>;
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// Temporary external export of defineWorld with namespaces disabled
|
|
113
|
+
export function defineWorldWithoutNamespaces<const world>(
|
|
114
|
+
world: validateWorld<world> & { namespaces: `Namespaces will be enabled soon` },
|
|
115
|
+
): resolveWorld<world> {
|
|
116
|
+
validateWorld(world);
|
|
117
|
+
return resolveWorld(world) as unknown as resolveWorld<world>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External exports.
|
|
3
|
+
*
|
|
4
|
+
* Be sure we're ready to commit to these being supported and changes made backward compatible!
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { helloWorldEvent, worldDeployedEvent } from "../worldEvents";
|
|
8
|
+
|
|
9
|
+
export { defineWorldWithoutNamespaces as defineWorld } from "../config/v2/world";
|
|
10
|
+
export type { World } from "../config/v2/output";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "../config/defaults";
|
|
2
|
+
export * from "../config/resolveWorldConfig";
|
|
3
|
+
export * from "../config/types";
|
|
4
|
+
export * from "../config/worldConfig";
|
|
5
|
+
|
|
6
|
+
export * from "../encodeSystemCall";
|
|
7
|
+
export * from "../encodeSystemCallFrom";
|
|
8
|
+
export * from "../encodeSystemCalls";
|
|
9
|
+
export * from "../encodeSystemCallsFrom";
|
package/ts/scripts/tablegen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { loadConfig } from "@latticexyz/config/node";
|
|
3
3
|
import { getRemappings, getSrcDirectory } from "@latticexyz/common/foundry";
|
|
4
|
-
import { Store as StoreConfig } from "@latticexyz/store
|
|
4
|
+
import { Store as StoreConfig } from "@latticexyz/store";
|
|
5
5
|
import { tablegen } from "@latticexyz/store/codegen";
|
|
6
6
|
|
|
7
7
|
const config = (await loadConfig()) as StoreConfig;
|
package/dist/chunk-APK5Q6HQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as y}from"./chunk-RF4HOV37.js";import{extendedScope as v,get as I,resolveTable as U,validateTable as b,mergeIfUndefined as l,validateTables as O,resolveStore as F,hasOwnKey as S,validateStore as L,isObject as W}from"@latticexyz/store/config/v2";var t={worldInterfaceName:"IWorld",worldgenDirectory:"world",worldImportPath:"@latticexyz/world/src/"},r={customWorldContract:void 0,postDeployScript:"PostDeploy",deploysDirectory:"./deploys",worldsFile:"./worlds.json"},d={systems:{},tables:{},excludeSystems:[],modules:[],codegen:t,deploy:r};import{mapObject as D}from"@latticexyz/common/utils";import{mergeIfUndefined as E}from"@latticexyz/store/config/v2";function c(e){return D(e,o=>E(o,y))}import{isObject as g,mergeIfUndefined as T}from"@latticexyz/store/config/v2";function i(e){return g(e)?T(e,t):t}import{mergeIfUndefined as k,isObject as w}from"@latticexyz/store/config/v2";function f(e){return w(e)?k(e,r):r}function _(e){let o=v(e);if(L(e),S(e,"namespaces")){if(!W(e.namespaces))throw new Error(`Expected namespaces, received ${JSON.stringify(e.namespaces)}`);for(let s of Object.values(e.namespaces))S(s,"tables")&&O(s.tables,o)}}function A(e){let o=v(e),s=e.namespaces??{},u=Object.fromEntries(Object.entries(s).map(([p,x])=>Object.entries(x.tables??{}).map(([m,a])=>(b(a,o),[`${p}__${m}`,U(l(a,{namespace:p,name:m}),o)]))).flat()),n=F(e);return l({...n,tables:{...n.tables,...u},codegen:l(n.codegen,i(e.codegen)),deploy:f(e.deploy),systems:c(e.systems??d.systems),excludeSystems:I(e,"excludeSystems"),modules:e.modules},d)}function Z(e){return _(e),A(e)}export{_ as a,A as b,Z as c};
|
|
2
|
-
//# sourceMappingURL=chunk-APK5Q6HQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../ts/config/v2/world.ts","../ts/config/v2/defaults.ts","../ts/config/v2/systems.ts","../ts/config/v2/codegen.ts","../ts/config/v2/deploy.ts"],"sourcesContent":["import { conform, evaluate, narrow } from \"@arktype/util\";\nimport {\n UserTypes,\n extendedScope,\n get,\n resolveTable,\n validateTable,\n mergeIfUndefined,\n validateTables,\n resolveStore,\n Store,\n hasOwnKey,\n validateStore,\n isObject,\n} from \"@latticexyz/store/config/v2\";\nimport { SystemsInput, WorldInput } from \"./input\";\nimport { CONFIG_DEFAULTS } from \"./defaults\";\nimport { Tables } from \"@latticexyz/store\";\nimport { resolveSystems } from \"./systems\";\nimport { resolveNamespacedTables, validateNamespaces } from \"./namespaces\";\nimport { resolveCodegen } from \"./codegen\";\nimport { resolveDeploy } from \"./deploy\";\n\nexport type validateWorld<world> = {\n readonly [key in keyof world]: key extends \"tables\"\n ? validateTables<world[key], extendedScope<world>>\n : key extends \"userTypes\"\n ? UserTypes\n : key extends \"enums\"\n ? narrow<world[key]>\n : key extends \"namespaces\"\n ? validateNamespaces<world[key], extendedScope<world>>\n : key extends keyof WorldInput\n ? conform<world[key], WorldInput[key]>\n : world[key];\n};\n\nexport function validateWorld(world: unknown): asserts world is WorldInput {\n const scope = extendedScope(world);\n validateStore(world);\n\n if (hasOwnKey(world, \"namespaces\")) {\n if (!isObject(world.namespaces)) {\n throw new Error(`Expected namespaces, received ${JSON.stringify(world.namespaces)}`);\n }\n for (const namespace of Object.values(world.namespaces)) {\n if (hasOwnKey(namespace, \"tables\")) {\n validateTables(namespace.tables, scope);\n }\n }\n }\n}\n\nexport type resolveWorld<world> = evaluate<\n resolveStore<world> &\n mergeIfUndefined<\n { tables: resolveNamespacedTables<world> } & Omit<\n {\n [key in keyof world]: key extends \"systems\"\n ? resolveSystems<world[key] & SystemsInput>\n : key extends \"deploy\"\n ? resolveDeploy<world[key]>\n : key extends \"codegen\"\n ? resolveCodegen<world[key]>\n : world[key];\n },\n \"namespaces\" | keyof Store\n >,\n typeof CONFIG_DEFAULTS\n >\n>;\n\nexport function resolveWorld<const world extends WorldInput>(world: world): resolveWorld<world> {\n const scope = extendedScope(world);\n const namespaces = world.namespaces ?? {};\n\n const resolvedNamespacedTables = Object.fromEntries(\n Object.entries(namespaces)\n .map(([namespaceKey, namespace]) =>\n Object.entries(namespace.tables ?? {}).map(([tableKey, table]) => {\n validateTable(table, scope);\n return [\n `${namespaceKey}__${tableKey}`,\n resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope),\n ];\n }),\n )\n .flat(),\n ) as Tables;\n\n const resolvedStore = resolveStore(world);\n\n return mergeIfUndefined(\n {\n ...resolvedStore,\n tables: { ...resolvedStore.tables, ...resolvedNamespacedTables },\n codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)),\n deploy: resolveDeploy(world.deploy),\n systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems),\n excludeSystems: get(world, \"excludeSystems\"),\n modules: world.modules,\n },\n CONFIG_DEFAULTS,\n ) as unknown as resolveWorld<world>;\n}\n\nexport function defineWorld<const world>(world: validateWorld<world>): resolveWorld<world> {\n validateWorld(world);\n return resolveWorld(world) as unknown as resolveWorld<world>;\n}\n","export const SYSTEM_DEFAULTS = {\n registerFunctionSelectors: true,\n openAccess: true,\n accessList: [] as string[],\n} as const;\n\nexport const CODEGEN_DEFAULTS = {\n worldInterfaceName: \"IWorld\",\n worldgenDirectory: \"world\",\n worldImportPath: \"@latticexyz/world/src/\",\n} as const;\n\nexport const DEPLOY_DEFAULTS = {\n customWorldContract: undefined,\n postDeployScript: \"PostDeploy\",\n deploysDirectory: \"./deploys\",\n worldsFile: \"./worlds.json\",\n} as const;\n\nexport const CONFIG_DEFAULTS = {\n systems: {},\n tables: {},\n excludeSystems: [] as string[],\n modules: [],\n codegen: CODEGEN_DEFAULTS,\n deploy: DEPLOY_DEFAULTS,\n} as const;\n","import { mapObject } from \"@latticexyz/common/utils\";\nimport { SYSTEM_DEFAULTS } from \"../defaults\";\nimport { SystemsInput } from \"./input\";\nimport { mergeIfUndefined } from \"@latticexyz/store/config/v2\";\n\nexport type resolveSystems<systems extends SystemsInput> = {\n [system in keyof systems]: mergeIfUndefined<systems[system], typeof SYSTEM_DEFAULTS>;\n};\n\nexport function resolveSystems<systems extends SystemsInput>(systems: systems): resolveSystems<systems> {\n return mapObject(systems, (system) => mergeIfUndefined(system, SYSTEM_DEFAULTS));\n}\n","import { isObject, mergeIfUndefined } from \"@latticexyz/store/config/v2\";\nimport { CODEGEN_DEFAULTS } from \"./defaults\";\n\nexport type resolveCodegen<codegen> = codegen extends {}\n ? mergeIfUndefined<codegen, typeof CODEGEN_DEFAULTS>\n : typeof CODEGEN_DEFAULTS;\n\nexport function resolveCodegen<codegen>(codegen: codegen): resolveCodegen<codegen> {\n return (\n isObject(codegen) ? mergeIfUndefined(codegen, CODEGEN_DEFAULTS) : CODEGEN_DEFAULTS\n ) as resolveCodegen<codegen>;\n}\n","import { mergeIfUndefined, isObject } from \"@latticexyz/store/config/v2\";\nimport { DEPLOY_DEFAULTS } from \"./defaults\";\n\nexport type resolveDeploy<deploy> = deploy extends {}\n ? mergeIfUndefined<deploy, typeof DEPLOY_DEFAULTS>\n : typeof DEPLOY_DEFAULTS;\n\nexport function resolveDeploy<deploy>(deploy: deploy): resolveDeploy<deploy> {\n return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as resolveDeploy<deploy>;\n}\n"],"mappings":"wCACA,OAEE,iBAAAA,EACA,OAAAC,EACA,gBAAAC,EACA,iBAAAC,EACA,oBAAAC,EACA,kBAAAC,EACA,gBAAAC,EAEA,aAAAC,EACA,iBAAAC,EACA,YAAAC,MACK,8BCRA,IAAMC,EAAmB,CAC9B,mBAAoB,SACpB,kBAAmB,QACnB,gBAAiB,wBACnB,EAEaC,EAAkB,CAC7B,oBAAqB,OACrB,iBAAkB,aAClB,iBAAkB,YAClB,WAAY,eACd,EAEaC,EAAkB,CAC7B,QAAS,CAAC,EACV,OAAQ,CAAC,EACT,eAAgB,CAAC,EACjB,QAAS,CAAC,EACV,QAASF,EACT,OAAQC,CACV,EC1BA,OAAS,aAAAE,MAAiB,2BAG1B,OAAS,oBAAAC,MAAwB,8BAM1B,SAASC,EAA6CC,EAA2C,CACtG,OAAOC,EAAUD,EAAUE,GAAWJ,EAAiBI,EAAQC,CAAe,CAAC,CACjF,CCXA,OAAS,YAAAC,EAAU,oBAAAC,MAAwB,8BAOpC,SAASC,EAAwBC,EAA2C,CACjF,OACEC,EAASD,CAAO,EAAIE,EAAiBF,EAASG,CAAgB,EAAIA,CAEtE,CCXA,OAAS,oBAAAC,EAAkB,YAAAC,MAAgB,8BAOpC,SAASC,EAAsBC,EAAuC,CAC3E,OAAQC,EAASD,CAAM,EAAIE,EAAiBF,EAAQG,CAAe,EAAIA,CACzE,CJ4BO,SAASC,EAAcC,EAA6C,CACzE,IAAMC,EAAQC,EAAcF,CAAK,EAGjC,GAFAG,EAAcH,CAAK,EAEfI,EAAUJ,EAAO,YAAY,EAAG,CAClC,GAAI,CAACK,EAASL,EAAM,UAAU,EAC5B,MAAM,IAAI,MAAM,iCAAiC,KAAK,UAAUA,EAAM,UAAU,GAAG,EAErF,QAAWM,KAAa,OAAO,OAAON,EAAM,UAAU,EAChDI,EAAUE,EAAW,QAAQ,GAC/BC,EAAeD,EAAU,OAAQL,CAAK,EAI9C,CAqBO,SAASO,EAA6CR,EAAmC,CAC9F,IAAMC,EAAQC,EAAcF,CAAK,EAC3BS,EAAaT,EAAM,YAAc,CAAC,EAElCU,EAA2B,OAAO,YACtC,OAAO,QAAQD,CAAU,EACtB,IAAI,CAAC,CAACE,EAAcL,CAAS,IAC5B,OAAO,QAAQA,EAAU,QAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAACM,EAAUC,CAAK,KAC1DC,EAAcD,EAAOZ,CAAK,EACnB,CACL,GAAGU,MAAiBC,IACpBG,EAAaC,EAAiBH,EAAO,CAAE,UAAWF,EAAc,KAAMC,CAAS,CAAC,EAAGX,CAAK,CAC1F,EACD,CACH,EACC,KAAK,CACV,EAEMgB,EAAgBC,EAAalB,CAAK,EAExC,OAAOgB,EACL,CACE,GAAGC,EACH,OAAQ,CAAE,GAAGA,EAAc,OAAQ,GAAGP,CAAyB,EAC/D,QAASM,EAAiBC,EAAc,QAASE,EAAenB,EAAM,OAAO,CAAC,EAC9E,OAAQoB,EAAcpB,EAAM,MAAM,EAClC,QAASqB,EAAerB,EAAM,SAAWsB,EAAgB,OAAO,EAChE,eAAgBC,EAAIvB,EAAO,gBAAgB,EAC3C,QAASA,EAAM,OACjB,EACAsB,CACF,CACF,CAEO,SAASE,EAAyBxB,EAAkD,CACzF,OAAAD,EAAcC,CAAK,EACZQ,EAAaR,CAAK,CAC3B","names":["extendedScope","get","resolveTable","validateTable","mergeIfUndefined","validateTables","resolveStore","hasOwnKey","validateStore","isObject","CODEGEN_DEFAULTS","DEPLOY_DEFAULTS","CONFIG_DEFAULTS","mapObject","mergeIfUndefined","resolveSystems","systems","mapObject","system","SYSTEM_DEFAULTS","isObject","mergeIfUndefined","resolveCodegen","codegen","isObject","mergeIfUndefined","CODEGEN_DEFAULTS","mergeIfUndefined","isObject","resolveDeploy","deploy","isObject","mergeIfUndefined","DEPLOY_DEFAULTS","validateWorld","world","scope","extendedScope","validateStore","hasOwnKey","isObject","namespace","validateTables","resolveWorld","namespaces","resolvedNamespacedTables","namespaceKey","tableKey","table","validateTable","resolveTable","mergeIfUndefined","resolvedStore","resolveStore","resolveCodegen","resolveDeploy","resolveSystems","CONFIG_DEFAULTS","get","defineWorld"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../ts/config/resolveWorldConfig.ts"],"sourcesContent":["import { UnrecognizedSystemErrorFactory } from \"@latticexyz/config/library\";\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.systems);\n\n // Validate every key in systems 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([\"systems\", 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.systems[systemName], existingContracts),\n };\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;\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([\"systems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n"],"mappings":"AAAA,OAAS,kCAAAA,MAAsC,6BAaxC,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,OAAO,EAGxD,GAAIC,GACF,QAAWI,KAAcD,EACvB,GAAI,CAACH,EAAkB,SAASI,CAAU,GAAKA,IAAe,QAC5D,MAAMP,EAA+B,CAAC,UAAWO,CAAU,EAAGA,CAAU,EAkB9E,MAAO,CAAE,QAZW,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGH,EAAoB,GAAGE,CAAqB,CAAC,CAAC,EAAE,OACjFD,GAAS,CAACH,EAAO,eAAe,SAASG,CAAI,CAChD,EAG0E,OAAO,CAACG,EAAKD,KAC9E,CACL,GAAGC,EACH,CAACD,CAAU,EAAGE,EAAoBF,EAAYL,EAAO,QAAQK,CAAU,EAAGJ,CAAiB,CAC7F,GACC,CAAC,CAAC,CAE6B,CACpC,CAcO,SAASM,EAAoBF,EAAoBL,EAAuBC,EAA8B,CAC3G,IAAME,EAAOH,GAAQ,MAAQK,EACvBG,EAA4BR,GAAQ,2BAA6B,GACjES,EAAaT,GAAQ,YAAc,GACnCU,EAAgC,CAAC,EACjCC,EAA8B,CAAC,EAC/BC,EAAaZ,GAAU,CAACA,EAAO,WAAaA,EAAO,WAAa,CAAC,EAGvE,QAAWa,KAAkBD,EAC3B,GAAIC,EAAe,WAAW,IAAI,EAChCH,EAAoB,KAAKG,CAAc,MAClC,CAEL,GAAIZ,GAAqB,CAACA,EAAkB,SAASY,CAAc,EACjE,MAAMf,EAA+B,CAAC,UAAWO,EAAY,YAAY,EAAGQ,CAAc,EAE5FF,EAAkB,KAAKE,CAAc,EAIzC,MAAO,CAAE,KAAAV,EAAM,0BAAAK,EAA2B,WAAAC,EAAY,oBAAAC,EAAqB,kBAAAC,CAAkB,CAC/F","names":["UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","acc","resolveSystemConfig","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../ts/config/v2/compat.ts"],"sourcesContent":["import { conform, mutable } from \"@arktype/util\";\nimport { Module, World, Systems } from \"./output\";\nimport { storeToV1, Store } from \"@latticexyz/store/config/v2\";\n\ntype modulesToV1<modules extends readonly Module[]> = mutable<{\n [key in keyof modules]: Required<modules[key]>;\n}>;\n\nfunction modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules> {\n return modules.map((module) => ({\n name: module.name,\n root: module.root ?? false,\n args: module.args ?? [],\n })) as modulesToV1<modules>;\n}\n\ntype systemsToV1<systems extends Systems> = {\n [key in keyof systems]: {\n name?: systems[key][\"name\"];\n registerFunctionSelectors: systems[key][\"registerFunctionSelectors\"];\n } & ({ openAccess: true } | { openAccess: false; accessList: systems[key][\"accessList\"] });\n};\n\nfunction systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems> {\n return systems;\n}\n\nexport type worldToV1<world> = world extends World\n ? Omit<storeToV1<world>, \"v2\"> & {\n systems: systemsToV1<world[\"systems\"]>;\n excludeSystems: mutable<world[\"excludeSystems\"]>;\n modules: modulesToV1<world[\"modules\"]>;\n worldContractName: world[\"deploy\"][\"customWorldContract\"];\n postDeployScript: world[\"deploy\"][\"postDeployScript\"];\n deploysDirectory: world[\"deploy\"][\"deploysDirectory\"];\n worldsFile: world[\"deploy\"][\"worldsFile\"];\n worldInterfaceName: world[\"codegen\"][\"worldInterfaceName\"];\n worldgenDirectory: world[\"codegen\"][\"worldgenDirectory\"];\n worldImportPath: world[\"codegen\"][\"worldImportPath\"];\n v2: world;\n }\n : never;\n\nexport function worldToV1<world>(world: conform<world, World>): worldToV1<world> {\n const v1WorldConfig = {\n systems: systemsToV1(world.systems),\n excludeSystems: world.excludeSystems,\n modules: modulesToV1(world.modules),\n worldContractName: world.deploy.customWorldContract,\n postDeployScript: world.deploy.postDeployScript,\n deploysDirectory: world.deploy.deploysDirectory,\n worldsFile: world.deploy.worldsFile,\n worldInterfaceName: world.codegen.worldInterfaceName,\n worldgenDirectory: world.codegen.worldgenDirectory,\n worldImportPath: world.codegen.worldImportPath,\n };\n\n return { ...storeToV1(world as Store), ...v1WorldConfig, v2: world } as worldToV1<world>;\n}\n"],"mappings":"AAEA,OAAS,aAAAA,MAAwB,8BAMjC,SAASC,EAA+CC,EAAwC,CAC9F,OAAOA,EAAQ,IAAKC,IAAY,CAC9B,KAAMA,EAAO,KACb,KAAMA,EAAO,MAAQ,GACrB,KAAMA,EAAO,MAAQ,CAAC,CACxB,EAAE,CACJ,CA6BO,SAASC,EAAiBC,EAAgD,CAC/E,IAAMC,EAAgB,CACpB,QAAqBD,EAAM,QAC3B,eAAgBA,EAAM,eACtB,QAASE,EAAYF,EAAM,OAAO,EAClC,kBAAmBA,EAAM,OAAO,oBAChC,iBAAkBA,EAAM,OAAO,iBAC/B,iBAAkBA,EAAM,OAAO,iBAC/B,WAAYA,EAAM,OAAO,WACzB,mBAAoBA,EAAM,QAAQ,mBAClC,kBAAmBA,EAAM,QAAQ,kBACjC,gBAAiBA,EAAM,QAAQ,eACjC,EAEA,MAAO,CAAE,GAAGG,EAAUH,CAAc,EAAG,GAAGC,EAAe,GAAID,CAAM,CACrE","names":["storeToV1","modulesToV1","modules","module","worldToV1","world","v1WorldConfig","modulesToV1","storeToV1"]}
|
package/dist/ts/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as d,b as u}from"../chunk-AGPG4DQJ.js";import{a as l,b as s}from"../chunk-RF4HOV37.js";import{a as b,b as p}from"../chunk-GDMJNROL.js";import{encodeFunctionData as m}from"viem";function i({abi:t,systemId:e,functionName:o,args:a}){return[e,m({abi:t,functionName:o,args:a})]}import{encodeFunctionData as c}from"viem";function n({abi:t,from:e,systemId:o,functionName:a,args:r}){return[e,o,c({abi:t,functionName:a,args:r})]}function W(t,e){return e.map(o=>i({...o,abi:t}))}function H(t,e,o){return o.map(a=>n({...a,abi:t,from:e}))}var O="event WorldDeployed(address indexed newContract, uint256 salt)",h="event HelloWorld(bytes32 indexed worldVersion)";export{l as SYSTEM_DEFAULTS,s as WORLD_DEFAULTS,i as encodeSystemCall,n as encodeSystemCallFrom,W as encodeSystemCalls,H as encodeSystemCallsFrom,h as helloWorldEvent,p as resolveSystemConfig,b as resolveWorldConfig,O as worldDeployedEvent,u as zPluginWorldConfig,d as zWorldConfig};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/ts/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../ts/encodeSystemCall.ts","../../ts/encodeSystemCallFrom.ts","../../ts/encodeSystemCalls.ts","../../ts/encodeSystemCallsFrom.ts","../../ts/worldEvents.ts"],"sourcesContent":["import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\n\nexport type SystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>> = EncodeFunctionDataParameters<\n abi,\n functionName\n> & {\n readonly systemId: Hex;\n};\n\n/** Encode a system call to be passed as arguments into `World.call` */\nexport function encodeSystemCall<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n systemId,\n functionName,\n args,\n}: SystemCall<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]\n> {\n return [\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from \"viem\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall } from \"./encodeSystemCall\";\n\nexport type SystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>> = SystemCall<\n abi,\n functionName\n> & {\n readonly from: Address;\n};\n\n/** Encode a system call to be passed as arguments into `World.callFrom` */\nexport function encodeSystemCallFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>({\n abi,\n from,\n systemId,\n functionName,\n args,\n}: SystemCallFrom<abi, functionName>): AbiParametersToPrimitiveTypes<\n ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]\n> {\n return [\n from,\n systemId,\n encodeFunctionData<abi, functionName>({\n abi,\n functionName,\n args,\n } as unknown as EncodeFunctionDataParameters<abi, functionName>),\n ];\n}\n","import { Abi, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCall, encodeSystemCall } from \"./encodeSystemCall\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCall` */\nexport function encodeSystemCalls<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n systemCalls: readonly Omit<SystemCall<abi, functionName>, \"abi\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"call\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall<abi, functionName>));\n}\n","import { Abi, Address, type ContractFunctionName } from \"viem\";\nimport IWorldCallAbi from \"../out/IWorldKernel.sol/IWorldCall.abi.json\";\nimport { SystemCallFrom, encodeSystemCallFrom } from \"./encodeSystemCallFrom\";\nimport type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from \"abitype\";\n\n/** Encode system calls to be passed as arguments into `World.batchCallFrom` */\nexport function encodeSystemCallsFrom<abi extends Abi, functionName extends ContractFunctionName<abi>>(\n abi: abi,\n from: Address,\n systemCalls: readonly Omit<SystemCallFrom<abi, functionName>, \"abi\" | \"from\">[],\n): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, \"callFrom\">[\"inputs\"]>[] {\n return systemCalls.map((systemCall) =>\n encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom<abi, functionName>),\n );\n}\n","// from WorldFactory\nexport const worldDeployedEvent = \"event WorldDeployed(address indexed newContract, uint256 salt)\";\n\n// from World\nexport const helloWorldEvent = \"event HelloWorld(bytes32 indexed worldVersion)\";\n"],"mappings":"gJAAA,OAAiD,sBAAAA,MAAqD,OAY/F,SAASC,EAAkF,CAChG,IAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLF,EACAH,EAAsC,CACpC,IAAAE,EACA,aAAAE,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CC5BA,OAA4C,sBAAAC,MAA8D,OAanG,SAASC,EAAsF,CACpG,IAAAC,EACA,KAAAC,EACA,SAAAC,EACA,aAAAC,EACA,KAAAC,CACF,EAEE,CACA,MAAO,CACLH,EACAC,EACAJ,EAAsC,CACpC,IAAAE,EACA,aAAAG,EACA,KAAAC,CACF,CAA+D,CACjE,CACF,CCzBO,SAASC,EACdC,EACAC,EAC6F,CAC7F,OAAOA,EAAY,IAAKC,GAAeC,EAAiB,CAAE,GAAGD,EAAY,IAAAF,CAAI,CAAkC,CAAC,CAClH,CCLO,SAASI,EACdC,EACAC,EACAC,EACiG,CACjG,OAAOA,EAAY,IAAKC,GACtBC,EAAqB,CAAE,GAAGD,EAAY,IAAAH,EAAK,KAAAC,CAAK,CAAsC,CACxF,CACF,CCbO,IAAMI,EAAqB,iEAGrBC,EAAkB","names":["encodeFunctionData","encodeSystemCall","abi","systemId","functionName","args","encodeFunctionData","encodeSystemCallFrom","abi","from","systemId","functionName","args","encodeSystemCalls","abi","systemCalls","systemCall","encodeSystemCall","encodeSystemCallsFrom","abi","from","systemCalls","systemCall","encodeSystemCallFrom","worldDeployedEvent","helloWorldEvent"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../ts/node/render-solidity/renderSystemInterface.ts","../../../ts/node/render-solidity/renderWorldInterface.ts","../../../ts/node/render-solidity/worldgen.ts"],"sourcesContent":["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 `\n ${renderedSolidityHeader}\n\n ${renderImports(imports)}\n\n /**\n * @title ${name} \n * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)\n * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.\n */\n interface ${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\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 renderWorldInterface(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}IWorldKernel.sol` },\n ]\n : [\n {\n symbol: \"IBaseWorld\",\n path: `${worldImportPath}codegen/interfaces/IBaseWorld.sol`,\n },\n ];\n const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol);\n\n return `\n ${renderedSolidityHeader}\n\n ${renderAbsoluteImports(baseImports)}\n\n ${renderRelativeImports(imports)}\n\n /**\n * @title ${interfaceName} \n * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)\n * @notice This interface integrates all systems and associated function selectors \n * that are dynamically registered in the World during deployment.\n * @dev This is an autogenerated file; do not edit manually.\n */\n interface ${interfaceName} is ${renderArguments(importSymbols)} {\n }\n `;\n}\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from \"@latticexyz/common/codegen\";\nimport { renderSystemInterface } from \"./renderSystemInterface\";\nimport { renderWorldInterface } from \"./renderWorldInterface\";\nimport { resolveWorldConfig } from \"../../config/resolveWorldConfig\";\nimport { World as WorldConfig } from \"../../config/v2/output\";\nimport { worldToV1 } from \"../../config/v2/compat\";\n\nexport async function worldgen(\n configV2: WorldConfig,\n existingContracts: { path: string; basename: string }[],\n outputBaseDirectory: string,\n) {\n const config = worldToV1(configV2);\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 const output = renderSystemInterface({\n name: systemInterfaceName,\n functionPrefix: config.namespace === \"\" ? \"\" : `${config.namespace}__`,\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 = renderWorldInterface({\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 world interface\");\n}\n"],"mappings":"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","names":["renderArguments","renderList","renderedSolidityHeader","renderImports","renderSystemInterface","options","imports","name","functionPrefix","functions","errors","parameters","stateMutability","returnParameters","renderReturnParameters","renderArguments","renderedSolidityHeader","renderAbsoluteImports","renderRelativeImports","renderWorldInterface","options","interfaceName","storeImportPath","worldImportPath","imports","baseImports","importSymbols","symbol","readFileSync","path","formatAndWriteSolidity","contractToInterface","worldgen","configV2","existingContracts","outputBaseDirectory","config","worldToV1","resolvedConfig","resolveWorldConfig","basename","worldgenBaseDirectory","path","systems","systemInterfaceImports","system","data","readFileSync","functions","errors","symbolImports","contractToInterface","imports","symbolImport","systemInterfaceName","output","renderSystemInterface","fullOutputPath","formatAndWriteSolidity","renderWorldInterface"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as r}from"../../chunk-AGPG4DQJ.js";import"../../chunk-RF4HOV37.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/library";import{ZodError as s}from"zod";t(e=>{try{return r.parse(e)}catch(o){throw o instanceof s?i(o,"WorldConfig Validation Error"):o}});import"@latticexyz/store/register";export{c as mudConfig,C as mudCoreConfig,g as resolveTableId};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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/library\";\nimport { ZodError } from \"zod\";\nimport { zPluginWorldConfig } from \"../config/worldConfig\";\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/library\";\n\nimport \"@latticexyz/store/register\";\nimport { WORLD_DEFAULTS } from \"../config/defaults\";\nimport { WorldUserConfig, WorldConfig, ExpandSystemsConfig } from \"../config/types\";\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/library\" {\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 worldsFile: typeof WORLD_DEFAULTS.worldsFile;\n worldgenDirectory: typeof WORLD_DEFAULTS.worldgenDirectory;\n worldImportPath: typeof WORLD_DEFAULTS.worldImportPath;\n modules: typeof WORLD_DEFAULTS.modules;\n }\n > {\n systems: ExpandSystemsConfig<T[\"systems\"] extends Record<string, unknown> ? T[\"systems\"] : Record<string, never>>;\n }\n}\n"],"mappings":"4EAMA,MAAO,6BACP,OAAS,aAAAA,EAAW,iBAAAC,EAAe,kBAAAC,MAAsB,6BCPzD,OAAS,uBAAAC,EAAqB,sBAAAC,MAA0B,6BACxD,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,ECdD,MAAO","names":["mudConfig","mudCoreConfig","resolveTableId","extendMUDCoreConfig","fromZodErrorCustom","ZodError","extendMUDCoreConfig","config","zPluginWorldConfig","error","ZodError","fromZodErrorCustom"]}
|
package/ts/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./config/defaults";
|
|
2
|
-
export * from "./config/resolveWorldConfig";
|
|
3
|
-
export * from "./config/types";
|
|
4
|
-
export * from "./config/worldConfig";
|
|
5
|
-
|
|
6
|
-
export * from "./encodeSystemCall";
|
|
7
|
-
export * from "./encodeSystemCallFrom";
|
|
8
|
-
export * from "./encodeSystemCalls";
|
|
9
|
-
export * from "./encodeSystemCallsFrom";
|
|
10
|
-
export * from "./worldEvents";
|
|
File without changes
|
|
@@ -81,7 +81,6 @@ declare const zWorldConfig: z.ZodObject<{
|
|
|
81
81
|
})[] | undefined;
|
|
82
82
|
}>, "many">>;
|
|
83
83
|
}, "strip", z.ZodTypeAny, {
|
|
84
|
-
worldInterfaceName: string;
|
|
85
84
|
systems: Record<string, {
|
|
86
85
|
registerFunctionSelectors: boolean;
|
|
87
86
|
name?: string | undefined;
|
|
@@ -92,11 +91,6 @@ declare const zWorldConfig: z.ZodObject<{
|
|
|
92
91
|
openAccess: false;
|
|
93
92
|
})>;
|
|
94
93
|
excludeSystems: string[];
|
|
95
|
-
postDeployScript: string;
|
|
96
|
-
deploysDirectory: string;
|
|
97
|
-
worldsFile: string;
|
|
98
|
-
worldgenDirectory: string;
|
|
99
|
-
worldImportPath: string;
|
|
100
94
|
modules: {
|
|
101
95
|
name: string;
|
|
102
96
|
args: ({
|
|
@@ -108,6 +102,12 @@ declare const zWorldConfig: z.ZodObject<{
|
|
|
108
102
|
})[];
|
|
109
103
|
root: boolean;
|
|
110
104
|
}[];
|
|
105
|
+
worldInterfaceName: string;
|
|
106
|
+
worldgenDirectory: string;
|
|
107
|
+
worldImportPath: string;
|
|
108
|
+
postDeployScript: string;
|
|
109
|
+
deploysDirectory: string;
|
|
110
|
+
worldsFile: string;
|
|
111
111
|
worldContractName?: string | undefined;
|
|
112
112
|
}, {
|
|
113
113
|
worldContractName?: string | undefined;
|