Skip to main content

InvitationRules

InvitationRules

This contract manages the rules and logic for users to invite others into the community.

Manages the logic to allow users to invite others to the community.

ACTIVIST_DELAY_BLOCKS

uint16 ACTIVIST_DELAY_BLOCKS

The minimum number of blocks an activist needs to wait to invite Regenerators or Inspectors again.

lastInviteBlocks

mapping(address => uint256) lastInviteBlocks

Relationship between address and last general invitation blockNumber.

lastInviteActivist

mapping(address => uint256) lastInviteActivist

Relationship between activist address and last activist invitation blockNumber (for Regenerator/Inspector).

canBeInviteds

mapping(enum CommunityTypes.UserType => enum CommunityTypes.UserType) canBeInviteds

Maps which UserType (inviter) can invite which other UserTypes (invited).

The key is the inviter's UserType, and the value is a mapping from UserType (invited) to a boolean (true if allowed).

communityRules

contract ICommunityRules communityRules

CommunityRules contract interface

researcherRules

contract IResearcherRules researcherRules

ResearcherRules contract interface

developerRules

contract IDeveloperRules developerRules

DeveloperRules contract interface

activistRules

contract IActivistRules activistRules

ActivistRules contract interface

contributorRules

contract IContributorRules contributorRules

ContributorRules contract interface

constructor

constructor(address communityRulesAddress, address researcherRulesAddress, address developerRulesAddress, address activistRulesAddress, address contributorRulesAddress) public

Constructor that initializes the addresses of the rule contracts and defines invitation permissions.

Ensures that all contract addresses are valid (not null).

Parameters

NameTypeDescription
communityRulesAddressaddressAddress of the CommunityRules contract.
researcherRulesAddressaddressAddress of the ResearcherRules contract.
developerRulesAddressaddressAddress of the DeveloperRules contract.
activistRulesAddressaddressAddress of the ActivistRules contract.
contributorRulesAddressaddressAddress of the ContributorRules contract.

invite

function invite(address invited, enum CommunityTypes.UserType userType) external

Only most active users can invite new users to the system, respecting delay and type rules.

Allows a user to attempt to invite another wallet to the community.

Parameters

NameTypeDescription
invitedaddressThe address of the wallet to be invited.
userTypeenum CommunityTypes.UserTypeThe user type to which the invited user will be assigned.

inviteRegeneratorInspector

function inviteRegeneratorInspector(address invited, enum CommunityTypes.UserType userType) external

Activists can invite Regenerators or Inspectors to the system, respecting the specific activist delay.

Allows an activist to invite Regenerators or Inspectors to the community.

Parameters

NameTypeDescription
invitedaddressThe address of the wallet to be invited.
userTypeenum CommunityTypes.UserTypeThe user type to which the invited user will be assigned (must be REGENERATOR or INSPECTOR).

onlyOwnerInvite

function onlyOwnerInvite(address invited, enum CommunityTypes.UserType userType) public

The owner can invite any user type without delay or type restrictions. If ownership is renounced, no wallet will be able to call this function.

Allows the contract owner to invite a wallet to the community.

Parameters

NameTypeDescription
invitedaddressThe address of the wallet to be invited.
userTypeenum CommunityTypes.UserTypeThe user type to which the invited user will be assigned.

UserInvited

event UserInvited(address inviter, address invited, enum CommunityTypes.UserType invitedType, uint256 blockNumber)

Event emitted when a user invites another.

Parameters

NameTypeDescription
inviteraddressThe address of the user who made the invitation.
invitedaddressThe address of the invited user.
invitedTypeenum CommunityTypes.UserTypeThe user type assigned to the invited user.
blockNumberuint256The block number at which the invitation was made.