@latticexyz/world 2.0.0-alpha.1.22 → 2.0.0-alpha.1.23

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.
@@ -1,151 +1,2 @@
1
- import { mudConfig as e } from "@latticexyz/config";
2
- const r = e({
3
- worldImportPath: "../",
4
- worldgenDirectory: "interfaces",
5
- worldInterfaceName: "IBaseWorld",
6
- codegenDirectory: "",
7
- tables: {
8
- /************************************************************************
9
- *
10
- * CORE TABLES
11
- *
12
- ************************************************************************/
13
- NamespaceOwner: {
14
- primaryKeys: {
15
- namespace: "bytes16"
16
- },
17
- schema: {
18
- owner: "address"
19
- }
20
- },
21
- ResourceAccess: {
22
- primaryKeys: {
23
- resourceSelector: "bytes32",
24
- caller: "address"
25
- },
26
- schema: {
27
- access: "bool"
28
- }
29
- },
30
- InstalledModules: {
31
- primaryKeys: {
32
- moduleName: "bytes16",
33
- argumentsHash: "bytes32"
34
- // Hash of the params passed to the `install` function
35
- },
36
- schema: {
37
- moduleAddress: "address"
38
- },
39
- // TODO: this is a workaround to use `getRecord` instead of `getField` in the autogen library,
40
- // to allow using the table before it is registered. This is because `getRecord` passes the schema
41
- // to store, while `getField` loads it from storage. Remove this once we have support for passing the
42
- // schema in `getField` too. (See https://github.com/latticexyz/mud/issues/444)
43
- dataStruct: !0
44
- },
45
- /************************************************************************
46
- *
47
- * MODULE TABLES
48
- *
49
- ************************************************************************/
50
- Systems: {
51
- directory: "modules/core/tables",
52
- primaryKeys: {
53
- resourceSelector: "bytes32"
54
- },
55
- schema: {
56
- system: "address",
57
- publicAccess: "bool"
58
- },
59
- dataStruct: !1
60
- },
61
- SystemRegistry: {
62
- directory: "modules/core/tables",
63
- primaryKeys: {
64
- system: "address"
65
- },
66
- schema: {
67
- resourceSelector: "bytes32"
68
- }
69
- },
70
- ResourceType: {
71
- directory: "modules/core/tables",
72
- primaryKeys: {
73
- resourceSelector: "bytes32"
74
- },
75
- schema: {
76
- resourceType: "Resource"
77
- }
78
- },
79
- FunctionSelectors: {
80
- directory: "modules/core/tables",
81
- name: "funcSelectors",
82
- primaryKeys: {
83
- functionSelector: "bytes4"
84
- },
85
- schema: {
86
- namespace: "bytes16",
87
- name: "bytes16",
88
- systemFunctionSelector: "bytes4"
89
- },
90
- dataStruct: !1
91
- },
92
- KeysWithValue: {
93
- directory: "modules/keyswithvalue/tables",
94
- primaryKeys: {
95
- valueHash: "bytes32"
96
- },
97
- schema: {
98
- keysWithValue: "bytes32[]"
99
- // For now only supports 1 key per value
100
- },
101
- tableIdArgument: !0
102
- },
103
- UniqueEntity: {
104
- directory: "modules/uniqueentity/tables",
105
- primaryKeys: {},
106
- schema: "uint256",
107
- tableIdArgument: !0,
108
- storeArgument: !0
109
- },
110
- /************************************************************************
111
- *
112
- * TEST TABLES
113
- *
114
- ************************************************************************/
115
- Bool: {
116
- directory: "../test/tables",
117
- primaryKeys: {},
118
- schema: {
119
- value: "bool"
120
- },
121
- tableIdArgument: !0
122
- },
123
- AddressArray: {
124
- directory: "../test/tables",
125
- schema: "address[]",
126
- tableIdArgument: !0
127
- }
128
- },
129
- enums: {
130
- Resource: ["NONE", "NAMESPACE", "TABLE", "SYSTEM"]
131
- },
132
- excludeSystems: [
133
- // IUniqueEntitySystem is not part of the root namespace and
134
- // installed separately by UniqueEntityModule.
135
- // TODO: Move optional modules into a separate package
136
- // (see https://github.com/latticexyz/mud/pull/584)
137
- "UniqueEntitySystem",
138
- // Worldgen currently does not support systems inheriting logic
139
- // from other contracts, so all parts of CoreSystem are named
140
- // System too to be included in the IBaseWorld interface.
141
- // However, IStoreRegistrationSystem overlaps with IStore if
142
- // included in IBaseWorld, so it needs to be excluded from worldgen.
143
- // TODO: add support for inheritance to worldgen
144
- // (see: https://github.com/latticexyz/mud/issues/631)
145
- "StoreRegistrationSystem"
146
- ]
147
- });
148
- export {
149
- r as default
150
- };
151
- //# sourceMappingURL=mud.config.js.map
1
+ import{mudConfig as e}from"@latticexyz/config";var r=e({worldImportPath:"../",worldgenDirectory:"interfaces",worldInterfaceName:"IBaseWorld",codegenDirectory:"",tables:{NamespaceOwner:{primaryKeys:{namespace:"bytes16"},schema:{owner:"address"}},ResourceAccess:{primaryKeys:{resourceSelector:"bytes32",caller:"address"},schema:{access:"bool"}},InstalledModules:{primaryKeys:{moduleName:"bytes16",argumentsHash:"bytes32"},schema:{moduleAddress:"address"},dataStruct:!0},Systems:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{system:"address",publicAccess:"bool"},dataStruct:!1},SystemRegistry:{directory:"modules/core/tables",primaryKeys:{system:"address"},schema:{resourceSelector:"bytes32"}},ResourceType:{directory:"modules/core/tables",primaryKeys:{resourceSelector:"bytes32"},schema:{resourceType:"Resource"}},FunctionSelectors:{directory:"modules/core/tables",name:"funcSelectors",primaryKeys:{functionSelector:"bytes4"},schema:{namespace:"bytes16",name:"bytes16",systemFunctionSelector:"bytes4"},dataStruct:!1},KeysWithValue:{directory:"modules/keyswithvalue/tables",primaryKeys:{valueHash:"bytes32"},schema:{keysWithValue:"bytes32[]"},tableIdArgument:!0},UniqueEntity:{directory:"modules/uniqueentity/tables",primaryKeys:{},schema:"uint256",tableIdArgument:!0,storeArgument:!0},Bool:{directory:"../test/tables",primaryKeys:{},schema:{value:"bool"},tableIdArgument:!0},AddressArray:{directory:"../test/tables",schema:"address[]",tableIdArgument:!0}},enums:{Resource:["NONE","NAMESPACE","TABLE","SYSTEM"]},excludeSystems:["UniqueEntitySystem","StoreRegistrationSystem"]});export{r as default};
2
+ //# sourceMappingURL=mud.config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mud.config.js","sources":["../mud.config.ts"],"sourcesContent":["import { mudConfig } from \"@latticexyz/config\";\n\nexport default mudConfig({\n worldImportPath: \"../\",\n worldgenDirectory: \"interfaces\",\n worldInterfaceName: \"IBaseWorld\",\n codegenDirectory: \"\",\n tables: {\n /************************************************************************\n *\n * CORE TABLES\n *\n ************************************************************************/\n NamespaceOwner: {\n primaryKeys: {\n namespace: \"bytes16\",\n },\n schema: {\n owner: \"address\",\n },\n },\n ResourceAccess: {\n primaryKeys: {\n resourceSelector: \"bytes32\",\n caller: \"address\",\n },\n schema: {\n access: \"bool\",\n },\n },\n InstalledModules: {\n primaryKeys: {\n moduleName: \"bytes16\",\n argumentsHash: \"bytes32\", // Hash of the params passed to the `install` function\n },\n schema: {\n moduleAddress: \"address\",\n },\n // TODO: this is a workaround to use `getRecord` instead of `getField` in the autogen library,\n // to allow using the table before it is registered. This is because `getRecord` passes the schema\n // to store, while `getField` loads it from storage. Remove this once we have support for passing the\n // schema in `getField` too. (See https://github.com/latticexyz/mud/issues/444)\n dataStruct: true,\n },\n /************************************************************************\n *\n * MODULE TABLES\n *\n ************************************************************************/\n Systems: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n resourceSelector: \"bytes32\",\n },\n schema: {\n system: \"address\",\n publicAccess: \"bool\",\n },\n dataStruct: false,\n },\n SystemRegistry: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n system: \"address\",\n },\n schema: {\n resourceSelector: \"bytes32\",\n },\n },\n ResourceType: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n resourceSelector: \"bytes32\",\n },\n schema: {\n resourceType: \"Resource\",\n },\n },\n FunctionSelectors: {\n directory: \"modules/core/tables\",\n name: \"funcSelectors\",\n primaryKeys: {\n functionSelector: \"bytes4\",\n },\n schema: {\n namespace: \"bytes16\",\n name: \"bytes16\",\n systemFunctionSelector: \"bytes4\",\n },\n dataStruct: false,\n },\n KeysWithValue: {\n directory: \"modules/keyswithvalue/tables\",\n primaryKeys: {\n valueHash: \"bytes32\",\n },\n schema: {\n keysWithValue: \"bytes32[]\", // For now only supports 1 key per value\n },\n tableIdArgument: true,\n },\n UniqueEntity: {\n directory: \"modules/uniqueentity/tables\",\n primaryKeys: {},\n schema: \"uint256\",\n tableIdArgument: true,\n storeArgument: true,\n },\n /************************************************************************\n *\n * TEST TABLES\n *\n ************************************************************************/\n Bool: {\n directory: \"../test/tables\",\n primaryKeys: {},\n schema: {\n value: \"bool\",\n },\n tableIdArgument: true,\n },\n AddressArray: {\n directory: \"../test/tables\",\n schema: \"address[]\",\n tableIdArgument: true,\n },\n },\n enums: {\n Resource: [\"NONE\", \"NAMESPACE\", \"TABLE\", \"SYSTEM\"],\n },\n\n excludeSystems: [\n // IUniqueEntitySystem is not part of the root namespace and\n // installed separately by UniqueEntityModule.\n // TODO: Move optional modules into a separate package\n // (see https://github.com/latticexyz/mud/pull/584)\n \"UniqueEntitySystem\",\n\n // Worldgen currently does not support systems inheriting logic\n // from other contracts, so all parts of CoreSystem are named\n // System too to be included in the IBaseWorld interface.\n // However, IStoreRegistrationSystem overlaps with IStore if\n // included in IBaseWorld, so it needs to be excluded from worldgen.\n // TODO: add support for inheritance to worldgen\n // (see: https://github.com/latticexyz/mud/issues/631)\n \"StoreRegistrationSystem\",\n ],\n});\n"],"names":["mud_config","mudConfig"],"mappings":";AAEA,MAAAA,IAAeC,EAAU;AAAA,EACvB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMN,gBAAgB;AAAA,MACd,aAAa;AAAA,QACX,WAAW;AAAA,MACb;AAAA,MACA,QAAQ;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,gBAAgB;AAAA,MACd,aAAa;AAAA,QACX,kBAAkB;AAAA,QAClB,QAAQ;AAAA,MACV;AAAA,MACA,QAAQ;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,kBAAkB;AAAA,MAChB,aAAa;AAAA,QACX,YAAY;AAAA,QACZ,eAAe;AAAA;AAAA,MACjB;AAAA,MACA,QAAQ;AAAA,QACN,eAAe;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA,MAKA,YAAY;AAAA,IACd;AAAA;AAAA;AAAA;AAAA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A,EACA,OAAO;AAAA,IACL,UAAU,CAAC,QAAQ,aAAa,SAAS,QAAQ;AAAA,EACnD;AAAA,EAEA,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA;AAAA,EACF;AACF,CAAC;"}
1
+ {"version":3,"sources":["../mud.config.ts"],"sourcesContent":["import { mudConfig } from \"@latticexyz/config\";\n\nexport default mudConfig({\n worldImportPath: \"../\",\n worldgenDirectory: \"interfaces\",\n worldInterfaceName: \"IBaseWorld\",\n codegenDirectory: \"\",\n tables: {\n /************************************************************************\n *\n * CORE TABLES\n *\n ************************************************************************/\n NamespaceOwner: {\n primaryKeys: {\n namespace: \"bytes16\",\n },\n schema: {\n owner: \"address\",\n },\n },\n ResourceAccess: {\n primaryKeys: {\n resourceSelector: \"bytes32\",\n caller: \"address\",\n },\n schema: {\n access: \"bool\",\n },\n },\n InstalledModules: {\n primaryKeys: {\n moduleName: \"bytes16\",\n argumentsHash: \"bytes32\", // Hash of the params passed to the `install` function\n },\n schema: {\n moduleAddress: \"address\",\n },\n // TODO: this is a workaround to use `getRecord` instead of `getField` in the autogen library,\n // to allow using the table before it is registered. This is because `getRecord` passes the schema\n // to store, while `getField` loads it from storage. Remove this once we have support for passing the\n // schema in `getField` too. (See https://github.com/latticexyz/mud/issues/444)\n dataStruct: true,\n },\n /************************************************************************\n *\n * MODULE TABLES\n *\n ************************************************************************/\n Systems: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n resourceSelector: \"bytes32\",\n },\n schema: {\n system: \"address\",\n publicAccess: \"bool\",\n },\n dataStruct: false,\n },\n SystemRegistry: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n system: \"address\",\n },\n schema: {\n resourceSelector: \"bytes32\",\n },\n },\n ResourceType: {\n directory: \"modules/core/tables\",\n primaryKeys: {\n resourceSelector: \"bytes32\",\n },\n schema: {\n resourceType: \"Resource\",\n },\n },\n FunctionSelectors: {\n directory: \"modules/core/tables\",\n name: \"funcSelectors\",\n primaryKeys: {\n functionSelector: \"bytes4\",\n },\n schema: {\n namespace: \"bytes16\",\n name: \"bytes16\",\n systemFunctionSelector: \"bytes4\",\n },\n dataStruct: false,\n },\n KeysWithValue: {\n directory: \"modules/keyswithvalue/tables\",\n primaryKeys: {\n valueHash: \"bytes32\",\n },\n schema: {\n keysWithValue: \"bytes32[]\", // For now only supports 1 key per value\n },\n tableIdArgument: true,\n },\n UniqueEntity: {\n directory: \"modules/uniqueentity/tables\",\n primaryKeys: {},\n schema: \"uint256\",\n tableIdArgument: true,\n storeArgument: true,\n },\n /************************************************************************\n *\n * TEST TABLES\n *\n ************************************************************************/\n Bool: {\n directory: \"../test/tables\",\n primaryKeys: {},\n schema: {\n value: \"bool\",\n },\n tableIdArgument: true,\n },\n AddressArray: {\n directory: \"../test/tables\",\n schema: \"address[]\",\n tableIdArgument: true,\n },\n },\n enums: {\n Resource: [\"NONE\", \"NAMESPACE\", \"TABLE\", \"SYSTEM\"],\n },\n\n excludeSystems: [\n // IUniqueEntitySystem is not part of the root namespace and\n // installed separately by UniqueEntityModule.\n // TODO: Move optional modules into a separate package\n // (see https://github.com/latticexyz/mud/pull/584)\n \"UniqueEntitySystem\",\n\n // Worldgen currently does not support systems inheriting logic\n // from other contracts, so all parts of CoreSystem are named\n // System too to be included in the IBaseWorld interface.\n // However, IStoreRegistrationSystem overlaps with IStore if\n // included in IBaseWorld, so it needs to be excluded from worldgen.\n // TODO: add support for inheritance to worldgen\n // (see: https://github.com/latticexyz/mud/issues/631)\n \"StoreRegistrationSystem\",\n ],\n});\n"],"mappings":"AAAA,OAAS,aAAAA,MAAiB,qBAE1B,IAAOC,EAAQD,EAAU,CACvB,gBAAiB,MACjB,kBAAmB,aACnB,mBAAoB,aACpB,iBAAkB,GAClB,OAAQ,CAMN,eAAgB,CACd,YAAa,CACX,UAAW,SACb,EACA,OAAQ,CACN,MAAO,SACT,CACF,EACA,eAAgB,CACd,YAAa,CACX,iBAAkB,UAClB,OAAQ,SACV,EACA,OAAQ,CACN,OAAQ,MACV,CACF,EACA,iBAAkB,CAChB,YAAa,CACX,WAAY,UACZ,cAAe,SACjB,EACA,OAAQ,CACN,cAAe,SACjB,EAKA,WAAY,EACd,EAMA,QAAS,CACP,UAAW,sBACX,YAAa,CACX,iBAAkB,SACpB,EACA,OAAQ,CACN,OAAQ,UACR,aAAc,MAChB,EACA,WAAY,EACd,EACA,eAAgB,CACd,UAAW,sBACX,YAAa,CACX,OAAQ,SACV,EACA,OAAQ,CACN,iBAAkB,SACpB,CACF,EACA,aAAc,CACZ,UAAW,sBACX,YAAa,CACX,iBAAkB,SACpB,EACA,OAAQ,CACN,aAAc,UAChB,CACF,EACA,kBAAmB,CACjB,UAAW,sBACX,KAAM,gBACN,YAAa,CACX,iBAAkB,QACpB,EACA,OAAQ,CACN,UAAW,UACX,KAAM,UACN,uBAAwB,QAC1B,EACA,WAAY,EACd,EACA,cAAe,CACb,UAAW,+BACX,YAAa,CACX,UAAW,SACb,EACA,OAAQ,CACN,cAAe,WACjB,EACA,gBAAiB,EACnB,EACA,aAAc,CACZ,UAAW,8BACX,YAAa,CAAC,EACd,OAAQ,UACR,gBAAiB,GACjB,cAAe,EACjB,EAMA,KAAM,CACJ,UAAW,iBACX,YAAa,CAAC,EACd,OAAQ,CACN,MAAO,MACT,EACA,gBAAiB,EACnB,EACA,aAAc,CACZ,UAAW,iBACX,OAAQ,YACR,gBAAiB,EACnB,CACF,EACA,MAAO,CACL,SAAU,CAAC,OAAQ,YAAa,QAAS,QAAQ,CACnD,EAEA,eAAgB,CAKd,qBASA,yBACF,CACF,CAAC","names":["mudConfig","mud_config_default"]}
@@ -0,0 +1,28 @@
1
+ import{renderArguments as l,renderList as W,renderedSolidityHeader as w,renderRelativeImports as R}from"@latticexyz/common/codegen";function c(e){let{imports:o,name:a,functionPrefix:r,functions:s}=e;return`${w}
2
+
3
+ ${R(o)}
4
+
5
+ interface ${a} {
6
+ ${W(s,({name:n,parameters:m,stateMutability:i,returnParameters:t})=>`
7
+ function ${r}${n}(
8
+ ${l(m)}
9
+ ) external ${i} ${D(t)};
10
+ `)}
11
+ }
12
+
13
+ `}function D(e){return e.length>0?`returns (${l(e)})`:""}import{renderArguments as O,renderedSolidityHeader as g,renderImports as N,renderRelativeImports as j}from"@latticexyz/common/codegen";function f(e){let{interfaceName:o,storeImportPath:a,worldImportPath:r,imports:s}=e,n=o==="IBaseWorld"?[{symbol:"IStore",path:`${a}IStore.sol`},{symbol:"IWorldKernel",path:`${r}interfaces/IWorldKernel.sol`}]:[{symbol:"IBaseWorld",path:`${r}interfaces/IBaseWorld.sol`}],m=[...n,...s].map(({symbol:i})=>i);return`${g}
14
+
15
+ ${N(n)}
16
+
17
+ ${j(s)}
18
+
19
+ /**
20
+ * The ${o} interface includes all systems dynamically added to the World
21
+ * during the deploy process.
22
+ */
23
+ interface ${o} is ${O(m)} {
24
+
25
+ }
26
+
27
+ `}import{readFileSync as v}from"fs";import d from"path";import{formatAndWriteSolidity as u,contractToInterface as B}from"@latticexyz/common/codegen";async function k(e,o,a){let r=d.join(a,e.worldgenDirectory),s=o.filter(({basename:t})=>Object.keys(e.systems).includes(t)),n=[];for(let t of s){let y=v(t.path,"utf8"),{functions:I,symbols:h}=B(y,t.basename),$=h.map(S=>({symbol:S,fromPath:t.path,usedInPath:r})),p=`I${t.basename}`,{name:P}=e.systems[t.basename],b=c({name:p,functionPrefix:e.namespace===""?"":`${e.namespace}_${P}_`,functions:I,imports:$}),x=d.join(r,p+".sol");await u(b,x,"Generated system interface"),n.push({symbol:p,fromPath:`${p}.sol`,usedInPath:"./"})}let m=f({interfaceName:e.worldInterfaceName,imports:n,storeImportPath:e.storeImportPath,worldImportPath:e.worldImportPath}),i=d.join(r,e.worldInterfaceName+".sol");await u(m,i,"Generated system interface")}export{c as renderSystemInterface,f as renderWorld,k as worldgen};
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../ts/render-solidity/renderSystemInterface.ts","../../ts/render-solidity/renderWorld.ts","../../ts/render-solidity/worldgen.ts"],"sourcesContent":["import { renderArguments, renderList, renderedSolidityHeader, renderRelativeImports } from \"@latticexyz/common/codegen\";\nimport { RenderSystemInterfaceOptions } from \"./types.js\";\n\nexport function renderSystemInterface(options: RenderSystemInterfaceOptions) {\n const { imports, name, functionPrefix, functions } = options;\n\n return `${renderedSolidityHeader}\n\n${renderRelativeImports(imports)}\n\ninterface ${name} {\n ${renderList(\n functions,\n ({ name, parameters, stateMutability, returnParameters }) => `\n function ${functionPrefix}${name}(\n ${renderArguments(parameters)}\n ) external ${stateMutability} ${renderReturnParameters(returnParameters)};\n `\n )}\n}\n\n`;\n}\n\nfunction renderReturnParameters(returnParameters: string[]) {\n if (returnParameters.length > 0) {\n return `returns (${renderArguments(returnParameters)})`;\n } else {\n return \"\";\n }\n}\n","import {\n renderArguments,\n renderedSolidityHeader,\n renderImports,\n renderRelativeImports,\n type ImportDatum,\n} from \"@latticexyz/common/codegen\";\nimport type { RenderWorldOptions } from \"./types\";\n\nexport function renderWorld(options: RenderWorldOptions) {\n const { interfaceName, storeImportPath, worldImportPath, imports } = options;\n const baseImports: ImportDatum[] =\n interfaceName === \"IBaseWorld\"\n ? [\n { symbol: \"IStore\", path: `${storeImportPath}IStore.sol` },\n { symbol: \"IWorldKernel\", path: `${worldImportPath}interfaces/IWorldKernel.sol` },\n ]\n : [\n {\n symbol: \"IBaseWorld\",\n path: `${worldImportPath}interfaces/IBaseWorld.sol`,\n },\n ];\n const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol);\n\n return `${renderedSolidityHeader}\n\n${renderImports(baseImports)}\n\n${renderRelativeImports(imports)}\n\n/**\n * The ${interfaceName} interface includes all systems dynamically added to the World\n * during the deploy process.\n */\ninterface ${interfaceName} is ${renderArguments(importSymbols)} {\n\n}\n\n`;\n}\n","import { readFileSync } from \"fs\";\nimport path from \"path\";\nimport { MUDConfig } from \"@latticexyz/config\";\nimport { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from \"@latticexyz/common/codegen\";\nimport { renderSystemInterface } from \"./renderSystemInterface.js\";\nimport { renderWorld } from \"./renderWorld.js\";\n\nexport async function worldgen(\n config: MUDConfig,\n existingContracts: { path: string; basename: string }[],\n outputBaseDirectory: string\n) {\n const worldgenBaseDirectory = path.join(outputBaseDirectory, config.worldgenDirectory);\n const systems = existingContracts.filter(({ basename }) => Object.keys(config.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, symbols } = contractToInterface(data, system.basename);\n const imports = symbols.map((symbol) => ({\n symbol,\n fromPath: system.path,\n usedInPath: worldgenBaseDirectory,\n }));\n const systemInterfaceName = `I${system.basename}`;\n // create an interface using the external functions and imports\n const { name } = config.systems[system.basename];\n const output = renderSystemInterface({\n name: systemInterfaceName,\n functionPrefix: config.namespace === \"\" ? \"\" : `${config.namespace}_${name}_`,\n functions,\n imports,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, systemInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n\n // prepare imports for IWorld\n systemInterfaceImports.push({\n symbol: systemInterfaceName,\n fromPath: `${systemInterfaceName}.sol`,\n usedInPath: \"./\",\n });\n }\n\n // render IWorld\n const output = renderWorld({\n interfaceName: config.worldInterfaceName,\n imports: systemInterfaceImports,\n storeImportPath: config.storeImportPath,\n worldImportPath: config.worldImportPath,\n });\n // write to file\n const fullOutputPath = path.join(worldgenBaseDirectory, config.worldInterfaceName + \".sol\");\n await formatAndWriteSolidity(output, fullOutputPath, \"Generated system interface\");\n}\n"],"mappings":"AAAA,OAAS,mBAAAA,EAAiB,cAAAC,EAAY,0BAAAC,EAAwB,yBAAAC,MAA6B,6BAGpF,SAASC,EAAsBC,EAAuC,CAC3E,GAAM,CAAE,QAAAC,EAAS,KAAAC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C,EAAwBC,EAAK,KAAKF,EAAqBF,EAAO,iBAAiB,EAC/EK,EAAUJ,EAAkB,OAAO,CAAC,CAAE,SAAAK,CAAS,IAAM,OAAO,KAAKN,EAAO,OAAO,EAAE,SAASM,CAAQ,CAAC,EAEnGC,EAAgD,CAAC,EACvD,QAAWC,KAAUH,EAAS,CAC5B,IAAMI,EAAOC,EAAaF,EAAO,KAAM,MAAM,EAEvC,CAAE,UAAAG,EAAW,QAAAC,CAAQ,EAAIC,EAAoBJ,EAAMD,EAAO,QAAQ,EAClEM,EAAUF,EAAQ,IAAKG,IAAY,CACvC,OAAAA,EACA,SAAUP,EAAO,KACjB,WAAYL,CACd,EAAE,EACIa,EAAsB,IAAIR,EAAO,WAEjC,CAAE,KAAAS,CAAK,EAAIjB,EAAO,QAAQQ,EAAO,QAAQ,EACzCU,EAASC,EAAsB,CACnC,KAAMH,EACN,eAAgBhB,EAAO,YAAc,GAAK,GAAK,GAAGA,EAAO,aAAaiB,KACtE,UAAAN,EACA,QAAAG,CACF,CAAC,EAEKM,EAAiBhB,EAAK,KAAKD,EAAuBa,EAAsB,MAAM,EACpF,MAAMK,EAAuBH,EAAQE,EAAgB,4BAA4B,EAGjFb,EAAuB,KAAK,CAC1B,OAAQS,EACR,SAAU,GAAGA,QACb,WAAY,IACd,CAAC,EAIH,IAAME,EAASI,EAAY,CACzB,cAAetB,EAAO,mBACtB,QAASO,EACT,gBAAiBP,EAAO,gBACxB,gBAAiBA,EAAO,eAC1B,CAAC,EAEKoB,EAAiBhB,EAAK,KAAKD,EAAuBH,EAAO,mBAAqB,MAAM,EAC1F,MAAMqB,EAAuBH,EAAQE,EAAgB,4BAA4B,CACnF","names":["renderArguments","renderList","renderedSolidityHeader","renderRelativeImports","renderSystemInterface","options","imports","name","functionPrefix","functions","parameters","stateMutability","returnParameters","renderReturnParameters","renderArguments","renderedSolidityHeader","renderImports","renderRelativeImports","renderWorld","options","interfaceName","storeImportPath","worldImportPath","imports","baseImports","importSymbols","symbol","readFileSync","path","formatAndWriteSolidity","contractToInterface","worldgen","config","existingContracts","outputBaseDirectory","worldgenBaseDirectory","path","systems","basename","systemInterfaceImports","system","data","readFileSync","functions","symbols","contractToInterface","imports","symbol","systemInterfaceName","name","output","renderSystemInterface","fullOutputPath","formatAndWriteSolidity","renderWorld"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/world",
3
- "version": "2.0.0-alpha.1.22+2f59f2a8",
3
+ "version": "2.0.0-alpha.1.23+9fca0c94",
4
4
  "description": "World framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "license": "MIT",
11
11
  "type": "module",
12
12
  "exports": {
13
- ".": "./dist/index.js",
13
+ ".": "./dist/ts/index.js",
14
14
  "./mud.config.js": "./dist/mud.config.js",
15
15
  "./abi/*": "./abi/*"
16
16
  },
@@ -19,7 +19,7 @@
19
19
  "build": "pnpm run build:codegen && pnpm run build:abi && pnpm run build:typechain && pnpm run build:js",
20
20
  "build:abi": "forge build --out abi --skip test script",
21
21
  "build:codegen": "tsx ./ts/scripts/tablegen.ts && tsx ./ts/scripts/worldgen.ts",
22
- "build:js": "vite build",
22
+ "build:js": "tsup",
23
23
  "build:typechain": "typechain --target ethers-v5 'abi/**/*.sol/!(*.abi).json'",
24
24
  "clean": "pnpm run clean:abi && pnpm run clean:typechain && pnpm run clean:js",
25
25
  "clean:abi": "rimraf abi",
@@ -34,46 +34,32 @@
34
34
  "test:typescript": "tsc --noEmit"
35
35
  },
36
36
  "dependencies": {
37
- "@solidity-parser/parser": "^0.16.0"
38
- },
39
- "devDependencies": {
40
37
  "@ethersproject/abi": "^5.7.0",
41
38
  "@ethersproject/providers": "^5.7.2",
42
- "@latticexyz/common": "2.0.0-alpha.1.22+2f59f2a8",
43
- "@latticexyz/config": "2.0.0-alpha.1.22+2f59f2a8",
44
- "@latticexyz/schema-type": "2.0.0-alpha.1.22+2f59f2a8",
45
- "@latticexyz/store": "2.0.0-alpha.1.22+2f59f2a8",
39
+ "@latticexyz/common": "2.0.0-alpha.1.23+9fca0c94",
40
+ "@latticexyz/config": "2.0.0-alpha.1.23+9fca0c94",
41
+ "@latticexyz/schema-type": "2.0.0-alpha.1.23+9fca0c94",
42
+ "@latticexyz/store": "2.0.0-alpha.1.23+9fca0c94",
43
+ "ethers": "^5.7.2"
44
+ },
45
+ "devDependencies": {
46
46
  "@typechain/ethers-v5": "^10.2.0",
47
47
  "@types/ejs": "^3.1.1",
48
48
  "@types/glob": "^7.2.0",
49
49
  "@types/mocha": "^9.1.1",
50
50
  "@types/node": "^18.15.11",
51
- "@types/rollup-plugin-peer-deps-external": "^2.2.1",
52
51
  "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084",
53
52
  "ejs": "^3.1.8",
54
- "ethers": "^5.7.2",
55
53
  "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3",
56
54
  "glob": "^8.0.3",
57
55
  "hardhat": "^2.10.1",
58
56
  "rimraf": "^3.0.2",
59
- "rollup-plugin-peer-deps-external": "^2.2.4",
60
57
  "solhint": "^3.3.7",
61
58
  "solidity-docgen": "^0.6.0-beta.22",
59
+ "tsup": "^6.7.0",
62
60
  "tsx": "^3.12.6",
63
61
  "typechain": "^8.1.1",
64
- "typedoc": "^0.23.10",
65
- "vite": "^4.3.0",
66
- "vitest": "^0.30.1"
67
- },
68
- "peerDependencies": {
69
- "@ethersproject/abi": "^5.7.0",
70
- "@ethersproject/providers": "^5.7.2",
71
- "@latticexyz/config": "latest",
72
- "@latticexyz/schema-type": "latest",
73
- "@latticexyz/store": "latest",
74
- "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084",
75
- "ethers": "^5.7.2",
76
- "forge-std": "https://github.com/foundry-rs/forge-std.git#b4f121555729b3afb3c5ffccb62ff4b6e2818fd3"
62
+ "typedoc": "^0.23.10"
77
63
  },
78
- "gitHead": "2f59f2a8c127fef3154e28d672f53ec96939a912"
64
+ "gitHead": "9fca0c9432f2690c0bae39f5fc0818a8e1d22554"
79
65
  }