@latticexyz/world 2.2.21-f4db683f90214b03bb8d68635a3825cc9bf58263 → 2.2.22-01a4d064e5fd8e579d54bb3aa8997f225c6960d3
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-6KRKTNJ5.js → chunk-WKPUHKX4.js} +2 -1
- package/dist/{chunk-6KRKTNJ5.js.map → chunk-WKPUHKX4.js.map} +1 -1
- package/dist/internal.d.ts +16 -2
- package/dist/internal.js +114 -46
- package/dist/internal.js.map +1 -1
- package/dist/mud.config.js +1 -1
- package/dist/node.js +68 -43
- package/dist/node.js.map +1 -1
- package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
- package/out/AccessManagementSystemLib.sol/AccessManagementSystemLib.json +1 -1
- package/out/AccessManagementSystemLib.sol/_grantAccess_ResourceId_address.json +1 -1
- package/out/AccessManagementSystemLib.sol/_renounceOwnership_ResourceId.json +1 -1
- package/out/AccessManagementSystemLib.sol/_revokeAccess_ResourceId_address.json +1 -1
- package/out/AccessManagementSystemLib.sol/_transferOwnership_ResourceId_address.json +1 -1
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
- package/out/BalanceTransferSystemLib.sol/BalanceTransferSystemLib.json +1 -1
- package/out/BalanceTransferSystemLib.sol/_transferBalanceToAddress_ResourceId_address_uint256.json +1 -1
- package/out/BalanceTransferSystemLib.sol/_transferBalanceToNamespace_ResourceId_ResourceId_uint256.json +1 -1
- package/out/BatchCall.t.sol/BatchCallTest.json +1 -1
- package/out/BatchCall.t.sol/TestSystem.json +1 -1
- package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
- package/out/BatchCallSystemLib.sol/BatchCallSystemLib.json +1 -1
- package/out/BatchCallSystemLib.sol/_batchCallFrom_SystemCallFromDataArray.json +1 -1
- package/out/BatchCallSystemLib.sol/_batchCall_SystemCallDataArray.json +1 -1
- package/out/DelegationControl.sol/DelegationControl.json +1 -1
- package/out/DelegationControlMock.sol/DelegationControlMock.json +1 -1
- package/out/Factories.t.sol/FactoriesTest.json +1 -1
- package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
- package/out/InitModule.sol/InitModule.json +1 -1
- package/out/InitModule.t.sol/InitModuleTest.json +1 -1
- package/out/InitModule.t.sol/WorldMock.json +1 -1
- package/out/InitSystems.t.sol/LimitedCallContextTest.json +1 -1
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
- package/out/ModuleInstallationSystemLib.sol/ModuleInstallationSystemLib.json +1 -1
- package/out/ModuleInstallationSystemLib.sol/_installModule_IModule_bytes.json +1 -1
- package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
- package/out/RegistrationSystemLib.sol/RegistrationSystemLib.json +1 -1
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/StoreRegistrationSystemLib.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_registerStoreHook_ResourceId_IStoreHook_uint8.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_registerTable_ResourceId_FieldLayout_Schema_Schema_stringArray_stringArray.json +1 -1
- package/out/StoreRegistrationSystemLib.sol/_unregisterStoreHook_ResourceId_IStoreHook.json +1 -1
- package/out/System.sol/System.json +1 -1
- package/out/System.t.sol/SystemTest.json +1 -1
- package/out/System.t.sol/TestSystem.json +1 -1
- package/out/Utils.t.sol/UtilsTest.json +1 -1
- package/out/Utils.t.sol/UtilsTestSystem.json +1 -1
- package/out/World.t.sol/EchoSystemHook.json +1 -1
- package/out/World.t.sol/IWorldTestSystem.json +1 -1
- package/out/World.t.sol/PayableFallbackSystem.json +1 -1
- package/out/World.t.sol/RevertSystemHook.json +1 -1
- package/out/World.t.sol/WorldTest.json +1 -1
- package/out/World.t.sol/WorldTestSystem.json +1 -1
- package/out/WorldBalance.t.sol/WorldBalanceTest.json +1 -1
- package/out/WorldBalance.t.sol/WorldBalanceTestSystem.json +1 -1
- package/out/WorldDynamicUpdate.t.sol/UpdateInDynamicFieldTest.json +1 -1
- package/out/WorldFactory.sol/WorldFactory.json +1 -1
- package/out/WorldProxy.sol/WorldProxy.json +1 -1
- package/out/WorldProxy.t.sol/WorldProxyTest.json +1 -1
- package/out/WorldProxyFactory.sol/WorldProxyFactory.json +1 -1
- package/out/WorldProxyFactory.t.sol/WorldProxyFactoryTest.json +1 -1
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/WorldRegistrationSystemLib.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerDelegation_address_ResourceId_bytes.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerFunctionSelector_ResourceId_string.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerNamespaceDelegation_ResourceId_ResourceId_bytes.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerNamespace_ResourceId.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerRootFunctionSelector_ResourceId_string_string.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerSystemHook_ResourceId_ISystemHook_uint8.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_registerSystem_ResourceId_System_bool.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterDelegation_address.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterNamespaceDelegation_ResourceId.json +1 -1
- package/out/WorldRegistrationSystemLib.sol/_unregisterSystemHook_ResourceId_ISystemHook.json +1 -1
- package/out/build-info/{6366a746548e984842b93ef762b76b99.json → bf27acd14b2b959864c0abf4ffaa7965.json} +1 -1
- package/package.json +9 -9
- package/src/System.sol +1 -1
package/dist/node.js
CHANGED
@@ -258,6 +258,7 @@ import {
|
|
258
258
|
renderedSolidityHeader as renderedSolidityHeader2,
|
259
259
|
renderImports as renderImports2
|
260
260
|
} from "@latticexyz/common/codegen";
|
261
|
+
import { stringToHex } from "viem";
|
261
262
|
function renderSystemLibrary(options) {
|
262
263
|
const {
|
263
264
|
imports: systemImports,
|
@@ -266,11 +267,18 @@ function renderSystemLibrary(options) {
|
|
266
267
|
systemName,
|
267
268
|
namespace,
|
268
269
|
resourceId,
|
269
|
-
functions,
|
270
|
+
functions: functionsInput,
|
270
271
|
errors: systemErrors,
|
271
272
|
worldImportPath,
|
272
273
|
storeImportPath
|
273
274
|
} = options;
|
275
|
+
const functions = functionsInput.map((func) => ({
|
276
|
+
...func,
|
277
|
+
// Format parameters (add auxiliary argument names, replace calldata location)
|
278
|
+
parameters: formatParams(func.parameters),
|
279
|
+
// Remove `payable` from stateMutability for library functions
|
280
|
+
stateMutability: func.stateMutability.replace("payable", "")
|
281
|
+
}));
|
274
282
|
const imports = [
|
275
283
|
...systemImports,
|
276
284
|
{
|
@@ -390,7 +398,7 @@ function renderErrors(errors) {
|
|
390
398
|
}
|
391
399
|
function renderUserTypeFunction(contractFunction, userTypeName) {
|
392
400
|
const { name, parameters, stateMutability, returnParameters } = contractFunction;
|
393
|
-
const args = [`${userTypeName} self`, ...parameters]
|
401
|
+
const args = [`${userTypeName} self`, ...parameters];
|
394
402
|
const functionSignature = `
|
395
403
|
function ${name}(
|
396
404
|
${renderArguments2(args)}
|
@@ -407,7 +415,7 @@ function renderUserTypeFunction(contractFunction, userTypeName) {
|
|
407
415
|
}
|
408
416
|
function renderCallWrapperFunction(contractFunction, callingFromRootSystemErrorName) {
|
409
417
|
const { name, parameters, stateMutability, returnParameters } = contractFunction;
|
410
|
-
const args = [`CallWrapper memory self`, ...parameters]
|
418
|
+
const args = [`CallWrapper memory self`, ...parameters];
|
411
419
|
const functionSignature = `
|
412
420
|
function ${name}(
|
413
421
|
${renderArguments2(args)}
|
@@ -451,7 +459,7 @@ function renderRootCallWrapperFunction(contractFunction, namespace) {
|
|
451
459
|
if (namespace === "" && stateMutability != "") {
|
452
460
|
return "";
|
453
461
|
}
|
454
|
-
const args = ["RootCallWrapper memory self", ...parameters]
|
462
|
+
const args = ["RootCallWrapper memory self", ...parameters];
|
455
463
|
const functionSignature = `
|
456
464
|
function ${name}(
|
457
465
|
${renderArguments2(args)}
|
@@ -492,7 +500,7 @@ function renderFunctionInterface(contractFunction) {
|
|
492
500
|
}
|
493
501
|
function functionInterfaceName(contractFunction) {
|
494
502
|
const { name, parameters } = contractFunction;
|
495
|
-
const paramTypes = parameters.map((param) => param.split(" ")[0]).map((type5) => type5.replace("[]", "Array")).join("_");
|
503
|
+
const paramTypes = parameters.map((param) => param.split(" ")[0]).map((type5) => type5.replace("[]", "Array")).map((type5) => type5.replace(/\[.+\]/, (match2) => stringToHex(match2))).join("_");
|
496
504
|
return `_${name}${paramTypes.length === 0 ? "" : `_${paramTypes}`}`;
|
497
505
|
}
|
498
506
|
function renderEncodeSystemCall(contractFunction) {
|
@@ -512,6 +520,14 @@ function renderReturnParameters2(returnParameters) {
|
|
512
520
|
if (returnParameters.length == 0) return "";
|
513
521
|
return `returns (${renderArguments2(returnParameters)})`;
|
514
522
|
}
|
523
|
+
function formatParams(params) {
|
524
|
+
let auxCount = 0;
|
525
|
+
return params.map((arg) => arg.replace(/ calldata /, " memory ")).map((arg) => {
|
526
|
+
const items = arg.split(" ");
|
527
|
+
const needsAux = items.length === 1 || items.length === 2 && items[1] === "memory";
|
528
|
+
return needsAux ? `${arg} __aux${auxCount++}` : arg;
|
529
|
+
});
|
530
|
+
}
|
515
531
|
|
516
532
|
// ts/node/render-solidity/renderWorldInterface.ts
|
517
533
|
import { renderArguments as renderArguments3, renderedSolidityHeader as renderedSolidityHeader3, renderImports as renderImports3 } from "@latticexyz/common/codegen";
|
@@ -553,7 +569,7 @@ function renderWorldInterface({
|
|
553
569
|
}
|
554
570
|
|
555
571
|
// ts/node/render-solidity/worldgen.ts
|
556
|
-
import
|
572
|
+
import fs2 from "node:fs/promises";
|
557
573
|
import path4 from "node:path";
|
558
574
|
import { formatAndWriteSolidity, contractToInterface } from "@latticexyz/common/codegen";
|
559
575
|
|
@@ -562,6 +578,7 @@ import { isHex } from "viem";
|
|
562
578
|
|
563
579
|
// ts/node/getSystemContracts.ts
|
564
580
|
import path3 from "node:path";
|
581
|
+
import fs from "node:fs/promises";
|
565
582
|
|
566
583
|
// ts/node/findSolidityFiles.ts
|
567
584
|
import path2 from "node:path";
|
@@ -5270,8 +5287,8 @@ var PathScurryBase = class {
|
|
5270
5287
|
*
|
5271
5288
|
* @internal
|
5272
5289
|
*/
|
5273
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
5274
|
-
this.#fs = fsFromOption(
|
5290
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
|
5291
|
+
this.#fs = fsFromOption(fs4);
|
5275
5292
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
5276
5293
|
cwd = fileURLToPath(cwd);
|
5277
5294
|
}
|
@@ -5829,8 +5846,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
5829
5846
|
/**
|
5830
5847
|
* @internal
|
5831
5848
|
*/
|
5832
|
-
newRoot(
|
5833
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
5849
|
+
newRoot(fs4) {
|
5850
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
5834
5851
|
}
|
5835
5852
|
/**
|
5836
5853
|
* Return true if the provided path string is an absolute path
|
@@ -5858,8 +5875,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
5858
5875
|
/**
|
5859
5876
|
* @internal
|
5860
5877
|
*/
|
5861
|
-
newRoot(
|
5862
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
5878
|
+
newRoot(fs4) {
|
5879
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
5863
5880
|
}
|
5864
5881
|
/**
|
5865
5882
|
* Return true if the provided path string is an absolute path
|
@@ -6947,19 +6964,25 @@ async function findSolidityFiles({ cwd, pattern = "**" }) {
|
|
6947
6964
|
}
|
6948
6965
|
|
6949
6966
|
// ts/node/getSystemContracts.ts
|
6967
|
+
import { parseSystem } from "@latticexyz/common/codegen";
|
6968
|
+
import { isDefined } from "@latticexyz/common/utils";
|
6950
6969
|
async function getSystemContracts({
|
6951
6970
|
rootDir,
|
6952
6971
|
config
|
6953
6972
|
}) {
|
6954
|
-
const
|
6973
|
+
const filePaths = await findSolidityFiles({
|
6955
6974
|
cwd: rootDir,
|
6956
6975
|
pattern: path3.join(config.sourceDirectory, "**")
|
6957
6976
|
});
|
6958
|
-
|
6959
|
-
(file) =>
|
6960
|
-
|
6961
|
-
|
6962
|
-
|
6977
|
+
const files = await Promise.all(
|
6978
|
+
filePaths.map(async (file) => {
|
6979
|
+
const source = await fs.readFile(path3.join(rootDir, file.filename), "utf-8");
|
6980
|
+
return { ...file, source };
|
6981
|
+
})
|
6982
|
+
);
|
6983
|
+
return files.map((file) => {
|
6984
|
+
const parsedSystem = parseSystem(file.source, file.basename);
|
6985
|
+
if (!parsedSystem) return;
|
6963
6986
|
const namespaceLabel = (() => {
|
6964
6987
|
if (!config.multipleNamespaces && config.namespace != null) return config.namespace;
|
6965
6988
|
const relativePath = path3.relative(path3.join(rootDir, config.sourceDirectory), file.filename);
|
@@ -6976,7 +6999,7 @@ async function getSystemContracts({
|
|
6976
6999
|
namespaceLabel,
|
6977
7000
|
systemLabel: file.basename
|
6978
7001
|
};
|
6979
|
-
});
|
7002
|
+
}).filter(isDefined);
|
6980
7003
|
}
|
6981
7004
|
|
6982
7005
|
// ts/node/resolveSystems.ts
|
@@ -7034,7 +7057,7 @@ async function worldgen({
|
|
7034
7057
|
config.codegen.outputDirectory,
|
7035
7058
|
config.codegen.worldgenDirectory
|
7036
7059
|
);
|
7037
|
-
const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions).map((system) => {
|
7060
|
+
const systems = (await resolveSystems({ rootDir, config })).filter((system) => system.deploy.registerWorldFunctions || config.codegen.generateSystemLibraries).map((system) => {
|
7038
7061
|
const interfaceName = `I${system.label}`;
|
7039
7062
|
const libraryName = `${system.label}Lib`;
|
7040
7063
|
const sourceDir = config.multipleNamespaces ? path4.join(config.sourceDirectory, "namespaces", system.namespaceLabel) : config.sourceDirectory;
|
@@ -7054,12 +7077,12 @@ async function worldgen({
|
|
7054
7077
|
if (clean) {
|
7055
7078
|
const libraryDirs = [...new Set(systems.map(({ libraryPath }) => path4.dirname(libraryPath)))];
|
7056
7079
|
await Promise.all([
|
7057
|
-
|
7058
|
-
...libraryDirs.map((dir) =>
|
7080
|
+
fs2.rm(worldgenOutDir, { recursive: true, force: true }),
|
7081
|
+
...libraryDirs.map((dir) => fs2.rm(dir, { recursive: true, force: true }))
|
7059
7082
|
]);
|
7060
7083
|
}
|
7061
7084
|
const outputPath = path4.join(worldgenOutDir, config.codegen.worldInterfaceName + ".sol");
|
7062
|
-
const worldImports = systems.map(
|
7085
|
+
const worldImports = systems.filter((system) => system.deploy.registerWorldFunctions).map(
|
7063
7086
|
(system) => ({
|
7064
7087
|
symbol: system.interfaceName,
|
7065
7088
|
path: "./" + path4.relative(path4.dirname(outputPath), system.interfacePath)
|
@@ -7069,22 +7092,24 @@ async function worldgen({
|
|
7069
7092
|
const worldImportPath = config.codegen.worldImportPath.startsWith(".") ? "./" + path4.relative(path4.dirname(outputPath), path4.join(rootDir, config.codegen.worldImportPath)) : config.codegen.worldImportPath;
|
7070
7093
|
await Promise.all(
|
7071
7094
|
systems.map(async (system) => {
|
7072
|
-
const source = await
|
7095
|
+
const source = await fs2.readFile(path4.join(rootDir, system.sourcePath), "utf8");
|
7073
7096
|
const { functions, errors, symbolImports } = contractToInterface(source, system.label);
|
7074
|
-
|
7075
|
-
|
7076
|
-
symbol,
|
7077
|
-
|
7078
|
-
|
7079
|
-
|
7080
|
-
|
7081
|
-
|
7082
|
-
|
7083
|
-
|
7084
|
-
|
7085
|
-
|
7086
|
-
|
7087
|
-
|
7097
|
+
if (system.deploy.registerWorldFunctions) {
|
7098
|
+
const interfaceImports = symbolImports.map(
|
7099
|
+
({ symbol, path: importPath }) => ({
|
7100
|
+
symbol,
|
7101
|
+
path: importPath.startsWith(".") ? "./" + path4.relative(worldgenOutDir, path4.join(rootDir, path4.dirname(system.sourcePath), importPath)) : importPath
|
7102
|
+
})
|
7103
|
+
);
|
7104
|
+
const systemInterface = renderSystemInterface({
|
7105
|
+
name: system.interfaceName,
|
7106
|
+
functionPrefix: system.namespace === "" ? "" : `${system.namespace}__`,
|
7107
|
+
functions,
|
7108
|
+
errors,
|
7109
|
+
imports: interfaceImports
|
7110
|
+
});
|
7111
|
+
await formatAndWriteSolidity(systemInterface, system.interfacePath, "Generated system interface");
|
7112
|
+
}
|
7088
7113
|
if (config.codegen.generateSystemLibraries) {
|
7089
7114
|
const systemImport = {
|
7090
7115
|
symbol: system.label,
|
@@ -7129,7 +7154,7 @@ async function worldgen({
|
|
7129
7154
|
import path5 from "node:path";
|
7130
7155
|
import { readFile } from "node:fs/promises";
|
7131
7156
|
import { type as type2 } from "arktype";
|
7132
|
-
import { indent, isDefined } from "@latticexyz/common/utils";
|
7157
|
+
import { indent, isDefined as isDefined2 } from "@latticexyz/common/utils";
|
7133
7158
|
import { size, sliceHex } from "viem";
|
7134
7159
|
|
7135
7160
|
// ts/node/common.ts
|
@@ -7207,7 +7232,7 @@ ${indent(artifact.message)}`);
|
|
7207
7232
|
return;
|
7208
7233
|
}
|
7209
7234
|
return artifact;
|
7210
|
-
}).filter(
|
7235
|
+
}).filter(isDefined2).filter(hasMetadata).map((artifact) => {
|
7211
7236
|
artifact;
|
7212
7237
|
const sourcePath = Object.keys(artifact.metadata.settings.compilationTarget)[0];
|
7213
7238
|
const name = artifact.metadata.settings.compilationTarget[sourcePath];
|
@@ -7316,7 +7341,7 @@ async function buildSystemsManifest(opts) {
|
|
7316
7341
|
}
|
7317
7342
|
|
7318
7343
|
// ts/node/loadSystemsManifest.ts
|
7319
|
-
import
|
7344
|
+
import fs3 from "node:fs/promises";
|
7320
7345
|
import path7 from "node:path";
|
7321
7346
|
import { type as type4 } from "arktype";
|
7322
7347
|
import { indent as indent2 } from "@latticexyz/common/utils";
|
@@ -7324,13 +7349,13 @@ var parseManifest = type4("string").pipe.try((s) => JSON.parse(s), SystemsManife
|
|
7324
7349
|
async function loadSystemsManifest(opts) {
|
7325
7350
|
const outFile = path7.join(opts.rootDir, systemsManifestFilename);
|
7326
7351
|
try {
|
7327
|
-
await
|
7352
|
+
await fs3.access(outFile, fs3.constants.F_OK | fs3.constants.R_OK);
|
7328
7353
|
} catch (error2) {
|
7329
7354
|
throw new Error(
|
7330
7355
|
`Systems manifest at "${systemsManifestFilename}" not found or not readable. Run \`mud build\` before trying again.`
|
7331
7356
|
);
|
7332
7357
|
}
|
7333
|
-
const json = await
|
7358
|
+
const json = await fs3.readFile(outFile, "utf8");
|
7334
7359
|
const manifest = parseManifest(json);
|
7335
7360
|
if (manifest instanceof type4.errors) {
|
7336
7361
|
throw new Error(
|