Skip to content

Commit

Permalink
prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Sep 19, 2022
1 parent ff077b3 commit 71c2018
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
15 changes: 8 additions & 7 deletions contracts/SoulName.sol
Expand Up @@ -71,10 +71,11 @@ contract SoulName is NFT, 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
function mint(
address to,
string memory name
) public override returns (uint256) {
function mint(address to, string memory name)
public
override
returns (uint256)
{
require(!nameExists(name), "NAME_ALREADY_EXISTS");
require(bytes(name).length > 0, "ZERO_LENGTH_NAME");
require(
Expand Down Expand Up @@ -149,9 +150,9 @@ contract SoulName is NFT, ISoulName {
address owner = ownerOf(soulNameData.tokenId);

if (soulboundIdentity.balanceOf(owner) > 0) {
identityId = soulboundIdentity.tokenOfOwner(owner);
identityId = soulboundIdentity.tokenOfOwner(owner);
} else {
revert("USER_MUST_HAVE_AN_IDENTITY");
revert("USER_MUST_HAVE_AN_IDENTITY");
}

return (_getName(soulNameData.name), identityId);
Expand Down Expand Up @@ -189,7 +190,7 @@ contract SoulName is NFT, ISoulName {
{
// return identity id if exists
address owner = soulboundIdentity.ownerOf(identityId);

return getIdentityNames(owner);
}

Expand Down
5 changes: 1 addition & 4 deletions contracts/interfaces/ISoulName.sol
Expand Up @@ -2,10 +2,7 @@
pragma solidity ^0.8.7;

interface ISoulName {
function mint(
address to,
string memory name
) external returns (uint256);
function mint(address to, string memory name) external returns (uint256);

function getExtension() external view returns (string memory);

Expand Down
34 changes: 14 additions & 20 deletions test/SoulName.test.ts
Expand Up @@ -123,30 +123,21 @@ describe("Soul Name", () => {
});

it("should success to mint a name twice to the same idenity", async () => {
await soulName
.connect(owner)
.mint(address1.address, SOUL_NAME1);
await soulName.connect(owner).mint(address1.address, SOUL_NAME1);

await soulName
.connect(owner)
.mint(address1.address, SOUL_NAME2);
await soulName.connect(owner).mint(address1.address, SOUL_NAME2);
});

it("should fail to mint duplicated name", async () => {
await soulName
.connect(owner)
.mint(address1.address, SOUL_NAME1);
await soulName.connect(owner).mint(address1.address, SOUL_NAME1);

await expect(
soulName.connect(owner).mint(address1.address, SOUL_NAME1)
).to.be.rejected;
await expect(soulName.connect(owner).mint(address1.address, SOUL_NAME1))
.to.be.rejected;
});

it("should fail to mint from non-owner address", async () => {
await expect(
soulName
.connect(address1)
.mint(address1.address, SOUL_NAME1)
soulName.connect(address1).mint(address1.address, SOUL_NAME1)
).to.be.rejected;
});
});
Expand Down Expand Up @@ -212,9 +203,9 @@ describe("Soul Name", () => {
});

it("getIdentityNames returns array of SBT names in lower case", async () => {
expect(await soulName["getIdentityNames(uint256)"](identityId1)).to.deep.equal([
SOUL_NAME1.toLowerCase()
]);
expect(
await soulName["getIdentityNames(uint256)"](identityId1)
).to.deep.equal([SOUL_NAME1.toLowerCase()]);
});

it("should get a valid token URI", async () => {
Expand Down Expand Up @@ -256,7 +247,9 @@ describe("Soul Name", () => {

const [, identityId] = await soulName.getIdentityData(SOUL_NAME1);

const identityAddress2 = await soulboundIdentity.tokenOfOwner(address2.address);
const identityAddress2 = await soulboundIdentity.tokenOfOwner(
address2.address
);

await expect(identityId).to.be.equals(identityAddress2);
});
Expand Down Expand Up @@ -300,7 +293,8 @@ describe("Soul Name", () => {
await expect(
soulName.getIdentityData("soulNameTest1")
).to.be.rejectedWith("NAME_NOT_FOUND");
await expect(await soulName["getIdentityNames(uint256)"](identityId1)).to.be.empty;
await expect(await soulName["getIdentityNames(uint256)"](identityId1)).to
.be.empty;
});
});
});

0 comments on commit 71c2018

Please sign in to comment.