Skip to content

Commit

Permalink
update SoulName.mint() function
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Nov 14, 2022
1 parent 1809e7e commit 960e9c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
9 changes: 2 additions & 7 deletions contracts/SoulName.sol
Expand Up @@ -108,22 +108,20 @@ contract SoulName is MasaNFT, ISoulName {
/// @dev The caller can mint more than one name. The soul name must be unique.
/// @param to Address of the owner of the new soul name
/// @param name Name of the new soul name
/// @param identityId TokenId of the soulbound identity that will be pointed from this soul name
/// @param yearsPeriod Years of validity of the name
/// @param _tokenURI URI of the NFT
function mint(
address to,
string memory name,
uint256 identityId,
uint256 yearsPeriod,
string memory _tokenURI
) public override returns (uint256) {
require(isAvailable(name), "NAME_ALREADY_EXISTS");
require(bytes(name).length > 0, "ZERO_LENGTH_NAME");
require(yearsPeriod > 0, "ZERO_YEARS_PERIOD");
require(
soulboundIdentity.ownerOf(identityId) != address(0),
"IDENTITY_NOT_FOUND"
soulboundIdentity.balanceOf(to) > 0,
"ADDRESS_DOES_NOT_HAVE_IDENTITY"
);
require(
Utils.startsWith(_tokenURI, "ar://") ||
Expand All @@ -135,7 +133,6 @@ contract SoulName is MasaNFT, ISoulName {
_setTokenURI(tokenId, _tokenURI);

tokenData[tokenId].name = name;
tokenData[tokenId].identityId = identityId;
tokenData[tokenId].expirationDate = block.timestamp.add(
YEAR.mul(yearsPeriod)
);
Expand All @@ -144,8 +141,6 @@ contract SoulName is MasaNFT, ISoulName {
nameData[lowercaseName].tokenId = tokenId;
nameData[lowercaseName].exists = true;

identityNames[identityId].push(lowercaseName);

return tokenId;
}

Expand Down
9 changes: 1 addition & 8 deletions contracts/SoulStore.sol
Expand Up @@ -388,15 +388,8 @@ contract SoulStore is DexAMM, Ownable {
) internal returns (uint256) {
// mint Soul Name token
ISoulName soulName = soulboundIdentity.getSoulName();
uint256 identityId = soulboundIdentity.tokenOfOwner(to);

uint256 tokenId = soulName.mint(
to,
name,
identityId,
yearsPeriod,
_tokenURI
);
uint256 tokenId = soulName.mint(to, name, yearsPeriod, _tokenURI);

emit SoulNamePurchased(to, tokenId, name, yearsPeriod);

Expand Down

0 comments on commit 960e9c5

Please sign in to comment.