Merge branch 'master' of github.com:Giveth/liquidpledging

This commit is contained in:
Jordi Baylina 2017-10-03 09:53:06 +02:00
commit 942a5d55ab
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
2 changed files with 29 additions and 26 deletions

View File

@ -10,19 +10,18 @@ contract LiquidPledging is LiquidPledgingBase {
// Constructor // Constructor
////// //////
// This constructor actualy also calls the constructor for the // This constructor also calls the constructor for `LiquidPledgingBase`
// `LiquidPledgingBase` contract
function LiquidPledging(address _vault) LiquidPledgingBase(_vault) { function LiquidPledging(address _vault) LiquidPledgingBase(_vault) {
} }
/// @notice This is how value enters into the system which creates notes. The /// @notice This is how value enters into the system which creates pledges;
/// token of value goes into the vault and then the amount in the Note /// the token of value goes into the vault and the amount in the pledge
/// relevant to this donor without delegates is increased. /// relevant to this Giver without delegates is increased, and a normal
/// After that, a normal transfer is done to the idReceiver. /// transfer is done to the idReceiver
/// @param idDonor Identifier of the donor thats donating. /// @param idDonor Identifier of the donor thats donating.
/// @param idReceiver To whom it's transfered. Can be the same donor, another /// @param idReceiver To whom it's transfered. Can be the same donor, another
/// donor, a delegate or a project /// donor, a delegate or a project
function donate(uint64 idDonor, uint64 idReceiver) payable {// TODO change to `pledge()` function donate(uint64 idDonor, uint64 idReceiver) payable {
NoteManager storage sender = findManager(idDonor); NoteManager storage sender = findManager(idDonor);
checkManagerOwner(sender); checkManagerOwner(sender);
@ -36,7 +35,7 @@ contract LiquidPledging is LiquidPledgingBase {
vault.transfer(amount); // transfers the baseToken to the Vault vault.transfer(amount); // transfers the baseToken to the Vault
uint64 idNote = findNote( uint64 idNote = findNote(
idDonor, idDonor,
new uint64[](0), //what is new new uint64[](0), //what is new?
0, 0,
0, 0,
0, 0,
@ -52,9 +51,9 @@ contract LiquidPledging is LiquidPledgingBase {
} }
/// @notice This is the main function to move value from one Note to the other /// @notice Moves value between notes
/// @param idSender ID of the donor, delegate or project manager that is transfering /// @param idSender ID of the donor, delegate or project manager that is transferring
/// the funds from Note to Note. This manager must have permisions to move the value /// the funds from Note to Note. This manager must have permissions to move the value
/// @param idNote Id of the note that's moving the value /// @param idNote Id of the note that's moving the value
/// @param amount Quantity of value that's being moved /// @param amount Quantity of value that's being moved
/// @param idReceiver Destination of the value, can be a donor sending to a donor or /// @param idReceiver Destination of the value, can be a donor sending to a donor or
@ -138,8 +137,8 @@ contract LiquidPledging is LiquidPledgingBase {
/// @notice This method is used to withdraw value from the system. This can be used /// @notice This method is used to withdraw value from the system. This can be used
/// by the donors to avoid committing the donation or by project manager to use /// by the donors to avoid committing the donation or by project manager to use
/// the Ether. /// the Ether.
/// @param idNote Id of the note that wants to be withdrawed. /// @param idNote Id of the note that wants to be withdrawn.
/// @param amount Quantity of Ether that wants to be withdrawed. /// @param amount Quantity of Ether that wants to be withdrawn.
function withdraw(uint64 idNote, uint amount) { function withdraw(uint64 idNote, uint amount) {
idNote = normalizeNote(idNote); idNote = normalizeNote(idNote);
@ -167,8 +166,8 @@ contract LiquidPledging is LiquidPledgingBase {
} }
/// @notice Method called by the vault to confirm a payment. /// @notice Method called by the vault to confirm a payment.
/// @param idNote Id of the note that wants to be withdrawed. /// @param idNote Id of the note that wants to be withdrawn.
/// @param amount Quantity of Ether that wants to be withdrawed. /// @param amount Quantity of Ether that wants to be withdrawn.
function confirmPayment(uint64 idNote, uint amount) onlyVault { function confirmPayment(uint64 idNote, uint amount) onlyVault {
Note storage n = findNote(idNote); Note storage n = findNote(idNote);
@ -197,7 +196,7 @@ contract LiquidPledging is LiquidPledgingBase {
require(n.paymentState == PaymentState.Paying); //TODO change to revert require(n.paymentState == PaymentState.Paying); //TODO change to revert
// When a payment is cacnceled, never is assigned to a project. // When a payment is canceled, never is assigned to a project.
uint64 oldNote = findNote( uint64 oldNote = findNote(
n.owner, n.owner,
n.delegationChain, n.delegationChain,
@ -291,7 +290,7 @@ contract LiquidPledging is LiquidPledgingBase {
/////// ///////
// this function is obvious, but it can also be called to undelegate everyone // this function is obvious, but it can also be called to undelegate everyone
// by setting your self as teh idReceiver // by setting yourself as the idReceiver
function transferOwnershipToProject(uint64 idNote, uint amount, uint64 idReceiver) internal { function transferOwnershipToProject(uint64 idNote, uint amount, uint64 idReceiver) internal {
Note storage n = findNote(idNote); Note storage n = findNote(idNote);
@ -346,7 +345,7 @@ contract LiquidPledging is LiquidPledgingBase {
doTransfer(idNote, toNote, amount); doTransfer(idNote, toNote, amount);
} }
/// @param q Unmber of undelegations /// @param q Number of undelegations
function undelegate(uint64 idNote, uint amount, uint q) internal { function undelegate(uint64 idNote, uint amount, uint q) internal {
Note storage n = findNote(idNote); Note storage n = findNote(idNote);
uint64[] memory newDelegationChain = new uint64[](n.delegationChain.length - q); uint64[] memory newDelegationChain = new uint64[](n.delegationChain.length - q);
@ -394,13 +393,13 @@ contract LiquidPledging is LiquidPledgingBase {
} }
// This function does 2 things, #1: it checks to make sure that the pledges are correct // This function does 2 things, #1: it checks to make sure that the pledges are correct
// if the a pledged project has already been commited then it changes the owner // if the a pledged project has already been committed then it changes the owner
// to be the proposed project (Note that the UI will have to read the commit time and manually // to be the proposed project (Note that the UI will have to read the commit time and manually
// do what this function does to the note for the end user at the expiration of the committime) // do what this function does to the note for the end user at the expiration of the commitTime)
// #2: It checks to make sure that if there has been a cancellation in the chain of projects, // #2: It checks to make sure that if there has been a cancellation in the chain of projects,
// then it adjusts the note's owner appropriately. // then it adjusts the note's owner appropriately.
// This call can be called from any body at any time on any node. In general it can be called // This call can be called from any body at any time on any node. In general it can be called
// to froce the calls of the affected plugins. // to force the calls of the affected plugins, which also need to be predicted by the UI
function normalizeNote(uint64 idNote) returns(uint64) { function normalizeNote(uint64 idNote) returns(uint64) {
Note storage n = findNote(idNote); Note storage n = findNote(idNote);

View File

@ -14,7 +14,8 @@ contract Owned {
address public owner; address public owner;
/// @notice The Constructor assigns the message sender to be `owner` /// @notice The Constructor assigns the account deploying the contract to be
/// the `owner`
function Owned() { function Owned() {
owner = msg.sender; owner = msg.sender;
} }
@ -22,15 +23,18 @@ contract Owned {
address public newOwner; address public newOwner;
/// @notice `owner` can step down and assign some other address to this role /// @notice `owner` can step down and assign some other address to this role
/// @param _newOwner The address of the new owner. 0x0 can be used to create /// but after this function is called the current owner still has ownership
/// an unowned neutral vault, however that cannot be undone /// powers in this contract; change of ownership is a 2 step process
/// @param _newOwner The address of the new owner. A simple contract with
/// the ability to accept ownership but the inability to do anything else
/// can be used to create an unowned contract to achieve decentralization
function changeOwner(address _newOwner) onlyOwner { function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner; newOwner = _newOwner;
} }
/// @notice `newOwner` can accept ownership over this contract
function acceptOwnership() { function acceptOwnership() {
if (msg.sender == newOwner) { require(msg.sender == newOwner) {
owner = newOwner; owner = newOwner;
} }
} }