Skip to content

fix(contracts): address validation guards in factory, token vault, and twap oracle - #319

Merged
Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
Gabbydunkk:fix/factory-vault-oracle-validations
Aug 26, 2026
Merged

fix(contracts): address validation guards in factory, token vault, and twap oracle#319
Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
Gabbydunkk:fix/factory-vault-oracle-validations

Conversation

@Gabbydunkk

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR resolves 4 validation and error-handling issues across TokenVault, DripFactory, and TwapOracle:

  1. TokenVault uninitialized error distinction (Closes Docs: TokenVault overloads NotAuthorized to mean 'not yet initialized' #301):

    • Added NotInitialized = 8 and AlreadyInitialized = 9 variants to TokenVault's Error enum.
    • Updated deposit, withdraw, set_limit, set_operator, revoke_operator, pause, and unpause to return Error::NotInitialized when called on an uninitialized vault instead of misleadingly returning Error::NotAuthorized (or Error::ArithmeticOverflow).
    • Added unit tests for uninitialized and duplicate-initialization states in contracts/token-vault/src/tests.rs.
  2. DripFactory token address validation (Closes Enhancement: DripFactory::create_stream never validates the token address, unlike the recipient #302):

    • Added InvalidToken = 28 to DripFactory's Error enum.
    • Added is_zero_stellar_account(&env, &token) check in DripFactory::create_stream returning typed Error::InvalidToken, matching the documented validation rules in README.md.
    • Added unit and integration tests in tests/factory_deploy.rs and tests/factory_batch_create.rs.
  3. Reject sender as stream recipient (Closes Enhancement: DripFactory::create_stream doesn't reject sender == recipient #303):

    • Added recipient == sender validation in DripFactory::create_stream returning Error::InvalidRecipient.
    • Updated README.md validation rules and added unit tests in tests/factory_deploy.rs and tests/factory_batch_create.rs.
  4. TwapOracle max_staleness validation (Closes Enhancement: TwapOracle::configure_oracle doesn't validate max_staleness #305):

    • Added InvalidMaxStaleness = 1015 to TwapOracle's Error enum.
    • Added config.max_staleness == 0 validation to TwapOracle::configure_oracle returning Error::InvalidMaxStaleness.
    • Added unit test configure_oracle_rejects_zero_max_staleness in contracts/oracle/src/lib.rs.

Closes #301
Closes #302
Closes #303
Closes #305

@Gabbydunkk
Gabbydunkk requested a review from Jaydbrown as a code owner August 26, 2026 07:08
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Gabbydunkk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jaydbrown

Copy link
Copy Markdown
Contributor

Thanks for the contribution here — squash-merging this now. Any follow-ups we'll track in a fresh issue. 🚀

@Jaydbrown
Jaydbrown merged commit 7ab500e into conduit-protocol:main Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants