Skip to content

Collapse the triplicated DisputeResolution, raise_dispute, and resolve_dispute definitions#666

Merged
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Baskarayelu:issue-655
Jun 29, 2026
Merged

Collapse the triplicated DisputeResolution, raise_dispute, and resolve_dispute definitions#666
mikewheeleer merged 1 commit into
Talenttrust:mainfrom
Baskarayelu:issue-655

Conversation

@Baskarayelu

Copy link
Copy Markdown
Contributor

Closes #655

Summary

  • Remove duplicate mod amount_validation declaration and duplicate safe_add_amounts function from lib.rs
  • Remove duplicate DisputeResolution re-export (was exported from both dispute and types; now only from types)
  • Remove duplicate EscrowError contracterror enum in lib.rs; replaced by pub type EscrowError = Error aliasing the canonical Error from types.rs
  • Remove duplicate #[contractimpl] impl Escrow block from dispute.rs: raise_dispute and resolve_dispute are now defined exactly once, in lib.rs
  • Remove duplicate DataKey enum from types.rs (second definition was byte-for-byte identical)
  • Remove duplicate Error enum from types.rs; merge missing EscrowCapExceeded into canonical first definition with a non-colliding discriminant (51 instead of 50 which is taken by AlreadyCancelled)
  • Add DisputeResolution::code() method on the canonical type in types.rs (used by the resolve_dispute event payload)
  • Rewrite test/dispute.rs with focused, self-contained tests covering all four resolution variants (FullRefund, FullPayout, PartialRefund, Split), security gates (non-party caller, no arbiter, non-disputed state, double resolve), and the conservation invariant

Security notes

All security invariants are preserved on the single code path:

  • Pause/emergency gate fires before any state mutation
  • Only client or freelancer may raise a dispute
  • Arbiter must be assigned before a dispute can be raised
  • Only the assigned arbiter may resolve a dispute
  • Resolution only allowed on Disputed contracts
  • Conservation invariant released_amount + refunded_amount == funded_amount is asserted after every resolution

🤖 Generated with Claude Code

…resolve_dispute definitions (Talenttrust#655)

- Remove duplicate `mod amount_validation` declaration in lib.rs
- Remove duplicate `safe_add_amounts` function definition in lib.rs
- Remove duplicate re-exports (`DisputeResolution` from both `dispute` and `types`)
- Remove duplicate `EscrowError` contracterror enum (replaced by `pub type EscrowError = Error`)
- Remove duplicate `#[contractimpl] impl Escrow` block from dispute.rs (raise_dispute
  and resolve_dispute now defined exactly once, in lib.rs)
- Remove duplicate `DataKey` enum from types.rs (second definition was identical)
- Remove duplicate `Error` enum from types.rs; merge missing `EscrowCapExceeded = 51`
  into the canonical first definition (avoids discriminant collision with AlreadyCancelled = 50)
- Add `DisputeResolution::code()` method to types.rs (used in resolve_dispute event)
- Rewrite test/dispute.rs with focused, self-contained tests covering all four resolution
  variants, raise/resolve security gates, and the conservation invariant

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mikewheeleer

Copy link
Copy Markdown
Contributor

appreciate this — thanks for picking it up 🙌

@mikewheeleer mikewheeleer merged commit 8965b14 into Talenttrust:main Jun 29, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collapse the triplicated DisputeResolution, raise_dispute, and resolve_dispute definitions

2 participants