Skip to content

feat: implement dispute raising function (raise_dispute)#27

Merged
meshackyaro merged 2 commits into
trustflow-protocol:mainfrom
Akpolo:feat/issue-3-raise-dispute
Jun 28, 2026
Merged

feat: implement dispute raising function (raise_dispute)#27
meshackyaro merged 2 commits into
trustflow-protocol:mainfrom
Akpolo:feat/issue-3-raise-dispute

Conversation

@Akpolo

@Akpolo Akpolo commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the raise_dispute entrypoint (issue #3): either party to an escrow — the depositor or the beneficiary — can halt release and call for a jury.

The core contract was an un-assembled scaffold (no lib.rs, no [package]), so this PR wires it into a buildable Soroban contract and implements the dispute logic on top of the existing types/storage/errors modules.

What it does

  • Entrypoint (contracts/src/lib.rs): a #[contract] TrustFlowContract exposing raise_dispute(env, escrow_id, caller, reason).
  • Logic (contracts/src/dispute.rs):
    • caller.require_auth();
    • only a party to the escrow (depositor or beneficiary) may raise — others get Unauthorized;
    • only an Active escrow can be disputed (→ Disputed, which halts release); a missing escrow → EscrowNotFound, a settled/already-disputed one → InvalidState (this also makes a second raise a no-op);
    • records a DisputeRecord for the jury and extends TTL;
    • emits a disputed event (topics (disputed, escrow_id), data raised_by) for indexers.
  • Fix: storage.extend_ttl used a newer-SDK method; switched to the soroban-sdk 20 persistent TTL API (bump) and removed an unused import so the module compiles.

Tasks / acceptance criteria

  • Implement Rust logic for the dispute-raising function
  • Comprehensive unit tests (6): depositor & beneficiary can raise; outsider rejected; missing escrow, non-active escrow, and double-raise rejected; event emission asserted
  • Proper event emission for indexing
  • cargo fmt clean; cargo clippy clean (only upstream soroban-sdk macro cfg warnings remain)
  • soroban/cargo build compiles to WASM without bloat — trustflow_core.wasm is ~10 KB

Test plan

cargo test -p trustflow-core            # 6 passed
cargo fmt -p trustflow-core -- --check  # clean
cargo clippy -p trustflow-core --all-targets
cargo build -p trustflow-core --target wasm32-unknown-unknown --release
cargo check --workspace                 # abundance + crowdfund still build

Note: the workspace pins soroban-sdk = 20.0.0-rc2, so the implementation uses the 20.x API and classic env.events().publish for the event. Wiring the other scaffold modules (settlement/fee/governance/oracle) and enforcing the Disputed guard on the release path are out of scope here and left for their own issues.

Closes #3

Assembles the core TrustFlow contract and exposes raise_dispute, letting either
party (depositor or beneficiary) halt escrow release and call for a jury.

- Wire contracts/ as a buildable Soroban package with a #[contract]
  TrustFlowContract and the raise_dispute entrypoint (lib.rs).
- Harden raise_dispute: require_auth(caller), restrict to escrow parties, only
  allow disputing an Active escrow (transitions it to Disputed to halt release),
  record a DisputeRecord for the jury, extend TTL, and emit a `disputed` event
  for indexers.
- Fix storage.extend_ttl to the soroban-sdk 20 persistent TTL API (bump) and
  drop an unused import.
- Add Rust unit tests: depositor/beneficiary can raise; outsider rejected;
  missing escrow, non-active escrow, and double-raise all rejected; event emitted.

cargo fmt + clippy clean (only upstream SDK-macro cfg warnings); cargo test
passes (6 tests); builds to a 10KB wasm32 artifact.

Closes trustflow-protocol#3
@meshackyaro

Copy link
Copy Markdown
Contributor

Summary

Implements the raise_dispute entrypoint (issue #3): either party to an escrow — the depositor or the beneficiary — can halt release and call for a jury.

The core contract was an un-assembled scaffold (no lib.rs, no [package]), so this PR wires it into a buildable Soroban contract and implements the dispute logic on top of the existing types/storage/errors modules.

What it does

  • Entrypoint (contracts/src/lib.rs): a #[contract] TrustFlowContract exposing raise_dispute(env, escrow_id, caller, reason).

  • Logic (contracts/src/dispute.rs):

    • caller.require_auth();
    • only a party to the escrow (depositor or beneficiary) may raise — others get Unauthorized;
    • only an Active escrow can be disputed (→ Disputed, which halts release); a missing escrow → EscrowNotFound, a settled/already-disputed one → InvalidState (this also makes a second raise a no-op);
    • records a DisputeRecord for the jury and extends TTL;
    • emits a disputed event (topics (disputed, escrow_id), data raised_by) for indexers.
  • Fix: storage.extend_ttl used a newer-SDK method; switched to the soroban-sdk 20 persistent TTL API (bump) and removed an unused import so the module compiles.

Tasks / acceptance criteria

  • Implement Rust logic for the dispute-raising function
  • Comprehensive unit tests (6): depositor & beneficiary can raise; outsider rejected; missing escrow, non-active escrow, and double-raise rejected; event emission asserted
  • Proper event emission for indexing
  • cargo fmt clean; cargo clippy clean (only upstream soroban-sdk macro cfg warnings remain)
  • soroban/cargo build compiles to WASM without bloat — trustflow_core.wasm is ~10 KB

Test plan

cargo test -p trustflow-core            # 6 passed
cargo fmt -p trustflow-core -- --check  # clean
cargo clippy -p trustflow-core --all-targets
cargo build -p trustflow-core --target wasm32-unknown-unknown --release
cargo check --workspace                 # abundance + crowdfund still build

Note: the workspace pins soroban-sdk = 20.0.0-rc2, so the implementation uses the 20.x API and classic env.events().publish for the event. Wiring the other scaffold modules (settlement/fee/governance/oracle) and enforcing the Disputed guard on the release path are out of scope here and left for their own issues.

Closes #3

Fix conflicts and also ensure the CI passes

@meshackyaro meshackyaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done and thank you for your contribution.

@meshackyaro meshackyaro merged commit 501764b into trustflow-protocol:main Jun 28, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 28, 2026
10 tasks
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.

Implement Dispute Raising Function

2 participants