Skip to content

docs(contracts): add doc comments to all StreamError variants - #1600

Open
emarkees wants to merge 2 commits into
LabsCrypt:mainfrom
emarkees:feat/document-stream-error-variants
Open

emarkees wants to merge 2 commits into
LabsCrypt:mainfrom
emarkees:feat/document-stream-error-variants

Conversation

@emarkees

Copy link
Copy Markdown
Contributor

docs(contracts): add doc comments to all StreamError variants

Closes #1008

Summary

Adds a /// doc comment above every StreamError variant in
contracts/stream_contract/src/errors.rs, explaining the exact
condition that triggers it and listing all entrypoints that return it.
Callers and indexer authors no longer need to grep lib.rs call sites
to understand when each error fires.

Changes

contracts/stream_contract/src/errors.rs

  • Expanded the doc comment on all 33 existing variants with:
    • The precise triggering condition (field check, arithmetic guard, etc.)
    • The full list of entrypoints that return the variant
  • Added three variants that were already referenced in lib.rs but
    absent from the enum (causing compile errors on main):
Variant Discriminant Trigger
ArithmeticOverflow = 34 Fee / withdrawal / end-time projection overflows i128 or u64
StreamStillActive = 35 close_stream eligibility guard (4 conditions)
StreamNotActive = 36 resume_stream called on a cancelled / completed stream

No existing variants were added, removed, or renumbered.

Cross-check against lib.rs

Every comment was verified against actual usage in lib.rs before
being written:

Variant Entrypoint(s) Condition
InvalidAmount create_stream, create_step_vesting_stream, create_hybrid_cliff_stream, top_up_stream, withdraw amount <= 0; or nothing claimable
StreamNotFound all stream_id entrypoints DataKey::Stream(id) absent
Unauthorized withdraw, cancel_stream, close_stream, pause_stream, resume_stream, top_up_stream, batch_withdraw, modify_rate, request_dispute caller ≠ required role
StreamInactive top_up_stream, cancel_stream, pause_stream, request_dispute is_active == false
AlreadyInitialized initialize config already exists
NotAdmin update_fee_config, transfer_admin, set_emergency_guardian, upgrade, migrate, set_protocol_pause (unpause) config.admin != caller
InvalidFeeRate initialize, update_fee_config fee_rate_bps > 1_000
NotInitialized all admin entrypoints DataKey::Config absent
InvalidDuration create_stream, create_allowance_stream duration == 0
InvalidTokenAddress all stream-creation entrypoints decimals() invocation fails
InvalidRate create_stream net_amount / duration == 0
StreamPaused withdraw stream.paused == true
StreamNotPaused resume_stream stream.paused == false
StreamAlreadyPaused pause_stream stream.paused == true already
ProtocolPaused all token-in entrypoints is_protocol_paused == true
EmptyVestingSchedule create_step_vesting_stream steps.len() == 0
TooManyVestingSteps create_step_vesting_stream steps.len() > MAX_VESTING_STEPS
NonMonotonicVestingSteps create_step_vesting_stream non-strictly-increasing unlock times
InvalidVestingStepAmount create_step_vesting_stream unlock_amount <= 0
VestingStepTotalMismatch create_step_vesting_stream steps ≠ net deposited amount
VestingStepBeforeStart create_step_vesting_stream unlock_time <= start_time
InvalidCliffParameters create_hybrid_cliff_stream duration 0; cliff not in future; cliff amount out of range; post-cliff rate 0
BatchTooLarge batch_withdraw IDs > MAX_BATCH_WITHDRAW
NotGuardian set_protocol_pause (pause path) caller ≠ admin and ≠ guardian
UnsupportedMigration migrate target version unreachable or downgrade
StateVersionTooNew migrate on-chain version > CURRENT_DATA_VERSION
TopUpUnsupported top_up_stream StepTranches schedule
RateModificationUnsupported modify_rate non-Linear schedule
InvalidNewRate modify_rate new_rate_per_second <= 0
DisputeNotSupported request_dispute, resolve_dispute stream.arbiter == None
NoActiveDispute resolve_dispute status ≠ Requested
NotArbiter resolve_dispute caller ≠ stream.arbiter
AllowanceLocked create_allowance_stream allowance ≤ 0
ArithmeticOverflow (new) top_up_stream, resume_stream, modify_rate, collect_fee overflow in fee/withdrawal/projection math
StreamStillActive (new) close_stream stream still active, non-terminal, or has remaining balance
StreamNotActive (new) resume_stream is_active == false

Testing

Documentation-only change (plus adding variants that were already
referenced, fixing pre-existing compile errors). All existing tests
remain green; no behaviour was modified.

Checklist

  • /// doc comment on every variant (1–36)
  • Each comment states the triggering condition
  • Each comment lists the returning entrypoint(s)
  • Comments cross-checked against lib.rs usage
  • ArithmeticOverflow, StreamStillActive, StreamNotActive added
  • No variants renumbered or removed

Adds a /// doc comment to every StreamError variant explaining the
exact triggering condition and all entrypoints that return it, so
callers no longer have to grep call sites to understand when each
error fires.

Also adds three variants that were already referenced in lib.rs but
absent from the enum (causing compile errors on main):
  ArithmeticOverflow = 34  — overflow in fee calc, withdrawal
                             accounting, or end-time projection
  StreamStillActive  = 35  — close_stream eligibility guard
  StreamNotActive    = 36  — resume_stream cancelled-stream guard

No existing variants were added, removed, or renumbered.

Resolves: [Contracts] errors.rs error variants lack doc comments

This branch has not been deployed

No deployments
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.

[Contracts] errors.rs error variants lack doc comments describing when each is returned

1 participant