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

feat(world): move interfaces/factories to root #1606

Merged
merged 3 commits into from
Sep 25, 2023
Merged
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
17 changes: 17 additions & 0 deletions .changeset/beige-badgers-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@latticexyz/world": major
---

Moves World interfaces and factories files for consistency with our other packages.

If you import any World interfaces or factories directly, you'll need to update the import path:

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

```diff
- import { IBaseWorld } from "@latticexyz/world/src/factories/WorldFactory.sol";
+ import { IBaseWorld } from "@latticexyz/world/src/WorldFactory.sol";
```
2 changes: 1 addition & 1 deletion packages/world-modules/src/interfaces/IBaseWorld.sol
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ pragma solidity >=0.8.21;
/* Autogenerated file. Do not edit manually. */

import { IStore } from "@latticexyz/store/src/IStore.sol";
import { IWorldKernel } from "@latticexyz/world/src/interfaces/IWorldKernel.sol";
import { IWorldKernel } from "@latticexyz/world/src/IWorldKernel.sol";

/**
* The IBaseWorld interface includes all systems dynamically added to the World
4 changes: 2 additions & 2 deletions packages/world-modules/test/StandardDelegationsModule.t.sol
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@ import { System } from "@latticexyz/world/src/System.sol";
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.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 { IWorldErrors } from "@latticexyz/world/src/IWorldErrors.sol";
import { DELEGATION_CONTROL_INTERFACE_ID } from "@latticexyz/world/src/IDelegationControl.sol";

import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol";
import { Systems } from "@latticexyz/world/src/codegen/tables/Systems.sol";
2 changes: 1 addition & 1 deletion packages/world-modules/test/UniqueEntityModule.t.sol
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";

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

import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol";
import { UniqueEntityModule } from "../src/modules/uniqueentity/UniqueEntityModule.sol";
2 changes: 1 addition & 1 deletion packages/world/src/AccessControl.sol
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
pragma solidity >=0.8.21;

import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol";
import { IWorldErrors } from "./interfaces/IWorldErrors.sol";
import { IWorldErrors } from "./IWorldErrors.sol";

import { ResourceAccess } from "./codegen/tables/ResourceAccess.sol";
import { NamespaceOwner } from "./codegen/tables/NamespaceOwner.sol";
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/world/src/Delegation.sol
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ pragma solidity >=0.8.21;

import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { UNLIMITED_DELEGATION } from "./constants.sol";
import { IDelegationControl } from "./interfaces/IDelegationControl.sol";
import { IDelegationControl } from "./IDelegationControl.sol";
import { SystemCall } from "./SystemCall.sol";

library Delegation {
6 changes: 3 additions & 3 deletions packages/world/src/DelegationControl.sol
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
pragma solidity >=0.8.21;

import { WorldContextConsumer } from "./WorldContext.sol";
import { IDelegationControl, DELEGATION_CONTROL_INTERFACE_ID } from "./interfaces/IDelegationControl.sol";
import { WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "./interfaces/IWorldContextConsumer.sol";
import { IERC165, ERC165_INTERFACE_ID } from "./interfaces/IERC165.sol";
import { IDelegationControl, DELEGATION_CONTROL_INTERFACE_ID } from "./IDelegationControl.sol";
import { WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "./IWorldContextConsumer.sol";
import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol";

abstract contract DelegationControl is WorldContextConsumer, IDelegationControl {
function supportsInterface(
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
pragma solidity >=0.8.21;

import { IWorldContextConsumer, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "./IWorldContextConsumer.sol";
import { ResourceId } from "../WorldResourceId.sol";
import { ResourceId } from "./WorldResourceId.sol";

// ERC-165 Interface ID (see https://eips.ethereum.org/EIPS/eip-165)
bytes4 constant DELEGATION_CONTROL_INTERFACE_ID = IDelegationControl.verify.selector ^
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
pragma solidity >=0.8.21;

import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol";
import { ResourceId } from "../WorldResourceId.sol";
import { ResourceId } from "./WorldResourceId.sol";

// ERC-165 Interface ID (see https://eips.ethereum.org/EIPS/eip-165)
bytes4 constant SYSTEM_HOOK_INTERFACE_ID = ISystemHook.onBeforeCallSystem.selector ^
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ pragma solidity >=0.8.21;

import { IWorldErrors } from "./IWorldErrors.sol";
import { IModule } from "./IModule.sol";
import { ResourceId } from "../WorldResourceId.sol";
import { ResourceId } from "./WorldResourceId.sol";

interface IWorldModuleInstallation {
/**
4 changes: 2 additions & 2 deletions packages/world/src/Module.sol
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
pragma solidity >=0.8.21;

import { WorldContextConsumer } from "./WorldContext.sol";
import { IModule, MODULE_INTERFACE_ID } from "./interfaces/IModule.sol";
import { IERC165, ERC165_INTERFACE_ID } from "./interfaces/IERC165.sol";
import { IModule, MODULE_INTERFACE_ID } from "./IModule.sol";
import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol";

abstract contract Module is IModule, WorldContextConsumer {
// ERC-165 supportsInterface (see https://eips.ethereum.org/EIPS/eip-165)
4 changes: 2 additions & 2 deletions packages/world/src/SystemCall.sol
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ import { WorldContextProvider } from "./WorldContext.sol";
import { revertWithBytes } from "./revertWithBytes.sol";
import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "./systemHookTypes.sol";

import { IWorldErrors } from "./interfaces/IWorldErrors.sol";
import { ISystemHook } from "./interfaces/ISystemHook.sol";
import { IWorldErrors } from "./IWorldErrors.sol";
import { ISystemHook } from "./ISystemHook.sol";

import { FunctionSelectors } from "./codegen/tables/FunctionSelectors.sol";
import { Systems } from "./codegen/tables/Systems.sol";
4 changes: 2 additions & 2 deletions packages/world/src/SystemHook.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "./interfaces/ISystemHook.sol";
import { ERC165_INTERFACE_ID } from "./interfaces/IERC165.sol";
import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "./ISystemHook.sol";
import { ERC165_INTERFACE_ID } from "./IERC165.sol";

abstract contract SystemHook is ISystemHook {
// ERC-165 supportsInterface (see https://eips.ethereum.org/EIPS/eip-165)
6 changes: 3 additions & 3 deletions packages/world/src/World.sol
Original file line number Diff line number Diff line change
@@ -25,9 +25,9 @@ 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 { IModule, MODULE_INTERFACE_ID } from "./IModule.sol";
import { IWorldKernel } from "./IWorldKernel.sol";
import { IDelegationControl } from "./IDelegationControl.sol";

import { Systems } from "./codegen/tables/Systems.sol";
import { SystemHooks } from "./codegen/tables/SystemHooks.sol";
4 changes: 2 additions & 2 deletions packages/world/src/WorldContext.sol
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@ pragma solidity >=0.8.21;

import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { revertWithBytes } from "./revertWithBytes.sol";
import { ERC165_INTERFACE_ID } from "./interfaces/IERC165.sol";
import { IWorldContextConsumer, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "./interfaces/IWorldContextConsumer.sol";
import { ERC165_INTERFACE_ID } from "./IERC165.sol";
import { IWorldContextConsumer, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "./IWorldContextConsumer.sol";

// The context size is 20 bytes for msg.sender, and 32 bytes for msg.value
uint256 constant CONTEXT_BYTES = 20 + 32;
Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@
pragma solidity >=0.8.21;

import { Create2 } from "./Create2.sol";
import { World } from "../World.sol";
import { World } from "./World.sol";
import { IWorldFactory } from "./IWorldFactory.sol";
import { IBaseWorld } from "../codegen/interfaces/IBaseWorld.sol";
import { IModule } from "../interfaces/IModule.sol";
import { ROOT_NAMESPACE_ID } from "../constants.sol";
import { IBaseWorld } from "./codegen/interfaces/IBaseWorld.sol";
import { IModule } from "./IModule.sol";
import { ROOT_NAMESPACE_ID } from "./constants.sol";

contract WorldFactory is IWorldFactory {
IModule public coreModule;
2 changes: 1 addition & 1 deletion packages/world/src/codegen/interfaces/IBaseWorld.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.

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/modules/core/CoreSystem.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { IWorldErrors } from "../../interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../../IWorldErrors.sol";

import { AccessManagementSystem } from "./implementations/AccessManagementSystem.sol";
import { BalanceTransferSystem } from "./implementations/BalanceTransferSystem.sol";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { IModule } from "../../../interfaces/IModule.sol";
import { IModule } from "../../../IModule.sol";
import { System } from "../../../System.sol";
import { AccessControl } from "../../../AccessControl.sol";
import { ResourceId, WorldResourceIdLib } from "../../../WorldResourceId.sol";
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { revertWithBytes } from "../../../revertWithBytes.sol";
import { WorldResourceIdLib, WorldResourceIdInstance } from "../../../WorldResourceId.sol";
import { AccessControl } from "../../../AccessControl.sol";
import { RESOURCE_NAMESPACE } from "../../../worldResourceTypes.sol";
import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../../../IWorldErrors.sol";

import { Balances } from "../../../codegen/tables/Balances.sol";

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

import { IModule, MODULE_INTERFACE_ID } from "../../../interfaces/IModule.sol";
import { IModule, MODULE_INTERFACE_ID } from "../../../IModule.sol";
import { System } from "../../../System.sol";
import { AccessControl } from "../../../AccessControl.sol";
import { WorldContextProvider } from "../../../WorldContext.sol";
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ import { SystemRegistry } from "../../../codegen/tables/SystemRegistry.sol";
import { Systems } from "../../../codegen/tables/Systems.sol";
import { FunctionSelectors } from "../../../codegen/tables/FunctionSelectors.sol";

import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../../../IWorldErrors.sol";

import { CORE_SYSTEM_ID } from "../constants.sol";

Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ import { NamespaceOwner } from "../../../codegen/tables/NamespaceOwner.sol";
import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol";
import { UserDelegationControl } from "../../../codegen/tables/UserDelegationControl.sol";
import { NamespaceDelegationControl } from "../../../codegen/tables/NamespaceDelegationControl.sol";
import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../../../interfaces/ISystemHook.sol";
import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol";
import { IDelegationControl, DELEGATION_CONTROL_INTERFACE_ID } from "../../../interfaces/IDelegationControl.sol";
import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../../../ISystemHook.sol";
import { IWorldErrors } from "../../../IWorldErrors.sol";
import { IDelegationControl, DELEGATION_CONTROL_INTERFACE_ID } from "../../../IDelegationControl.sol";

import { SystemHooks, SystemHooksTableId } from "../../../codegen/tables/SystemHooks.sol";
import { SystemRegistry } from "../../../codegen/tables/SystemRegistry.sol";
4 changes: 2 additions & 2 deletions packages/world/src/requireInterface.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

import { IERC165 } from "./interfaces/IERC165.sol";
import { IWorldErrors } from "./interfaces/IWorldErrors.sol";
import { IERC165 } from "./IERC165.sol";
import { IWorldErrors } from "./IWorldErrors.sol";

/**
* Require the given contract to support the given interface by calling the ERC-165 supportsInterface function.
2 changes: 1 addition & 1 deletion packages/world/test/AccessControl.t.sol
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { StoreMock } from "@latticexyz/store/test/StoreMock.sol";

import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../src/IWorldErrors.sol";
import { World } from "../src/World.sol";
import { AccessControl } from "../src/AccessControl.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/WorldResourceId.sol";
2 changes: 1 addition & 1 deletion packages/world/test/BatchCall.t.sol
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import { UNLIMITED_DELEGATION } from "../src/constants.sol";
import { ResourceId, WorldResourceIdLib } from "../src/WorldResourceId.sol";
import { RESOURCE_SYSTEM } from "../src/worldResourceTypes.sol";

import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../src/IWorldErrors.sol";
import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol";
import { CoreModule } from "../src/modules/core/CoreModule.sol";
import { SystemCallData, SystemCallFromData } from "../src/modules/core/types.sol";
6 changes: 3 additions & 3 deletions packages/world/test/Factories.t.sol
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ import { World } from "../src/World.sol";
import { ResourceId } from "../src/WorldResourceId.sol";
import { CoreModule } from "../src/modules/core/CoreModule.sol";
import { CORE_MODULE_NAME } from "../src/modules/core/constants.sol";
import { Create2Factory } from "../src/factories/Create2Factory.sol";
import { WorldFactory } from "../src/factories/WorldFactory.sol";
import { IWorldFactory } from "../src/factories/IWorldFactory.sol";
import { Create2Factory } from "../src/Create2Factory.sol";
import { WorldFactory } from "../src/WorldFactory.sol";
import { IWorldFactory } from "../src/IWorldFactory.sol";
import { InstalledModules } from "../src/codegen/tables/InstalledModules.sol";
import { NamespaceOwner } from "../src/codegen/tables/NamespaceOwner.sol";
import { ROOT_NAMESPACE_ID } from "../src/constants.sol";
2 changes: 1 addition & 1 deletion packages/world/test/SystemHook.t.sol
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";

import { Hook, HookLib } from "@latticexyz/store/src/Hook.sol";
import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM, ALL } from "../src/systemHookTypes.sol";
import { ISystemHook } from "../src/interfaces/ISystemHook.sol";
import { ISystemHook } from "../src/ISystemHook.sol";

contract SystemHookTest is Test, GasReporter {
function testFuzzEncode(address hookAddress, bool enableBeforeCallSystem, bool enableAfterCallSystem) public {
4 changes: 2 additions & 2 deletions packages/world/test/World.t.sol
Original file line number Diff line number Diff line change
@@ -43,8 +43,8 @@ import { SystemRegistry } from "../src/codegen/tables/SystemRegistry.sol";
import { FunctionSelectors } from "../src/codegen/tables/FunctionSelectors.sol";

import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol";
import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol";
import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../src/interfaces/ISystemHook.sol";
import { IWorldErrors } from "../src/IWorldErrors.sol";
import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../src/ISystemHook.sol";

import { Bool } from "./codegen/tables/Bool.sol";
import { TwoFields, TwoFieldsData } from "./codegen/tables/TwoFields.sol";
2 changes: 1 addition & 1 deletion packages/world/test/WorldBalance.t.sol
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/
import { ROOT_NAMESPACE, ROOT_NAMESPACE_ID } from "../src/constants.sol";
import { CoreModule } from "../src/modules/core/CoreModule.sol";
import { Balances } from "../src/codegen/tables/Balances.sol";
import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../src/IWorldErrors.sol";
import { RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "../src/worldResourceTypes.sol";

using WorldResourceIdInstance for ResourceId;
2 changes: 1 addition & 1 deletion packages/world/test/WorldDynamicUpdate.t.sol
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import { AddressArray } from "./codegen/tables/AddressArray.sol";
import { CoreModule } from "../src/modules/core/CoreModule.sol";

import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol";
import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol";
import { IWorldErrors } from "../src/IWorldErrors.sol";

contract UpdateInDynamicFieldTest is Test, GasReporter {
using WorldResourceIdInstance for ResourceId;
2 changes: 1 addition & 1 deletion packages/world/ts/node/render-solidity/renderWorld.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ export function renderWorld(options: RenderWorldOptions) {
interfaceName === "IBaseWorld"
? [
{ symbol: "IStore", path: `${storeImportPath}IStore.sol` },
{ symbol: "IWorldKernel", path: `${worldImportPath}interfaces/IWorldKernel.sol` },
{ symbol: "IWorldKernel", path: `${worldImportPath}IWorldKernel.sol` },
]
: [
{