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

fix(store,world): exclude ERC165 interface ID from custom interface ID's [L-06] #2014

Merged
merged 6 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
37 changes: 0 additions & 37 deletions docs/pages/store/reference/store-core.mdx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files were changed by docs:generate:api 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear what happened there but let's ignore these changes for this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the doc changes from this PR

Original file line number Diff line number Diff line change
Expand Up @@ -774,16 +774,6 @@ event Store_SetRecord(
);
```

**Parameters**

| Name | Type | Description |
| ---------------- | --------------- | ------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the record is set. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
| `staticData` | `bytes` | The static data of the record. |
| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
| `dynamicData` | `bytes` | The dynamic data of the record. |

### Store_SpliceStaticData

Emitted when static data in the store is spliced.
Expand All @@ -795,15 +785,6 @@ so the total length of the data remains the same and no data is shifted._
event Store_SpliceStaticData(ResourceId indexed tableId, bytes32[] keyTuple, uint48 start, bytes data);
```

**Parameters**

| Name | Type | Description |
| ---------- | ------------ | --------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
| `keyTuple` | `bytes32[]` | An array representing the key for the record. |
| `start` | `uint48` | The start position in bytes for the splice operation. |
| `data` | `bytes` | The data to write to the static data of the record at the start byte. |

### Store_SpliceDynamicData

Emitted when dynamic data in the store is spliced.
Expand All @@ -819,28 +800,10 @@ event Store_SpliceDynamicData(
);
```

**Parameters**

| Name | Type | Description |
| ---------------- | --------------- | ------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
| `start` | `uint48` | The start position in bytes for the splice operation. |
| `deleteCount` | `uint40` | The number of bytes to delete in the splice operation. |
| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
| `data` | `bytes` | The data to insert into the dynamic data of the record at the start byte. |

### Store_DeleteRecord

Emitted when a record is deleted from the store.

```solidity
event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple);
```

**Parameters**

| Name | Type | Description |
| ---------- | ------------ | ------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the record is deleted. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
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
43 changes: 0 additions & 43 deletions docs/pages/store/reference/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ event Store_SetRecord(
);
```

**Parameters**

| Name | Type | Description |
| ---------------- | --------------- | ------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the record is set. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
| `staticData` | `bytes` | The static data of the record. |
| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
| `dynamicData` | `bytes` | The dynamic data of the record. |

### Store_SpliceStaticData

Emitted when static data in the store is spliced.
Expand All @@ -44,15 +34,6 @@ so the total length of the data remains the same and no data is shifted._
event Store_SpliceStaticData(ResourceId indexed tableId, bytes32[] keyTuple, uint48 start, bytes data);
```

**Parameters**

| Name | Type | Description |
| ---------- | ------------ | --------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
| `keyTuple` | `bytes32[]` | An array representing the key for the record. |
| `start` | `uint48` | The start position in bytes for the splice operation. |
| `data` | `bytes` | The data to write to the static data of the record at the start byte. |

### Store_SpliceDynamicData

Emitted when dynamic data in the store is spliced.
Expand All @@ -68,17 +49,6 @@ event Store_SpliceDynamicData(
);
```

**Parameters**

| Name | Type | Description |
| ---------------- | --------------- | ------------------------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
| `start` | `uint48` | The start position in bytes for the splice operation. |
| `deleteCount` | `uint40` | The number of bytes to delete in the splice operation. |
| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
| `data` | `bytes` | The data to insert into the dynamic data of the record at the start byte. |

### Store_DeleteRecord

Emitted when a record is deleted from the store.
Expand All @@ -87,13 +57,6 @@ Emitted when a record is deleted from the store.
event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple);
```

**Parameters**

| Name | Type | Description |
| ---------- | ------------ | ------------------------------------------------------- |
| `tableId` | `ResourceId` | The ID of the table where the record is deleted. |
| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |

## IStoreErrors

[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreErrors.sol)
Expand Down Expand Up @@ -191,12 +154,6 @@ Emitted when the store is initialized.
event HelloStore(bytes32 indexed storeVersion);
```

**Parameters**

| Name | Type | Description |
| -------------- | --------- | ---------------------------------- |
| `storeVersion` | `bytes32` | The version of the Store contract. |

## IStoreRead

[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreRead.sol)
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
Loading