Skip to content

Commit

Permalink
add default soul name the first in the return array of getSoulNames()
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed May 8, 2023
1 parent ac32793 commit 22ab4ae
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions contracts/SoulName.sol
Expand Up @@ -340,14 +340,29 @@ contract SoulName is MasaNFT, ISoulName, ReentrancyGuard {
string[] memory _sbtNames = new string[](results);
uint256 index = 0;

for (uint256 i = 0; i < balance; i++) {
uint256 tokenId = tokenOfOwnerByIndex(owner, i);
if (defaultSoulName[owner].exists) {
uint256 tokenId = defaultSoulName[owner].tokenId;
if (tokenData[tokenId].expirationDate >= block.timestamp) {
_sbtNames[index] = Utils.toLowerCase(tokenData[tokenId].name);
index = index.add(1);
}
}

for (uint256 i = 0; i < balance; i++) {
uint256 tokenId = tokenOfOwnerByIndex(owner, i);
if (
!defaultSoulName[owner].exists ||
tokenId != defaultSoulName[owner].tokenId
) {
if (tokenData[tokenId].expirationDate >= block.timestamp) {
_sbtNames[index] = Utils.toLowerCase(
tokenData[tokenId].name
);
index = index.add(1);
}
}
}

// return identity names if exists and are active
return _sbtNames;
}
Expand Down

0 comments on commit 22ab4ae

Please sign in to comment.