Skip to content

Commit

Permalink
feat: lookup nft ownership (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
aahna-ashina committed Oct 3, 2023
1 parent fd7d52b commit 90f931a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/INationCred.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ interface INationCred {
*
* @param citizen The address of an NFT passport's owner
*/
function isActive(address citizen) external view returns (bool);
function isActiveByAddress(address citizen) external view returns (bool);
}
17 changes: 15 additions & 2 deletions contracts/NationCred.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;

import "./INationCred.sol";
import {INationCred} from "./INationCred.sol";
import {IERC721} from "@openzeppelin/contracts/interfaces/IERC721.sol";

/**
* @notice Stores the passport IDs of active Nation3 citizens.
*/
contract NationCred is INationCred {
address public owner;

IERC721 public passport;
uint16[] private passportIDs;

constructor() {
owner = address(msg.sender);
passport = IERC721(0x3337dac9F251d4E403D6030E18e3cfB6a2cb1333);
}

function setOwner(address owner_) public {
Expand All @@ -33,4 +35,15 @@ contract NationCred is INationCred {
}
return false;
}

function isActiveByAddress(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;
}
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"typescript": "^5.0.3"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.0"
"@openzeppelin/contracts": "^4.9.3"
}
}

0 comments on commit 90f931a

Please sign in to comment.