Skip to content

Bounty Manager

Rahul Saxena edited this page Aug 11, 2023 · 7 revisions

File: BountyManager.sol

Things to know

  1. This is a module to manage bounties.
  2. 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.
  3. Here are valid roles in this module: BountyAdmin, ClaimAdmin and VerifyAdmin.
  4. 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;
     }

Modifiers

  1. onlyRole(uint8 roleId)
modifier onlyRole(uint8 roleId)

Uses the IRoleAuthorizer module's isAuthorized function to check if the caller is authorized.

  1. onlyClaimContributor(uint claimId)
modifier onlyClaimContributor(uint claimId)

Only a valid claim contributor could call.

  1. validPayoutAmounts
modifier validPayoutAmounts(
        uint minimumPayoutAmount,
        uint maximumPayoutAmount
    )

Checks if the minimumPayoutAmount is non-zero and lesser than the maximumPayoutAmount.

  1. validBountyId
modifier validBountyId(uint bountyId)

Checks if bountyId already exists.

  1. validClaimId
modifier validClaimId(uint claimId)

Checks if claimId already exists.

View Functions

1. getBountyInformation

function getBountyInformation(uint bountyId)
        external
        view
        returns (Bounty memory);

Returns the Bounty instance with id id.

Parameters

  1. uint bountyId: The id of the Bounty to return.

Return Data

  1. Bounty memory: Bounty with id id.

2. listBountyIds

function listBountyIds() external view returns (uint[] memory);

Returns total list of Bounty IDs. List is in ascending order.

Return Data

  1. uint[] memory: List of Bounty ids.

3. isExistingBountyId

 function isExistingBountyId(uint bountyId) external view returns (bool);

Returns whether Bounty with id id exists.

Parameters

  1. uint bountyId: The id of the Bounty to test.

Return Data

  1. bool: True if Claim with id id exists, false otherwise.

4. getClaimInformation

function getClaimInformation(uint claimId)
        external
        view
        returns (Claim memory);

Returns the Claim instance with id id.

Parameters

  1. uint claimId: The id of the Claim to return.

Return Data

  1. Claim memory: Claim with id id.

5. listClaimIds

function listClaimIds() external view returns (uint[] memory);

Returns total list of claim IDs. List is in ascending order.

Return Data

  1. uint[] memory: List of Claim ids.

6. isExistingClaimId

function isExistingClaimId(uint claimId) external view returns (bool);

Returns whether Claim with id id exists.

Parameters

  1. uint claimId: The id of the Bounty to test.

Return Data

  1. bool: True if Claim with id id exists, false otherwise.

7. listClaimIdsForContributorAddress

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.

Parameters

  1. address contributorAddrs: claim ids are filtered by the contributor address

Return Data

  1. uint[] memory: List of Claim ids.

Write Functions

1. addBounty

function addBounty(
        uint minimumPayoutAmount,
        uint maximumPayoutAmount,
        bytes calldata details
    ) external returns (uint);

Adds a new Bounty. Reverts if an argument invalid.

Parameters

  1. uint minimumPayoutAmount: The minimum amount of tokens the Bounty will pay out upon being claimed
  2. uint maximumPayoutAmount: The maximum amount of tokens the Bounty will pay out upon being claimed
  3. bytes details: The Bounty's details.

Return Data

  1. uint: The newly added Bounty's id.

2. updateBounty

function updateBounty(uint bountyId, bytes calldata details) external;

Updates a Bounty's information. Reverts if an argument invalid.

Parameters:

  1. uint bountyId: The id of the Bounty that will be updated
  2. bytes details: The Bounty's details

3. lockBounty

function lockBounty(uint bountyId) external;

Locks the Bounty so it can't be claimed. Only callable by authorized addresses. Reverts if id invalid.

Parameters

  1. uint bountyId: The id of the Bounty that will be locked.

4. addClaim

function addClaim(
        uint bountyId,
        Contributor[] calldata contributors,
        bytes calldata details
    ) external returns (uint);

Adds a new Claim. Reverts if an argument invalid.

Parameters

  1. uint bountyId: The contributor information for the Claim
  2. Contributor[] contributors: The Claim's details
  3. bytes details: More relevant details about the claim

Return Data

  1. uint: The newly added Claim's id.

5. updateClaimContributors

function updateClaimContributors(
        uint claimId,
        uint bountyId,
        Contributor[] calldata contributors
    ) external;

Updates a Claim's contributor information. Reverts if an argument invalid.

Parameters

  1. uint claimId: The id of the Claim that will be updated.
  2. uint bountyId: The id of the bounty the Claim wants to claim.
  3. Contibutors[] contributors: The contributor information for the Claim.

6. updateClaimDetails

function updateClaimDetails(uint claimId, bytes calldata details)
        external;

Updates a Claim Details.

Parameters

  1. uint claimId: The id of the Claim that will be updated.
  2. bytes details: The Claim's details.

7. verifyClaim

function verifyClaim(uint claimId, uint bountyId) external;

Completes a Bounty by verifying a claim. Only callable by authorized addresses. Reverts if id invalid.

Parameters

  1. uint claimId: The id of the Claim that wants to claim the Bounty.
  2. uint bountyId: The id of the Bounty that will be claimed.

8. grantBountyAdminRole

function grantBountyAdminRole(address addr) external;

Grants the BountyAdmin Role to a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets the role granted

9. grantClaimAdminRole

 function grantClaimAdminRole(address addr) external;

Grants the ClaimAdmin Role to a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets the role granted

10. grantVerifyAdminRole

 function grantVerifyAdminRole(address addr) external;

Grants the VerifyAdmin Role to a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets the role granted

11. revokeBountyAdminRole

function revokeBountyAdminRole(address addr) external;

Revokes the BountyAdmin Role from a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets their role revoked

12. revokeClaimAdminRole

function revokeClaimAdminRole(address addr) external;

Revokes the ClaimAdmin Role from a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets their role revoked

13. revokeVerifyAdminRole

function revokeVerifyAdminRole(address addr) external;

Revokes the VerifyAdmin Role from a specified address. Only callable by authorized addresses.

Parameters

  1. address addr: Address that gets their role revoked
Clone this wiki locally