Add item existence checks and removal functionality in ItemRegistry contract#35
Add item existence checks and removal functionality in ItemRegistry contract#35mahabubAlahi wants to merge 1 commit intooz-audit-fixesfrom
Conversation
mahabubAlahi
commented
Mar 3, 2026
- Introduced a mapping to track item existence for each owner.
- Added error handling for adding duplicate items and removing non-existent items.
- Implemented an event for item removal.
- Updated addItem and removeItem functions to incorporate new checks and emit appropriate events.
…ontract - Introduced a mapping to track item existence for each owner. - Added error handling for adding duplicate items and removing non-existent items. - Implemented an event for item removal. - Updated addItem and removeItem functions to incorporate new checks and emit appropriate events.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0657a0728
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| Items[_msgSender()][itemId] = item; | ||
| emit ItemAdded(_msgSender(), itemId, item); | ||
| if (s_itemExists[owner][itemId]) revert ItemRegistryItemAlreadyExists(itemId); |
There was a problem hiding this comment.
Validate in-batch duplicates before existence lookup
In addItemsBatch, checking s_itemExists before the duplicate scan causes a duplicate ID within the same input array to revert with ItemRegistryItemAlreadyExists instead of ItemRegistryDuplicateItemId: after the first occurrence is written, the second hits the existence check first. This makes ItemRegistryDuplicateItemId effectively unreachable for the new duplicate-batch case and breaks callers that rely on distinct custom errors to differentiate malformed input from true pre-existing on-chain state.
Useful? React with 👍 / 👎.