-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store,world): move hooks to bit flags (#1527)
Co-authored-by: alvarius <[email protected]>
- Loading branch information
Showing
19 changed files
with
266 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
"@latticexyz/store": major | ||
"@latticexyz/world": major | ||
--- | ||
|
||
Moved the registration of store hooks and systems hooks to bitmaps with bitwise operator instead of a struct. | ||
|
||
```diff | ||
- import { StoreHookLib } from "@latticexyz/src/StoreHook.sol"; | ||
+ import { | ||
+ BEFORE_SET_RECORD, | ||
+ BEFORE_SET_FIELD, | ||
+ BEFORE_DELETE_RECORD | ||
+ } from "@latticexyz/store/storeHookTypes.sol"; | ||
|
||
StoreCore.registerStoreHook( | ||
tableId, | ||
subscriber, | ||
- StoreHookLib.encodeBitmap({ | ||
- onBeforeSetRecord: true, | ||
- onAfterSetRecord: false, | ||
- onBeforeSetField: true, | ||
- onAfterSetField: false, | ||
- onBeforeDeleteRecord: true, | ||
- onAfterDeleteRecord: false | ||
- }) | ||
+ BEFORE_SET_RECORD | BEFORE_SET_FIELD | BEFORE_DELETE_RECORD | ||
); | ||
``` | ||
|
||
```diff | ||
- import { SystemHookLib } from "../src/SystemHook.sol"; | ||
+ import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "../src/systemHookTypes.sol"; | ||
|
||
world.registerSystemHook( | ||
systemId, | ||
subscriber, | ||
- SystemHookLib.encodeBitmap({ onBeforeCallSystem: true, onAfterCallSystem: true }) | ||
+ BEFORE_CALL_SYSTEM | AFTER_CALL_SYSTEM | ||
); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
uint8 constant BEFORE_SET_RECORD = 1 << 0; | ||
uint8 constant AFTER_SET_RECORD = 1 << 1; | ||
// TODO: do we need to differentiate between static and dynamic set field? | ||
uint8 constant BEFORE_SET_FIELD = 1 << 2; | ||
uint8 constant AFTER_SET_FIELD = 1 << 3; | ||
uint8 constant BEFORE_DELETE_RECORD = 1 << 4; | ||
uint8 constant AFTER_DELETE_RECORD = 1 << 5; |
Oops, something went wrong.