Skip to main content

DeveloperRules

DeveloperRules

This contract defines and manages the rules and data specific to "Developer" users within the system. Developers are primarily responsible for the development of the project through submitting development reports, which are subject to validation and penalty mechanisms.

Inherits functionalities from Ownable (for contract deploy setup), Callable (for whitelisted function access), and Invitable (for managing invitation logic). It interacts with CommunityRules for general user management, DeveloperPool for reward distribution, VoteRules for voting eligibility, and ValidationRules for report validation processes.

MAX_USER_COUNT

uint16 MAX_USER_COUNT

Maximum users count allowed for this UserType.

maxPenalties

uint8 maxPenalties

The maximum number of penalties a developer can accumulate before facing invalidation.

timeBetweenWorks

uint32 timeBetweenWorks

The minimum number of blocks that must elapse between a developer's successful report publications. This prevents spamming or rapid consecutive report submissions.

securityBlocksToValidation

uint32 securityBlocksToValidation

The number of blocks before the end of an era during which no new reports can be published. This period allows validators sufficient time to analyze and vote on reports before the era concludes.

reportsCount

uint64 reportsCount

The total count of development reports that are currently considered valid (not invalidated).

reportsTotalCount

uint64 reportsTotalCount

The grand total count of all development reports ever submitted, including invalidated ones. This acts as a global unique ID counter for new reports.

totalActiveLevels

uint256 totalActiveLevels

The sum of all active levels from valid reports by non-denied developers.

reports

mapping(uint256 => struct Report) reports

A mapping from a unique report ID to its detailed Report data structure. Stores all submitted development reports.

reportsIds

mapping(address => uint256[]) reportsIds

A mapping from a developer's wallet address to an array of IDs of reports they have submitted.

penalties

mapping(address => struct Penalty[]) penalties

A mapping from a developer's wallet address to an array of Penalty structs they have received.

developersAddress

mapping(uint256 => address) developersAddress

A mapping from a unique developer ID to their corresponding wallet address. Facilitates lookup of a developer's address by their ID.

reportPenalized

mapping(uint64 => bool) reportPenalized

Tracks report IDs that have already been invalidated.

communityRules

contract ICommunityRules communityRules

The interface of the CommunityRules contract, used to interact with community-wide rules, user types, and invitation data.

developerPool

contract IDeveloperPool developerPool

The interface of the DeveloperPool contract, responsible for managing and distributing token rewards to developers.

validationRules

contract IValidationRules validationRules

The interface of the ValidationRules contract, which defines the rules and processes for validating or invalidating development reports.

voteRules

contract IVoteRules voteRules

The interface of the VoteRules contract, which defines rules for user voting eligibility, particularly for report validation.

validationRulesAddress

address validationRulesAddress

The address of the InspectionRules contract.

constructor

constructor(uint32 timeBetweenWorks_, uint8 maxPenalties_, uint32 securityBlocksToValidation_) public

Initializes the DeveloperRules contract with key parameters for report management. Note: External contract addresses (communityRules, developerPool, etc.) are set via setContractInterfaces after deployment, following an onlyOwner pattern for secure initialization.

Parameters

NameTypeDescription
timeBetweenWorks_uint32The required blocks between report publications.
maxPenalties_uint8The maximum allowed penalties for a developer.
securityBlocksToValidation_uint32The number of blocks before era end to block new report submissions.

setContractInterfaces

function setContractInterfaces(struct ContractsDependency contractDependency) external

onlyOwner function to set contract interfaces. This function must be called only once after the contract deploy and ownership must be renounced.

Parameters

NameTypeDescription
contractDependencystruct ContractsDependencyAddresses of system contracts used.

setContractCall

function setContractCall(address _validationRulesAddress) external

onlyOwner function to set contract call addresses. This function must be called only once after the contract deploy and ownership must be renounced.

Parameters

NameTypeDescription
_validationRulesAddressaddressAddress of ValidationRules.

addDeveloper

function addDeveloper(string name, string proofPhoto) external

Users must meet specific criteria (previous invitation, system vacancies) to successfully register as a developer.

Requirements:

  • The caller (msg.sender) must not already be a registered developer.
  • The name string must not exceed 50 characters in byte length.
  • The proofPhoto string must not exceed 150 characters in byte length.
  • The total number of DEVELOPER users in the system must not exceed 16,000.

Allows a user to attempt to register as a developer. Creates a new Developer profile for the caller if all requirements are met.

Parameters

NameTypeDescription
namestringThe chosen name for the developer.
proofPhotostringA hash or identifier (e.g., URL) for the developer's identity verification photo.

addReport

function addReport(string description, string report) external

Development reports can only be published if certain time conditions and user type requirements are met.

Requirements:

  • The description string must not exceed 300 characters in byte length.
  • The report hash/identifier string must not exceed 150 characters in byte length.
  • The caller (msg.sender) must be a registered DEVELOPER.
  • The current block number must be greater than securityBlocksToValidation blocks away from the end of the current era (i.e., not within the security window).
  • The developer must be eligible to publish based on timeBetweenWorks (checked via canPublishReport).

Allows a developer to attempt to publish a new development report.

Parameters

NameTypeDescription
descriptionstringA title or brief description of the report.
reportstringA hash or identifier (e.g., IPFS CID) of the detailed development report file.

addReportValidation

function addReportValidation(uint64 id, string justification) external

Only authorized validators can initiate this process after meeting specific time requirements.

Requirements:

  • The justification string must not exceed 300 characters in byte length.
  • The caller (msg.sender) must be eligible to vote (checked via voteRules.canVote).
  • The caller must have waited the required timeBetweenVotes (checked via validationRules.waitedTimeBetweenVotes).
  • The target report must exist and be currently valid, and its era must be the current era or a past one.

Allows a validator to vote to invalidate a specific development report. This process increments the validation count for the report and may trigger its invalidation.

Parameters

NameTypeDescription
iduint64The unique ID of the report to be validated/invalidated.
justificationstringA string explaining why the report is being invalidated.

withdraw

function withdraw() external

Developers can claim tokens for their development service.

Requirements:

  • The caller (msg.sender) must be a registered DEVELOPER.
  • The developer must be eligible for withdrawal in their current era (checked via developerPool.canWithdraw).
  • The developer's current era (developer.pool.currentEra) will be incremented upon successful withdrawal attempt.

Allows a developer to initiate a withdrawal of Regeneration Credits based on their published reports and current era.

removePoolLevels

function removePoolLevels(address addr) external

Can only be called by whitelisted addresses, the ValidatorRules contract.

Allows an authorized caller to remove levels from a developer's pool. This function updates the developer's local level and notifies the DeveloperPool contract.

Parameters

NameTypeDescription
addraddressThe wallet address of the developer from whom levels are to be removed.

canSendInvite

function canSendInvite(address addr) public view returns (bool)

Only most active users _canSendInvite.

Checks if a specific developer address is eligible to send new invitations.

Parameters

NameTypeDescription
addraddressThe address of the developer to check.

Return Values

NameTypeDescription
[0]boolbool true if the developer is eligible to send an invite, false otherwise.

getDeveloper

function getDeveloper(address addr) public view returns (struct Developer developer)

Provides the full profile of a developer.

Returns a developer's detailed profile.

Parameters

NameTypeDescription
addraddressThe address of the developer to retrieve.

Return Values

NameTypeDescription
developerstruct DeveloperThe Developer struct containing the user's data.

getReport

function getReport(uint64 id) public view returns (struct Report)

Provides the full details of a specific development report.

Returns the detailed Report data for a given report ID.

Parameters

NameTypeDescription
iduint64The unique ID of the report to retrieve.

Return Values

NameTypeDescription
[0]struct ReportReport The Report struct containing the report's data.

getReportsIds

function getReportsIds(address addr) public view returns (uint256[])

Provides a list of all reports submitted by a given user.

Returns an array of IDs of the reports made by a specific address.

Parameters

NameTypeDescription
addraddressThe address of the developer whose reports are to be retrieved.

Return Values

NameTypeDescription
[0]uint256[]uint256[] An array of report IDs.

totalPenalties

function totalPenalties(address addr) public view returns (uint256)

Provides the current penalty count for a specific developer.

Returns the total number of penalties an address has accumulated.

Parameters

NameTypeDescription
addraddressThe developer's wallet address.

Return Values

NameTypeDescription
[0]uint256uint256 The total number of penalties for the given address.

poolCurrentEra

function poolCurrentEra() public view returns (uint256)

This function provides the current era from the perspective of the reward pool, essential for era-based eligibility and reward calculations for developers.

Returns the current era as determined by the DeveloperPool contract.

Return Values

NameTypeDescription
[0]uint256uint256 The current era of the DeveloperPool.

canPublishReport

function canPublishReport(address addr) public view returns (bool)

This function determines if a developer has waited the required time since their last publication.

Checks if a user can publish a new report based on timeBetweenWorks.

Parameters

NameTypeDescription
addraddressThe address of the developer to check.

Return Values

NameTypeDescription
[0]boolbool true if the developer can publish a report, false otherwise.

nextEraIn

function nextEraIn() public view returns (uint256)

Provides a countdown to the next era for report planning.

Calculates the number of blocks remaining until the start of the next era, according to the DeveloperPool contract's era definition.

Return Values

NameTypeDescription
[0]uint256uint256 The amount of blocks remaining until the next era begins.

DeveloperRegistered

event DeveloperRegistered(uint256 id, address developerAddress, string name, uint256 blockNumber)

Emitted when a new developer successfully registers.

Parameters

NameTypeDescription
iduint256The unique ID of the newly registered developer.
developerAddressaddressThe wallet address of the developer.
namestringThe name provided by the developer.
blockNumberuint256The block number at which the registration occurred.

ReportAdded

event ReportAdded(uint256 id, address developerAddress, string description, uint256 blockNumber)

Emitted when a new development report is successfully added by a developer.

Parameters

NameTypeDescription
iduint256The unique ID of the new report.
developerAddressaddressThe address of the developer who submitted the report.
descriptionstringThe description/title of the report.
blockNumberuint256The block number at which the report was added.

ReportInvalidated

event ReportInvalidated(uint64 reportId, address developerAddress, string justification, uint256 newPenaltyCount, uint256 blockNumber)

Emitted when a development report is officially invalidated after reaching the required votes. This event signifies a final state change for the report.

Parameters

NameTypeDescription
reportIduint64The ID of the report that was invalidated.
developerAddressaddressThe address of the developer of the invalidated report.
justificationstringThe justification provided by the validator who triggered the invalidation (last vote).
newPenaltyCountuint256The total number of penalties the developer now has.
blockNumberuint256The block number at which the report was invalidated.

ReportValidation

event ReportValidation(address _validatorAddress, uint256 _resourceId, string _justification)

Emitted

Parameters

NameTypeDescription
_validatorAddressaddressThe address of the validator.
_resourceIduint256The id of the resource receiving the vote.
_justificationstringThe justification provided for the vote.

PenaltyAdded

event PenaltyAdded(address developerAddress, uint256 associatedReportId, uint256 blockNumber)

Emitted when a penalty is added to a developer's record.

Parameters

NameTypeDescription
developerAddressaddressThe address of the developer who received the penalty.
associatedReportIduint256The ID of the report linked to this penalty.
blockNumberuint256The block number at which the penalty was added.

DeveloperWithdrawalInitiated

event DeveloperWithdrawalInitiated(address developerAddress, uint256 era, uint256 blockNumber)

Emitted when a developer successfully initiates a withdrawal of tokens.

Parameters

NameTypeDescription
developerAddressaddressThe address of the developer initiating the withdrawal.
erauint256The era for which the withdrawal was initiated.
blockNumberuint256The block number at which the withdrawal was initiated.

DeveloperLevelIncreased

event DeveloperLevelIncreased(address developerAddress, uint256 newLevel, uint256 blockNumber)

Emitted when a developer's level is increased.

Parameters

NameTypeDescription
developerAddressaddressThe address of the developer whose level was increased.
newLeveluint256The new total level of the developer.
blockNumberuint256The block number at which the level increase occurred.