Skip to content

feat(contract): recipient-initiated stream pause/resume with auto-res… - #614

Merged
Topmatrixmor2014 merged 7 commits into
FinChippay:mainfrom
Chigybillionz:feat/recipient-stream-pause-resume
Aug 25, 2026
Merged

feat(contract): recipient-initiated stream pause/resume with auto-res…#614
Topmatrixmor2014 merged 7 commits into
FinChippay:mainfrom
Chigybillionz:feat/recipient-stream-pause-resume

Conversation

@Chigybillionz

Copy link
Copy Markdown
Contributor

Close #558

Summary of the issue

Previously, stream payment recipients could only perform destructive lifecycle operations (reject_stream), which permanently closed the stream and returned unaccrued tokens to the payer. Recipients had no mechanism to temporarily pause incoming stream token accruals during compliance/KYC reviews, accounting periods, or disputes without severing the stream relationship.

Root cause

The Stream data structure lacked fields to track recipient-initiated pauses (recipient_paused, recipient_paused_at, recipient_paused_duration, auto_resume_ledger, pause_reason), and the contract lacked entry points (pause_stream_by_recipient, resume_stream_by_recipient, get_stream_pause_info) and pure token calculation logic (claimable_at) to deduct paused ledger windows from active streaming time.

Solution implemented

  1. Extended Stream with 5 recipient pause tracking fields and introduced the StreamPauseInfo struct to query pause state and auto-resume deadlines.
  2. Implemented pause_stream_by_recipient with auto_resume_ledger deadline validation (l > current_ledger and l <= current_ledger + MAX_PAUSE_LEDGERS) and reason: Symbol context tracking.
  3. Implemented resume_stream_by_recipient to accumulate paused duration (recipient_paused_duration += current_ledger - recipient_paused_at) and clear pause state.
  4. Added auto-resume handling in claim_stream and pure claimable_at calculation to automatically reactivate accrual when sequence reaches auto_resume_ledger.
  5. Ensured full compatibility with existing payer actions (top_up_stream, close_stream), recipient actions (reject_stream), and transfer_stream.

Key changes made

  • Extended Stream struct and added StreamPauseInfo struct in contracts/finchippay-contract/src/lib.rs.
  • Added const MAX_PAUSE_LEDGERS: u32 = 6_307_200; (~1 year at 5s/ledger).
  • Added pause_stream_by_recipient, resume_stream_by_recipient, get_stream_pause_info, and pure claimable_at functions.
  • Added auto-resume evaluation in claim_stream before claimable token calculation.
  • Expanded test suite with 7 new integration and property-based test functions verifying pause/resume lifecycles, auto-resume, duration safety limits, operation compatibility, and invariants I1–I8.

Any trade-offs or considerations

  • Pause duration accumulation is tracked per-stream in recipient_paused_duration to ensure separate accounting from contract-wide emergency pause.
  • Auto-resuming evaluates dynamically in view functions (get_claimable, get_stream_pause_info) and mutates state on claim_stream, ensuring payers are never trapped by an unresumed stream past deadline.

Testing steps (how to verify the fix)

  1. Run cargo test in the contract crate:
    cargo test --manifest-path contracts/finchippay-contract/Cargo.toml

Chigybillionz and others added 3 commits August 16, 2026 02:29
- Normalize logger.error calls to use structured format (msg, ctx, error)
- Fix BigInt literal syntax (0n → BigInt(0)) for broader compatibility
- Add null coalescing for explorerUrl returns to fix href type errors
- Cast custom event handlers as EventListener for window.addEventListener
- Remove baseFee param from payment transaction builders (use server defaults)
- Add buildClaimStreamTransaction import to StreamingPayments
- Expand Invoice interface with status, PDF generation stubs
- Add PaymentRecord "payment" type alias and timestamp/hash fields
- Add address book contact management with encrypted storage
- Fix ledger optional peer dependency imports with @ts-expect-error
- Simplify escrow return to use result.hash directly
- Add recipient field to InvoiceModal form state

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@github-actions github-actions Bot added the needs-review PR ready for Greptile AI code review label Aug 22, 2026
Comment thread frontend/lib/wallet.ts
Comment on lines +28 to +34
import {
getOrCreateSalt,
deriveKey,
setSessionKey,
getSessionKey,
getSessionOwner,
} from "@/lib/encryption";
Chigybillionz and others added 2 commits August 22, 2026 20:49
The dual push/pull_request triggers caused duplicate skipped checks
on feature branch pushes. Remove the push trigger so CI only runs
on pull_request events, eliminating the noise.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Topmatrixmor2014

Copy link
Copy Markdown
Contributor

please address the review comments on this PR

@Topmatrixmor2014
Topmatrixmor2014 merged commit 418ec33 into FinChippay:main Aug 25, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review PR ready for Greptile AI code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recipient-Initiated Stream Pause/Resume with Auto-Resume Deadline

3 participants