feat: implement dispute raising function (raise_dispute)#27
Conversation
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
Fix conflicts and also ensure the CI passes |
meshackyaro
left a comment
There was a problem hiding this comment.
Well done and thank you for your contribution.
Summary
Implements the
raise_disputeentrypoint (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 existingtypes/storage/errorsmodules.What it does
contracts/src/lib.rs): a#[contract] TrustFlowContractexposingraise_dispute(env, escrow_id, caller, reason).contracts/src/dispute.rs):caller.require_auth();Unauthorized;Activeescrow 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);DisputeRecordfor the jury and extends TTL;disputedevent (topics(disputed, escrow_id), dataraised_by) for indexers.storage.extend_ttlused a newer-SDK method; switched to thesoroban-sdk20 persistent TTL API (bump) and removed an unused import so the module compiles.Tasks / acceptance criteria
cargo fmtclean;cargo clippyclean (only upstreamsoroban-sdkmacrocfgwarnings remain)soroban/cargobuild compiles to WASM without bloat —trustflow_core.wasmis ~10 KBTest plan
Note: the workspace pins
soroban-sdk = 20.0.0-rc2, so the implementation uses the 20.x API and classicenv.events().publishfor the event. Wiring the other scaffold modules (settlement/fee/governance/oracle) and enforcing theDisputedguard on the release path are out of scope here and left for their own issues.Closes #3