fix(escrow): add bounds validation, issuer verification, and cleanup - #691
Merged
K1NGD4VID merged 4 commits intoAug 28, 2026
Merged
Conversation
|
@xeladev4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
xeladev4
force-pushed
the
fix/escrow-bounds-validation-and-issuer-checks
branch
2 times, most recently
from
August 27, 2026 23:47
484be82 to
def87b2
Compare
Closes TrusTrove#541, TrusTrove#542, TrusTrove#543, TrusTrove#545 - Add upper-bound validation for u128 to i128 casts to prevent overflow - Remove unused DataKey::InvoiceContract and clean up initialize() signature - Add issuer verification in release_to_issuer() to prevent unauthorized transfers - Replace raw unwrap() in usdc_client() with typed NotInitialized error - Update lock() signature to require issuer parameter - Update release_to_pool() to use pool auth instead of invoice contract auth - Add tests for i128::MAX boundary validation and issuer mismatch detection Note: Pool integration tests require corresponding updates to pool contract to work with new escrow API
The escrow contract's lock() function now requires an issuer parameter as part of the issuer verification fix. This commit updates the pool contract's fund_invoice() function to pass the issuer address when calling escrow.lock(). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
xeladev4
force-pushed
the
fix/escrow-bounds-validation-and-issuer-checks
branch
from
August 28, 2026 00:04
d2e4c62 to
d7857c2
Compare
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
xeladev4
force-pushed
the
fix/escrow-bounds-validation-and-issuer-checks
branch
from
August 28, 2026 00:09
028981a to
4d2da41
Compare
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
DataKey::InvoiceContractand clean upinitialize()signaturerelease_to_issuer()to prevent unauthorized transfersunwrap()inusdc_client()with typedNotInitializederrorChanges
amount > i128::MAX as u128checks inlock(),release_to_pool(),release_to_issuer(), andhandle_default()to prevent silent negative wraparound when casting u128 to i128DataKey::InvoiceContractvariant, updatedinitialize()to only acceptadmin,pool_contract, andusdc_assetparameters, and corrected rustdoc to match actual behaviorissuerfield toEscrowRecord, updatedlock()to require issuer parameter, and added validation inrelease_to_issuer()to ensure the recipient matches the stored issuerunwrap()inusdc_client()withunwrap_or_else(|| panic_with_error!(env, EscrowError::NotInitialized))for consistency with other storage readsrelease_to_pool()to use pool auth instead of invoice contract auth (aligns with actual usage pattern)Test plan
test_lock_fails_amount_exceeds_i128_maxto verify rejection of amounts > i128::MAXtest_lock_succeeds_at_i128_maxto verify boundary acceptancetest_release_to_pool_fails_amount_exceeds_i128_maxfor release_to_pool validationtest_release_to_issuer_mismatched_address_panicsto verify issuer validationlock()signature with issuer parameterValidation commands
cargo test -p trusttrove-escrow cargo build --workspaceCloses #541
Closes #542
Closes #543
Closes #545