feat(contract): recipient-initiated stream pause/resume with auto-res… - #614
Merged
Topmatrixmor2014 merged 7 commits intoAug 25, 2026
Conversation
- 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>
Comment on lines
+28
to
+34
| import { | ||
| getOrCreateSalt, | ||
| deriveKey, | ||
| setSessionKey, | ||
| getSessionKey, | ||
| getSessionOwner, | ||
| } from "@/lib/encryption"; |
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>
Contributor
|
please address the review comments on this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Streamdata 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
Streamwith 5 recipient pause tracking fields and introduced theStreamPauseInfostruct to query pause state and auto-resume deadlines.pause_stream_by_recipientwithauto_resume_ledgerdeadline validation (l > current_ledgerandl <= current_ledger + MAX_PAUSE_LEDGERS) andreason: Symbolcontext tracking.resume_stream_by_recipientto accumulate paused duration (recipient_paused_duration += current_ledger - recipient_paused_at) and clear pause state.claim_streamand pureclaimable_atcalculation to automatically reactivate accrual when sequence reachesauto_resume_ledger.top_up_stream,close_stream), recipient actions (reject_stream), andtransfer_stream.Key changes made
Streamstruct and addedStreamPauseInfostruct incontracts/finchippay-contract/src/lib.rs.const MAX_PAUSE_LEDGERS: u32 = 6_307_200;(~1 year at 5s/ledger).pause_stream_by_recipient,resume_stream_by_recipient,get_stream_pause_info, and pureclaimable_atfunctions.claim_streambefore claimable token calculation.Any trade-offs or considerations
recipient_paused_durationto ensure separate accounting from contract-wide emergency pause.get_claimable,get_stream_pause_info) and mutates state onclaim_stream, ensuring payers are never trapped by an unresumed stream past deadline.Testing steps (how to verify the fix)
cargo test --manifest-path contracts/finchippay-contract/Cargo.toml