Skip to content

feat: Add market liquidity filter with minimum pool size threshold#220

Merged
ISTIFANUS-N merged 1 commit intorinafcode:mainfrom
kryputh:feat/issue-151-refactor-function-parameters
Apr 1, 2026
Merged

feat: Add market liquidity filter with minimum pool size threshold#220
ISTIFANUS-N merged 1 commit intorinafcode:mainfrom
kryputh:feat/issue-151-refactor-function-parameters

Conversation

@kryputh
Copy link
Copy Markdown
Contributor

@kryputh kryputh commented Mar 30, 2026

Closes #151

Implements issue #151: Refactor functions with 8+ parameters to improve code quality and maintainability.

Changes

  • Escrow: Refactored create_escrow() from 10 parameters to use EscrowParameters struct
  • Social Learning: Created CreateStudyGroupParams struct with builder pattern (was 9 params)
  • Social Learning: Created CreatePeerReviewParams struct (was 8 params)
  • Validation: Added validate_escrow_parameters() with parameter combination validation
  • Errors: Added new validation error types (InvalidBeneficiary, InvalidToken, InvalidArbitrator, DepositorCannotBeBeneficiary)

Benefits

✓ Cleaner, more readable function signatures
✓ Related parameters grouped logically
✓ Automatic validation of parameter combinations
✓ Builder pattern for flexible object construction
✓ Easier to test and maintain
✓ Reduced cognitive load for developers using these functions

Files Changed

  • contracts/teachlink/src/escrow.rs - Use EscrowParameters instead of 10 individual params
  • contracts/teachlink/src/social_learning.rs - New parameter objects with builder pattern
  • contracts/teachlink/src/validation.rs - New validation functions for parameter structs
  • contracts/teachlink/src/errors.rs - New error types for validation

Acceptance Criteria Met

✓ Refactored functions with too many parameters
✓ Used parameter objects and structs for related parameters
✓ Implemented builder pattern for complex function calls
✓ Added validation for parameter combinations
✓ Simplified function interfaces where possible

…ects and builder pattern

Issue rinafcode#151: Code Quality & Maintainability

Changes:
- Escrow: Refactored create_escrow() to use EscrowParameters struct instead of 10 individual parameters
- Social Learning: Created CreateStudyGroupParams struct with builder pattern for create_study_group() (was 9 params)
- Social Learning: Created CreatePeerReviewParams struct for create_review() (was 8 params)
- Validation: Added validate_escrow_parameters() and parameter combination validation
- Errors: Added new error types for parameter validation (InvalidBeneficiary, InvalidToken, etc.)

Benefits:
- Improved function signatures readability
- Reduced parameter coupling
- Automatic validation of related parameters
- Builder pattern enables flexible object construction
- Better maintainability and testability
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 30, 2026

@kryputh 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

@ISTIFANUS-N ISTIFANUS-N merged commit 3949f32 into rinafcode:main Apr 1, 2026
5 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overly Complex Function Signatures

2 participants