Repository navigation
fix: keep the recipient's claimable balance unwithdrawn after a cancel (#542) - #665
Closed
PINYOPATTANAWASANPORN wants to merge 1 commit into
Closed
PINYOPATTANAWASANPORN wants to merge 1 commit into
PINYOPATTANAWASANPORN wants to merge 1 commit into
Conversation
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.
Summary of Changes
Fixes #542. When a stream is cancelled,
applyCancellationinsrc/repositories/streams.tsnow only freezestotalAmountto the vested balance at cancellation (stored.withdrawn + recipientAmount) and setsendTimetocancelledAt, without updatingwithdrawn. The recipient's vested-but-unwithdrawn tokens remain claimable, accurately reflecting the smart contract's behavior.Root Cause / Technical Context
Previously,
applyCancellationset bothtotalAmountandwithdrawntofrozenTotal, operating under the assumption that cancellation settled the recipient's balance immediately. In reality, the Soroban contract only refunds unvested tokens to the sender, leaving the recipient's balance (recipient_amount) claimable. Prematurely markingwithdrawn = frozenTotalzeroed out the derivedwithdrawablefield, and caused subsequent withdrawals to incrementwithdrawnpasttotalAmount.Verification & Testing
tests/repositories/streams.test.tscovering:totalAmountwithout settingwithdrawnin the update payload.missingwhen the stream does not exist.duplicatewhenupdateManymatches 0 rows due to an event race.applyCancellation,docs/database-schema.md, andprisma/schema.prismaupdated to state "still claimable" instead of "paid".docs/derived-figures.mdupdated to reflect mathematical parity.npm run typecheck: Exit Code 0 (tsc --noEmit && tsc -p tsconfig.test.json).npm test: 49/49 test files passed, 583/583 tests passed.npm run build: Exit Code 0.Impact & Compatibility