Repository navigation
Conversation
…e#399) - Add reusable Soroban smart contract in contracts/item_durability - Implement Item structure with owner, max_durability, and current_durability - Support admin-gated register_item function with max durability validation - Implement use_item function: decrements durability by 1 per use - Enforce fail-closed rejection when item durability reaches zero (ZeroDurability error) - Verify caller authorization to ensure only the authenticated owner can use items - Emit Soroban events on durability change: (use, item_id) -> (user, current_durability) - Expose read functions for get_item and get_durability - Support secure admin transfer via transfer_admin - Add comprehensive unit test suite in src/test.rs - Add detailed README.md documentation and workspace entry in Cargo.toml Closes MindFlowInteractive#399
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This pull request implements the Item Durability Module (Stage 1 of the Durability chain) for the Quest Contract ecosystem as requested in #399.
Key Features & Architecture
contracts/item_durabilityItemstruct tracks itemowner,max_durability, andcurrent_durability.register_item(item_id, owner, max_durability)ensures items start initialized at full durability.use_item(user, item_id)authenticates the owner and decrements durability by exactly 1 per use.ZeroDurabilityonce an item is depleted.topic: (use, item_id), data: (user, current_durability).get_item(item_id)andget_durability(item_id).transfer_admin.contracts/item_durability/src/test.rsverifying registration, sequential decrement by 1, zero-durability rejection, unauthorized user rejection, non-existent item handling, and admin transfers.README.mddetailing storage schema, error codes, events, and integration examples.Verification
cargo check --package item_durabilitypassed with 0 errors.Cargo.tomlworkspace members.Closes #399