Skip to content

Fix: 2 issues (#876, #877) - #948

Open
Novastrum1 wants to merge 1 commit into
Stellar-split:mainfrom
Novastrum1:simple/876-877
Open

Novastrum1 wants to merge 1 commit into
Stellar-split:mainfrom
Novastrum1:simple/876-877

Conversation

@Novastrum1

Copy link
Copy Markdown

Closes #876
Closes #877

Issues

#876 Implement milestone-based payment releases with conditions

Overview

Allow recipients to set conditions (deliverables, approvals) before invoice funds are released.

Requirements

  • Design milestone creation interface
  • Implement condition validation system
  • Add approval workflow for conditions
  • Create condition verification tracking
  • Add evidence/documentation upload
  • Implement conditional fund release

Acceptance Criteria

[ ] Milestones can be defined and tracked
[ ] Conditions are enforced before release
[ ] Approval workflow works correctly
[ ] Evidence upload and verification works
[ ] Funds released on condition satisfaction

Definition of Done

All CI checks must pass before the PR is reviewed.

#877 Add invoice dispute resolution system

Overview

Implement structured dispute workflow with evidence, arbitration, and resolution tracking.

Requirements

  • Design dispute creation and tracking
  • Implement evidence submission system
  • Add arbitrator selection mechanism
  • Create dispute timeline and history
  • Implement resolution enforcement
  • Add dispute notifications and alerts

Acceptance Criteria

[ ] Disputes can be created with details
[ ] Evidence can be submitted by both parties
[ ] Arbitrators can review and decide
[ ] Resolution is enforced and tracked
[ ] Notifications keep parties informed

Definition of Done

All CI checks must pass before the PR is reviewed.

Summary

Implement domain logic (state machines, validation, release gating) in lib modules first so UI components stay thin and testable. Reuse existing IPFS, arbitrator registry, and notification helpers rather than duplicating. Ensure all new localStorage keys are namespaced (e.g., stellarsplit_milestones_v1, stellarsplit_disputes_v1). Add unit tests for condition validation, release gating, dispute state transitions, and resolution enforcement. Run lint, typecheck, and tests before PR. The release gate must be enforced server-side/contract-side as well; the client-side gate is a UX safeguard only.

Changes

  • Extend the milestone domain model to support conditional releases. Add types for MilestoneCondition (deliverable, approval, evidence), ConditionStatus, ApprovalRecord, EvidenceRecord, and MilestoneState. Implement validation functions (validateCondition, canReleaseMilestone) that enforce all conditions are satisfied before release. Add persistence helpers (getMilestones, saveMilestones, addCondition, submitEvidence, approveCondition, verifyCondition) backed by localStorage, and a release gate function that throws if any condition is unmet. Include unit-testable pure functions for condition validation and release gating. (src/lib/invoiceMilestones.ts)
  • Add a dispute state machine and persistence layer. Define DisputeStatus (open, evidence, arbitration, resolved, enforced), DisputeRecord with initiator, reason, description, assigned arbitrators, evidence list, append-only timeline events, and resolution outcome. Implement createDispute, submitEvidence (both parties), assignArbitrator, recordVote, resolveDispute, and enforceResolution functions with validation (e.g., cannot resolve without arbitrator votes, cannot enforce before resolution). Persist to localStorage and expose helpers for the UI. Also add arbitrator assignment helpers (assignArbitrators, getAssignedArbitrators) that integrate with the existing registry. (src/lib/arbitrators.ts)
  • Wire notifications for milestone and dispute lifecycle events. Add preference flags for milestoneConditionMet, milestoneReleased, disputeOpened, disputeEvidenceSubmitted, disputeResolved, and disputeEnforced. Implement notifyMilestoneConditionMet, notifyMilestoneReleased, notifyDisputeOpened, notifyDisputeEvidenceSubmitted, notifyDisputeResolved, and notifyDisputeEnforced functions that respect preferences and use sendBrowserNotification. Ensure existing notification helpers remain unchanged. (src/lib/notifications.ts)
  • Add evidence upload helpers for milestones and disputes. Reuse uploadToIpfsWithFallback and isValidCid; add a wrapper uploadEvidence(file) that validates file type/size via existing IPFS rules, returns { cid, filename, size, uploadedAt }, and a validateEvidenceReference(cid) helper. This supports both milestone evidence and dispute evidence submission. (src/lib/ipfs.ts)
  • Extend invoice status handling to support conditional release gating and dispute states. Add helper functions canReleaseInvoice(invoiceId) that checks milestone conditions via invoiceMilestones, and transitionToDisputed/transitionToReleased that validate the current state machine. Ensure Disputed status blocks release until dispute resolution is enforced. Export a function isReleaseBlocked(invoiceId) used by the release flow. (src/lib/invoiceStatus.ts)
  • Add a conditional release function to the Stellar client layer. Implement releaseMilestoneFunds({ invoiceId, milestoneId, payer }) that first calls the milestone release gate (canReleaseMilestone) and throws if conditions are unmet, then invokes the existing contract release path. Also add enforceDisputeResolution({ invoiceId, outcome }) that calls the appropriate release/refund contract method based on the resolved dispute outcome. Both functions should emit notifications on success. (src/lib/stellar.ts)
  • Add API client methods for milestone and dispute operations. Implement createMilestone, submitMilestoneEvidence, approveMilestoneCondition, releaseMilestone, createDispute, submitDisputeEvidence, assignDisputeArbitrator, resolveDispute, and enforceDisputeResolution using apiFetch (with CSRF via apiClient for mutations). Include error handling and typed responses. (src/lib/api.ts)
  • Add CSRF-aware API client wrappers for the new milestone and dispute mutation endpoints. Implement postMilestone, postMilestoneEvidence, postMilestoneApproval, postMilestoneRelease, postDispute, postDisputeEvidence, postDisputeArbitrator, postDisputeResolve, and postDisputeEnforce using the existing apiFetch with CSRF token injection. These wrappers are consumed by the UI components. (src/lib/apiClient.ts)
  • Extend the activity event types to include milestone and dispute events. Add 'milestone_condition_met', 'milestone_released', 'dispute_opened', 'dispute_evidence_submitted', 'dispute_resolved', and 'dispute_enforced' to ActivityEventType so the activity feed can render these lifecycle events. (src/types/activity.ts)
  • Build the milestone creation and management UI. Add a MilestoneEditor section that lets the recipient define milestones with conditions (deliverable text, approval requirement, evidence requirement), upload evidence via the IPFS helper, display condition status (pending/approved/verified), and show a Release button that is disabled until all conditions are satisfied. Wire the release button to the conditional release API and emit notifications. Integrate into the existing invoice detail view. (src/components/InvoiceDetail.tsx)
  • Update the dispute panel to use the new dispute state machine. Replace ad-hoc dispute metadata with DisputeRecord from arbitrators.ts, show evidence list with IPFS links, display arbitrator assignment and vote status, and add a resolution enforcement button visible to arbitrators once votes are complete. Wire evidence submission to the IPFS helper and the dispute API, and emit notifications on each transition. (src/components/DisputePanel.tsx)
  • Update the dispute timeline to render the append-only timeline from DisputeRecord (open, evidence, arbitration, resolved, enforced) with timestamps and actors. Support the new event types and show resolution enforcement as a distinct final event. Ensure it reads from the persisted dispute record rather than only contract events. (src/components/DisputeTimeline.tsx)
  • Update the dispute wizard to create a DisputeRecord via the new API, validate description length and reason, allow arbitrator selection from the registry (or manual entry), and submit evidence optionally during creation. On success, emit a dispute-opened notification and refresh the invoice. (src/components/DisputeWizard.tsx)
  • Enhance the arbitrator picker to support assignment mode (selecting arbitrators for a dispute) in addition to display mode. Add an onAssign callback and a multi-select mode used by the dispute wizard and panel. Show vote status and resolved-dispute counts from the registry. (src/components/ArbitratorPicker.tsx)
  • Extend the notification center to poll and render milestone and dispute notifications. Add new notification types ('milestone', 'dispute') with icons, and detect state transitions (condition met, milestone released, dispute opened, evidence submitted, resolved, enforced) from the persisted records. Keep the existing polling logic for payments and funding. (src/components/NotificationCenter.tsx)
  • Update the proof viewer to support viewing milestone and dispute evidence by CID. Add a mode prop ('payment' | 'evidence') and render IPFS evidence (images/PDFs) via getIpfsUrl, with validation via isValidCid. Reuse the existing zoom/pan controls for image evidence. (src/components/ProofViewer.tsx)
  • Update the status timeline to include milestone condition events and dispute lifecycle events. Derive events from the milestone records (condition met, evidence submitted, released) and dispute records (opened, evidence, resolved, enforced) in addition to the existing funding events. Ensure the mobile stepper reflects a Disputed state. (src/components/StatusTimeline.tsx)

Co-authored-by: Simple Agent <agent@simple.dev>
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Novastrum1 is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Novastrum1 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! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
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.

Add invoice dispute resolution system Implement milestone-based payment releases with conditions

1 participant