IWeb3Task
AlreadyVoted
Emitted when msg.sender
already voted for a specific task.
InsufficientBalance
Emitted when authorization Id (Role) does not hold enough balance to operate.
InvalidEndDate
Emitted when endDate
is less than block.timestamp
.
InvalidStatus
Emitted when status
provided mismatches the one asked by the function.
InvalidTaskId
Emitted when taskId
is not valid when calling {Web3Task-getTask}.
QuorumUpdated
Emmited when the minimum APPROVALS
to complete a task is updated.
TaskCreated
Emitted when a new taskId
is created.
TaskStarted
Emitted when a task is started.
TaskUpdated
Emitted when a task is reviewed.
TaskReviewed
Emitted when a review is pushed for a task.
Deposit
Emitted when a deposit is made.
Withdraw
Emitted when a withdraw is made.
Status
Enum representing the possible states of a task.
Task
Core struct of a task.
setMinQuorum
This function sets the minimum quorum of approvals to complete a task.
Emit a {QuorumUpdated} event.
createTask
The core function to create a task.
Will increment global _taskId
.
Emits a {TaskCreated} event.
Requirements:
task.endDate
must be greater thanblock.timestamp
.task.status
must beStatus.Created
.msg.sender
must be an authorized operator (see {AccessControl}).
startTask
This function starts a task. It will set the msg.sender
as the assignee in case none is provided. Meaning anyone with the authorization can start the task.
The task status will be set to Status.Progress
and the next step is to execute the task and call a {reviewTask} when ready.
Emits a {TaskStarted} event.
Requirements:
_taskId
must be a valid task id.task.status
must beStatus.Created
.task.endDate
must be greater thanblock.timestamp
.msg.sender
must be an authorized operator (see {AccessControl}).
reviewTask
This function reviews a task and let the caller push a metadata.
Metadata is a string that can be used to store any kind of information related to the task. It can be used to store a link to a file using IPFS.
IMPORTANT: This function can be called more than once by both task creator or asssignee. This is because we want to allow a ping-pong of reviews until the due date or completion. This will create a history of reviews that can be used to track the progress of the task and raise a dispute if needed.
Emits a {TaskUpdated} event.
Requirements:
_taskId
must be a valid task id.msg.sender
must be_task.assignee
or the_task.creator
.task.status
must beStatus.Progress
orStatus.Review
.task.endDate
must be greater thanblock.timestamp
.msg.sender
must be an authorized operator (see {AccessControl}).
NOTE
If the status is Status.Progress
it will be set to Status.Review
once.
completeTask
This function completes a task and transfers the rewards to the assignee.
The task status will be set to Status.Completed
and the task will be considered done.
The _task.assignee
will receive the _task.reward
and also a NFT representing the completed task with the tokenId equal to the _taskId
.
IMPORTANT: The assignee agrees to the reward distribution by completing the task and its aware that the task can be disputed by the creator. The assignee can also open a dispute if the creator does not approve the completion by reaching higher DAO authorities.
Emits a {TaskUpdated} event.
Requirements:
_taskId
must be a valid task id.task.status
must beStatus.Review
.task.endDate
must be greater thanblock.timestamp
.msg.sender
must be an authorized operator (see {AccessControl}).msg.sender
can only cast one vote per task.APPROVALS
must reach the quorum.
cancelTask
This function cancels a task and invalidates its continuity.
The task status will be set to Status.Canceled
.
Emits a {TaskUpdated} event.
IMPORTANT
Tasks that were previously set to Completed
can be canceled as well, but the assignee will keep the reward and the NFT.
Requirements:
_taskId
must be a valid task id.task.status
cannot beStatus.Canceled
.task.endDate
must be greater thanblock.timestamp
.msg.sender
must be an authorized operator (see {AccessControl}).
getTask
This function returns a task by its id.
Requirements:
_taskId
must exist.task.endDate
must be greater than `block.timestamp, otherwise the task is considered expired._
getUserTasks
This function returns all tasks created by a given address.
getReviews
This function returns all reviews for a given task
getBalance
This function returns the balance of a given authorization role.
NOTE
It will return 0 if the authorization role does not exist or if the authorization role has not received any deposit.
getTaskId
This function returns the last taskId created.
NOTE taskId is an incremental number that starts at 1. If no task was created, it will return 0.
getMinQuorum
This function returns the minimum approvals required to complete a task.
NOTE
The Quorum can be updated by the contract owner. And it will emit a {QuorumUpdated} event.
getQuorumApprovals
This function returns the amount of approvals cast into a task.
getScore
This function returns the score of a given address.
hasVoted
This function returns a boolean if the addr
has voted for a specific task.
deposit
This function allows to deposit funds into the contract into a specific authorization role.
If the authorization role is e.g.: "Leader of Marketing" as the authId
number 5, then sending funds to this function passing the id will increase the balance of the authorization role by msg.value
.
Emits a {Deposit} event.
NOTE
Any authorization role id can be used as a parameter, even those that are not yet created. For this and more related issues, there is an {emergencyWithdraw} in the contract.
withdraw
This function allows to withdrawal of funds from the contract from a specific authorization role.
Emits a {Withdraw} event.
Requirements:
msg.sender
must be an authorized operator (see {AccessControl}).balance
of the authorization, role must be greater than_amount
.
emergengyWithdraw
This function allows to withdrawal of all funds from the contract.
Emits a {Withdraw} event.
Requirements:
msg.sender
must be the contract owner (see {AccessControl}).
IWeb3Task Summarize
The IWeb3Task
smart contract is an interface that defines the structure and behavior of a task.
Task Status: The contract defines an enumeration
Status
that represents the possible states of a task. These states includeCreated
,Progress
,Review
,Completed
, andCanceled
.Task Structure: The contract defines a struct
Task
that represents a task. This struct includes the status of the task, the title and description of the task, the reward for the task, the end date of the task, the roles authorized to operate the task, the role of the creator of the task, the assignee of the task, and any metadata associated with the task.
Last updated