commit
e2f1b0fe21
|
@ -14,9 +14,10 @@ contract Owned {
|
||||||
|
|
||||||
address public owner;
|
address public owner;
|
||||||
|
|
||||||
|
|
||||||
/// @notice The Constructor assigns the account deploying the contract to be
|
/// @notice The Constructor assigns the account deploying the contract to be
|
||||||
/// the `owner`
|
/// the `owner`
|
||||||
function Owned() {
|
function Owned() public {
|
||||||
owner = msg.sender;
|
owner = msg.sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,12 +29,12 @@ contract Owned {
|
||||||
/// @param _newOwner The address of the new owner. A simple contract with
|
/// @param _newOwner The address of the new owner. A simple contract with
|
||||||
/// the ability to accept ownership but the inability to do anything else
|
/// the ability to accept ownership but the inability to do anything else
|
||||||
/// can be used to create an unowned contract to achieve decentralization
|
/// can be used to create an unowned contract to achieve decentralization
|
||||||
function changeOwner(address _newOwner) onlyOwner {
|
function changeOwner(address _newOwner) public onlyOwner {
|
||||||
newOwner = _newOwner;
|
newOwner = _newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice `newOwner` can accept ownership over this contract
|
/// @notice `newOwner` can accept ownership over this contract
|
||||||
function acceptOwnership() {
|
function acceptOwnership() public {
|
||||||
require(msg.sender == newOwner);
|
require(msg.sender == newOwner);
|
||||||
owner = newOwner;
|
owner = newOwner;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ pragma solidity ^0.4.11;
|
||||||
/// to allow for an optional escape hatch to be implemented
|
/// 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
|
/// @dev This declares a few functions from `LiquidPledging` so that the
|
||||||
/// `Vault` contract can interface with the `LiquidPledging` contract
|
/// `Vault` contract can interface with the `LiquidPledging` contract
|
||||||
contract LiquidPledging {
|
contract LiquidPledging {
|
||||||
function confirmPayment(uint64 idNote, uint amount);
|
function confirmPayment(uint64 idNote, uint amount) public;
|
||||||
function cancelPayment(uint64 idNote, uint amount);
|
function cancelPayment(uint64 idNote, uint amount) public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,35 +39,35 @@ contract Vault is Owned {
|
||||||
uint amount; // amount of ETH (in wei) to be sent
|
uint amount; // amount of ETH (in wei) to be sent
|
||||||
}
|
}
|
||||||
|
|
||||||
// @dev An array that contains all the payments for this Vault
|
/// @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
|
/// @dev `liquidPledging` is the only address that can call a function with
|
||||||
/// this modifier
|
/// this modifier
|
||||||
modifier onlyLiquidPledging() {
|
modifier onlyLiquidPledging() {
|
||||||
require(msg.sender == address(liquidPledging));
|
require(msg.sender == address(liquidPledging));
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
/// @dev USED FOR TESTING???
|
/// @dev USED FOR TESTING???
|
||||||
function VaultMock() {
|
function VaultMock() public pure {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function () payable {
|
function () public payable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLiquidPledging(address _newLiquidPledging) onlyOwner {
|
function setLiquidPledging(address _newLiquidPledging) public onlyOwner {
|
||||||
require(address(liquidPledging) == 0x0);
|
require(address(liquidPledging) == 0x0);
|
||||||
liquidPledging = LiquidPledging(_newLiquidPledging);
|
liquidPledging = LiquidPledging(_newLiquidPledging);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAutopay(bool _automatic) onlyOwner {
|
function setAutopay(bool _automatic) public onlyOwner {
|
||||||
autoPay = _automatic;
|
autoPay = _automatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) {
|
function authorizePayment(bytes32 _ref, address _dest, uint _amount) public onlyLiquidPledging returns (uint) {
|
||||||
uint idPayment = payments.length;
|
uint idPayment = payments.length;
|
||||||
payments.length ++;
|
payments.length ++;
|
||||||
payments[idPayment].state = PaymentStatus.Pending;
|
payments[idPayment].state = PaymentStatus.Pending;
|
||||||
|
@ -75,14 +75,20 @@ contract Vault is Owned {
|
||||||
payments[idPayment].dest = _dest;
|
payments[idPayment].dest = _dest;
|
||||||
payments[idPayment].amount = _amount;
|
payments[idPayment].amount = _amount;
|
||||||
|
|
||||||
AuthorizePayment(idPayment, _ref, _dest, _amount);
|
AuthorizePayment(
|
||||||
|
idPayment,
|
||||||
|
_ref,
|
||||||
|
_dest,
|
||||||
|
_amount
|
||||||
|
);
|
||||||
|
|
||||||
if (autoPay) doConfirmPayment(idPayment);
|
if (autoPay)
|
||||||
|
doConfirmPayment(idPayment);
|
||||||
|
|
||||||
return idPayment;
|
return idPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmPayment(uint _idPayment) onlyOwner {
|
function confirmPayment(uint _idPayment) public onlyOwner {
|
||||||
doConfirmPayment(_idPayment);
|
doConfirmPayment(_idPayment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +105,7 @@ contract Vault is Owned {
|
||||||
ConfirmPayment(_idPayment);
|
ConfirmPayment(_idPayment);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelPayment(uint _idPayment) onlyOwner {
|
function cancelPayment(uint _idPayment) public onlyOwner {
|
||||||
doCancelPayment(_idPayment);
|
doCancelPayment(_idPayment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,19 +122,21 @@ contract Vault is Owned {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function multiConfirm(uint[] _idPayments) onlyOwner {
|
function multiConfirm(uint[] _idPayments) public onlyOwner {
|
||||||
for (uint i=0; i < _idPayments.length; i++) {
|
for (uint i = 0; i < _idPayments.length; i++) {
|
||||||
doConfirmPayment(_idPayments[i]);
|
doConfirmPayment(_idPayments[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function multiCancel(uint[] _idPayments) onlyOwner {
|
|
||||||
for (uint i=0; i < _idPayments.length; i++) {
|
function multiCancel(uint[] _idPayments) public onlyOwner {
|
||||||
|
for (uint i = 0; i < _idPayments.length; i++) {
|
||||||
doCancelPayment(_idPayments[i]);
|
doCancelPayment(_idPayments[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nPayments() constant returns (uint) {
|
|
||||||
|
function nPayments() constant public returns (uint) {
|
||||||
return payments.length;
|
return payments.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue