-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Admin
committed
Nov 29, 2024
1 parent
7d57754
commit 6c53ac5
Showing
10 changed files
with
977 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
/** | ||
* @title DisputeResolution | ||
* @notice Provides a structured system for resolving project-related disputes | ||
*/ | ||
contract DisputeResolution { | ||
// Enum for dispute categories | ||
enum DisputeCategory { | ||
Funding, | ||
MilestoneCompletion, | ||
Collaboration, | ||
Deliverables, | ||
Other | ||
} | ||
|
||
// Enum for dispute status | ||
enum DisputeStatus { | ||
Initiated, | ||
UnderReview, | ||
Mediation, | ||
Resolved, | ||
Closed | ||
} | ||
|
||
// Struct to represent a dispute | ||
struct Dispute { | ||
uint256 id; | ||
address project; | ||
address initiator; | ||
address respondent; | ||
DisputeCategory category; | ||
string description; | ||
DisputeStatus status; | ||
uint256 createdAt; | ||
uint256 resolvedAt; | ||
address mediator; | ||
string resolution; | ||
} | ||
|
||
// Mapping of dispute ID to Dispute | ||
mapping(uint256 => Dispute) public disputes; | ||
|
||
// Counter for dispute IDs | ||
uint256 public disputeCounter; | ||
|
||
// Mapping to track active disputes per project | ||
mapping(address => uint256[]) public projectDisputes; | ||
|
||
// Mapping of approved mediators | ||
mapping(address => bool) public approvedMediators; | ||
|
||
// Events | ||
event DisputeInitiated( | ||
uint256 indexed disputeId, address indexed project, address initiator, DisputeCategory category | ||
); | ||
|
||
event DisputeStatusChanged(uint256 indexed disputeId, DisputeStatus newStatus); | ||
|
||
event DisputeResolved(uint256 indexed disputeId, string resolution); | ||
|
||
// Modifier to restrict actions to approved mediators | ||
modifier onlyApprovedMediator() { | ||
require(approvedMediators[msg.sender], "Not an approved mediator"); | ||
_; | ||
} | ||
|
||
/** | ||
* @notice Add an approved mediator | ||
* @param _mediator Address of the mediator | ||
*/ | ||
function addMediator(address _mediator) public { | ||
approvedMediators[_mediator] = true; | ||
} | ||
|
||
/** | ||
* @notice Initiate a new dispute | ||
* @param _project Project address | ||
* @param _respondent Address of the respondent | ||
* @param _category Dispute category | ||
* @param _description Detailed description of the dispute | ||
*/ | ||
function initiateDispute( | ||
address _project, | ||
address _respondent, | ||
DisputeCategory _category, | ||
string memory _description | ||
) public returns (uint256) { | ||
disputeCounter++; | ||
|
||
disputes[disputeCounter] = Dispute({ | ||
id: disputeCounter, | ||
project: _project, | ||
initiator: msg.sender, | ||
respondent: _respondent, | ||
category: _category, | ||
description: _description, | ||
status: DisputeStatus.Initiated, | ||
createdAt: block.timestamp, | ||
resolvedAt: 0, | ||
mediator: address(0), | ||
resolution: "" | ||
}); | ||
|
||
projectDisputes[_project].push(disputeCounter); | ||
|
||
emit DisputeInitiated(disputeCounter, _project, msg.sender, _category); | ||
|
||
return disputeCounter; | ||
} | ||
|
||
/** | ||
* @notice Update dispute status | ||
* @param _disputeId ID of the dispute | ||
* @param _newStatus New status for the dispute | ||
*/ | ||
function updateDisputeStatus(uint256 _disputeId, DisputeStatus _newStatus) public onlyApprovedMediator { | ||
disputes[_disputeId].status = _newStatus; | ||
|
||
emit DisputeStatusChanged(_disputeId, _newStatus); | ||
} | ||
|
||
/** | ||
* @notice Resolve a dispute | ||
* @param _disputeId ID of the dispute | ||
* @param _resolution Resolution details | ||
*/ | ||
function resolveDispute(uint256 _disputeId, string memory _resolution) public onlyApprovedMediator { | ||
Dispute storage dispute = disputes[_disputeId]; | ||
|
||
dispute.status = DisputeStatus.Resolved; | ||
dispute.resolution = _resolution; | ||
dispute.resolvedAt = block.timestamp; | ||
|
||
emit DisputeResolved(_disputeId, _resolution); | ||
} | ||
|
||
/** | ||
* @notice Get disputes for a project | ||
* @param _project Project address | ||
* @return Array of dispute IDs | ||
*/ | ||
function getProjectDisputes(address _project) public view returns (uint256[] memory) { | ||
return projectDisputes[_project]; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
/** | ||
* @title ProjectCategories | ||
* @notice Manages project categories and tags for discovery | ||
*/ | ||
contract ProjectCategories { | ||
// Enum for predefined project domains | ||
enum ProjectDomain { | ||
Technology, | ||
SocialImpact, | ||
CreativeArts, | ||
Education, | ||
Environment, | ||
Healthcare, | ||
Other | ||
} | ||
|
||
// Struct to represent a project category | ||
struct Category { | ||
uint256 id; | ||
string name; | ||
ProjectDomain domain; | ||
string description; | ||
bool isActive; | ||
} | ||
|
||
// Mapping of category ID to Category | ||
mapping(uint256 => Category) public categories; | ||
|
||
// Counter for category IDs | ||
uint256 public categoryCounter; | ||
|
||
// Mapping of project address to its categories/tags | ||
mapping(address => uint256[]) public projectCategories; | ||
|
||
// Event for category creation | ||
event CategoryCreated(uint256 indexed categoryId, string name, ProjectDomain domain); | ||
|
||
// Event for project categorization | ||
event ProjectCategorized(address indexed project, uint256[] categoryIds); | ||
|
||
/** | ||
* @notice Create a new project category | ||
* @param _name Name of the category | ||
* @param _domain Domain of the category | ||
* @param _description Description of the category | ||
*/ | ||
function createCategory(string memory _name, ProjectDomain _domain, string memory _description) | ||
public | ||
returns (uint256) | ||
{ | ||
categoryCounter++; | ||
|
||
categories[categoryCounter] = | ||
Category({id: categoryCounter, name: _name, domain: _domain, description: _description, isActive: true}); | ||
|
||
emit CategoryCreated(categoryCounter, _name, _domain); | ||
return categoryCounter; | ||
} | ||
|
||
/** | ||
* @notice Assign categories to a project | ||
* @param _project Address of the project | ||
* @param _categoryIds Array of category IDs to assign | ||
*/ | ||
function categorizeProject(address _project, uint256[] memory _categoryIds) public { | ||
// Validate category IDs exist | ||
for (uint256 i = 0; i < _categoryIds.length; i++) { | ||
require(categories[_categoryIds[i]].isActive, "Invalid or inactive category"); | ||
} | ||
|
||
projectCategories[_project] = _categoryIds; | ||
|
||
emit ProjectCategorized(_project, _categoryIds); | ||
} | ||
|
||
/** | ||
* @notice Get categories for a specific project | ||
* @param _project Address of the project | ||
* @return Array of category IDs | ||
*/ | ||
function getProjectCategories(address _project) public view returns (uint256[] memory) { | ||
return projectCategories[_project]; | ||
} | ||
} |
Oops, something went wrong.