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): emit event after calling beforeSetRecord hook [L-02] #2017

Merged
merged 24 commits into from
Jan 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3b3541d
fix(store): emit event after calling beforeSetRecord hook
yonadaa Dec 5, 2023
54317e4
fix: move splice events
yonadaa Dec 5, 2023
93d3b99
chore: docs, gas
yonadaa Dec 5, 2023
ab426ef
fix: rearrange _spliceDynamicData
yonadaa Dec 5, 2023
5edfb74
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 5, 2024
15c2f5d
chore: do not change docs
yonadaa Jan 5, 2024
0d5ee29
fix: emit delete record event after hook
yonadaa Jan 5, 2024
e26a209
chore: changeset
yonadaa Jan 5, 2024
8526b26
fix: do not change encoded lengths
yonadaa Jan 5, 2024
90dd47d
fix: update correct lengths
yonadaa Jan 5, 2024
5a79dd2
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 11, 2024
9cb4a3c
fix: proper early return for offchain tables
yonadaa Jan 12, 2024
2a84f6a
test: ensure that events are emitted for offchain table sets
yonadaa Jan 12, 2024
d05b85e
test: check for deleted offchain tables
yonadaa Jan 12, 2024
3d50fb3
feat: disable before hooks for offchain tables
yonadaa Jan 12, 2024
568aaf0
chore: gas tests
yonadaa Jan 12, 2024
2cbc51a
refactor: use boolean
yonadaa Jan 12, 2024
b4c2a40
perf: remove offchain check for before hooks
yonadaa Jan 12, 2024
5535e9f
refactor: early return with offchain tables immediately
yonadaa Jan 12, 2024
cb82d13
chore: move comments
yonadaa Jan 12, 2024
af2f79d
chore: comment
yonadaa Jan 12, 2024
03bd4b8
chore: root gas report
yonadaa Jan 12, 2024
38e6351
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 12, 2024
ea87f34
Update .changeset/beige-ads-melt.md
holic Jan 12, 2024
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
Prev Previous commit
Next Next commit
fix: proper early return for offchain tables
yonadaa committed Jan 12, 2024
commit 9cb4a3c08b78370110fd0bad050b9d349e2e0706
10 changes: 5 additions & 5 deletions packages/store/src/StoreCore.sol
Original file line number Diff line number Diff line change
@@ -583,11 +583,6 @@ library StoreCore {
* @param fieldLayout The field layout for the record.
*/
function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal {
// Early return if the table is an offchain table
if (tableId.getType() != RESOURCE_TABLE) {
return;
}

// Call onBeforeDeleteRecord hooks (before actually modifying the state, so observers have access to the previous state if needed)
bytes21[] memory hooks = StoreHooks._get(tableId);
for (uint256 i; i < hooks.length; i++) {
@@ -600,6 +595,11 @@ library StoreCore {
// Emit event to notify indexers
emit Store_DeleteRecord(tableId, keyTuple);

// Early return if the table is an offchain table
if (tableId.getType() != RESOURCE_TABLE) {
return;
}

// Delete static data
uint256 staticDataLocation = StoreCoreInternal._getStaticDataLocation(tableId, keyTuple);
Storage.store({ storagePointer: staticDataLocation, offset: 0, data: new bytes(fieldLayout.staticDataLength()) });
Loading