mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-01-12 04:24:23 +00:00
spellcheck comments
This commit is contained in:
parent
77efe8ca90
commit
ee8e2b777b
@ -91,7 +91,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
/// @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 giver sending to
|
/// @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
|
/// 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(
|
function transfer(
|
||||||
uint64 idSender,
|
uint64 idSender,
|
||||||
uint64 idPledge,
|
uint64 idPledge,
|
||||||
@ -168,10 +168,10 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
|
|
||||||
// If the receiver is already part of the delegate chain and is
|
// If the receiver is already part of the delegate chain and is
|
||||||
// before the sender, then the sender and all of the other
|
// before the sender, then the sender and all of the other
|
||||||
// delegates after the RECEIVER are revomved from the chain,
|
// delegates after the RECEIVER are removed from the chain,
|
||||||
// this is interesting because the delegate undelegates from the
|
// this is interesting because the delegate is removed from the
|
||||||
// delegates that delegated to this delegate... game theory
|
// delegates that delegated to this delegate. Are there game theory
|
||||||
// issues? should this be allowed
|
// issues? should this be allowed?
|
||||||
} else if (receiverDIdx <= senderDIdx) {
|
} else if (receiverDIdx <= senderDIdx) {
|
||||||
undelegate(
|
undelegate(
|
||||||
idPledge,
|
idPledge,
|
||||||
@ -182,7 +182,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
return;
|
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
|
// the delegates after them in the chain and choose a project
|
||||||
if (receiver.adminType == PledgeAdminType.Project) {
|
if (receiver.adminType == PledgeAdminType.Project) {
|
||||||
idPledge = undelegate(
|
idPledge = undelegate(
|
||||||
@ -285,7 +285,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
CancelProject(idProject);
|
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 idPledge Id of the pledge that should be canceled.
|
||||||
/// @param amount Quantity of Ether that wants to be rolled back.
|
/// @param amount Quantity of Ether that wants to be rolled back.
|
||||||
function cancelPledge(uint64 idPledge, uint amount) {
|
function cancelPledge(uint64 idPledge, uint amount) {
|
||||||
@ -320,7 +320,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
/// using the D64 bitmask
|
/// using the D64 bitmask
|
||||||
/// @param idReceiver Destination of the value, can be a giver sending
|
/// @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
|
/// 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(
|
function mTransfer(
|
||||||
uint64 idSender,
|
uint64 idSender,
|
||||||
uint[] pledgesAmounts,
|
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
|
/// efficiently
|
||||||
/// @param amount An array of pledge amounts and IDs which are extrapolated
|
/// @param amount An array of pledge amounts and IDs which are extrapolated
|
||||||
/// using the D64 bitmask
|
/// using the D64 bitmask
|
||||||
@ -390,11 +390,11 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
///////
|
///////
|
||||||
|
|
||||||
/// @notice `transferOwnershipToProject` allows for the transfer of
|
/// @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
|
/// everyone by setting one's own id for the idReceiver
|
||||||
/// @param idPledge Id of the pledge to be transfered.
|
/// @param idPledge Id of the pledge to be transfered.
|
||||||
/// @param amount Quantity of value that's being 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(
|
function transferOwnershipToProject(
|
||||||
uint64 idPledge,
|
uint64 idPledge,
|
||||||
uint amount,
|
uint amount,
|
||||||
@ -403,7 +403,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
|
|
||||||
// Ensure that the pledge is not already at max pledge depth
|
// 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(getPledgeLevel(n) < MAX_INTERPROJECT_LEVEL);
|
||||||
require(!isProjectCanceled(idReceiver));
|
require(!isProjectCanceled(idReceiver));
|
||||||
|
|
||||||
@ -462,7 +462,9 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
|
|
||||||
require(n.delegationChain.length < MAX_DELEGATES);
|
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<n.delegationChain.length; i++) {
|
for (uint i = 0; i<n.delegationChain.length; i++) {
|
||||||
newDelegationChain[i] = n.delegationChain[i];
|
newDelegationChain[i] = n.delegationChain[i];
|
||||||
}
|
}
|
||||||
@ -492,7 +494,9 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
uint q
|
uint q
|
||||||
) internal returns (uint64){
|
) internal returns (uint64){
|
||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
uint64[] memory newDelegationChain = new uint64[](n.delegationChain.length - q);
|
uint64[] memory newDelegationChain = new uint64[](
|
||||||
|
n.delegationChain.length - q
|
||||||
|
);
|
||||||
for (uint i=0; i<n.delegationChain.length - q; i++) {
|
for (uint i=0; i<n.delegationChain.length - q; i++) {
|
||||||
newDelegationChain[i] = n.delegationChain[i];
|
newDelegationChain[i] = n.delegationChain[i];
|
||||||
}
|
}
|
||||||
@ -514,7 +518,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
/// @dev This function should potentially be named more specifically.
|
/// @dev This function should potentially be named more specifically.
|
||||||
/// @param idPledge Id of the pledge that will be assigned.
|
/// @param idPledge Id of the pledge that will be assigned.
|
||||||
/// @param amount Quantity of value this pledge leader would be assigned.
|
/// @param amount Quantity of value this pledge leader would be assigned.
|
||||||
/// @param idReceiver The project this pledge will potentialy
|
/// @param idReceiver The project this pledge will potentially
|
||||||
/// be assigned to.
|
/// be assigned to.
|
||||||
function proposeAssignProject(
|
function proposeAssignProject(
|
||||||
uint64 idPledge,
|
uint64 idPledge,
|
||||||
@ -578,12 +582,12 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
|
|
||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
|
|
||||||
// Check to make sure this pledge hasnt 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.paymentState != PaymentState.Pledged)
|
||||||
return idPledge;
|
return idPledge;
|
||||||
|
|
||||||
// First send to a project if it's proposed and commited
|
// First send to a project if it's proposed and committed
|
||||||
if ((n.intendedProject > 0) && ( getTime() > n.commitTime)) {
|
if ((n.intendedProject > 0) && ( getTime() > n.commitTime)) {
|
||||||
uint64 oldPledge = findOrCreatePledge(
|
uint64 oldPledge = findOrCreatePledge(
|
||||||
n.owner,
|
n.owner,
|
||||||
@ -621,7 +625,7 @@ contract LiquidPledging is LiquidPledgingBase {
|
|||||||
/// Specifically what this does in relation to the plugin is something
|
/// Specifically what this does in relation to the plugin is something
|
||||||
/// that largely depends on the functions of that plugin. This function
|
/// that largely depends on the functions of that plugin. This function
|
||||||
/// is generally called in pairs, once before, and once after a transfer.
|
/// 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.
|
/// before or after a transfer.
|
||||||
/// @param adminId This should be the Id of the *trusted* individual
|
/// @param adminId This should be the Id of the *trusted* individual
|
||||||
/// who has control over this plugin.
|
/// who has control over this plugin.
|
||||||
|
@ -58,9 +58,13 @@ contract LiquidPledgingBase {
|
|||||||
uint amount;
|
uint amount;
|
||||||
uint64 owner; // PledgeAdmin
|
uint64 owner; // PledgeAdmin
|
||||||
uint64[] delegationChain; // list of index numbers
|
uint64[] delegationChain; // list of index numbers
|
||||||
uint64 intendedProject; // TODO change the name only used for when delegates are precommiting to a project
|
// TODO change the name only used for when delegates are
|
||||||
uint64 commitTime; // When the intendedProject will become the owner
|
// pre-committing to a project
|
||||||
uint64 oldPledge; // this points to the Pledge[] index that the Pledge was derived from
|
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;
|
PaymentState paymentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +72,8 @@ contract LiquidPledgingBase {
|
|||||||
PledgeAdmin[] admins; //The list of pledgeAdmins 0 means there is no admin
|
PledgeAdmin[] admins; //The list of pledgeAdmins 0 means there is no admin
|
||||||
Vault public vault;
|
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
|
mapping (bytes32 => uint64) hPledge2idx;//TODO Fix typo
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +92,8 @@ contract LiquidPledgingBase {
|
|||||||
// Constructor
|
// 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
|
/// @param _vault The vault where ETH backing this pledge is stored
|
||||||
function LiquidPledgingBase(address _vault) {
|
function LiquidPledgingBase(address _vault) {
|
||||||
admins.length = 1; // we reserve the 0 admin
|
admins.length = 1; // we reserve the 0 admin
|
||||||
@ -104,8 +110,13 @@ contract LiquidPledgingBase {
|
|||||||
/// @param name This is the name used to identify the giver.
|
/// @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 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 commitTime Set the default commit time period for this giver.
|
||||||
/// @param plugin This is givers liquid pledge plugin allowing for extended functionality.
|
/// @param plugin This is givers liquid pledge plugin allowing for
|
||||||
function addGiver(string name, string url, uint64 commitTime, ILiquidPledgingPlugin plugin
|
/// extended functionality.
|
||||||
|
function addGiver(
|
||||||
|
string name,
|
||||||
|
string url,
|
||||||
|
uint64 commitTime,
|
||||||
|
ILiquidPledgingPlugin plugin
|
||||||
) returns (uint64 idGiver) {
|
) returns (uint64 idGiver) {
|
||||||
|
|
||||||
idGiver = uint64(admins.length);
|
idGiver = uint64(admins.length);
|
||||||
@ -163,9 +174,9 @@ contract LiquidPledgingBase {
|
|||||||
string url,
|
string url,
|
||||||
uint64 commitTime,
|
uint64 commitTime,
|
||||||
ILiquidPledgingPlugin plugin
|
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(
|
admins.push(PledgeAdmin(
|
||||||
PledgeAdminType.Delegate,
|
PledgeAdminType.Delegate,
|
||||||
@ -177,10 +188,10 @@ contract LiquidPledgingBase {
|
|||||||
false,
|
false,
|
||||||
plugin));
|
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,
|
/// @notice `updateDelegate` allows for basic update operation to change the address,
|
||||||
/// name or commitTime associated with a specific delegate.
|
/// 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 newUrl This is a link to the delegates profile or a representative site.
|
||||||
/// @param newCommitTime Set the default commit time period for this giver.
|
/// @param newCommitTime Set the default commit time period for this giver.
|
||||||
function updateDelegate(
|
function updateDelegate(
|
||||||
uint64 idDelegate,
|
uint64 idxDelegate,
|
||||||
address newAddr,
|
address newAddr,
|
||||||
string newName,
|
string newName,
|
||||||
string newUrl,
|
string newUrl,
|
||||||
uint64 newCommitTime) {
|
uint64 newCommitTime) {
|
||||||
PledgeAdmin storage delegate = findAdmin(idDelegate);
|
PledgeAdmin storage delegate = findAdmin(idxDelegate);
|
||||||
require(delegate.adminType == PledgeAdminType.Delegate);
|
require(delegate.adminType == PledgeAdminType.Delegate);
|
||||||
require(delegate.addr == msg.sender);
|
require(delegate.addr == msg.sender);
|
||||||
delegate.addr = newAddr;
|
delegate.addr = newAddr;
|
||||||
delegate.name = newName;
|
delegate.name = newName;
|
||||||
delegate.url = newUrl;
|
delegate.url = newUrl;
|
||||||
delegate.commitTime = newCommitTime;
|
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.
|
/// @notice `addProject` Creates a project and adds it to the list of admins.
|
||||||
/// @param name This is the name used to identify the project.
|
/// @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
|
/// @notice `getPledgeDelegate` returns a single delegate given the pledge ID
|
||||||
/// and the delegate ID.
|
/// and the delegate ID.
|
||||||
/// @param idPledge The ID internally representing the pledge.
|
/// @param idPledge The ID internally representing the pledge.
|
||||||
/// @param idDelegate The ID internally representing the delegate.
|
/// @param idxDelegate The ID internally representing the delegate.
|
||||||
function getPledgeDelegate(uint64 idPledge, uint idDelegate) constant returns(
|
function getPledgeDelegate(uint64 idPledge, uint idxDelegate) constant returns(
|
||||||
uint64 idDelegate,
|
uint64 idxDelegate,
|
||||||
address addr,
|
address addr,
|
||||||
string name
|
string name
|
||||||
) {
|
) {
|
||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
idDelegate = n.delegationChain[idDelegate - 1];
|
idxDelegate = n.delegationChain[idxDelegate - 1];
|
||||||
PledgeAdmin storage delegate = findAdmin(idDelegate);
|
PledgeAdmin storage delegate = findAdmin(idxDelegate);
|
||||||
addr = delegate.addr;
|
addr = delegate.addr;
|
||||||
name = delegate.name;
|
name = delegate.name;
|
||||||
}
|
}
|
||||||
@ -361,10 +372,16 @@ contract LiquidPledgingBase {
|
|||||||
// Private methods
|
// Private methods
|
||||||
///////
|
///////
|
||||||
|
|
||||||
/// @notice All pledges technically exist... but if the pledge hasn't been
|
/// @notice All pledges technically exist. If the pledge hasn't been
|
||||||
/// created in this system yet then it wouldn't be in the hash array
|
/// created in this system yet it simply isn't in the hash array
|
||||||
/// hPledge2idx[]; this creates a Pledge with and amount of 0 if one is not
|
/// hPledge2idx[] yet; this creates a Pledge with an initial amount of 0 if one is not
|
||||||
/// created already...
|
/// 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(
|
function findOrCreatePledge(
|
||||||
uint64 owner,
|
uint64 owner,
|
||||||
uint64[] delegationChain,
|
uint64[] delegationChain,
|
||||||
@ -383,11 +400,17 @@ contract LiquidPledgingBase {
|
|||||||
return idx;
|
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) {
|
function findAdmin(uint64 idAdmin) internal returns (PledgeAdmin storage) {
|
||||||
require(idAdmin < admins.length);
|
require(idAdmin < admins.length);
|
||||||
return admins[idAdmin];
|
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) {
|
function findPledge(uint64 idPledge) internal returns (Pledge storage) {
|
||||||
require(idPledge < pledges.length);
|
require(idPledge < pledges.length);
|
||||||
return pledges[idPledge];
|
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
|
// a constant for the case that a delegate is requested that is not a delegate in the system
|
||||||
uint64 constant NOTFOUND = 0xFFFFFFFFFFFFFFFF;
|
uint64 constant NOTFOUND = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
|
||||||
// helper function that searches the delegationChain fro a specific delegate and
|
/// @notice `getDelegateIdx` is a helper function that searches the delegationChain
|
||||||
// level of delegation returns their idx in the delegation chain which reflect their level of authority
|
/// for a specific delegate and level of delegation returns their idx in the
|
||||||
function getDelegateIdx(Pledge n, uint64 idDelegate) internal returns(uint64) {
|
/// 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<n.delegationChain.length; i++) {
|
for (uint i=0; i<n.delegationChain.length; i++) {
|
||||||
if (n.delegationChain[i] == idDelegate) return uint64(i);
|
if (n.delegationChain[i] == idxDelegate) return uint64(i);
|
||||||
}
|
}
|
||||||
return NOTFOUND;
|
return NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function that returns the pledge level solely to check that transfers
|
/// @notice `getPledgeLevel` is a helper function that returns the pledge "depth"
|
||||||
// between Projects not violate MAX_INTERPROJECT_LEVEL
|
/// which can be used to check that transfers between Projects
|
||||||
|
/// not violate MAX_INTERPROJECT_LEVEL
|
||||||
|
/// @param n The pledge that will be searched.
|
||||||
function getPledgeLevel(Pledge n) internal returns(uint) {
|
function getPledgeLevel(Pledge n) internal returns(uint) {
|
||||||
if (n.oldPledge == 0) return 0; //changed
|
if (n.oldPledge == 0) return 0; //changed
|
||||||
Pledge storage oldN = findPledge(n.oldPledge);
|
Pledge storage oldN = findPledge(n.oldPledge);
|
||||||
return getPledgeLevel(oldN) + 1;
|
return getPledgeLevel(oldN) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function that returns the max commit time of the owner and all the
|
/// @notice `maxCommitTime` is a helper function that returns the maximum
|
||||||
// delegates
|
/// commit time of the owner and all the delegates.
|
||||||
|
/// @param n The pledge that will be searched.
|
||||||
function maxCommitTime(Pledge n) internal returns(uint commitTime) {
|
function maxCommitTime(Pledge n) internal returns(uint commitTime) {
|
||||||
PledgeAdmin storage m = findAdmin(n.owner);
|
PledgeAdmin storage m = findAdmin(n.owner);
|
||||||
commitTime = m.commitTime;
|
commitTime = m.commitTime;
|
||||||
@ -425,8 +455,9 @@ contract LiquidPledgingBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function that returns the project level solely to check that there
|
/// @notice `getProjectLevel` is a helper function that returns the project
|
||||||
// are not too many Projects that violate MAX_SUBCAMPAIGNS_LEVEL
|
/// level which can be used to check that there are not too many Projects
|
||||||
|
/// that violate MAX_SUBCAMPAIGNS_LEVEL.
|
||||||
function getProjectLevel(PledgeAdmin m) internal returns(uint) {
|
function getProjectLevel(PledgeAdmin m) internal returns(uint) {
|
||||||
assert(m.adminType == PledgeAdminType.Project);
|
assert(m.adminType == PledgeAdminType.Project);
|
||||||
if (m.parentProject == 0) return(1);
|
if (m.parentProject == 0) return(1);
|
||||||
@ -434,6 +465,9 @@ contract LiquidPledgingBase {
|
|||||||
return getProjectLevel(parentNM);
|
return getProjectLevel(parentNM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice `isProjectCanceled` is a basic helper function to check if
|
||||||
|
/// a project has been cancelled.
|
||||||
|
/// @param projectId The internal id of the project to lookup.
|
||||||
function isProjectCanceled(uint64 projectId) constant returns (bool) {
|
function isProjectCanceled(uint64 projectId) constant returns (bool) {
|
||||||
PledgeAdmin storage m = findAdmin(projectId);
|
PledgeAdmin storage m = findAdmin(projectId);
|
||||||
if (m.adminType == PledgeAdminType.Giver) return false;
|
if (m.adminType == PledgeAdminType.Giver) return false;
|
||||||
@ -443,8 +477,9 @@ contract LiquidPledgingBase {
|
|||||||
return isProjectCanceled(m.parentProject);
|
return isProjectCanceled(m.parentProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @notice A helper function for canceling projects
|
/// @notice `getOldestPledgeNotCanceled` is a helper function to get the oldest pledge
|
||||||
// @param idPledge the pledge that may or may not be canceled
|
/// that hasn't been cancelled recursively.
|
||||||
|
/// @param idPledge The starting place to lookup the pledges from
|
||||||
function getOldestPledgeNotCanceled(uint64 idPledge) internal constant returns(uint64) { //todo rename
|
function getOldestPledgeNotCanceled(uint64 idPledge) internal constant returns(uint64) { //todo rename
|
||||||
if (idPledge == 0) return 0;
|
if (idPledge == 0) return 0;
|
||||||
Pledge storage n = findPledge(idPledge);
|
Pledge storage n = findPledge(idPledge);
|
||||||
@ -458,6 +493,12 @@ contract LiquidPledgingBase {
|
|||||||
return getOldestPledgeNotCanceled(n.oldPledge);
|
return getOldestPledgeNotCanceled(n.oldPledge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @notice `checkAdminOwner` is a helper function designed to throw
|
||||||
|
/// an error code if the user is not an admin. As PledgeAdmin is an
|
||||||
|
/// an internal structure this basically works like a modifier check
|
||||||
|
/// would however using internal data.
|
||||||
|
/// @dev Looking into whether this can be done with a modifier would be good
|
||||||
|
/// @param m A PledgeAdmin structure object.
|
||||||
function checkAdminOwner(PledgeAdmin m) internal constant {
|
function checkAdminOwner(PledgeAdmin m) internal constant {
|
||||||
require((msg.sender == m.addr) || (msg.sender == address(m.plugin)));
|
require((msg.sender == m.addr) || (msg.sender == address(m.plugin)));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user