State to Status refactor
This commit is contained in:
parent
2af64a9e60
commit
bd5c29cf2f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -195,10 +195,10 @@ contract LiquidPledgingBase {
|
||||||
/// @notice Creates a new Campaign
|
/// @notice Creates a new Campaign
|
||||||
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
||||||
if (parentCampaign != 0) {
|
if (parentCampaign != 0) {
|
||||||
PledgeAdmin storage pm = findAdmin(parentCampaign);
|
PledgeAdmin storage pa = findAdmin(parentCampaign);
|
||||||
require(pm.adminType == PledgeAdminType.Campaign);
|
require(pa.adminType == PledgeAdminType.Campaign);
|
||||||
require(pm.addr == msg.sender);
|
require(pa.addr == msg.sender);
|
||||||
require(getCampaignLevel(pm) < MAX_SUBCAMPAIGN_LEVEL);
|
require(getCampaignLevel(pa) < MAX_SUBCAMPAIGN_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
idCampaign = uint64(admins.length);
|
idCampaign = uint64(admins.length);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -195,10 +195,10 @@ contract LiquidPledgingBase {
|
||||||
/// @notice Creates a new Campaign
|
/// @notice Creates a new Campaign
|
||||||
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
||||||
if (parentCampaign != 0) {
|
if (parentCampaign != 0) {
|
||||||
PledgeAdmin storage pm = findAdmin(parentCampaign);
|
PledgeAdmin storage pa = findAdmin(parentCampaign);
|
||||||
require(pm.adminType == PledgeAdminType.Campaign);
|
require(pa.adminType == PledgeAdminType.Campaign);
|
||||||
require(pm.addr == msg.sender);
|
require(pa.addr == msg.sender);
|
||||||
require(getCampaignLevel(pm) < MAX_SUBCAMPAIGN_LEVEL);
|
require(getCampaignLevel(pa) < MAX_SUBCAMPAIGN_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
idCampaign = uint64(admins.length);
|
idCampaign = uint64(admins.length);
|
||||||
|
|
|
@ -195,10 +195,10 @@ contract LiquidPledgingBase {
|
||||||
/// @notice Creates a new Campaign
|
/// @notice Creates a new Campaign
|
||||||
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
||||||
if (parentCampaign != 0) {
|
if (parentCampaign != 0) {
|
||||||
PledgeAdmin storage pm = findAdmin(parentCampaign);
|
PledgeAdmin storage pa = findAdmin(parentCampaign);
|
||||||
require(pm.adminType == PledgeAdminType.Campaign);
|
require(pa.adminType == PledgeAdminType.Campaign);
|
||||||
require(pm.addr == msg.sender);
|
require(pa.addr == msg.sender);
|
||||||
require(getCampaignLevel(pm) < MAX_SUBCAMPAIGN_LEVEL);
|
require(getCampaignLevel(pa) < MAX_SUBCAMPAIGN_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
idCampaign = uint64(admins.length);
|
idCampaign = uint64(admins.length);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -68,7 +68,7 @@ contract Vault is Owned {
|
||||||
LiquidPledging public liquidPledging; // liquidPledging contract's address
|
LiquidPledging public liquidPledging; // liquidPledging contract's address
|
||||||
bool public autoPay; // if false, payments will take 2 txs to be completed
|
bool public autoPay; // if false, payments will take 2 txs to be completed
|
||||||
|
|
||||||
enum PaymentState {
|
enum PaymentStatus {
|
||||||
Pending, // means the payment is awaiting confirmation
|
Pending, // means the payment is awaiting confirmation
|
||||||
Paid, // means the payment has been sent
|
Paid, // means the payment has been sent
|
||||||
Canceled // means the payment will never be sent
|
Canceled // means the payment will never be sent
|
||||||
|
@ -77,7 +77,7 @@ contract Vault is Owned {
|
||||||
/// each payment the `ref` param makes it easy to track the movements of
|
/// each payment the `ref` param makes it easy to track the movements of
|
||||||
/// funds transparently by its connection to other `Payment` structs
|
/// funds transparently by its connection to other `Payment` structs
|
||||||
struct Payment {
|
struct Payment {
|
||||||
PaymentState state; //
|
PaymentStatus state; //
|
||||||
bytes32 ref; // an input that references details from other contracts
|
bytes32 ref; // an input that references details from other contracts
|
||||||
address dest; // recipient of the ETH
|
address dest; // recipient of the ETH
|
||||||
uint amount; // amount of ETH (in wei) to be sent
|
uint amount; // amount of ETH (in wei) to be sent
|
||||||
|
@ -114,7 +114,7 @@ contract Vault is Owned {
|
||||||
function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) {
|
function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) {
|
||||||
uint idPayment = payments.length;
|
uint idPayment = payments.length;
|
||||||
payments.length ++;
|
payments.length ++;
|
||||||
payments[idPayment].state = PaymentState.Pending;
|
payments[idPayment].state = PaymentStatus.Pending;
|
||||||
payments[idPayment].ref = _ref;
|
payments[idPayment].ref = _ref;
|
||||||
payments[idPayment].dest = _dest;
|
payments[idPayment].dest = _dest;
|
||||||
payments[idPayment].amount = _amount;
|
payments[idPayment].amount = _amount;
|
||||||
|
@ -133,9 +133,9 @@ contract Vault is Owned {
|
||||||
function doConfirmPayment(uint _idPayment) internal {
|
function doConfirmPayment(uint _idPayment) internal {
|
||||||
require(_idPayment < payments.length);
|
require(_idPayment < payments.length);
|
||||||
Payment storage p = payments[_idPayment];
|
Payment storage p = payments[_idPayment];
|
||||||
require(p.state == PaymentState.Pending);
|
require(p.state == PaymentStatus.Pending);
|
||||||
|
|
||||||
p.state = PaymentState.Paid;
|
p.state = PaymentStatus.Paid;
|
||||||
p.dest.transfer(p.amount); // only ETH denominated in wei
|
p.dest.transfer(p.amount); // only ETH denominated in wei
|
||||||
|
|
||||||
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
||||||
|
@ -150,9 +150,9 @@ contract Vault is Owned {
|
||||||
function doCancelPayment(uint _idPayment) internal {
|
function doCancelPayment(uint _idPayment) internal {
|
||||||
require(_idPayment < payments.length);
|
require(_idPayment < payments.length);
|
||||||
Payment storage p = payments[_idPayment];
|
Payment storage p = payments[_idPayment];
|
||||||
require(p.state == PaymentState.Pending);
|
require(p.state == PaymentStatus.Pending);
|
||||||
|
|
||||||
p.state = PaymentState.Canceled;
|
p.state = PaymentStatus.Canceled;
|
||||||
|
|
||||||
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
||||||
|
|
||||||
|
|
|
@ -159,10 +159,10 @@ contract LiquidPledgingBase {
|
||||||
/// @notice Creates a new Campaign
|
/// @notice Creates a new Campaign
|
||||||
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
function addCampaign(string name, string url, address campaignAdmin, uint64 parentCampaign, uint64 commitTime, ILiquidPledgingPlugin plugin) returns (uint64 idCampaign) {
|
||||||
if (parentCampaign != 0) {
|
if (parentCampaign != 0) {
|
||||||
PledgeAdmin storage pm = findAdmin(parentCampaign);
|
PledgeAdmin storage pa = findAdmin(parentCampaign);
|
||||||
require(pm.adminType == PledgeAdminType.Campaign);
|
require(pa.adminType == PledgeAdminType.Campaign);
|
||||||
require(pm.addr == msg.sender);
|
require(pa.addr == msg.sender);
|
||||||
require(getCampaignLevel(pm) < MAX_SUBCAMPAIGN_LEVEL);
|
require(getCampaignLevel(pa) < MAX_SUBCAMPAIGN_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
idCampaign = uint64(admins.length);
|
idCampaign = uint64(admins.length);
|
||||||
|
|
|
@ -24,7 +24,7 @@ contract Vault is Owned {
|
||||||
LiquidPledging public liquidPledging; // liquidPledging contract's address
|
LiquidPledging public liquidPledging; // liquidPledging contract's address
|
||||||
bool public autoPay; // if false, payments will take 2 txs to be completed
|
bool public autoPay; // if false, payments will take 2 txs to be completed
|
||||||
|
|
||||||
enum PaymentState {
|
enum PaymentStatus {
|
||||||
Pending, // means the payment is awaiting confirmation
|
Pending, // means the payment is awaiting confirmation
|
||||||
Paid, // means the payment has been sent
|
Paid, // means the payment has been sent
|
||||||
Canceled // means the payment will never be sent
|
Canceled // means the payment will never be sent
|
||||||
|
@ -33,7 +33,7 @@ contract Vault is Owned {
|
||||||
/// each payment the `ref` param makes it easy to track the movements of
|
/// each payment the `ref` param makes it easy to track the movements of
|
||||||
/// funds transparently by its connection to other `Payment` structs
|
/// funds transparently by its connection to other `Payment` structs
|
||||||
struct Payment {
|
struct Payment {
|
||||||
PaymentState state; //
|
PaymentStatus state; //
|
||||||
bytes32 ref; // an input that references details from other contracts
|
bytes32 ref; // an input that references details from other contracts
|
||||||
address dest; // recipient of the ETH
|
address dest; // recipient of the ETH
|
||||||
uint amount; // amount of ETH (in wei) to be sent
|
uint amount; // amount of ETH (in wei) to be sent
|
||||||
|
@ -70,7 +70,7 @@ contract Vault is Owned {
|
||||||
function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) {
|
function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) {
|
||||||
uint idPayment = payments.length;
|
uint idPayment = payments.length;
|
||||||
payments.length ++;
|
payments.length ++;
|
||||||
payments[idPayment].state = PaymentState.Pending;
|
payments[idPayment].state = PaymentStatus.Pending;
|
||||||
payments[idPayment].ref = _ref;
|
payments[idPayment].ref = _ref;
|
||||||
payments[idPayment].dest = _dest;
|
payments[idPayment].dest = _dest;
|
||||||
payments[idPayment].amount = _amount;
|
payments[idPayment].amount = _amount;
|
||||||
|
@ -89,9 +89,9 @@ contract Vault is Owned {
|
||||||
function doConfirmPayment(uint _idPayment) internal {
|
function doConfirmPayment(uint _idPayment) internal {
|
||||||
require(_idPayment < payments.length);
|
require(_idPayment < payments.length);
|
||||||
Payment storage p = payments[_idPayment];
|
Payment storage p = payments[_idPayment];
|
||||||
require(p.state == PaymentState.Pending);
|
require(p.state == PaymentStatus.Pending);
|
||||||
|
|
||||||
p.state = PaymentState.Paid;
|
p.state = PaymentStatus.Paid;
|
||||||
p.dest.transfer(p.amount); // only ETH denominated in wei
|
p.dest.transfer(p.amount); // only ETH denominated in wei
|
||||||
|
|
||||||
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
||||||
|
@ -106,9 +106,9 @@ contract Vault is Owned {
|
||||||
function doCancelPayment(uint _idPayment) internal {
|
function doCancelPayment(uint _idPayment) internal {
|
||||||
require(_idPayment < payments.length);
|
require(_idPayment < payments.length);
|
||||||
Payment storage p = payments[_idPayment];
|
Payment storage p = payments[_idPayment];
|
||||||
require(p.state == PaymentState.Pending);
|
require(p.state == PaymentStatus.Pending);
|
||||||
|
|
||||||
p.state = PaymentState.Canceled;
|
p.state = PaymentStatus.Canceled;
|
||||||
|
|
||||||
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
liquidPledging.cancelPayment(uint64(p.ref), p.amount);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue