Added comments and other small changes
This commit is contained in:
parent
5ccf92d502
commit
be4741aa38
|
@ -1,37 +1,54 @@
|
||||||
pragma solidity ^0.4.11;
|
pragma solidity ^0.4.11;
|
||||||
|
|
||||||
|
/// @title Vault
|
||||||
|
/// @author Jordi Baylina
|
||||||
|
/// @notice This contract holds ether securely for liquid pledging systems. For
|
||||||
|
/// this iteration the funds will come straight from the Giveth Multisig as a
|
||||||
|
/// safety precaution, but once fully tested and optimized this contract will
|
||||||
|
/// be a safe place to store funds equipped with optional variable time delays
|
||||||
|
/// to allow for an optional escape hatch to be implemented
|
||||||
import "./Owned.sol";
|
import "./Owned.sol";
|
||||||
|
|
||||||
|
/// @dev This is declares a few functions from `LiquidPledging` so that the
|
||||||
|
/// `Vault` contract can interface with the `LiquidPledging` contract
|
||||||
contract LiquidPledging {
|
contract LiquidPledging {
|
||||||
function confirmPayment(uint64 idNote, uint amount);
|
function confirmPayment(uint64 idNote, uint amount);
|
||||||
function cancelPayment(uint64 idNote, uint amount);
|
function cancelPayment(uint64 idNote, uint amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// @dev `Vault` is a higher level contract built off of the `Owned`
|
||||||
|
/// contract that holds funds for the liquid pledging system.
|
||||||
contract Vault is Owned {
|
contract Vault is Owned {
|
||||||
|
|
||||||
LiquidPledging public liquidPledging;
|
LiquidPledging public liquidPledging; // liquidPledging contract's address
|
||||||
bool public autoPay;
|
bool public autoPay; // if false, payments will take 2 txs to be completed
|
||||||
|
|
||||||
enum PaymentState {
|
enum PaymentState {
|
||||||
Pending,
|
Pending, // means the payment is awaiting confirmation
|
||||||
Paid,
|
Paid, // means the payment has been sent
|
||||||
Canceled
|
Canceled // means the payment will never be sent
|
||||||
}
|
}
|
||||||
|
/// @dev `Payment` is a public structure that describes the details of
|
||||||
|
/// each payment the `ref` param makes it easy to track the movements of
|
||||||
|
/// funds transparently by its connection to other `Payment` structs
|
||||||
struct Payment {
|
struct Payment {
|
||||||
PaymentState state;
|
PaymentState state; //
|
||||||
bytes32 ref;
|
bytes32 ref; // an input that references details from other contracts
|
||||||
address dest;
|
address dest; // recipient of the ETH
|
||||||
uint amount;
|
uint amount; // amount of ETH (in wei) to be sent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @dev An array that contains all the payments for this Vault
|
||||||
Payment[] public payments;
|
Payment[] public payments;
|
||||||
|
|
||||||
|
// @dev `liquidPledging` is the only address that can call a function with
|
||||||
|
/// this modifier
|
||||||
modifier onlyLiquidPledging() {
|
modifier onlyLiquidPledging() {
|
||||||
require(msg.sender == address(liquidPledging));
|
require(msg.sender == address(liquidPledging));
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
/// @dev USED FOR TESTING???
|
||||||
function VaultMock() {
|
function VaultMock() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,6 +58,7 @@ contract Vault is Owned {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLiquidPledging(address _newLiquidPledging) onlyOwner {
|
function setLiquidPledging(address _newLiquidPledging) onlyOwner {
|
||||||
|
require(address(liquidPledging) == 0x0);
|
||||||
liquidPledging = LiquidPledging(_newLiquidPledging);
|
liquidPledging = LiquidPledging(_newLiquidPledging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +92,7 @@ contract Vault is Owned {
|
||||||
require(p.state == PaymentState.Pending);
|
require(p.state == PaymentState.Pending);
|
||||||
|
|
||||||
p.state = PaymentState.Paid;
|
p.state = PaymentState.Paid;
|
||||||
p.dest.transfer(p.amount);
|
p.dest.transfer(p.amount); // only ETH denominated in wei
|
||||||
|
|
||||||
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
liquidPledging.confirmPayment(uint64(p.ref), p.amount);
|
||||||
|
|
||||||
|
@ -117,5 +135,4 @@ contract Vault is Owned {
|
||||||
event ConfirmPayment(uint indexed idPayment);
|
event ConfirmPayment(uint indexed idPayment);
|
||||||
event CancelPayment(uint indexed idPayment);
|
event CancelPayment(uint indexed idPayment);
|
||||||
event AuthorizePayment(uint indexed idPayment, bytes32 indexed ref, address indexed dest, uint amount);
|
event AuthorizePayment(uint indexed idPayment, bytes32 indexed ref, address indexed dest, uint amount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue