Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: voiding #420

Merged
merged 5 commits into from
Apr 4, 2023
Merged

refactor: voiding #420

merged 5 commits into from
Apr 4, 2023

Conversation

PaulRBerg
Copy link
Member

@PaulRBerg PaulRBerg commented Apr 4, 2023

Addresses #23.

This PR does three things:

  1. Refactors the streamedAmountOf function to void the stream if there is a calculation error and the streamed amount exceeds the deposit amount. If this bug occurs (which should never happen, but still):
    • In the linear streams and in the single-segment dynamic streams, the withdrawn amount is considered the streamed amount, which in effect freezes the stream and lets the sender cancel and recover their funds.
    • In the multi-segment dynamic streams, the segment streamed amount is considered zero, which in effect voids the segment.
  2. Removes the unchecked blocks in cancel, _withdraw, returnableAmountOf, and withdrawableAmountOf.
  3. Removes the now-unneeded assertion amounts.deposit >= amounts.withdrawn in the _withdraw function

docs: improve wording in comments
refactor: remove unneeded "assert" in "_withdraw"
refactor: delete in-memory stream in "_withdraw"
@PaulRBerg
Copy link
Member Author

Merging now. Coverage decreased, but that's expected - we added code that we don't know how to test (because we think it should never happen).

@PaulRBerg PaulRBerg merged commit cea9e5c into main Apr 4, 2023
@PaulRBerg PaulRBerg deleted the refactor/voiding branch April 4, 2023 18:53
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.

1 participant