@giveth/lpp-milestones
v2.0.0-beta.4
Published
LiquidPledging milestone contracts
Downloads
6
Readme
Contracts for LiquidPledging milestone plugins
Welcome to the code for the milestone plugins for liquid pledging. These contracts set the rules for milestones on the Giveth dapp.
Table of contents
Milestone Contracts
BridgedMilestone
This milestone is intended to work with the bridged version of LiquidPledging. Upon withdraw/disbursement of funds, they will be sent directly to the giveth-bridge contract to be bridge to the home network. After the HomeBridge
payment timeout has passed, the funds will transferred to the recipient
.
Recipient
This entity which will receive the milestone donations. This can be unset (address(0)
) upon deploy. If recipient == address(0)
, then the manager
can follow Changing the recipient to set the recipient
.
Available Actions:
- withdraw the funds
- if
reviewer != address(0)
:- request a review of the milestone
Changing the recipient
You must call changeRecipient(address newRecipient)
in order to change the recipient.
The following rules apply:
- If
recipient == address(0)
, only themanager
can set the recipient - If
recipient != address(0)
, only the currentrecipient
can change the recipient
NOTE: This is done is a single call, instead of a more fail-proof 2 step propose/accept process. If a mistake is made when setting/changing the recipient, the milestone will need to be canceled and re-created.
Manager
This entity is responsible for "managing" the milestone.
Available Actions:
- canceling the milestone
- disbursing the funds to the
recipient
- if
recipient == address(0)
:- set the
recipient
- set the
- if
reviewer != address(0)
:- request a review of the milestone
NOTE: This can be the recipient
, the Giveth campaign manager, etc.
Reviewer (optional)
Constraints imposed if set:
- milestone can only be withdrawn if
state = MilestoneState.COMPLETED
- milestone flow is as follows:
manger
orrecipient
requests a review by callingrequestReview()
reviewer
can either accept (approveCompleted()
) or reject (rejectCompleted()
) the milestone as complete- If the milestone is rejected, go back to step 1
manager
orrecipient
can disburse/withdraw the funds by callingwithdraw(uint64 idPledge, uint amount)
ormWithdraw(uint[] pledgesAmounts)
. The funds will always be sent to therecipient
Available Actions:
- canceling the milestone
- accept the milestone as completed
Changing the reviewer
In order to change the address, the current reviewer needs to call changeReviewer(address newReviewer)
.
NOTE: This is done is a single call, instead of a more fail-proof 2 step propose/accept process. If a mistake is made when changing the reviewer, the milestone will need to be canceled and re-created.
Funding/Withdraw
Upon initialization, the milestone can decide to limit donations to a single token (acceptedToken = token_address
), the native currency (acceptedToken = address(0)
), or any token (acceptedToken = address(-1)
).
Donations can only be withdrawn if a recipient
has been set.
Depending on the behavior of the LiquidPledging app, withdraw may be a 2-step process. When calling withdraw(uint64 idPledge, uint amount, address token)
or mWithdraw(uint[] pledgesAmounts, address[] tokens)
an attempt will be made to disburse the payment to the recipient. If there is a delay between withdrawing from LiquidPledging and the funds being sent, then a 2nd call to disburse(address token)
or mDisburse(address[] tokens)
will need to be made to send the funds to the recipient
.
NOTE: This milestone can continue to receive funds indefinetly.
LPMilestone
This milestone is intended to raise funds for an exsting LiquidPledging admin
. Any raised funds can only be transferred transfered directly to the LiquidPledging admin
.
All behavior is the same as the BridgedMilestone except as noted below.
Recipient
This is the adminId
of the LiquidPledging admin
who will receive the funds from this milestone. Only the manager
will be able to execute the actions mentioned in BridgedMilestone - Available Actions.
Withdraw/Disbursement
As noted above, the funds will never leave the LiquidPledging contract.
NOTE: If the recipient is canceled this milestone will not be withdrawable and any withdrawn pledges may be under the control of this milestone again. This milestone must be canceled to roll-back any remaining pledges to the previous owner.
Development
Install
- Click Star on this repo near the top-right corner of this web page (if you want to).
- Join our community if you haven't already.
- Fork this repo by clicking Fork button in top-right corner of this web page. Continue to follow instruction steps from your own lpp-milestones repo.
- The rest of these steps must be done from your machine's command line. Clone your own "lpp-milestones" repo:
git clone https://github.com/GITHUB_USERNAME/lpp-milestones.git
- Change directories to lpp-milestones:
cd lpp-milestones
Requirements
Make sure you have NodeJS (v8.4.0 or higher) and npm (5.4.1 or higher) installed.
Package
The lpp-milestones contracts are published as an npm package for developer convenience. To include it as a dependency in your package.json run this from your apps root dirctory.
npm install lpp-milestones --save
Run demo
This plugin is currently being used by the Giveth dapp. Follow the instructions on the readme.
Help
Reach out to us on slack/riot for any help or to share ideas.