Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(world): move codegen files #1592

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/curly-countries-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@latticexyz/cli": patch
"@latticexyz/world-modules": patch
"@latticexyz/world": major
---

Tables and interfaces in the `world` package are now generated to the `codegen` folder.
This is only a breaking change if you imported tables or codegenerated interfaces from `@latticexyz/world` directly.
If you're using the MUD CLI, the changed import paths are already integrated and no further changes are necessary.

```diff
- import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
+ import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

```
2 changes: 1 addition & 1 deletion e2e/packages/contracts/src/codegen/world/IWorld.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/world-modules/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ export default mudConfig({
},
},
},
excludeSystems: [],
excludeSystems: ["UniqueEntitySystem"],
});
4 changes: 1 addition & 3 deletions packages/world-modules/src/interfaces/IBaseWorld.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ pragma solidity >=0.8.21;
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { IWorldKernel } from "@latticexyz/world/src/interfaces/IWorldKernel.sol";

import { IUniqueEntitySystem } from "./IUniqueEntitySystem.sol";

/**
* The IBaseWorld interface includes all systems dynamically added to the World
* during the deploy process.
*/
interface IBaseWorld is IStore, IWorldKernel, IUniqueEntitySystem {
interface IBaseWorld is IStore, IWorldKernel {

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

/* Autogenerated file. Do not edit manually. */

// TODO allow overriding namespace per-system (or a separate config for modules?)
interface IUniqueEntitySystem {
function getUniqueEntity() external returns (bytes32);
function uniqueEntity_system_getUniqueEntity() external returns (bytes32 uniqueEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ResourceIds } from "@latticexyz/store/src/codegen/tables/ResourceIds.so

import { Module } from "@latticexyz/world/src/Module.sol";

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { PackedCounter } from "@latticexyz/store/src/PackedCounter.sol";
import { Tables } from "@latticexyz/store/src/codegen/tables/Tables.sol";
import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { BEFORE_SET_RECORD, BEFORE_SPLICE_STATIC_DATA, AFTER_SPLICE_STATIC_DATA, BEFORE_SPLICE_DYNAMIC_DATA, AFTER_SPLICE_DYNAMIC_DATA, BEFORE_DELETE_RECORD } from "@latticexyz/store/src/storeHookTypes.sol";
import { Module } from "@latticexyz/world/src/Module.sol";

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol";
import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { Module } from "@latticexyz/world/src/Module.sol";
import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { Module } from "@latticexyz/world/src/Module.sol";
import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity >=0.8.21;

import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IUniqueEntitySystem } from "@latticexyz/world/src/interfaces/IUniqueEntitySystem.sol";
import { IUniqueEntitySystem } from "../../interfaces/IUniqueEntitySystem.sol";

/**
* Increment and get an entity nonce.
Expand Down
2 changes: 1 addition & 1 deletion packages/world-modules/test/KeysInTableModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SchemaEncodeHelper } from "@latticexyz/store/test/SchemaEncodeHelper.so
import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";

import { World } from "@latticexyz/world/src/World.sol";
import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol";
import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/world-modules/test/KeysWithValueModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
import { FieldLayoutEncodeHelper } from "@latticexyz/store/test/FieldLayoutEncodeHelper.sol";

import { World } from "@latticexyz/world/src/World.sol";
import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { WorldResourceIdLib, WorldResourceIdInstance, NAME_BITS, TYPE_BITS } from "@latticexyz/world/src/WorldResourceId.sol";
import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol";
import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol";
Expand Down
4 changes: 2 additions & 2 deletions packages/world-modules/test/StandardDelegationsModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@lattic
import { System } from "@latticexyz/world/src/System.sol";
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol";

import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { IWorldErrors } from "@latticexyz/world/src/interfaces/IWorldErrors.sol";
import { DELEGATION_CONTROL_INTERFACE_ID } from "@latticexyz/world/src/interfaces/IDelegationControl.sol";

import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol";
import { Systems } from "@latticexyz/world/src/modules/core/tables/Systems.sol";
import { Systems } from "@latticexyz/world/src/codegen/tables/Systems.sol";

import { StandardDelegationsModule } from "../src/modules/std-delegations/StandardDelegationsModule.sol";
import { CallboundDelegationControl } from "../src/modules/std-delegations/CallboundDelegationControl.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/world-modules/test/UniqueEntityModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";

import { World } from "@latticexyz/world/src/World.sol";
import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { IWorldErrors } from "@latticexyz/world/src/interfaces/IWorldErrors.sol";

import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/world-modules/test/query.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { PackedCounter } from "@latticexyz/store/src/PackedCounter.sol";
import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";

import { World } from "@latticexyz/world/src/World.sol";
import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol";
import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol";
Expand Down
9 changes: 1 addition & 8 deletions packages/world/mud.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { mudConfig } from "./ts/register";

export default mudConfig({
worldImportPath: "../",
worldImportPath: "../../",
worldgenDirectory: "interfaces",
worldInterfaceName: "IBaseWorld",
codegenDirectory: "",
userTypes: {
ResourceId: { filePath: "@latticexyz/store/src/ResourceId.sol", internalType: "bytes32" },
},
Expand Down Expand Up @@ -63,7 +62,6 @@ export default mudConfig({
*
************************************************************************/
Balances: {
directory: "modules/core/tables",
keySchema: {
namespaceId: "ResourceId",
},
Expand All @@ -72,7 +70,6 @@ export default mudConfig({
},
},
Systems: {
directory: "modules/core/tables",
keySchema: {
systemId: "ResourceId",
},
Expand All @@ -83,7 +80,6 @@ export default mudConfig({
dataStruct: false,
},
SystemRegistry: {
directory: "modules/core/tables",
keySchema: {
system: "address",
},
Expand All @@ -92,14 +88,12 @@ export default mudConfig({
},
},
SystemHooks: {
directory: "modules/core/tables",
keySchema: {
systemId: "ResourceId",
},
valueSchema: "bytes21[]",
},
FunctionSelectors: {
directory: "modules/core/tables",
keySchema: {
functionSelector: "bytes4",
},
Expand All @@ -110,7 +104,6 @@ export default mudConfig({
dataStruct: false,
},
FunctionSignatures: {
directory: "modules/core/tables",
keySchema: {
functionSelector: "bytes4",
},
Expand Down
4 changes: 2 additions & 2 deletions packages/world/src/AccessControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity >=0.8.21;
import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol";
import { IWorldErrors } from "./interfaces/IWorldErrors.sol";

import { ResourceAccess } from "./tables/ResourceAccess.sol";
import { NamespaceOwner } from "./tables/NamespaceOwner.sol";
import { ResourceAccess } from "./codegen/tables/ResourceAccess.sol";
import { NamespaceOwner } from "./codegen/tables/NamespaceOwner.sol";

library AccessControl {
using WorldResourceIdInstance for ResourceId;
Expand Down
8 changes: 4 additions & 4 deletions packages/world/src/SystemCall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "./systemHookTypes.sol";
import { IWorldErrors } from "./interfaces/IWorldErrors.sol";
import { ISystemHook } from "./interfaces/ISystemHook.sol";

import { FunctionSelectors } from "./modules/core/tables/FunctionSelectors.sol";
import { Systems } from "./modules/core/tables/Systems.sol";
import { SystemHooks } from "./modules/core/tables/SystemHooks.sol";
import { Balances } from "./modules/core/tables/Balances.sol";
import { FunctionSelectors } from "./codegen/tables/FunctionSelectors.sol";
import { Systems } from "./codegen/tables/Systems.sol";
import { SystemHooks } from "./codegen/tables/SystemHooks.sol";
import { Balances } from "./codegen/tables/Balances.sol";

library SystemCall {
using WorldResourceIdInstance for ResourceId;
Expand Down
2 changes: 1 addition & 1 deletion packages/world/src/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.21;

import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol";
import { SystemRegistry } from "./index.sol";
import { SystemRegistry } from "./codegen/tables/SystemRegistry.sol";

library Utils {
using WorldResourceIdInstance for ResourceId;
Expand Down
16 changes: 8 additions & 8 deletions packages/world/src/World.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import { revertWithBytes } from "./revertWithBytes.sol";
import { Delegation } from "./Delegation.sol";
import { requireInterface } from "./requireInterface.sol";

import { NamespaceOwner } from "./tables/NamespaceOwner.sol";
import { InstalledModules } from "./tables/InstalledModules.sol";
import { UserDelegationControl } from "./tables/UserDelegationControl.sol";
import { NamespaceDelegationControl } from "./tables/NamespaceDelegationControl.sol";
import { NamespaceOwner } from "./codegen/tables/NamespaceOwner.sol";
import { InstalledModules } from "./codegen/tables/InstalledModules.sol";
import { UserDelegationControl } from "./codegen/tables/UserDelegationControl.sol";
import { NamespaceDelegationControl } from "./codegen/tables/NamespaceDelegationControl.sol";

import { IModule, MODULE_INTERFACE_ID } from "./interfaces/IModule.sol";
import { IWorldKernel } from "./interfaces/IWorldKernel.sol";
import { IDelegationControl } from "./interfaces/IDelegationControl.sol";

import { Systems } from "./modules/core/tables/Systems.sol";
import { SystemHooks } from "./modules/core/tables/SystemHooks.sol";
import { FunctionSelectors } from "./modules/core/tables/FunctionSelectors.sol";
import { Balances } from "./modules/core/tables/Balances.sol";
import { Systems } from "./codegen/tables/Systems.sol";
import { SystemHooks } from "./codegen/tables/SystemHooks.sol";
import { FunctionSelectors } from "./codegen/tables/FunctionSelectors.sol";
import { Balances } from "./codegen/tables/Balances.sol";
import { CORE_MODULE_NAME } from "./modules/core/constants.sol";

contract World is StoreRead, IStoreData, IWorldKernel {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/world/src/factories/WorldFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.21;
import { Create2 } from "./Create2.sol";
import { World } from "../World.sol";
import { IWorldFactory } from "./IWorldFactory.sol";
import { IBaseWorld } from "../interfaces/IBaseWorld.sol";
import { IBaseWorld } from "../codegen/interfaces/IBaseWorld.sol";
import { IModule } from "../interfaces/IModule.sol";
import { ROOT_NAMESPACE_ID } from "../constants.sol";

Expand Down
7 changes: 0 additions & 7 deletions packages/world/src/interfaces/IUniqueEntitySystem.sol

This file was deleted.

Loading