Skip to content

Comments

feat: Refactor Remittance Split Error Handling#113

Open
mansory-01 wants to merge 1 commit intoRemitwise-Org:mainfrom
mansory-01:main
Open

feat: Refactor Remittance Split Error Handling#113
mansory-01 wants to merge 1 commit intoRemitwise-Org:mainfrom
mansory-01:main

Conversation

@mansory-01
Copy link

This PR refactors the remittance_split contract to improve error consistency and safety. It introduces a custom RemittanceSplitError enum and updates all public methods to return Result instead of panicking, aligning the contract with the bill_payments pattern.


Changes

Custom Error Enum

  • Introduced RemittanceSplitError enum with descriptive variants including PercentagesDoNotSumTo100, InvalidAmount, and Unauthorized.

Result-Based Refactoring

  • Refactored initialize_split, update_split, and calculate_split to return Result instead of panicking.
  • Refactored schedule management functions (create, modify, cancel) to return Result for consistent error propagation.

Contract Fixes & Cleanup

  • Fixed corrupted header and struct definitions in lib.rs.
  • Consolidated calculation logic in calculate_split to remove redundancy.
  • Resolved unused variable warnings in gas_bench.rs.

Test Suite Updates

  • Updated all unit tests to assert specific error variants against the new RemittanceSplitError enum.

Checklist

  • RemittanceSplitError enum introduced with descriptive variants
  • initialize_split, update_split, and calculate_split refactored to return Result
  • Schedule management functions (create, modify, cancel) refactored to return Result
  • Corrupted header and struct definitions in lib.rs fixed
  • Calculation logic in calculate_split consolidated
  • All unit tests updated to assert specific error variants
  • Unused variable warnings in gas_bench.rs resolved
  • All tests verified via cargo test -p remittance_split

Screenshot 2026-02-20 043738

closes #71

@Baskarayelu
Copy link
Contributor

@mansory-01 please fix the pipeline

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.

Use Custom Errors in Remittance Split Instead of panic!

2 participants