-
Notifications
You must be signed in to change notification settings - Fork 10
/
Filter.sol
52 lines (44 loc) · 1.3 KB
/
Filter.sol
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
pragma solidity 0.4.15;
import "./Disbursement.sol";
contract Filter {
event SetupAllowance(address indexed beneficiary, uint amount);
Disbursement public disburser;
address public owner;
mapping(address => Beneficiary) public beneficiaries;
struct Beneficiary {
uint claimAmount;
bool claimed;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function Filter(
address[] _beneficiaries,
uint[] _beneficiaryTokens
) {
owner = msg.sender;
for(uint i = 0; i < _beneficiaries.length; i++) {
beneficiaries[_beneficiaries[i]] = Beneficiary({
claimAmount: _beneficiaryTokens[i],
claimed: false
});
SetupAllowance(_beneficiaries[i],
beneficiaries[_beneficiaries[i]].claimAmount);
}
}
function setup(Disbursement _disburser)
public
onlyOwner
{
require(address(disburser) == 0 && address(_disburser) != 0);
disburser = _disburser;
}
function claim()
public
{
require(beneficiaries[msg.sender].claimed == false);
beneficiaries[msg.sender].claimed = true;
disburser.withdraw(msg.sender, beneficiaries[msg.sender].claimAmount);
}
}