Skip to content

Split Ratio Sum Validation #478

Description

@Kingsman-99

Description

Accepting split ratios that do not sum to exactly 100 % (or 10 000 basis points) silently causes either under-distribution or over-distribution of funds. The contract must enforce ratio integrity at invoice creation time.

Technical Context

In contracts/split/src/lib.rs, add a validate_ratios(ratios: &Vec<u32>) -> Result<(), SplitError> private function that sums the slice and compares to the constant BASIS_POINTS_TOTAL = 10_000u32 defined in types.rs. Call it from create_invoice before writing any storage. Return InvalidRatioSum error on mismatch.

Acceptance Criteria

  • Ratios summing to less than 10 000 are rejected with InvalidRatioSum
  • Ratios summing to more than 10 000 are rejected with InvalidRatioSum
  • A ratio vec with one entry equal to 10 000 is accepted
  • Empty ratio vec is rejected with a distinct EmptyRecipientList error
  • Validation runs before any storage writes occur
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions