Skip to content

Hardcoded Cancel Vote Index (u32::MAX) #161

@hman38705

Description

@hman38705

Description
The logic get_tally(e, market_id, u32::MAX) is used as a heuristic for tracking Cancel votes. Using u32::MAX as a reserved index is undocumented and risk-prone if a market were to theoretically support a very large number of legitimate outcomes. It lacks type safety and clear intention.

Requirements and context

  • Define a formal constant or enum variant for the cancellation vote index.
  • Centralize the definition in types.rs.

Suggested execution

  • Fork the repo and create a branch: git checkout -b refactor/issue-54-cancel-index
  • Replace raw literal with named constant.

Implementation changes

  • Add pub const CANCEL_OUTCOME_INDEX: u32 = u32::MAX; to types.rs.
  • Update cancellation.rs and voting.rs to use this constant.

Test and commit

  • Verify that votes cast for the CANCEL_OUTCOME_INDEX are correctly aggregated.

Example commit message
refactor: define and use CANCEL_OUTCOME_INDEX constant instead of raw literal

Guidelines

  • Code maintainability.
  • Timeframe: 12 hours.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions