rename PaymentState -> PledgeState

This commit is contained in:
perissology 2017-12-05 12:42:59 -08:00
parent 8153abbb69
commit 584726ffd0
3 changed files with 35 additions and 35 deletions

View File

@ -70,7 +70,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
0, 0,
PaymentState.Pledged PledgeState.Pledged
); );
@ -108,7 +108,7 @@ contract LiquidPledging is LiquidPledgingBase {
PledgeAdmin storage sender = findAdmin(idSender); PledgeAdmin storage sender = findAdmin(idSender);
checkAdminOwner(sender); checkAdminOwner(sender);
require(n.paymentState == PaymentState.Pledged); require(n.pledgeState == PledgeState.Pledged);
// If the sender is the owner // If the sender is the owner
if (n.owner == idSender) { if (n.owner == idSender) {
@ -208,7 +208,7 @@ contract LiquidPledging is LiquidPledgingBase {
Pledge storage n = findPledge(idPledge); Pledge storage n = findPledge(idPledge);
require(n.paymentState == PaymentState.Pledged); require(n.pledgeState == PledgeState.Pledged);
PledgeAdmin storage owner = findAdmin(n.owner); PledgeAdmin storage owner = findAdmin(n.owner);
@ -220,7 +220,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Paying PledgeState.Paying
); );
doTransfer(idPledge, idNewPledge, amount); doTransfer(idPledge, idNewPledge, amount);
@ -234,7 +234,7 @@ contract LiquidPledging is LiquidPledgingBase {
function confirmPayment(uint64 idPledge, uint amount) onlyVault { function confirmPayment(uint64 idPledge, uint amount) onlyVault {
Pledge storage n = findPledge(idPledge); Pledge storage n = findPledge(idPledge);
require(n.paymentState == PaymentState.Paying); require(n.pledgeState == PledgeState.Paying);
uint64 idNewPledge = findOrCreatePledge( uint64 idNewPledge = findOrCreatePledge(
n.owner, n.owner,
@ -242,7 +242,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Paid PledgeState.Paid
); );
doTransfer(idPledge, idNewPledge, amount); doTransfer(idPledge, idNewPledge, amount);
@ -254,7 +254,7 @@ contract LiquidPledging is LiquidPledgingBase {
function cancelPayment(uint64 idPledge, uint amount) onlyVault { function cancelPayment(uint64 idPledge, uint amount) onlyVault {
Pledge storage n = findPledge(idPledge); 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. // When a payment is canceled, never is assigned to a project.
uint64 oldPledge = findOrCreatePledge( uint64 oldPledge = findOrCreatePledge(
@ -263,7 +263,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
oldPledge = normalizePledge(oldPledge); oldPledge = normalizePledge(oldPledge);
@ -408,7 +408,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
uint64 toPledge = findOrCreatePledge( uint64 toPledge = findOrCreatePledge(
idReceiver, // Set the new owner idReceiver, // Set the new owner
@ -416,7 +416,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
oldPledge, oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, amount); doTransfer(idPledge, toPledge, amount);
} }
@ -439,7 +439,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
0, 0,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, amount); doTransfer(idPledge, toPledge, amount);
} }
@ -473,7 +473,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, amount); doTransfer(idPledge, toPledge, amount);
} }
@ -501,7 +501,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, amount); doTransfer(idPledge, toPledge, amount);
@ -531,7 +531,7 @@ contract LiquidPledging is LiquidPledgingBase {
idReceiver, idReceiver,
uint64(getTime() + maxCommitTime(n)), uint64(getTime() + maxCommitTime(n)),
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, amount); doTransfer(idPledge, toPledge, amount);
} }
@ -559,7 +559,7 @@ contract LiquidPledging is LiquidPledgingBase {
callPlugins(false, from, to, amount); 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: /// and does 2 things:
/// #1: Checks if the pledge should be committed. This means that /// #1: Checks if the pledge should be committed. This means that
/// if the pledge has an intendedProject and it is past the /// 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 // Check to make sure this pledge hasn't already been used
// or is in the process of being used // or is in the process of being used
if (n.paymentState != PaymentState.Pledged) { if (n.pledgeState != PledgeState.Pledged) {
return idPledge; return idPledge;
} }
@ -594,7 +594,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
n.oldPledge, n.oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
uint64 toPledge = findOrCreatePledge( uint64 toPledge = findOrCreatePledge(
n.intendedProject, n.intendedProject,
@ -602,7 +602,7 @@ contract LiquidPledging is LiquidPledgingBase {
0, 0,
0, 0,
oldPledge, oldPledge,
PaymentState.Pledged PledgeState.Pledged
); );
doTransfer(idPledge, toPledge, n.amount); doTransfer(idPledge, toPledge, n.amount);
idPledge = toPledge; idPledge = toPledge;

View File

@ -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 /// @dev This is an interface for `LPVault` which serves as a secure storage for
/// the ETH that backs the Pledges, only after `LiquidPledging` authorizes /// the ETH that backs the Pledges, only after `LiquidPledging` authorizes
/// payments can Pledges be converted for ETH /// 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 authorizePayment(bytes32 _ref, address _dest, uint _amount);
function () payable; function () payable;
} }
@ -40,7 +40,7 @@ contract LiquidPledgingBase is Owned {
uint constant MAX_INTERPROJECT_LEVEL = 20; uint constant MAX_INTERPROJECT_LEVEL = 20;
enum PledgeAdminType { Giver, Delegate, Project } 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 /// @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
@ -66,7 +66,7 @@ contract LiquidPledgingBase is Owned {
uint64 intendedProject; // Used when delegates are sending to projects uint64 intendedProject; // Used when delegates are sending to projects
uint64 commitTime; // When the intendedProject will become the owner uint64 commitTime; // When the intendedProject will become the owner
uint64 oldPledge; // Points to the id that this Pledge was derived from 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; Pledge[] pledges;
@ -336,7 +336,7 @@ contract LiquidPledgingBase is Owned {
uint64 intendedProject, uint64 intendedProject,
uint64 commitTime, uint64 commitTime,
uint64 oldPledge, uint64 oldPledge,
PaymentState paymentState PledgeState pledgeState
) { ) {
Pledge storage n = findPledge(idPledge); Pledge storage n = findPledge(idPledge);
amount = n.amount; amount = n.amount;
@ -345,7 +345,7 @@ contract LiquidPledgingBase is Owned {
intendedProject = n.intendedProject; intendedProject = n.intendedProject;
commitTime = n.commitTime; commitTime = n.commitTime;
oldPledge = n.oldPledge; oldPledge = n.oldPledge;
paymentState = n.paymentState; pledgeState = n.pledgeState;
} }
/// @notice Getter to find Delegate w/ the Pledge ID & the Delegate index /// @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 /// @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 /// pledge was came from, and in the case a Project is canceled, the Pledge
/// will revert back to it's previous state /// 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 /// @return The hPledge2idx index number
function findOrCreatePledge( function findOrCreatePledge(
uint64 owner, uint64 owner,
@ -429,17 +429,17 @@ contract LiquidPledgingBase is Owned {
uint64 intendedProject, uint64 intendedProject,
uint64 commitTime, uint64 commitTime,
uint64 oldPledge, uint64 oldPledge,
PaymentState paid // TODO CHANGE PAID TO STATE PledgeState state
) internal returns (uint64) ) internal returns (uint64)
{ {
bytes32 hPledge = sha3( bytes32 hPledge = sha3(
owner, delegationChain, intendedProject, commitTime, oldPledge, paid); owner, delegationChain, intendedProject, commitTime, oldPledge, state);
uint64 idx = hPledge2idx[hPledge]; uint64 idx = hPledge2idx[hPledge];
if (idx > 0) return idx; if (idx > 0) return idx;
idx = uint64(pledges.length); idx = uint64(pledges.length);
hPledge2idx[hPledge] = idx; hPledge2idx[hPledge] = idx;
pledges.push(Pledge( pledges.push(Pledge(
0, owner, delegationChain, intendedProject, commitTime, oldPledge, paid)); 0, owner, delegationChain, intendedProject, commitTime, oldPledge, state));
return idx; return idx;
} }

View File

@ -20,14 +20,14 @@ class LiquidPledgingState {
if (res.oldPledge) { if (res.oldPledge) {
pledge.oldPledge = res.oldPledge; pledge.oldPledge = res.oldPledge;
} }
if (res.paymentState === '0') { if (res.pledgeState === '0') {
pledge.paymentState = 'Pledged'; pledge.pledgeState = 'Pledged';
} else if (res.paymentState === '1') { } else if (res.pledgeState === '1') {
pledge.paymentState = 'Paying'; pledge.pledgeState = 'Paying';
} else if (res.paymentState === '2') { } else if (res.pledgeState === '2') {
pledge.paymentState = 'Paid'; pledge.pledgeState = 'Paid';
} else { } else {
pledge.paymentState = 'Unknown'; pledge.pledgeState = 'Unknown';
} }
const promises = []; const promises = [];
@ -68,7 +68,7 @@ class LiquidPledgingState {
admin.name = res.name; admin.name = res.name;
admin.url = res.url; admin.url = res.url;
admin.commitTime = res.commitTime; admin.commitTime = res.commitTime;
if (admin.paymentState === 'Project') { if (admin.adminType === 'Project') {
admin.parentProject = res.parentProject; admin.parentProject = res.parentProject;
admin.canceled = res.canceled; admin.canceled = res.canceled;
} }