-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMemberlist.sol
42 lines (34 loc) · 1.2 KB
/
Memberlist.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
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.18;
import "./../util/Auth.sol";
interface MemberlistLike {
function updateMember(address user, uint256 validUntil) external;
function members(address user) external view returns (uint256);
}
contract Memberlist is Auth {
mapping(address => uint256) public members;
constructor() {
wards[msg.sender] = 1;
emit Rely(msg.sender);
}
// --- Checking members ---
function member(address user) public view {
require((members[user] >= block.timestamp), "Memberlist/not-allowed-to-hold-token");
}
function hasMember(address user) public view returns (bool) {
if (members[user] >= block.timestamp) {
return true;
}
return false;
}
// --- Updating members ---
function updateMember(address user, uint256 validUntil) public auth {
require(block.timestamp <= validUntil, "Memberlist/invalid-valid-until");
members[user] = validUntil;
}
function updateMembers(address[] memory users, uint256 validUntil) public auth {
for (uint256 i = 0; i < users.length; i++) {
updateMember(users[i], validUntil);
}
}
}