feat: standardize Soroban contract errors and events - #198
Open
OsejiFabian wants to merge 1 commit into
Open
Conversation
Closes Lumina-eX#191 Generated with Codebuff 🤖 Co-Authored-By: Codebuff <[email protected]>
|
@OsejiFabian 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.
Summary
Closes #191
This PR standardizes the Soroban contract error and event interfaces across the escrow and dispute contracts, and updates the application-side event synchronization layer so frontend/backend consumers can reliably interpret on-chain operations.
Problem
The contracts previously exposed generic error enums with only implicit numeric semantics and emitted short, ad hoc topics such as
init,fund,submit, andrelease. The dispute contract did not emit lifecycle events at all. This made it difficult for consumers to:What changed
Standardized contract errors
#[repr(u32)]to both contract error enums.ERR_ALREADY_INITIALIZEDERR_NOT_INITIALIZEDERR_INVALID_STATEERR_UNAUTHORIZEDERR_INVALID_AMOUNTERR_MILESTONE_NOT_FOUNDERR_INSUFFICIENT_APPROVALSERR_VOTING_ENDEDERR_VOTING_NOT_ENDEDERR_ALREADY_VOTEDERR_NO_STAKEStandardized escrow events
Replaced untyped one-word event topics with typed Soroban
#[contractevent]definitions:EscrowCreatedEscrowFundedMilestoneSubmittedMilestoneApprovedMilestoneConfirmedPaymentReleasedDisputeRaisedRefundIssuedDisputeResolvedMilestoneExpiredEach event includes the relevant contract identifier and actor, with milestone identifiers indexed where applicable. Payment/refund/resolution events also include recipient and amount data.
Standardized dispute events
Added typed lifecycle events for the dispute contract:
DisputeCreatedVoteCastDisputeResolvedStakeClaimedThese events include
contract_id,dispute_id, andactortopics, plus structured amount, recipient, voting, and outcome data.Event synchronization compatibility
milestoneIddisputeIdactorrecipientamountsupportreleaseToFreelancerDatabase and documentation
009_contract_event_standardization.sql.docs/soroban-contract-events.mddocumenting:Tests
Compatibility and rollout notes
contract_sync_log.event_typevalues are not rewritten.Verification
The following checks were run locally:
pnpm lint— passed with four pre-existing warnings.git diff --check— passed.The following checks were attempted but are blocked by the current workspace/environment:
pnpm testand targeted Vitest — blocked before test collection by a missing@rolldownnative optional dependency.pnpm build— blocked by a missing@tailwindcss/oxidenative optional dependency.pnpm exec tsc --noEmit— reports numerous pre-existing repository-wide type errors outside this change.rustc,cargo,rustfmt, andstellarare not installed in the workspace.Checklist
Closes #191.