@latticexyz/world 2.0.0-alpha.1.32 → 2.0.0-alpha.1.34
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/ts/index.js.map
CHANGED
|
@@ -1 +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
|
|
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\";\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\";\nimport { renderWorld } from \"./renderWorld\";\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,EAAM,eAAAC,EAAgB,UAAAC,CAAU,EAAIJ,EAErD,MAAO,GAAGH;AAAA;AAAA,EAEVC,EAAsBG,CAAO;AAAA;AAAA,YAEnBC;AAAA,IACRN,EACAQ,EACA,CAAC,CAAE,KAAAF,EAAM,WAAAG,EAAY,gBAAAC,EAAiB,iBAAAC,CAAiB,IAAM;AAAA,eAClDJ,IAAiBD;AAAA,QACxBP,EAAgBU,CAAU;AAAA,iBACjBC,KAAmBE,EAAuBD,CAAgB;AAAA,GAEzE;AAAA;AAAA;AAAA,CAIF,CAEA,SAASC,EAAuBD,EAA4B,CAC1D,OAAIA,EAAiB,OAAS,EACrB,YAAYZ,EAAgBY,CAAgB,KAE5C,EAEX,CC9BA,OACE,mBAAAE,EACA,0BAAAC,EACA,iBAAAC,EACA,yBAAAC,MAEK,6BAGA,SAASC,EAAYC,EAA6B,CACvD,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,8BAA6C,CAClF,EACA,CACE,CACE,OAAQ,aACR,KAAM,GAAGA,4BACX,CACF,EACAG,EAAgB,CAAC,GAAGD,EAAa,GAAGD,CAA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B,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.
|
|
3
|
+
"version": "2.0.0-alpha.1.34+3d69f92d",
|
|
4
4
|
"description": "World framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ethersproject/abi": "^5.7.0",
|
|
37
37
|
"@ethersproject/providers": "^5.7.2",
|
|
38
|
-
"@latticexyz/common": "2.0.0-alpha.1.
|
|
39
|
-
"@latticexyz/config": "2.0.0-alpha.1.
|
|
40
|
-
"@latticexyz/schema-type": "2.0.0-alpha.1.
|
|
41
|
-
"@latticexyz/store": "2.0.0-alpha.1.
|
|
38
|
+
"@latticexyz/common": "2.0.0-alpha.1.34+3d69f92d",
|
|
39
|
+
"@latticexyz/config": "2.0.0-alpha.1.34+3d69f92d",
|
|
40
|
+
"@latticexyz/schema-type": "2.0.0-alpha.1.34+3d69f92d",
|
|
41
|
+
"@latticexyz/store": "2.0.0-alpha.1.34+3d69f92d",
|
|
42
42
|
"ethers": "^5.7.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"typechain": "^8.1.1",
|
|
61
61
|
"typedoc": "0.23.10"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3d69f92de42f695185a1fedf468694ddef36cc83"
|
|
64
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { renderArguments, renderList, renderedSolidityHeader, renderRelativeImports } from "@latticexyz/common/codegen";
|
|
2
|
-
import { RenderSystemInterfaceOptions } from "./types
|
|
2
|
+
import { RenderSystemInterfaceOptions } from "./types";
|
|
3
3
|
|
|
4
4
|
export function renderSystemInterface(options: RenderSystemInterfaceOptions) {
|
|
5
5
|
const { imports, name, functionPrefix, functions } = options;
|
|
@@ -2,8 +2,8 @@ import { readFileSync } from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { MUDConfig } from "@latticexyz/config";
|
|
4
4
|
import { formatAndWriteSolidity, contractToInterface, type RelativeImportDatum } from "@latticexyz/common/codegen";
|
|
5
|
-
import { renderSystemInterface } from "./renderSystemInterface
|
|
6
|
-
import { renderWorld } from "./renderWorld
|
|
5
|
+
import { renderSystemInterface } from "./renderSystemInterface";
|
|
6
|
+
import { renderWorld } from "./renderWorld";
|
|
7
7
|
|
|
8
8
|
export async function worldgen(
|
|
9
9
|
config: MUDConfig,
|