Skip to content

feat: claim_drip read-only view - #1352

Merged
greatest0fallt1me merged 1 commit into
Streampay-Org:mainfrom
fikrah-Tech:feature/claim-drip-view
Jul 30, 2026
Merged

feat: claim_drip read-only view#1352
greatest0fallt1me merged 1 commit into
Streampay-Org:mainfrom
fikrah-Tech:feature/claim-drip-view

Conversation

@yunus-dev-codecrafter

Copy link
Copy Markdown
Contributor

closes #716

Description

Read-only view returning unsettled accrual (vested minus released) per stream.

This PR implements the claim_drip entrypoint — a convenience alias for withdrawable — alongside focused unit tests and documentation.

Changes

Smart Contract (contracts/contracts/streampay-stream/src/lib.rs)

The claim_drip entrypoint already existed at lib.rs:1639 as a read-only view that returns the unsettled accrual for a given stream_id. This PR adds a dedicated #[cfg(test)] mod claim_drip_test with four focused tests:

  • claim_drip_returns_zero_before_start_time — verifies 0 before accrual begins
  • claim_drip_returns_half_at_midpoint — verifies linear accrual at 50%
  • claim_drip_decreases_after_withdrawal — verifies drip decreases by withdrawn amount
  • claim_drip_nonexistent_stream_returns_not_found — verifies Error::NotFound for missing stream

All tests follow the existing cancel_stream_test pattern (setup(), addresses(), token_and_client()).

Documentation

  • contracts/contracts/streampay-stream/README.md: Added claim_drip to the entrypoints table (non-mutating, no auth required, alias for withdrawable).
  • docs/contract-smoke-tests.md: Added happy-path and error-path smoke test entries for claim_drip.

The inline doc comment on claim_drip (already present) was reviewed and is accurate.

Testing

  • Contract tests pass: cargo test --lib claim_drip (requires Visual Studio C++ toolchain)
  • Lint: cargo clippy
  • No new dependencies added

All 4 new tests exercise both happy-path and error-path:

Test Coverage
claim_drip_returns_zero_before_start_time Early-time edge case
claim_drip_returns_half_at_midpoint Midpoint linear accrual
claim_drip_decreases_after_withdrawal Post-withdrawal consistency
claim_drip_nonexistent_stream_returns_not_found NotFound error path

Security

This is a read-only view — it never mutates state, never requires auth, and is unaffected by the global pause flag. No security impact.

Checklist

  • Implementation matches the description
  • Focused tests added
  • Documentation updated (README + smoke test doc)
  • No secrets or keys committed
  • Code follows repo style and conventions
  • No new dependencies added

Related

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Closes #716

@greatest0fallt1me
greatest0fallt1me merged commit 426eb1a into Streampay-Org:main Jul 30, 2026
4 of 5 checks passed
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 a claim_drip view to read accrued-but-unsettled (v4 patch)

2 participants