Skip to main content

ActivistRules

ActivistRules

This contract defines and manages the rules and data specific to "Activist" users within the system. Activists are responsible for inviting new Regenerators and Inspectors, and they earn rewards based on the approval of their invited users.

Inherits functionalities from Callable (for whitelisted function access) and Invitable (for managing invitation logic). It interacts with CommunityRules for general user management and ActivistPool for reward distribution.

MAX_USER_COUNT

uint16 MAX_USER_COUNT

Maximum users count allowed for this UserType.

MINIMUM_INSPECTIONS_TO_WON_POOL_LEVELS

uint16 MINIMUM_INSPECTIONS_TO_WON_POOL_LEVELS

Minimum inspections an inviter must complete to add activist level.

approvedInvites

uint64 approvedInvites

The total count of all invitations that have been successfully approved across the entire system.

totalActiveLevels

uint256 totalActiveLevels

The sum of all active levels from non-denied activists. Used for governance calculations.

activistsAddress

mapping(uint256 => address) activistsAddress

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

communityRules

contract ICommunityRules communityRules

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

activistPool

contract IActivistPool activistPool

The address of the ActivistPool contract, responsible for managing and distributing token rewards to activists.

inspectionRulesAddress

address inspectionRulesAddress

The address of the InspectionRules contract.

validationRulesAddress

address validationRulesAddress

The address of the InspectionRules contract.

constructor

constructor(address communityRulesAddress, address activistPoolAddress) public

Initializes the ActivistRules contract. Sets the addresses for the CommunityRules and ActivistPool contracts.

Parameters

NameTypeDescription
communityRulesAddressaddressThe address of the deployed CommunityRules contract.
activistPoolAddressaddressThe address of the deployed ActivistPool contract.

setContractCall

function setContractCall(address _inspectionRulesAddress, 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
_inspectionRulesAddressaddressAddress of InspectionRules.
_validationRulesAddressaddressAddress of ValidationRules.

addActivist

function addActivist(string name, string proofPhoto) external

Users must meet specific criteria (previously invitation, system proportionality) to successfully register as an activist.

Requirements:

  • The caller (msg.sender) must not already be a registered user.
  • The name and proofPhoto strings must not exceed 100 characters in byte length.
  • The total number of ACTIVIST users in the system must not exceed 16,000.

Allows a user to attempt to register as an activist. Creates a new Activist profile for the caller if all requirements are met.

Parameters

NameTypeDescription
namestringThe chosen name for the activist.
proofPhotostringA hash or identifier for the activist's identity verification photo.

withdraw

function withdraw() external

Activists can claim tokens for the services provided. The distribution is proportional to the amount of approved users in the current era.

Requirements:

  • The caller (msg.sender) must be a registered ACTIVIST.
  • The activist must have approvedUsers in their current era.
  • The activist's current era (activist.pool.currentEra) will be incremented upon successful withdrawal attempt.

Allows an activist to initiate a withdrawal of Regeneration Credits based on their approved invited users and current era.

addRegeneratorLevel

function addRegeneratorLevel(address regeneratorAddress, uint256 regeneratorTotalInspections) external

This function should be called by the InspectionRules contract. after a Regenerator completes their required inspections.

External function for authorized callers to add a pool level to an activist when an invited Regenerator reaches the minimum inspection threshold.

Parameters

NameTypeDescription
regeneratorAddressaddressThe wallet address of the invited Regenerator.
regeneratorTotalInspectionsuint256The total number of inspections completed by the Regenerator.

addInspectorLevel

function addInspectorLevel(address inspectorAddress, uint256 inspectorTotalInspections) external

This function should be called by the InspectionRules contract after an Inspector completes their required inspections.

External function for authorized callers to add a pool level to an activist when an invited Inspector reaches the minimum inspection threshold.

Parameters

NameTypeDescription
inspectorAddressaddressThe wallet address of the invited Inspector.
inspectorTotalInspectionsuint256The total number of inspections completed by the Inspector.

removePoolLevels

function removePoolLevels(address addr) external

Can only be called by the ValidationRules contract.

Allows an authorized caller to remove levels from an activist's pool. This function updates the activist's local level if user is not being denied and notifies the ActivistPool contract to remove the pool level.

Parameters

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

canSendInvite

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

Returns true if the activist can send an invite, false otherwise.

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

Parameters

NameTypeDescription
addraddressThe address of the activist to check.

Return Values

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

getActivist

function getActivist(address addr) public view returns (struct Activist)

Provides the full profile of an activist.

Returns the detailed Activist data for a given address.

Parameters

NameTypeDescription
addraddressThe address of the activist to retrieve.

Return Values

NameTypeDescription
[0]struct ActivistActivist The Activist struct containing the user's data.

poolCurrentEra

function poolCurrentEra() public view returns (uint256)

This function provides the current era from the perspective of the reward pool.

Returns the current era as determined by the ActivistPool contract.

Return Values

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

ActivistRegistered

event ActivistRegistered(uint256 id, address activistAddress, string name, uint256 blockNumber)

Emitted when a new activist successfully registers.

Parameters

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

ActivistLevelIncreased

event ActivistLevelIncreased(address activistAddress, uint256 newLevel, uint256 blockNumber)

Emitted when an activist's level is increased.

Parameters

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

ActivistWithdrawalInitiated

event ActivistWithdrawalInitiated(address activistAddress, uint256 era, uint256 blockNumber)

Emitted when an activist successfully initiates a withdrawal of tokens.

Parameters

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