fix: proposal counter starts at 0 to eliminate ID gap in create_proposal - #565
Merged
Naomi-Gift merged 1 commit intoAug 20, 2026
Merged
Conversation
Change unwrap_or(1) to unwrap_or(0) for NextAdminProposalId in both primary and scripts copies of admin_manager.rs. This ensures the first proposal gets ID 0, aligning with zero-based indexing and eliminating the gap where ID 0 was never used. Also added test_proposal_ids_start_at_zero to verify sequential zero-based ID assignment across multiple proposals. Closes HubDApp#531
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #531
Summary
Fixes the proposal ID initialization bug in create_proposal() where unwrap_or(1) caused the counter to start at 1, leaving ID 0 unused and creating an off-by-one gap in zero-based indexing.
Problem
In �dmin_manager.rs::create_proposal(), the proposal ID counter defaults to 1 via unwrap_or(1) when NextAdminProposalId is not yet stored. This means:
Fix
Changed unwrap_or(1) to unwrap_or(0) in both:
Now the first proposal correctly gets ID 0, with sequential incrementing from there.
Test Added
Testing
Note: cargo test requires MSVC build tools not available in this environment. The change is a single default value swap (1 ->