-
Notifications
You must be signed in to change notification settings - Fork 3
/
NationCred.sol
50 lines (43 loc) · 1.45 KB
/
NationCred.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
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.25;
import "./INationCred.sol";
import "@openzeppelin/contracts/interfaces/IERC721.sol";
/**
* @notice Stores the passport IDs of active Nation3 citizens.
*/
contract NationCred is INationCred {
string public constant VERSION = "0.7.0";
address public owner;
IERC721 public passport;
uint16[] private passportIDs;
constructor(address passportAddress) {
owner = address(msg.sender);
passport = IERC721(passportAddress);
}
function setOwner(address owner_) public {
require(msg.sender == owner, "You are not the owner");
owner = owner_;
}
function setActiveCitizens(uint16[] calldata passportIDs_) public {
require(msg.sender == owner, "You are not the owner");
passportIDs = passportIDs_;
}
function isActiveID(uint16 passportID) public view returns (bool) {
for (uint16 i = 0; i < passportIDs.length; i++) {
if (passportIDs[i] == passportID) {
return true;
}
}
return false;
}
function isActiveAddress(address citizen) public view returns (bool) {
for (uint16 i = 0; i < passportIDs.length; i++) {
uint256 passportID = passportIDs[i];
address passportOwner = passport.ownerOf(passportID);
if (passportOwner == citizen) {
return true;
}
}
return false;
}
}