Skip to content

Commit

Permalink
feat(world): change requireOwnerOrSelf to requireOwner (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Sep 12, 2023
1 parent d2c8488 commit 51914d6
Show file tree
Hide file tree
Showing 27 changed files with 660 additions and 187 deletions.
16 changes: 16 additions & 0 deletions .changeset/mighty-eels-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@latticexyz/world": major
---

- The access control library no longer allows calls by the `World` contract to itself to bypass the ownership check.
This is a breaking change for root modules that relied on this mechanism to register root tables, systems or function selectors.
To upgrade, root modules must use `delegatecall` instead of a regular `call` to install root tables, systems or function selectors.

```diff
- world.registerSystem(rootSystemId, rootSystemAddress);
+ address(world).delegatecall(abi.encodeCall(world.registerSystem, (rootSystemId, rootSystemAddress)));
```

- An `installRoot` method was added to the `IModule` interface.
This method is now called when installing a root module via `world.installRootModule`.
When installing non-root modules via `world.installModule`, the module's `install` function continues to be called.
23 changes: 23 additions & 0 deletions packages/world/abi/CoreModule.sol/CoreModule.abi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"inputs": [],
"name": "NonRootInstallNotSupported",
"type": "error"
},
{
"inputs": [
{
Expand All @@ -21,6 +26,11 @@
"name": "RequiredModuleNotFound",
"type": "error"
},
{
"inputs": [],
"name": "RootInstallModeNotSupported",
"type": "error"
},
{
"inputs": [
{
Expand Down Expand Up @@ -145,6 +155,19 @@
],
"name": "install",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"name": "installRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
Expand Down
23 changes: 23 additions & 0 deletions packages/world/abi/CoreModule.sol/CoreModule.abi.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
declare const abi: [
{
inputs: [];
name: "NonRootInstallNotSupported";
type: "error";
},
{
inputs: [
{
Expand All @@ -21,6 +26,11 @@ declare const abi: [
name: "RequiredModuleNotFound";
type: "error";
},
{
inputs: [];
name: "RootInstallModeNotSupported";
type: "error";
},
{
inputs: [
{
Expand Down Expand Up @@ -145,6 +155,19 @@ declare const abi: [
];
name: "install";
outputs: [];
stateMutability: "pure";
type: "function";
},
{
inputs: [
{
internalType: "bytes";
name: "";
type: "bytes";
}
];
name: "installRoot";
outputs: [];
stateMutability: "nonpayable";
type: "function";
}
Expand Down
23 changes: 23 additions & 0 deletions packages/world/abi/IModule.sol/IModule.abi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"inputs": [],
"name": "NonRootInstallNotSupported",
"type": "error"
},
{
"inputs": [
{
Expand All @@ -10,6 +15,11 @@
"name": "RequiredModuleNotFound",
"type": "error"
},
{
"inputs": [],
"name": "RootInstallModeNotSupported",
"type": "error"
},
{
"inputs": [],
"name": "getName",
Expand All @@ -35,5 +45,18 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "args",
"type": "bytes"
}
],
"name": "installRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
23 changes: 23 additions & 0 deletions packages/world/abi/IModule.sol/IModule.abi.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
declare const abi: [
{
inputs: [];
name: "NonRootInstallNotSupported";
type: "error";
},
{
inputs: [
{
Expand All @@ -10,6 +15,11 @@ declare const abi: [
name: "RequiredModuleNotFound";
type: "error";
},
{
inputs: [];
name: "RootInstallModeNotSupported";
type: "error";
},
{
inputs: [];
name: "getName";
Expand All @@ -35,6 +45,19 @@ declare const abi: [
outputs: [];
stateMutability: "nonpayable";
type: "function";
},
{
inputs: [
{
internalType: "bytes";
name: "args";
type: "bytes";
}
];
name: "installRoot";
outputs: [];
stateMutability: "nonpayable";
type: "function";
}
];
export default abi;
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"inputs": [],
"name": "NonRootInstallNotSupported",
"type": "error"
},
{
"inputs": [
{
Expand All @@ -10,6 +15,11 @@
"name": "RequiredModuleNotFound",
"type": "error"
},
{
"inputs": [],
"name": "RootInstallModeNotSupported",
"type": "error"
},
{
"inputs": [
{
Expand Down Expand Up @@ -43,12 +53,25 @@
"inputs": [
{
"internalType": "bytes",
"name": "args",
"name": "",
"type": "bytes"
}
],
"name": "install",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "args",
"type": "bytes"
}
],
"name": "installRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
declare const abi: [
{
inputs: [];
name: "NonRootInstallNotSupported";
type: "error";
},
{
inputs: [
{
Expand All @@ -10,6 +15,11 @@ declare const abi: [
name: "RequiredModuleNotFound";
type: "error";
},
{
inputs: [];
name: "RootInstallModeNotSupported";
type: "error";
},
{
inputs: [
{
Expand Down Expand Up @@ -43,12 +53,25 @@ declare const abi: [
inputs: [
{
internalType: "bytes";
name: "args";
name: "";
type: "bytes";
}
];
name: "install";
outputs: [];
stateMutability: "pure";
type: "function";
},
{
inputs: [
{
internalType: "bytes";
name: "args";
type: "bytes";
}
];
name: "installRoot";
outputs: [];
stateMutability: "nonpayable";
type: "function";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
[
{
"inputs": [
{
"internalType": "uint256",
"name": "length",
"type": "uint256"
}
],
"name": "PackedCounter_InvalidLength",
"inputs": [],
"name": "NonRootInstallNotSupported",
"type": "error"
},
{
Expand All @@ -21,46 +15,25 @@
"name": "RequiredModuleNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "length",
"type": "uint256"
}
],
"name": "SchemaLib_InvalidLength",
"type": "error"
},
{
"inputs": [],
"name": "SchemaLib_StaticTypeAfterDynamicType",
"name": "RootInstallModeNotSupported",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
},
{
"internalType": "uint256",
"name": "start",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "end",
"name": "length",
"type": "uint256"
}
],
"name": "Slice_OutOfBounds",
"name": "SchemaLib_InvalidLength",
"type": "error"
},
{
"inputs": [],
"name": "StoreCore_NotDynamicField",
"name": "SchemaLib_StaticTypeAfterDynamicType",
"type": "error"
},
{
Expand All @@ -80,12 +53,25 @@
"inputs": [
{
"internalType": "bytes",
"name": "args",
"name": "",
"type": "bytes"
}
],
"name": "install",
"outputs": [],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "args",
"type": "bytes"
}
],
"name": "installRoot",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
Expand Down
Loading

0 comments on commit 51914d6

Please sign in to comment.