forked from status-im/status-network-token
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContributionWallet.sol
More file actions
64 lines (51 loc) · 2.47 KB
/
ContributionWallet.sol
File metadata and controls
64 lines (51 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
pragma solidity ^0.4.11;
/*
Copyright 2017, Jordi Baylina
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// @title ContributionWallet Contract
/// @author Jordi Baylina
/// @dev This contract will be hold the Ether during the contribution period.
/// The idea of this contract is to avoid recycling Ether during the contribution
/// period. So all the ETH collected will be locked here until the contribution
/// period ends
import "./StatusContribution.sol";
// @dev Contract to hold sale raised funds during the sale period.
// Prevents attack in which the Aragon Multisig sends raised ether
// to the sale contract to mint tokens to itself, and getting the
// funds back immediately.
contract ContributionWallet {
// Public variables
address public multisig;
uint public finalBlock;
StatusContribution public contribution;
// @dev Constructor initializes public variables
// @param _multisig The address of the multisig that will receive the funds
// @param _finalBlock Block after which the multisig can request the funds
// @param _contribution Address of the StatusContribution contract
function ContributionWallet(address _multisig, uint _finalBlock, address _contribution) {
multisig = _multisig;
finalBlock = _finalBlock;
contribution = StatusContribution(_contribution);
}
// @dev Receive all sent funds without any further logic
function () public payable {}
// @dev Withdraw function sends all the funds to the wallet if conditions are correct
function withdraw() public {
if (msg.sender != multisig) throw; // Only the multisig can request it
if (block.number > finalBlock) return doWithdraw(); // Allow after the final block
if (contribution.finalized() != 0) return doWithdraw(); // Allow when sale is finalized
}
function doWithdraw() internal {
if (!multisig.send(this.balance)) throw;
}
}