From ee8e2b777b57aef80aab2f440c112d0a2f1871c0 Mon Sep 17 00:00:00 2001 From: Arthur L Lunn Date: Sat, 28 Oct 2017 04:27:47 -0400 Subject: [PATCH] spellcheck comments --- contracts/LiquidPledging.sol | 44 ++++++------ contracts/LiquidPledgingBase.sol | 117 +++++++++++++++++++++---------- 2 files changed, 103 insertions(+), 58 deletions(-) diff --git a/contracts/LiquidPledging.sol b/contracts/LiquidPledging.sol index 3a53c33..490e830 100644 --- a/contracts/LiquidPledging.sol +++ b/contracts/LiquidPledging.sol @@ -91,7 +91,7 @@ contract LiquidPledging is LiquidPledgingBase { /// @param amount Quantity of value that's being moved /// @param idReceiver Destination of the value, can be a giver sending to /// a giver or a delegate, a delegate to another delegate or a project - /// to precommit it to that project + /// to pre-commit it to that project function transfer( uint64 idSender, uint64 idPledge, @@ -168,10 +168,10 @@ contract LiquidPledging is LiquidPledgingBase { // If the receiver is already part of the delegate chain and is // before the sender, then the sender and all of the other - // delegates after the RECEIVER are revomved from the chain, - // this is interesting because the delegate undelegates from the - // delegates that delegated to this delegate... game theory - // issues? should this be allowed + // delegates after the RECEIVER are removed from the chain, + // this is interesting because the delegate is removed from the + // delegates that delegated to this delegate. Are there game theory + // issues? should this be allowed? } else if (receiverDIdx <= senderDIdx) { undelegate( idPledge, @@ -182,7 +182,7 @@ contract LiquidPledging is LiquidPledgingBase { return; } - // If the delegate wants to support a project, they undelegate all + // If the delegate wants to support a project, they remove all // the delegates after them in the chain and choose a project if (receiver.adminType == PledgeAdminType.Project) { idPledge = undelegate( @@ -285,7 +285,7 @@ contract LiquidPledging is LiquidPledgingBase { CancelProject(idProject); } - /// @notice Method called to cancel specfic pledge. + /// @notice Method called to cancel specific pledge. /// @param idPledge Id of the pledge that should be canceled. /// @param amount Quantity of Ether that wants to be rolled back. function cancelPledge(uint64 idPledge, uint amount) { @@ -315,12 +315,12 @@ contract LiquidPledging is LiquidPledgingBase { /// efficiently /// @param idSender ID of the giver, delegate or project admin that is /// transferring the funds from Pledge to Pledge. This admin must have - /// permissionsto move the value + /// permissions to move the value /// @param amount An array of pledge amounts and IDs which are extrapolated /// using the D64 bitmask /// @param idReceiver Destination of the value, can be a giver sending /// to a giver or a delegate or a delegate to another delegate or a - /// project to precommit it to that project + /// project to pre-commit it to that project function mTransfer( uint64 idSender, uint[] pledgesAmounts, @@ -360,7 +360,7 @@ contract LiquidPledging is LiquidPledgingBase { } } - /// @notice `mCancelPayment` allows for multiple pledges to be cancelled + /// @notice `mCancelPayment` allows for multiple pledges to be canceled /// efficiently /// @param amount An array of pledge amounts and IDs which are extrapolated /// using the D64 bitmask @@ -390,11 +390,11 @@ contract LiquidPledging is LiquidPledgingBase { /////// /// @notice `transferOwnershipToProject` allows for the transfer of - /// ownership to the project, but it can also be called to undelegate + /// ownership to the project, but it can also be called to un-delegate /// everyone by setting one's own id for the idReceiver /// @param idPledge Id of the pledge to be transfered. /// @param amount Quantity of value that's being transfered - /// @param idReceiver The new owner of the project (or self to undelegate) + /// @param idReceiver The new owner of the project (or self to un-delegate) function transferOwnershipToProject( uint64 idPledge, uint amount, @@ -403,7 +403,7 @@ contract LiquidPledging is LiquidPledgingBase { Pledge storage n = findPledge(idPledge); // Ensure that the pledge is not already at max pledge depth - // and the project has not been cancelled + // and the project has not been canceled require(getPledgeLevel(n) < MAX_INTERPROJECT_LEVEL); require(!isProjectCanceled(idReceiver)); @@ -429,7 +429,7 @@ contract LiquidPledging is LiquidPledgingBase { /// @notice `transferOwnershipToGiver` allows for the transfer of /// value back to the Giver, value is placed in a pledged state - /// without being attached to a project, delegation chain, or timeline. + /// without being attached to a project, delegation chain, or time line. /// @param idPledge Id of the pledge to be transfered. /// @param amount Quantity of value that's being transfered /// @param idReceiver The new owner of the pledge @@ -462,7 +462,9 @@ contract LiquidPledging is LiquidPledgingBase { Pledge storage n = findPledge(idPledge); require(n.delegationChain.length < MAX_DELEGATES); - uint64[] memory newDelegationChain = new uint64[](n.delegationChain.length + 1); + uint64[] memory newDelegationChain = new uint64[]( + n.delegationChain.length + 1 + ); for (uint i = 0; i 0) && ( getTime() > n.commitTime)) { uint64 oldPledge = findOrCreatePledge( n.owner, @@ -621,7 +625,7 @@ contract LiquidPledging is LiquidPledgingBase { /// Specifically what this does in relation to the plugin is something /// that largely depends on the functions of that plugin. This function /// is generally called in pairs, once before, and once after a transfer. - /// @param before This toggle determines whether the plugin call is occuring + /// @param before This toggle determines whether the plugin call is occurring /// before or after a transfer. /// @param adminId This should be the Id of the *trusted* individual /// who has control over this plugin. diff --git a/contracts/LiquidPledgingBase.sol b/contracts/LiquidPledgingBase.sol index 4f52818..1dcdd66 100644 --- a/contracts/LiquidPledgingBase.sol +++ b/contracts/LiquidPledgingBase.sol @@ -58,9 +58,13 @@ contract LiquidPledgingBase { uint amount; uint64 owner; // PledgeAdmin uint64[] delegationChain; // list of index numbers - uint64 intendedProject; // TODO change the name only used for when delegates are precommiting to a project - uint64 commitTime; // When the intendedProject will become the owner - uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from + // TODO change the name only used for when delegates are + // pre-committing to a project + uint64 intendedProject; + // When the intendedProject will become the owner + uint64 commitTime; + // this points to the Pledge[] index that the Pledge was derived from + uint64 oldPledge; PaymentState paymentState; } @@ -68,7 +72,8 @@ contract LiquidPledgingBase { PledgeAdmin[] admins; //The list of pledgeAdmins 0 means there is no admin Vault public vault; - // this mapping allows you to search for a specific pledge's index number by the hash of that pledge + // this mapping allows you to search for a specific pledge's + // index number by the hash of that pledge mapping (bytes32 => uint64) hPledge2idx;//TODO Fix typo @@ -87,7 +92,8 @@ contract LiquidPledgingBase { // Constructor ////// - /// @notice The Constructor creates the `LiquidPledgingBase` on the blockchain + /// @notice The Constructor creates the `LiquidPledgingBase` + /// on the blockchain /// @param _vault The vault where ETH backing this pledge is stored function LiquidPledgingBase(address _vault) { admins.length = 1; // we reserve the 0 admin @@ -104,9 +110,14 @@ contract LiquidPledgingBase { /// @param name This is the name used to identify the giver. /// @param url This is a link to the givers profile or a representative site. /// @param commitTime Set the default commit time period for this giver. - /// @param plugin This is givers liquid pledge plugin allowing for extended functionality. - function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin - ) returns (uint64 idGiver) { + /// @param plugin This is givers liquid pledge plugin allowing for + /// extended functionality. + function addGiver( + string name, + string url, + uint64 commitTime, + ILiquidPledgingPlugin plugin + ) returns (uint64 idGiver) { idGiver = uint64(admins.length); @@ -163,9 +174,9 @@ contract LiquidPledgingBase { string url, uint64 commitTime, ILiquidPledgingPlugin plugin - ) returns (uint64 idDelegate) { //TODO return index number + ) returns (uint64 idxDelegate) { //TODO return index number - idDelegate = uint64(admins.length); + idxDelegate = uint64(admins.length); admins.push(PledgeAdmin( PledgeAdminType.Delegate, @@ -177,10 +188,10 @@ contract LiquidPledgingBase { false, plugin)); - DelegateAdded(idDelegate); + DelegateAdded(idxDelegate); } - event DelegateAdded(uint64 indexed idDelegate); + event DelegateAdded(uint64 indexed idxDelegate); /// @notice `updateDelegate` allows for basic update operation to change the address, /// name or commitTime associated with a specific delegate. @@ -192,22 +203,22 @@ contract LiquidPledgingBase { /// @param newUrl This is a link to the delegates profile or a representative site. /// @param newCommitTime Set the default commit time period for this giver. function updateDelegate( - uint64 idDelegate, + uint64 idxDelegate, address newAddr, string newName, string newUrl, uint64 newCommitTime) { - PledgeAdmin storage delegate = findAdmin(idDelegate); + PledgeAdmin storage delegate = findAdmin(idxDelegate); require(delegate.adminType == PledgeAdminType.Delegate); require(delegate.addr == msg.sender); delegate.addr = newAddr; delegate.name = newName; delegate.url = newUrl; delegate.commitTime = newCommitTime; - DelegateUpdated(idDelegate); + DelegateUpdated(idxDelegate); } - event DelegateUpdated(uint64 indexed idDelegate); + event DelegateUpdated(uint64 indexed idxDelegate); /// @notice `addProject` Creates a project and adds it to the list of admins. /// @param name This is the name used to identify the project. @@ -313,15 +324,15 @@ contract LiquidPledgingBase { /// @notice `getPledgeDelegate` returns a single delegate given the pledge ID /// and the delegate ID. /// @param idPledge The ID internally representing the pledge. - /// @param idDelegate The ID internally representing the delegate. - function getPledgeDelegate(uint64 idPledge, uint idDelegate) constant returns( - uint64 idDelegate, + /// @param idxDelegate The ID internally representing the delegate. + function getPledgeDelegate(uint64 idPledge, uint idxDelegate) constant returns( + uint64 idxDelegate, address addr, string name ) { Pledge storage n = findPledge(idPledge); - idDelegate = n.delegationChain[idDelegate - 1]; - PledgeAdmin storage delegate = findAdmin(idDelegate); + idxDelegate = n.delegationChain[idxDelegate - 1]; + PledgeAdmin storage delegate = findAdmin(idxDelegate); addr = delegate.addr; name = delegate.name; } @@ -361,10 +372,16 @@ contract LiquidPledgingBase { // Private methods /////// - /// @notice All pledges technically exist... but if the pledge hasn't been - /// created in this system yet then it wouldn't be in the hash array - /// hPledge2idx[]; this creates a Pledge with and amount of 0 if one is not - /// created already... + /// @notice All pledges technically exist. If the pledge hasn't been + /// created in this system yet it simply isn't in the hash array + /// hPledge2idx[] yet; this creates a Pledge with an initial amount of 0 if one is not + /// created already. Otherwise + /// @param owner The owner of the pledge being looked up. + /// @param delegationChain The array of all delegates. + /// @param intendedProject The intended project is the project this pledge will Fund. + /// @param oldPledge This value is used to store the pledge the current pledge + /// is "coming from." + /// @param paid Based on the payment state this shows whether the pledge has been paid. function findOrCreatePledge( uint64 owner, uint64[] delegationChain, @@ -383,11 +400,17 @@ contract LiquidPledgingBase { return idx; } + /// @notice `findAdmin` is a basic getter to return a + /// specific admin (giver, delegate, or project) + /// @param idAdmin The admin ID to lookup. function findAdmin(uint64 idAdmin) internal returns (PledgeAdmin storage) { require(idAdmin < admins.length); return admins[idAdmin]; } + /// @notice `findPledge` is a basic getter to return a + /// specific pledge + /// @param idPledge The admin ID to pledge. function findPledge(uint64 idPledge) internal returns (Pledge storage) { require(idPledge < pledges.length); return pledges[idPledge]; @@ -396,25 +419,32 @@ contract LiquidPledgingBase { // a constant for the case that a delegate is requested that is not a delegate in the system uint64 constant NOTFOUND = 0xFFFFFFFFFFFFFFFF; - // helper function that searches the delegationChain fro a specific delegate and - // level of delegation returns their idx in the delegation chain which reflect their level of authority - function getDelegateIdx(Pledge n, uint64 idDelegate) internal returns(uint64) { + /// @notice `getDelegateIdx` is a helper function that searches the delegationChain + /// for a specific delegate and level of delegation returns their idx in the + /// delegation chain which reflect their level of authority. Returns MAX uint64 + /// if no delegate is found. + /// @param n The pledge that will be searched. + /// @param idxDelegate The internal ID of the delegate that's searched for. + function getDelegateIdx(Pledge n, uint64 idxDelegate) internal returns(uint64) { for (uint i=0; i