refactor(debit): extract shared check helper (#265) - #310
Merged
mikewheeleer merged 1 commit intoJul 24, 2026
Conversation
Contributor
|
@ALIPHATICHYD solid and well-scoped, merging now 🚢 |
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
Closes #265
This PR extracts repeated inline debit precondition checks and debiting logic in
contracts/escrow/src/lib.rsinto private helper functions:check_debit_precondition: Validates that an agent's prepaid credit balance is sufficient for projected usage bills, panicking withEscrowError::InsufficientCreditBalance(Document the schema-versioning and migration model for redeployments #28) if exceeded.debit_agent_credit: Deductsmin(billed, credit_balance)from the agent's prepaid balance in storage and publishes thecred_debevent.Key Changes
contracts/escrow/src/lib.rs:record_usagethroughcheck_debit_preconditionsettlethroughdebit_agent_creditcontracts/escrow/src/test.rs:duplicated-attributesandunnecessary-cast).Verification & Test Output