-
Notifications
You must be signed in to change notification settings - Fork 26
Bounty Manager
File: BountyManager.sol
- This is a module to manage bounties.
- This includes being able to add and edit bounties, and to be able to claim those bounties by valid contributors after verification by the
VerifyAdmin. - Here are valid roles in this module:
BountyAdmin,ClaimAdminandVerifyAdmin. - Also, here are some important structs, that you should know:
-
struct Bounty { /// @dev Minimum amount of tokens that can be paid out upon fulfillment of the bounty uint minimumPayoutAmount; /// @dev Maximum amount of tokens that can be paid out upon fulfillment of the bounty uint maximumPayoutAmount; /// @dev Arbitrary data to store Bounty details if necessary. /// CAN be empty. bytes details; /// @dev Id that claimed the bounty /// A Bounty is claimed if a Claim got acknowledged by a Verifier uint claimedBy; }
-
struct Contributor { /// @dev The contributor's address. address addr; /// @dev The amount of tokens the Contributor gets upon claimng the bounty uint claimAmount; }
-
struct Claim { uint bountyId; /// @dev The contributors of the claim /// MUST not be empty Contributor[] contributors; /// @dev Arbitrary data to store Claim details if necessary. /// CAN be empty. bytes details; }
- onlyRole(uint8 roleId)
modifier onlyRole(uint8 roleId)Uses the IRoleAuthorizer module's isAuthorized function to check if the caller is authorized.
- onlyClaimContributor(uint claimId)
modifier onlyClaimContributor(uint claimId)Only a valid claim contributor could call.
- validPayoutAmounts
modifier validPayoutAmounts(
uint minimumPayoutAmount,
uint maximumPayoutAmount
)Checks if the minimumPayoutAmount is non-zero and lesser than the maximumPayoutAmount.
- validBountyId
modifier validBountyId(uint bountyId)Checks if bountyId already exists.
- validClaimId
modifier validClaimId(uint claimId)Checks if claimId already exists.
function getBountyInformation(uint bountyId)
external
view
returns (Bounty memory);Returns the Bounty instance with id id.
- uint bountyId: The id of the Bounty to return.
- Bounty memory: Bounty with id
id.
function listBountyIds() external view returns (uint[] memory);Returns total list of Bounty IDs. List is in ascending order.
- uint[] memory: List of Bounty ids.
function isExistingBountyId(uint bountyId) external view returns (bool);Returns whether Bounty with id id exists.
- uint bountyId: The id of the Bounty to test.
- bool: True if Claim with id
idexists, false otherwise.
function getClaimInformation(uint claimId)
external
view
returns (Claim memory);Returns the Claim instance with id id.
- uint claimId: The id of the Claim to return.
- Claim memory: Claim with id
id.
function listClaimIds() external view returns (uint[] memory);Returns total list of claim IDs. List is in ascending order.
- uint[] memory: List of Claim ids.
function isExistingClaimId(uint claimId) external view returns (bool);Returns whether Claim with id id exists.
- uint claimId: The id of the Bounty to test.
- bool: True if Claim with id
idexists, false otherwise.
function listClaimIdsForContributorAddress(address contributorAddrs)
external
view
returns (uint[] memory);Returns a list of Claim ids in which contributor Address is used. List is in ascending order. Returns an empty.
- address contributorAddrs: claim ids are filtered by the contributor address
- uint[] memory: List of Claim ids.
function addBounty(
uint minimumPayoutAmount,
uint maximumPayoutAmount,
bytes calldata details
) external returns (uint);Adds a new Bounty. Reverts if an argument invalid.
- uint minimumPayoutAmount: The minimum amount of tokens the Bounty will pay out upon being claimed
- uint maximumPayoutAmount: The maximum amount of tokens the Bounty will pay out upon being claimed
- bytes details: The Bounty's details.
- uint: The newly added Bounty's id.
function updateBounty(uint bountyId, bytes calldata details) external;Updates a Bounty's information. Reverts if an argument invalid.
- uint bountyId: The id of the Bounty that will be updated
- bytes details: The Bounty's details
function lockBounty(uint bountyId) external;Locks the Bounty so it can't be claimed. Only callable by authorized addresses. Reverts if id invalid.
- uint bountyId: The id of the Bounty that will be locked.
function addClaim(
uint bountyId,
Contributor[] calldata contributors,
bytes calldata details
) external returns (uint);Adds a new Claim. Reverts if an argument invalid.
- uint bountyId: The contributor information for the Claim
- Contributor[] contributors: The Claim's details
- bytes details: More relevant details about the claim
- uint: The newly added Claim's id.
function updateClaimContributors(
uint claimId,
uint bountyId,
Contributor[] calldata contributors
) external;Updates a Claim's contributor information. Reverts if an argument invalid.
- uint claimId: The id of the Claim that will be updated.
- uint bountyId: The id of the bounty the Claim wants to claim.
- Contibutors[] contributors: The contributor information for the Claim.
function updateClaimDetails(uint claimId, bytes calldata details)
external;Updates a Claim Details.
- uint claimId: The id of the Claim that will be updated.
- bytes details: The Claim's details.
function verifyClaim(uint claimId, uint bountyId) external;Completes a Bounty by verifying a claim. Only callable by authorized addresses. Reverts if id invalid.
- uint claimId: The id of the Claim that wants to claim the Bounty.
- uint bountyId: The id of the Bounty that will be claimed.
function grantBountyAdminRole(address addr) external;Grants the BountyAdmin Role to a specified address. Only callable by authorized addresses.
- address addr: Address that gets the role granted
function grantClaimAdminRole(address addr) external;Grants the ClaimAdmin Role to a specified address. Only callable by authorized addresses.
- address addr: Address that gets the role granted
function grantVerifyAdminRole(address addr) external;Grants the VerifyAdmin Role to a specified address. Only callable by authorized addresses.
- address addr: Address that gets the role granted
function revokeBountyAdminRole(address addr) external;Revokes the BountyAdmin Role from a specified address. Only callable by authorized addresses.
- address addr: Address that gets their role revoked
function revokeClaimAdminRole(address addr) external;Revokes the ClaimAdmin Role from a specified address. Only callable by authorized addresses.
- address addr: Address that gets their role revoked
function revokeVerifyAdminRole(address addr) external;Revokes the VerifyAdmin Role from a specified address. Only callable by authorized addresses.
- address addr: Address that gets their role revoked