diff --git a/contracts/Vault.sol b/contracts/LPVault.sol similarity index 61% rename from contracts/Vault.sol rename to contracts/LPVault.sol index 1f1fe88..7df9a4d 100644 --- a/contracts/Vault.sol +++ b/contracts/LPVault.sol @@ -9,8 +9,8 @@ pragma solidity ^0.4.11; /// to allow for an optional escape hatch to be implemented import "./Owned.sol"; -/// @dev This is declares a few functions from `LiquidPledging` so that the -/// `Vault` contract can interface with the `LiquidPledging` contract +/// @dev `LiquidPledging` is a basic interface to allow the `Vault` contract +/// to confirm and cancel payments in the `LiquidPledging` contract. contract LiquidPledging { function confirmPayment(uint64 idNote, uint amount); function cancelPayment(uint64 idNote, uint amount); @@ -19,7 +19,7 @@ contract LiquidPledging { /// @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 LPVault is Owned { LiquidPledging public liquidPledging; // liquidPledging contract's address bool public autoPay; // if false, payments will take 2 txs to be completed @@ -57,16 +57,30 @@ contract Vault is Owned { } + /// @notice `setLiquidPledging` is used to attach a specific liquid pledging + /// instance to this vault. Keep in mind this isn't a single pledge but + /// instead an entire liquid pledging contract. + /// @param _newLiquidPledging A full liquid pledging contract function setLiquidPledging(address _newLiquidPledging) onlyOwner { require(address(liquidPledging) == 0x0); liquidPledging = LiquidPledging(_newLiquidPledging); } + /// @notice `setAutopay` is used to toggle whether the vault will + /// automatically confirm a payment after the payment has been authorized. + /// @param _automatic If true payments will confirm automatically function setAutopay(bool _automatic) onlyOwner { autoPay = _automatic; } - + /// @notice `authorizePayment` is used in order to approve a payment + /// from the liquid pledging contract. Whenever a project or other address + /// needs to receve a payment it needs to be authorized with this contract. + /// @param _ref This parameter is used to reference details about the + /// payment from another conttract. + /// @param _dest This is the address that payments will end up being sent to + /// @param _amount This is the amount that the payment is being authorized + /// for. function authorizePayment(bytes32 _ref, address _dest, uint _amount) onlyLiquidPledging returns (uint) { uint idPayment = payments.length; payments.length ++; @@ -82,10 +96,20 @@ contract Vault is Owned { return idPayment; } + /// @notice `confirmPayment` is a basic function used to allow the + /// owner of the vault to initiate a payment confirmation. Since + /// `authorizePayment` is the only pay to populate the `payments` array + /// this is generally used when `autopay` is `false` after a payment has + /// has been authorized. + /// @param _idPayment Array lookup for the payment. function confirmPayment(uint _idPayment) onlyOwner { doConfirmPayment(_idPayment); } + /// @notice `doConfirmPayment` is used to actually initiate a payment + /// to the final destination. All of the payment information should be + /// set before calling this function. + /// @param _idPayment Array lookup for the payment. function doConfirmPayment(uint _idPayment) internal { require(_idPayment < payments.length); Payment storage p = payments[_idPayment]; @@ -99,10 +123,16 @@ contract Vault is Owned { ConfirmPayment(_idPayment); } + /// @notice `cancelPayment` is used when `autopay` is `false` in order + /// to allow the owner to cancel a payment instead of confirming it. + /// @param _idPayment Array lookup for the payment. function cancelPayment(uint _idPayment) onlyOwner { doCancelPayment(_idPayment); } + /// @notice `doCancelPayment` This carries out the task of actually + /// canceling a payment instead of confirming it. + /// @param _idPayment Array lookup for the payment. function doCancelPayment(uint _idPayment) internal { require(_idPayment < payments.length); Payment storage p = payments[_idPayment]; @@ -116,18 +146,27 @@ contract Vault is Owned { } + /// @notice `multiConfirm` allows for more efficient confirmation of + /// multiple payments. + /// @param _idPayments An array of multiple payment ids function multiConfirm(uint[] _idPayments) onlyOwner { for (uint i=0; i < _idPayments.length; i++) { doConfirmPayment(_idPayments[i]); } } + /// @notice `multiCancel` allows for more efficient cancellation of + /// multiple payments. + /// @param _idPayments An array of multiple payment ids function multiCancel(uint[] _idPayments) onlyOwner { for (uint i=0; i < _idPayments.length; i++) { doCancelPayment(_idPayments[i]); } } + /// @notice `nPayments` Basic getter to return the number of payments + /// currently held in the system. Since payments are not removed from + /// the array this represents all payments over all time. function nPayments() constant returns (uint) { return payments.length; } diff --git a/contracts/LiquidPledgingBase.sol b/contracts/LiquidPledgingBase.sol index 1dcdd66..e5d3660 100644 --- a/contracts/LiquidPledgingBase.sol +++ b/contracts/LiquidPledgingBase.sol @@ -21,7 +21,7 @@ import "./ILiquidPledgingPlugin.sol"; /// @dev `Vault` serves as an interface to allow the `LiquidPledgingBase` /// contract to interface with a `Vault` contract -contract Vault { +contract LPVault { function authorizePayment(bytes32 _ref, address _dest, uint _amount); function () payable; } diff --git a/js/vault.js b/js/vault.js index 79ca76f..b9fe764 100644 --- a/js/vault.js +++ b/js/vault.js @@ -1,5 +1,5 @@ -const VaultAbi = require('../build/Vault.sol').VaultAbi; -const VaultByteCode = require('../build/Vault.sol').VaultByteCode; +const VaultAbi = require('../build/LPVault.sol').VaultAbi; +const VaultByteCode = require('../build/LPVault.sol').VaultByteCode; const generateClass = require('eth-contract-class').default; module.exports = generateClass(VaultAbi, VaultByteCode);