Skip to content

Commit

Permalink
fix(store,world): exclude ERC165 interface ID from custom interface I…
Browse files Browse the repository at this point in the history
…D's [L-06] (#2014)

Co-authored-by: alvrs <alvarius@lattice.xyz>
  • Loading branch information
yonadaaa and alvrs authored Jan 3, 2024
1 parent 1a0fa79 commit d8c8f66
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
6 changes: 6 additions & 0 deletions .changeset/angry-pigs-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@latticexyz/store": patch
"@latticexyz/world": patch
---

Exclude ERC165 interface ID from custom interface ID's.
3 changes: 1 addition & 2 deletions docs/pages/store/reference/store-hook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ bytes4 constant STORE_HOOK_INTERFACE_ID = IStoreHook.onBeforeSetRecord.selector
IStoreHook.onBeforeSpliceDynamicData.selector ^
IStoreHook.onAfterSpliceDynamicData.selector ^
IStoreHook.onBeforeDeleteRecord.selector ^
IStoreHook.onAfterDeleteRecord.selector ^
ERC165_INTERFACE_ID;
IStoreHook.onAfterDeleteRecord.selector;
```

## IStoreHook
Expand Down
5 changes: 2 additions & 3 deletions packages/store/src/IStoreHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.21;

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

Expand All @@ -14,8 +14,7 @@ bytes4 constant STORE_HOOK_INTERFACE_ID = IStoreHook.onBeforeSetRecord.selector
IStoreHook.onBeforeSpliceDynamicData.selector ^
IStoreHook.onAfterSpliceDynamicData.selector ^
IStoreHook.onBeforeDeleteRecord.selector ^
IStoreHook.onAfterDeleteRecord.selector ^
ERC165_INTERFACE_ID;
IStoreHook.onAfterDeleteRecord.selector;

interface IStoreHook is IERC165 {
/// @notice Error emitted when a function is not implemented.
Expand Down
6 changes: 2 additions & 4 deletions packages/world/src/IModule.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

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

/**
* @dev Calculation for ERC-165 interface ID for the IModule functions.
* Combines the selector for each function with the ERC165_INTERFACE_ID.
* See: https://eips.ethereum.org/EIPS/eip-165
*/
bytes4 constant MODULE_INTERFACE_ID = IModule.getName.selector ^
IModule.installRoot.selector ^
IModule.install.selector ^
ERC165_INTERFACE_ID;
IModule.install.selector;

/**
* @title IModule
Expand Down
6 changes: 2 additions & 4 deletions packages/world/src/ISystemHook.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;

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

/**
* @dev Calculation for ERC-165 interface ID for the ISystemHook functions.
* Combines the selector for each function with the ERC165_INTERFACE_ID.
* See: https://eips.ethereum.org/EIPS/eip-165
*/
bytes4 constant SYSTEM_HOOK_INTERFACE_ID = ISystemHook.onBeforeCallSystem.selector ^
ISystemHook.onAfterCallSystem.selector ^
ERC165_INTERFACE_ID;
ISystemHook.onAfterCallSystem.selector;

/**
* @title ISystemHook
Expand Down
5 changes: 2 additions & 3 deletions packages/world/src/IWorldContextConsumer.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 { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol";
import { IERC165 } from "./IERC165.sol";

/**
* @dev World Context Consumer Interface
Expand All @@ -12,8 +12,7 @@ import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol";

bytes4 constant WORLD_CONTEXT_CONSUMER_INTERFACE_ID = IWorldContextConsumer._msgSender.selector ^
IWorldContextConsumer._msgValue.selector ^
IWorldContextConsumer._world.selector ^
ERC165_INTERFACE_ID;
IWorldContextConsumer._world.selector;

/**
* @title WorldContextConsumer - Extracting trusted context values from appended calldata.
Expand Down

0 comments on commit d8c8f66

Please sign in to comment.