Initialize Escrow Storage/Admin & Implement Escrow::deposit#217
Merged
Conversation
…te tests to handle Result
|
@akargi 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! 🚀 |
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.
Closes: #67
This PR implements two related pieces of functionality for the
escrowSoroban contract:Escrow::depositlogicThese changes move the contract toward safer, auditable initialization and a hardened deposit flow with typed errors and event logging.
Summary of changes
Add typed contract errors and events
EscrowError(enum) — typed error codes for common failure modes.EscrowInitializedEvent— emitted once on successful initialize.AgentJudgeUpdatedEvent— emitted when admin updates the agent judge.DepositEvent— emitted on successful deposit.Initialize/admin improvements
initialize(env, admin, agent_judge) -> Result<(), EscrowError>AlreadyInitialized).AdminandAgentJudgeto instance storage.("escrow", "Initialized")event for off-chain consumers.set_agent_judge(env, new_agent_judge) -> Result<(), EscrowError>AgentJudgeand emitsAgentJudgeUpdatedevent.Deposit implementation
deposit(env, job_id, amount) -> Result<(), EscrowError>total_amountand transitions job toFunded.("escrow", "Deposit")event with job and amount.Tests
contracts/escrow/src/lib.rsto use the new Result-basedinitializeanddepositsignatures.Files changed
contracts/escrow/src/lib.rs— core contract logic + testsRationale
Security considerations
Address::require_auth()where appropriate.token::Client::transferto leverage Soroban token semantics.saturating_addto guard against overflow in the contract's no_std environment.Migration & compatibility notes
initializeanddepositfunctions now returnResulttypes. Callers (clients and backend) must handle these return values accordingly.How to run tests locally
rust-toolchain.toml).cargo test -p escrowNote: I attempted to run tests in the current environment but toolchain sync blocked the run; please run locally and paste any failing output and I will iterate fixes.
Acceptance criteria checklist
escrowpass locally.Depositevent.Notes for reviewers
deposit(token transfer behavior) andinitialize(double-init prevention and persistence of admin/judge addresses).EscrowErrorvariants are needed for finer-grained error handling.assert!-based checks to typed errors in a follow-up for consistent API behavior.Closes: #68