From 09a275b50c5b56bf0fbbf2a5e5aa380ebc9f3dcd Mon Sep 17 00:00:00 2001 From: Griff Green Date: Sun, 3 Dec 2017 22:18:31 -0300 Subject: [PATCH 1/4] Added a bunch of comments and TODOs!!! --- contracts/LiquidPledgingBase.sol | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/contracts/LiquidPledgingBase.sol b/contracts/LiquidPledgingBase.sol index 13bc059..18120c5 100644 --- a/contracts/LiquidPledgingBase.sol +++ b/contracts/LiquidPledgingBase.sol @@ -1,7 +1,8 @@ pragma solidity ^0.4.11; /* Copyright 2017, Jordi Baylina - Contributor: Adrià Massanet + Contributors: Adrià Massanet , RJ Ewing, Griff + Green, Arthur Lunn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,15 +21,16 @@ pragma solidity ^0.4.11; import "./ILiquidPledgingPlugin.sol"; import "../node_modules/giveth-common-contracts/contracts/Owned.sol"; -/// @dev `LPVault` serves as an interface to allow the `LiquidPledgingBase` -/// contract to interface with a `LPVault` contract -contract LPVault { +/// @dev This is an interface for `LPVault` which serves as a secure storage for +/// the ETH that backs the Pledges, only after `LiquidPledging` authorizes +/// payments can Pledges be converted for ETH +contract LPVault { // TODO: This should be `interface` instead of contract???????????????????????????????????????? function authorizePayment(bytes32 _ref, address _dest, uint _amount); function () payable; } /// @dev `LiquidPledgingBase` is the base level contract used to carry out -/// liquid pledging's most basic functions, mostly handling and searching the +/// liquidPledging's most basic functions, mostly handling and searching the /// data structures contract LiquidPledgingBase is Owned { @@ -38,10 +40,10 @@ contract LiquidPledgingBase is Owned { uint constant MAX_INTERPROJECT_LEVEL = 20; enum PledgeAdminType { Giver, Delegate, Project } - enum PaymentState { Pledged, Paying, Paid } + enum PaymentState { Pledged, Paying, Paid } //TODO Very confusing with PaymentStatus rename to PledgeState?????????????? /// @dev This struct defines the details of a `PledgeAdmin` which are - /// commonly referenced by their index in the `admins` array. + /// commonly referenced by their index in the `admins` array /// and can own pledges and act as delegates struct PledgeAdmin { PledgeAdminType adminType; // Giver, Delegate or Project @@ -64,7 +66,7 @@ contract LiquidPledgingBase is Owned { uint64 intendedProject; // Used when delegates are sending to projects uint64 commitTime; // When the intendedProject will become the owner uint64 oldPledge; // Points to the id that this Pledge was derived from - PaymentState paymentState; // Pledged, Paying, Paid + PaymentState paymentState; // Pledged, Paying, Paid //TODO Very confusing with PaymentStatus rename to pledgeState?????????????? } Pledge[] pledges; @@ -427,7 +429,7 @@ contract LiquidPledgingBase is Owned { uint64 intendedProject, uint64 commitTime, uint64 oldPledge, - PaymentState paid + PaymentState paid // TODO CHANGE PAID TO STATE ) internal returns (uint64) { bytes32 hPledge = sha3( From 36631f28ef74409a7a8a2426a016a3ee9eeb0fe5 Mon Sep 17 00:00:00 2001 From: Griff Green Date: Sun, 3 Dec 2017 22:23:15 -0300 Subject: [PATCH 2/4] added contributors Make sure you take your name off this and the other commits if you don't want it there --- contracts/ILiquidPledgingPlugin.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/ILiquidPledgingPlugin.sol b/contracts/ILiquidPledgingPlugin.sol index 75a1afc..ebe798f 100644 --- a/contracts/ILiquidPledgingPlugin.sol +++ b/contracts/ILiquidPledgingPlugin.sol @@ -2,7 +2,8 @@ pragma solidity ^0.4.11; /* Copyright 2017, Jordi Baylina - Contributor: Adrià Massanet + Contributors: Adrià Massanet , RJ Ewing, Griff + Green, Arthur Lunn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 584726ffd045f0c29491018d7d6e071f3b3cca32 Mon Sep 17 00:00:00 2001 From: perissology Date: Tue, 5 Dec 2017 12:42:59 -0800 Subject: [PATCH 3/4] rename PaymentState -> PledgeState --- contracts/LiquidPledging.sol | 36 ++++++++++++++++---------------- contracts/LiquidPledgingBase.sol | 18 ++++++++-------- js/liquidPledgingState.js | 16 +++++++------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/contracts/LiquidPledging.sol b/contracts/LiquidPledging.sol index 906556a..705eec0 100644 --- a/contracts/LiquidPledging.sol +++ b/contracts/LiquidPledging.sol @@ -70,7 +70,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, 0, - PaymentState.Pledged + PledgeState.Pledged ); @@ -108,7 +108,7 @@ contract LiquidPledging is LiquidPledgingBase { PledgeAdmin storage sender = findAdmin(idSender); checkAdminOwner(sender); - require(n.paymentState == PaymentState.Pledged); + require(n.pledgeState == PledgeState.Pledged); // If the sender is the owner if (n.owner == idSender) { @@ -208,7 +208,7 @@ contract LiquidPledging is LiquidPledgingBase { Pledge storage n = findPledge(idPledge); - require(n.paymentState == PaymentState.Pledged); + require(n.pledgeState == PledgeState.Pledged); PledgeAdmin storage owner = findAdmin(n.owner); @@ -220,7 +220,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Paying + PledgeState.Paying ); doTransfer(idPledge, idNewPledge, amount); @@ -234,7 +234,7 @@ contract LiquidPledging is LiquidPledgingBase { function confirmPayment(uint64 idPledge, uint amount) onlyVault { Pledge storage n = findPledge(idPledge); - require(n.paymentState == PaymentState.Paying); + require(n.pledgeState == PledgeState.Paying); uint64 idNewPledge = findOrCreatePledge( n.owner, @@ -242,7 +242,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Paid + PledgeState.Paid ); doTransfer(idPledge, idNewPledge, amount); @@ -254,7 +254,7 @@ contract LiquidPledging is LiquidPledgingBase { function cancelPayment(uint64 idPledge, uint amount) onlyVault { Pledge storage n = findPledge(idPledge); - require(n.paymentState == PaymentState.Paying); //TODO change to revert + require(n.pledgeState == PledgeState.Paying); //TODO change to revert // When a payment is canceled, never is assigned to a project. uint64 oldPledge = findOrCreatePledge( @@ -263,7 +263,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); oldPledge = normalizePledge(oldPledge); @@ -408,7 +408,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); uint64 toPledge = findOrCreatePledge( idReceiver, // Set the new owner @@ -416,7 +416,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, amount); } @@ -439,7 +439,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, 0, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, amount); } @@ -473,7 +473,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, amount); } @@ -501,7 +501,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, amount); @@ -531,7 +531,7 @@ contract LiquidPledging is LiquidPledgingBase { idReceiver, uint64(getTime() + maxCommitTime(n)), n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, amount); } @@ -559,7 +559,7 @@ contract LiquidPledging is LiquidPledgingBase { callPlugins(false, from, to, amount); } - /// @notice `normalizePledge` only affects pledges with the Pledged PaymentState + /// @notice `normalizePledge` only affects pledges with the Pledged PledgeState /// and does 2 things: /// #1: Checks if the pledge should be committed. This means that /// if the pledge has an intendedProject and it is past the @@ -582,7 +582,7 @@ contract LiquidPledging is LiquidPledgingBase { // Check to make sure this pledge hasn't already been used // or is in the process of being used - if (n.paymentState != PaymentState.Pledged) { + if (n.pledgeState != PledgeState.Pledged) { return idPledge; } @@ -594,7 +594,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, n.oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); uint64 toPledge = findOrCreatePledge( n.intendedProject, @@ -602,7 +602,7 @@ contract LiquidPledging is LiquidPledgingBase { 0, 0, oldPledge, - PaymentState.Pledged + PledgeState.Pledged ); doTransfer(idPledge, toPledge, n.amount); idPledge = toPledge; diff --git a/contracts/LiquidPledgingBase.sol b/contracts/LiquidPledgingBase.sol index 18120c5..530b6b0 100644 --- a/contracts/LiquidPledgingBase.sol +++ b/contracts/LiquidPledgingBase.sol @@ -24,7 +24,7 @@ import "../node_modules/giveth-common-contracts/contracts/Owned.sol"; /// @dev This is an interface for `LPVault` which serves as a secure storage for /// the ETH that backs the Pledges, only after `LiquidPledging` authorizes /// payments can Pledges be converted for ETH -contract LPVault { // TODO: This should be `interface` instead of contract???????????????????????????????????????? +interface LPVault { function authorizePayment(bytes32 _ref, address _dest, uint _amount); function () payable; } @@ -40,7 +40,7 @@ contract LiquidPledgingBase is Owned { uint constant MAX_INTERPROJECT_LEVEL = 20; enum PledgeAdminType { Giver, Delegate, Project } - enum PaymentState { Pledged, Paying, Paid } //TODO Very confusing with PaymentStatus rename to PledgeState?????????????? + enum PledgeState { Pledged, Paying, Paid } /// @dev This struct defines the details of a `PledgeAdmin` which are /// commonly referenced by their index in the `admins` array @@ -66,7 +66,7 @@ contract LiquidPledgingBase is Owned { uint64 intendedProject; // Used when delegates are sending to projects uint64 commitTime; // When the intendedProject will become the owner uint64 oldPledge; // Points to the id that this Pledge was derived from - PaymentState paymentState; // Pledged, Paying, Paid //TODO Very confusing with PaymentStatus rename to pledgeState?????????????? + PledgeState pledgeState; // Pledged, Paying, Paid } Pledge[] pledges; @@ -336,7 +336,7 @@ contract LiquidPledgingBase is Owned { uint64 intendedProject, uint64 commitTime, uint64 oldPledge, - PaymentState paymentState + PledgeState pledgeState ) { Pledge storage n = findPledge(idPledge); amount = n.amount; @@ -345,7 +345,7 @@ contract LiquidPledgingBase is Owned { intendedProject = n.intendedProject; commitTime = n.commitTime; oldPledge = n.oldPledge; - paymentState = n.paymentState; + pledgeState = n.pledgeState; } /// @notice Getter to find Delegate w/ the Pledge ID & the Delegate index @@ -421,7 +421,7 @@ contract LiquidPledgingBase is Owned { /// @param oldPledge This value is used to store the pledge the current /// pledge was came from, and in the case a Project is canceled, the Pledge /// will revert back to it's previous state - /// @param paid The payment state: Pledged, Paying, or Paid + /// @param state The pledge state: Pledged, Paying, or state /// @return The hPledge2idx index number function findOrCreatePledge( uint64 owner, @@ -429,17 +429,17 @@ contract LiquidPledgingBase is Owned { uint64 intendedProject, uint64 commitTime, uint64 oldPledge, - PaymentState paid // TODO CHANGE PAID TO STATE + PledgeState state ) internal returns (uint64) { bytes32 hPledge = sha3( - owner, delegationChain, intendedProject, commitTime, oldPledge, paid); + owner, delegationChain, intendedProject, commitTime, oldPledge, state); uint64 idx = hPledge2idx[hPledge]; if (idx > 0) return idx; idx = uint64(pledges.length); hPledge2idx[hPledge] = idx; pledges.push(Pledge( - 0, owner, delegationChain, intendedProject, commitTime, oldPledge, paid)); + 0, owner, delegationChain, intendedProject, commitTime, oldPledge, state)); return idx; } diff --git a/js/liquidPledgingState.js b/js/liquidPledgingState.js index 29e0e08..63c7a1e 100644 --- a/js/liquidPledgingState.js +++ b/js/liquidPledgingState.js @@ -20,14 +20,14 @@ class LiquidPledgingState { if (res.oldPledge) { pledge.oldPledge = res.oldPledge; } - if (res.paymentState === '0') { - pledge.paymentState = 'Pledged'; - } else if (res.paymentState === '1') { - pledge.paymentState = 'Paying'; - } else if (res.paymentState === '2') { - pledge.paymentState = 'Paid'; + if (res.pledgeState === '0') { + pledge.pledgeState = 'Pledged'; + } else if (res.pledgeState === '1') { + pledge.pledgeState = 'Paying'; + } else if (res.pledgeState === '2') { + pledge.pledgeState = 'Paid'; } else { - pledge.paymentState = 'Unknown'; + pledge.pledgeState = 'Unknown'; } const promises = []; @@ -68,7 +68,7 @@ class LiquidPledgingState { admin.name = res.name; admin.url = res.url; admin.commitTime = res.commitTime; - if (admin.paymentState === 'Project') { + if (admin.adminType === 'Project') { admin.parentProject = res.parentProject; admin.canceled = res.canceled; } From cf5c84e20f5245bda7fa1076211f1a0e4199c70b Mon Sep 17 00:00:00 2001 From: perissology Date: Tue, 5 Dec 2017 12:47:38 -0800 Subject: [PATCH 4/4] rename Pledge n -> Pledge p --- contracts/LPVault.sol | 4 +- contracts/LiquidPledging.sol | 146 +++++++++++++++---------------- contracts/LiquidPledgingBase.sol | 54 ++++++------ 3 files changed, 102 insertions(+), 102 deletions(-) diff --git a/contracts/LPVault.sol b/contracts/LPVault.sol index 674447b..3fc16c4 100644 --- a/contracts/LPVault.sol +++ b/contracts/LPVault.sol @@ -12,8 +12,8 @@ import "./Owned.sol"; /// @dev `LiquidPledging` is a basic interface to allow the `LPVault` contract /// to confirm and cancel payments in the `LiquidPledging` contract. contract LiquidPledging { - function confirmPayment(uint64 idNote, uint amount) public; - function cancelPayment(uint64 idNote, uint amount) public; + function confirmPayment(uint64 idPledge, uint amount) public; + function cancelPayment(uint64 idPledge, uint amount) public; } diff --git a/contracts/LiquidPledging.sol b/contracts/LiquidPledging.sol index 705eec0..4995e2f 100644 --- a/contracts/LiquidPledging.sol +++ b/contracts/LiquidPledging.sol @@ -103,15 +103,15 @@ contract LiquidPledging is LiquidPledgingBase { idPledge = normalizePledge(idPledge); - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); PledgeAdmin storage receiver = findAdmin(idReceiver); PledgeAdmin storage sender = findAdmin(idSender); checkAdminOwner(sender); - require(n.pledgeState == PledgeState.Pledged); + require(p.pledgeState == PledgeState.Pledged); // If the sender is the owner - if (n.owner == idSender) { + if (p.owner == idSender) { if (receiver.adminType == PledgeAdminType.Giver) { transferOwnershipToGiver(idPledge, amount, idReceiver); } else if (receiver.adminType == PledgeAdminType.Project) { @@ -120,7 +120,7 @@ contract LiquidPledging is LiquidPledgingBase { idPledge = undelegate( idPledge, amount, - n.delegationChain.length + p.delegationChain.length ); appendDelegate(idPledge, amount, idReceiver); } else { @@ -130,28 +130,28 @@ contract LiquidPledging is LiquidPledgingBase { } // If the sender is a delegate - uint senderDIdx = getDelegateIdx(n, idSender); + uint senderDIdx = getDelegateIdx(p, idSender); if (senderDIdx != NOTFOUND) { // If the receiver is another giver if (receiver.adminType == PledgeAdminType.Giver) { // Only accept to change to the original giver to // remove all delegates - assert(n.owner == idReceiver); - undelegate(idPledge, amount, n.delegationChain.length); + assert(p.owner == idReceiver); + undelegate(idPledge, amount, p.delegationChain.length); return; } // If the receiver is another delegate if (receiver.adminType == PledgeAdminType.Delegate) { - uint receiverDIdx = getDelegateIdx(n, idReceiver); + uint receiverDIdx = getDelegateIdx(p, idReceiver); // If the receiver is not in the delegate list if (receiverDIdx == NOTFOUND) { idPledge = undelegate( idPledge, amount, - n.delegationChain.length - senderDIdx - 1 + p.delegationChain.length - senderDIdx - 1 ); appendDelegate(idPledge, amount, idReceiver); @@ -163,7 +163,7 @@ contract LiquidPledging is LiquidPledgingBase { idPledge = undelegate( idPledge, amount, - n.delegationChain.length - senderDIdx - 1 + p.delegationChain.length - senderDIdx - 1 ); appendDelegate(idPledge, amount, idReceiver); @@ -177,7 +177,7 @@ contract LiquidPledging is LiquidPledgingBase { undelegate( idPledge, amount, - n.delegationChain.length - receiverDIdx - 1 + p.delegationChain.length - receiverDIdx - 1 ); } return; @@ -189,7 +189,7 @@ contract LiquidPledging is LiquidPledgingBase { idPledge = undelegate( idPledge, amount, - n.delegationChain.length - senderDIdx - 1 + p.delegationChain.length - senderDIdx - 1 ); proposeAssignProject(idPledge, amount, idReceiver); return; @@ -206,20 +206,20 @@ contract LiquidPledging is LiquidPledgingBase { idPledge = normalizePledge(idPledge); - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); - require(n.pledgeState == PledgeState.Pledged); + require(p.pledgeState == PledgeState.Pledged); - PledgeAdmin storage owner = findAdmin(n.owner); + PledgeAdmin storage owner = findAdmin(p.owner); checkAdminOwner(owner); uint64 idNewPledge = findOrCreatePledge( - n.owner, - n.delegationChain, + p.owner, + p.delegationChain, 0, 0, - n.oldPledge, + p.oldPledge, PledgeState.Paying ); @@ -232,16 +232,16 @@ contract LiquidPledging is LiquidPledgingBase { /// @param idPledge Id of the pledge that wants to be withdrawn. /// @param amount Quantity of Ether that wants to be withdrawn. function confirmPayment(uint64 idPledge, uint amount) onlyVault { - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); - require(n.pledgeState == PledgeState.Paying); + require(p.pledgeState == PledgeState.Paying); uint64 idNewPledge = findOrCreatePledge( - n.owner, - n.delegationChain, + p.owner, + p.delegationChain, 0, 0, - n.oldPledge, + p.oldPledge, PledgeState.Paid ); @@ -252,17 +252,17 @@ contract LiquidPledging is LiquidPledgingBase { /// @param idPledge Id of the pledge that wants to be canceled for withdraw. /// @param amount Quantity of Ether that wants to be rolled back. function cancelPayment(uint64 idPledge, uint amount) onlyVault { - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); - require(n.pledgeState == PledgeState.Paying); //TODO change to revert + require(p.pledgeState == PledgeState.Paying); //TODO change to revert // When a payment is canceled, never is assigned to a project. uint64 oldPledge = findOrCreatePledge( - n.owner, - n.delegationChain, + p.owner, + p.delegationChain, 0, 0, - n.oldPledge, + p.oldPledge, PledgeState.Pledged ); @@ -287,13 +287,13 @@ contract LiquidPledging is LiquidPledgingBase { function cancelPledge(uint64 idPledge, uint amount) { idPledge = normalizePledge(idPledge); - Pledge storage n = findPledge(idPledge); - require(n.oldPledge != 0); + Pledge storage p = findPledge(idPledge); + require(p.oldPledge != 0); - PledgeAdmin storage m = findAdmin(n.owner); + PledgeAdmin storage m = findAdmin(p.owner); checkAdminOwner(m); - uint64 oldPledge = getOldestPledgeNotCanceled(n.oldPledge); + uint64 oldPledge = getOldestPledgeNotCanceled(p.oldPledge); doTransfer(idPledge, oldPledge, amount); } @@ -395,19 +395,19 @@ contract LiquidPledging is LiquidPledgingBase { uint amount, uint64 idReceiver ) internal { - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); // Ensure that the pledge is not already at max pledge depth // and the project has not been canceled - require(getPledgeLevel(n) < MAX_INTERPROJECT_LEVEL); + require(getPledgeLevel(p) < MAX_INTERPROJECT_LEVEL); require(!isProjectCanceled(idReceiver)); uint64 oldPledge = findOrCreatePledge( - n.owner, - n.delegationChain, + p.owner, + p.delegationChain, 0, 0, - n.oldPledge, + p.oldPledge, PledgeState.Pledged ); uint64 toPledge = findOrCreatePledge( @@ -454,25 +454,25 @@ contract LiquidPledging is LiquidPledgingBase { uint amount, uint64 idReceiver ) internal { - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); - require(n.delegationChain.length < MAX_DELEGATES); + require(p.delegationChain.length < MAX_DELEGATES); uint64[] memory newDelegationChain = new uint64[]( - n.delegationChain.length + 1 + p.delegationChain.length + 1 ); - for (uint i = 0; i 0) && ( getTime() > n.commitTime)) { + if ((p.intendedProject > 0) && ( getTime() > p.commitTime)) { uint64 oldPledge = findOrCreatePledge( - n.owner, - n.delegationChain, + p.owner, + p.delegationChain, 0, 0, - n.oldPledge, + p.oldPledge, PledgeState.Pledged ); uint64 toPledge = findOrCreatePledge( - n.intendedProject, + p.intendedProject, new uint64[](0), 0, 0, oldPledge, PledgeState.Pledged ); - doTransfer(idPledge, toPledge, n.amount); + doTransfer(idPledge, toPledge, p.amount); idPledge = toPledge; - n = findPledge(idPledge); + p = findPledge(idPledge); } toPledge = getOldestPledgeNotCanceled(idPledge);// TODO toPledge is pledge defined if (toPledge != idPledge) { - doTransfer(idPledge, toPledge, n.amount); + doTransfer(idPledge, toPledge, p.amount); } return toPledge; @@ -695,12 +695,12 @@ contract LiquidPledging is LiquidPledgingBase { // or transferring context uint64 offset = idPledge == fromPledge ? 0 : 256; allowedAmount = amount; - Pledge storage n = findPledge(idPledge); + Pledge storage p = findPledge(idPledge); // Always call the plugin on the owner allowedAmount = callPlugin( before, - n.owner, + p.owner, fromPledge, toPledge, offset, @@ -708,10 +708,10 @@ contract LiquidPledging is LiquidPledgingBase { ); // Apply call plugin to all delegates - for (uint64 i=0; i 0) { + if (p.intendedProject > 0) { allowedAmount = callPlugin( before, - n.intendedProject, + p.intendedProject, fromPledge, toPledge, offset + 255, diff --git a/contracts/LiquidPledgingBase.sol b/contracts/LiquidPledgingBase.sol index 530b6b0..c56f71a 100644 --- a/contracts/LiquidPledgingBase.sol +++ b/contracts/LiquidPledgingBase.sol @@ -338,14 +338,14 @@ contract LiquidPledgingBase is Owned { uint64 oldPledge, PledgeState pledgeState ) { - Pledge storage n = findPledge(idPledge); - amount = n.amount; - owner = n.owner; - nDelegates = uint64(n.delegationChain.length); - intendedProject = n.intendedProject; - commitTime = n.commitTime; - oldPledge = n.oldPledge; - pledgeState = n.pledgeState; + Pledge storage p = findPledge(idPledge); + amount = p.amount; + owner = p.owner; + nDelegates = uint64(p.delegationChain.length); + intendedProject = p.intendedProject; + commitTime = p.commitTime; + oldPledge = p.oldPledge; + pledgeState = p.pledgeState; } /// @notice Getter to find Delegate w/ the Pledge ID & the Delegate index @@ -356,8 +356,8 @@ contract LiquidPledgingBase is Owned { address addr, string name ) { - Pledge storage n = findPledge(idPledge); - idDelegate = n.delegationChain[idxDelegate - 1]; + Pledge storage p = findPledge(idPledge); + idDelegate = p.delegationChain[idxDelegate - 1]; PledgeAdmin storage delegate = findAdmin(idDelegate); addr = delegate.addr; name = delegate.name; @@ -464,39 +464,39 @@ contract LiquidPledgingBase is Owned { /// @notice A getter that searches the delegationChain for the level of /// authority a specific delegate has within a Pledge - /// @param n The Pledge that will be searched + /// @param p The Pledge that will be searched /// @param idDelegate The specified delegate that's searched for /// @return If the delegate chain contains the delegate with the /// `admins` array index `idDelegate` this returns that delegates /// corresponding index in the delegationChain. Otherwise it returns /// the NOTFOUND constant - function getDelegateIdx(Pledge n, uint64 idDelegate) internal returns(uint64) { - for (uint i=0; i < n.delegationChain.length; i++) { - if (n.delegationChain[i] == idDelegate) return uint64(i); + function getDelegateIdx(Pledge p, uint64 idDelegate) internal returns(uint64) { + for (uint i=0; i < p.delegationChain.length; i++) { + if (p.delegationChain[i] == idDelegate) return uint64(i); } return NOTFOUND; } /// @notice A getter to find how many old "parent" pledges a specific Pledge /// had using a self-referential loop - /// @param n The Pledge being queried + /// @param p The Pledge being queried /// @return The number of old "parent" pledges a specific Pledge had - function getPledgeLevel(Pledge n) internal returns(uint) { - if (n.oldPledge == 0) return 0; - Pledge storage oldN = findPledge(n.oldPledge); + function getPledgeLevel(Pledge p) internal returns(uint) { + if (p.oldPledge == 0) return 0; + Pledge storage oldN = findPledge(p.oldPledge); return getPledgeLevel(oldN) + 1; // a loop lookup } /// @notice A getter to find the longest commitTime out of the owner and all /// the delegates for a specified pledge - /// @param n The Pledge being queried + /// @param p The Pledge being queried /// @return The maximum commitTime out of the owner and all the delegates - function maxCommitTime(Pledge n) internal returns(uint commitTime) { - PledgeAdmin storage m = findAdmin(n.owner); + function maxCommitTime(Pledge p) internal returns(uint commitTime) { + PledgeAdmin storage m = findAdmin(p.owner); commitTime = m.commitTime; // start with the owner's commitTime - for (uint i=0; i commitTime) commitTime = m.commitTime; @@ -532,15 +532,15 @@ contract LiquidPledgingBase is Owned { function getOldestPledgeNotCanceled(uint64 idPledge ) internal constant returns(uint64) { if (idPledge == 0) return 0; - Pledge storage n = findPledge(idPledge); - PledgeAdmin storage admin = findAdmin(n.owner); + Pledge storage p = findPledge(idPledge); + PledgeAdmin storage admin = findAdmin(p.owner); if (admin.adminType == PledgeAdminType.Giver) return idPledge; assert(admin.adminType == PledgeAdminType.Project); - if (!isProjectCanceled(n.owner)) return idPledge; + if (!isProjectCanceled(p.owner)) return idPledge; - return getOldestPledgeNotCanceled(n.oldPledge); + return getOldestPledgeNotCanceled(p.oldPledge); } /// @notice A check to see if the msg.sender is the owner or the