Repository navigation
Conversation
…vage (MindFlowInteractive#400, MindFlowInteractive#401) - Add modular Soroban smart contract in contracts/item_durability - Implement Item structure with owner, max_durability, current_durability, and is_broken state - Implement use_item function: decrements durability by 1, marks broken and emits broken event upon reaching zero - Implement repair_item function: allows owner to restore durability via token payment to designated sink address - Enforce repair cost formula proportional to restored durability and cap at max_durability - Block repair of broken items to enforce item lifecycle integrity - Implement salvage_item function: allows owner to salvage broken items for configured material payout tokens - Destroy item record upon salvage to prevent double-salvaging - Add full unit test suite in src/test.rs covering usage, breakage, repair calculations, caps, sink routing, and salvage lifecycle - Add detailed README.md documentation and workspace entry in Cargo.toml Closes MindFlowInteractive#400 Closes MindFlowInteractive#401
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 provides a comprehensive, production-grade Soroban smart contract for the Item Durability lifecycle across Stages 1, 2, and 3, fulfilling all acceptance criteria for both #400 and #401:
Durability Usage & Break State (Stage 1 & 3):
Itementity trackingowner,max_durability,current_durability, andis_brokenstatus.use_item: decrements durability by 1 per use with owner authentication.(broken, item_id)event.ZeroDurabilityerror).Repair with Token Payment Sink (Stage 2 - Item Durability: Repair #400):
repair_item: allows item owner to restore missing durability by paying tokens.cost = units_to_repair * cost_per_unit.max_durability.sink_addressviasoroban_sdk::token::Client.ItemBrokenerror).Break & Salvage Material Payout (Stage 3 - Item Durability: Break and Salvage #401):
salvage_item: allows owner to salvage broken items for configured material payout tokens.ItemNotBrokenerror).Testing & Tooling:
src/test.rs(6/6 passing tests covering usage, breakage, repair calculations, cap enforcement, sink routing, salvage payouts, and authorization).Cargo.toml.contracts/item_durability/README.md.Closes #400
Closes #401