Skip to content

[Bug] Demo app never reconciles milestone status against real on-chain state #147

Description

@collinsezedike

Summary

JobsContext.tsx's submitMilestone/disputeMilestone/voteOnMilestone/finalizeMilestone each fire a real transaction against packages/tholos-sdk, then optimistically set the local milestone status by assuming the call succeeded exactly as expected. None of them read the contract back. docs/src/INTEGRATION.md (lines 146-160) documents the correct pattern for this exact situation: poll get_assertion_state(id), or watch events, neither of which this app does.

Scope

  • Add a way to read real assertion state (get_assertion_state) into lib/tholos.ts, alongside the existing assert_outcome/dispute/resolve/finalize calls.
  • After each action in JobsContext.tsx, or on a polling interval for any milestone with an assertionId, reconcile local status from the real read instead of assuming success.
  • A milestone whose challenge window has passed uncontested should reflect that it's now eligible for finalize, driven by the real state, not by silence in the local optimistic status.

Proposed approach

Add getAssertionState(id) to lib/tholos.ts wrapping the SDK's get_assertion_state. In JobsContext.tsx, after a successful action call, immediately re-read state and set status from that read rather than a hardcoded guess (e.g. voteOnMilestone currently sets released/returned from the return value of resolveAssertion alone). For milestones with an assertionId and no terminal status yet, poll on an interval (or on demand via a refresh action) so status advances even without the user having just taken an action, e.g. once someone else's finalize call lands, or once a challenge window quietly expires.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmediumModerate scope or risk

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions