Skip to content

Add Status Enum & updateIssueStatus Function #4

@nottherealalanturing

Description

@nottherealalanturing

Module: Smart Contracts (Flare Network – Solidity)
Description:
Introduce a Status enum to clearly define the lifecycle of an issue. Update the Issue struct to use this enum and implement a function that allows authorized entities to update the status of a given issue.


✅ Tasks

1. Define the Status Enum

  • Add the following enum to GroundUpIssue.sol:
enum Status { Pending, UnderReview, Resolved, Rejected }

2. Update the Issue Struct

  • Replace the status field type from string to Status:
Status status;
  • Initialize to Status.Pending when reporting an issue (reportIssue).

3. Implement updateIssueStatus Function

  • Add the function:
function updateIssueStatus(uint256 _issueId, Status _newStatus) public onlyOwner // or onlyAuthorized
  • Requirements:

    • Ensure the issue exists.
    • Update the status field in the corresponding Issue struct.
    • Update latestStatusUpdateTimestamp to block.timestamp.
    • Emit a StatusUpdated event.

4. Declare the Event

event StatusUpdated(
  uint256 indexed issueId,
  Status newStatus,
  address indexed updater,
  uint256 timestamp
);

5. Access Control

  • Restrict updateIssueStatus to onlyOwner or use a custom onlyAuthorized modifier, if already implemented.

6. Testing

  • Unit test the following:

    • Status updates work for valid issue IDs.
    • The enum transitions are properly reflected in storage.
    • The StatusUpdated event is emitted.
    • Unauthorized access is prevented.

✅ Acceptance Criteria

  • Status enum is defined and used in the Issue struct.
  • reportIssue initializes the issue with Status.Pending.
  • updateIssueStatus modifies the issue status securely and updates timestamp.
  • Event logs are correctly emitted.
  • All logic is tested and passes.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions