aboutsummaryrefslogtreecommitdiffstats
path: root/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
diff options
context:
space:
mode:
Diffstat (limited to 'test/compilationTests/zeppelin/crowdsale/RefundVault.sol')
-rw-r--r--test/compilationTests/zeppelin/crowdsale/RefundVault.sol56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
new file mode 100644
index 00000000..cc92ff9f
--- /dev/null
+++ b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
@@ -0,0 +1,56 @@
+pragma solidity ^0.4.11;
+
+import '../math/SafeMath.sol';
+import '../ownership/Ownable.sol';
+
+/**
+ * @title RefundVault
+ * @dev This contract is used for storing funds while a crowdsale
+ * is in progress. Supports refunding the money if crowdsale fails,
+ * and forwarding it if crowdsale is successful.
+ */
+contract RefundVault is Ownable {
+ using SafeMath for uint256;
+
+ enum State { Active, Refunding, Closed }
+
+ mapping (address => uint256) public deposited;
+ address public wallet;
+ State public state;
+
+ event Closed();
+ event RefundsEnabled();
+ event Refunded(address indexed beneficiary, uint256 weiAmount);
+
+ function RefundVault(address _wallet) {
+ require(_wallet != 0x0);
+ wallet = _wallet;
+ state = State.Active;
+ }
+
+ function deposit(address investor) onlyOwner payable {
+ require(state == State.Active);
+ deposited[investor] = deposited[investor].add(msg.value);
+ }
+
+ function close() onlyOwner {
+ require(state == State.Active);
+ state = State.Closed;
+ Closed();
+ wallet.transfer(this.balance);
+ }
+
+ function enableRefunds() onlyOwner {
+ require(state == State.Active);
+ state = State.Refunding;
+ RefundsEnabled();
+ }
+
+ function refund(address investor) {
+ require(state == State.Refunding);
+ uint256 depositedValue = deposited[investor];
+ deposited[investor] = 0;
+ investor.transfer(depositedValue);
+ Refunded(investor, depositedValue);
+ }
+}