Skip to content

Commit

Permalink
rename SoulBoundName to SoulName
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Aug 23, 2022
1 parent 9e54549 commit 4d704be
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 161 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -6,15 +6,15 @@

- `SoulBoundCreditReport`: [`0x16C2f2c5F3aea4b70595Ea45693784247f951aD1`](https://alfajores-blockscout.celo-testnet.org/address/0x16C2f2c5F3aea4b70595Ea45693784247f951aD1/transactions)
- `SoulBoundIdentity`: [`0xD0f3C1361d8Fba40CbC85cC546c38511b510dedd`](https://alfajores-blockscout.celo-testnet.org/address/0xD0f3C1361d8Fba40CbC85cC546c38511b510dedd/transactions)
- `SoulBoundName`: [`0x47fF7Cab4AF63ac2C0c62122866c979c40217Ffe`](https://alfajores-blockscout.celo-testnet.org/address/0x47fF7Cab4AF63ac2C0c62122866c979c40217Ffe/transactions)
- `SoulName`: [`0x47fF7Cab4AF63ac2C0c62122866c979c40217Ffe`](https://alfajores-blockscout.celo-testnet.org/address/0x47fF7Cab4AF63ac2C0c62122866c979c40217Ffe/transactions)
- `SoulLinker`: [`0x5D3e2fd5eB8685f964d0fAb2B0F34436bFcB3A42`](https://alfajores-blockscout.celo-testnet.org/address/0x5D3e2fd5eB8685f964d0fAb2B0F34436bFcB3A42/transactions)
- `SoulBoundIdentityRouter`: [`0x7241c6F15aE018f4a5C05242d7cC00519FCF03f1`](https://alfajores-blockscout.celo-testnet.org/address/0x7241c6F15aE018f4a5C05242d7cC00519FCF03f1/transactions)

### Rinkeby test network

- `SoulBoundCreditReport`: [`0x1471A7d3914a38e7488111001e50eCc29D627166`](https://rinkeby.etherscan.io/address/0x1471A7d3914a38e7488111001e50eCc29D627166)
- `SoulBoundIdentity`: [`0xd9B0185D3865727fEaB5760bF13dde39b00263e5`](https://rinkeby.etherscan.io/address/0xd9B0185D3865727fEaB5760bF13dde39b00263e5)
- `SoulBoundName`: [`0x736bda94F926E23a2318d7eb09dF36A09D9a59fA`](https://rinkeby.etherscan.io/address/0x736bda94F926E23a2318d7eb09dF36A09D9a59fA)
- `SoulName`: [`0x736bda94F926E23a2318d7eb09dF36A09D9a59fA`](https://rinkeby.etherscan.io/address/0x736bda94F926E23a2318d7eb09dF36A09D9a59fA)
- `SoulLinker`: [`0x0ffF769274a4fDa68Bf6E99FE0982c4c26B1A4A0`](https://rinkeby.etherscan.io/address/0x0ffF769274a4fDa68Bf6E99FE0982c4c26B1A4A0)
- `SoulBoundIdentityRouter`: [`0xfFbDb1C2e8AA500D9Eb5ACA9f044B1C6B22865Db`](https://rinkeby.etherscan.io/address/0xfFbDb1C2e8AA500D9Eb5ACA9f044B1C6B22865Db)

Expand Down
32 changes: 16 additions & 16 deletions contracts/SoulBoundIdentityRouter.sol
Expand Up @@ -3,28 +3,28 @@ pragma solidity ^0.8.7;

import "@openzeppelin/contracts/access/Ownable.sol";
import "./SoulBoundIdentity.sol";
import "./SoulBoundName.sol";
import "./SoulName.sol";

contract SoulBoundIdentityRouter is Ownable {
/* ========== STATE VARIABLES ========== */

SoulBoundIdentity public soulBoundIdentity;
SoulBoundName public soulBoundName;
SoulName public soulName;

/* ========== INITIALIZE ========== */

constructor(
address owner,
SoulBoundIdentity _soulBoundIdentity,
SoulBoundName _soulBoundName
SoulName _soulName
) Ownable() {
require(address(_soulBoundIdentity) != address(0), "ZERO_ADDRESS");
require(address(_soulBoundName) != address(0), "ZERO_ADDRESS");
require(address(_soulName) != address(0), "ZERO_ADDRESS");

Ownable.transferOwnership(owner);

soulBoundIdentity = _soulBoundIdentity;
soulBoundName = _soulBoundName;
soulName = _soulName;
}

/* ========== RESTRICTED FUNCTIONS ========== */
Expand All @@ -38,10 +38,10 @@ contract SoulBoundIdentityRouter is Ownable {
soulBoundIdentity = _soulBoundIdentity;
}

function setSoulBoundName(SoulBoundName _soulBoundName) external onlyOwner {
require(address(_soulBoundName) != address(0), "ZERO_ADDRESS");
require(soulBoundName != _soulBoundName, "SAME_VALUE");
soulBoundName = _soulBoundName;
function setSoulName(SoulName _soulName) external onlyOwner {
require(address(_soulName) != address(0), "ZERO_ADDRESS");
require(soulName != _soulName, "SAME_VALUE");
soulName = _soulName;
}

/* ========== MUTATIVE FUNCTIONS ========== */
Expand All @@ -52,7 +52,7 @@ contract SoulBoundIdentityRouter is Ownable {
returns (uint256)
{
uint256 identityId = soulBoundIdentity.mint(to);
uint256 nameId = soulBoundName.mint(to, name, identityId);
uint256 nameId = soulName.mint(to, name, identityId);

return identityId;
}
Expand All @@ -68,7 +68,7 @@ contract SoulBoundIdentityRouter is Ownable {
}

function ownerOf(string memory name) public view returns (address) {
(, uint256 tokenId) = soulBoundName.getIdentityData(name);
(, uint256 tokenId) = soulName.getIdentityData(name);
return soulBoundIdentity.ownerOf(tokenId);
}

Expand All @@ -77,7 +77,7 @@ contract SoulBoundIdentityRouter is Ownable {
}

function tokenURI(string memory name) public view returns (string memory) {
(, uint256 tokenId) = soulBoundName.getIdentityData(name);
(, uint256 tokenId) = soulName.getIdentityData(name);
return soulBoundIdentity.tokenURI(tokenId);
}

Expand All @@ -95,15 +95,15 @@ contract SoulBoundIdentityRouter is Ownable {
}

function nameExists(string memory name) public view returns (bool exists) {
return soulBoundName.nameExists(name);
return soulName.nameExists(name);
}

function getIdentityData(string memory name)
external
view
returns (string memory sbtName, uint256 identityId)
{
return soulBoundName.getIdentityData(name);
return soulName.getIdentityData(name);
}

function getIdentityNames(address owner)
Expand All @@ -112,15 +112,15 @@ contract SoulBoundIdentityRouter is Ownable {
returns (string[] memory sbtNames)
{
uint256 tokenId = tokenOfOwner(owner);
return soulBoundName.getIdentityNames(tokenId);
return soulName.getIdentityNames(tokenId);
}

function getIdentityNames(uint256 tokenId)
external
view
returns (string[] memory sbtNames)
{
return soulBoundName.getIdentityNames(tokenId);
return soulName.getIdentityNames(tokenId);
}

/* ========== PRIVATE FUNCTIONS ========== */
Expand Down
52 changes: 22 additions & 30 deletions contracts/SoulBoundName.sol → contracts/SoulName.sol
Expand Up @@ -4,10 +4,10 @@ pragma solidity ^0.8.7;
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./tokens/NFT.sol";
import "./interfaces/ISoulBoundNameResolver.sol";
import "./interfaces/ISoulNameResolver.sol";
import "./SoulBoundIdentity.sol";

contract SoulBoundName is NFT, ISoulBoundNameResolver {
contract SoulName is NFT, ISoulNameResolver {
using Strings for uint256;

/* ========== STATE VARIABLES ========== */
Expand All @@ -16,10 +16,10 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
string public extension; // suffix of the names (.sol?)

mapping(uint256 => string) tokenIdToName; // used to sort through all names (name in lowercase)
mapping(string => SoulBoundNameData) soulBoundNames; // register of all soulbound names (name in lowercase)
mapping(string => SoulNameData) soulNames; // register of all soulbound names (name in lowercase)
mapping(uint256 => string[]) identityIdToNames; // register of all names associated to an identityId

struct SoulBoundNameData {
struct SoulNameData {
string name; // Name with lowercase and uppercase
uint256 identityId;
}
Expand Down Expand Up @@ -71,8 +71,8 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
string memory lowercaseName = _toLowerCase(name);
tokenIdToName[tokenId] = lowercaseName;

soulBoundNames[lowercaseName].name = name;
soulBoundNames[lowercaseName].identityId = identityId;
soulNames[lowercaseName].name = name;
soulNames[lowercaseName].identityId = identityId;

identityIdToNames[identityId].push(lowercaseName);

Expand All @@ -90,10 +90,10 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
);

string memory name = tokenIdToName[tokenId];
uint256 oldIdentityId = soulBoundNames[name].identityId;
uint256 oldIdentityId = soulNames[name].identityId;

// change value from soulBoundNames
soulBoundNames[name].identityId = identityId;
// change value from soulNames
soulNames[name].identityId = identityId;

// remove name from identityIdToNames[oldIdentityId]
_removeFromIdentityIdToNames(oldIdentityId, name);
Expand All @@ -106,11 +106,11 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
require(_exists(tokenId), "TOKEN_NOT_FOUND");

string memory name = tokenIdToName[tokenId];
uint256 identityId = soulBoundNames[name].identityId;
uint256 identityId = soulNames[name].identityId;

// remove info from tokenIdToName, soulboundnames and identityIdToNames
// remove info from tokenIdToName, soulnames and identityIdToNames
delete tokenIdToName[tokenId];
delete soulBoundNames[name];
delete soulNames[name];
_removeFromIdentityIdToNames(identityId, name);

super.burn(tokenId);
Expand All @@ -125,7 +125,7 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
returns (bool exists)
{
string memory lowercaseName = _toLowerCase(name);
return (bytes(soulBoundNames[lowercaseName].name).length > 0);
return (bytes(soulNames[lowercaseName].name).length > 0);
}

function getIdentityData(string memory name)
Expand All @@ -135,16 +135,12 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
returns (string memory sbtName, uint256 identityId)
{
string memory lowercaseName = _toLowerCase(name);
SoulBoundNameData memory soulBoundNameData = soulBoundNames[
lowercaseName
];
require(bytes(soulBoundNameData.name).length > 0, "NAME_NOT_FOUND");
SoulNameData memory soulNameData = soulNames[lowercaseName];
require(bytes(soulNameData.name).length > 0, "NAME_NOT_FOUND");

return (
string(
bytes.concat(bytes(soulBoundNameData.name), bytes(extension))
),
soulBoundNameData.identityId
string(bytes.concat(bytes(soulNameData.name), bytes(extension))),
soulNameData.identityId
);
}

Expand All @@ -168,21 +164,17 @@ contract SoulBoundName is NFT, ISoulBoundNameResolver {
require(bytes(name).length != 0, "TOKEN_NOT_FOUND");

string memory lowercaseName = _toLowerCase(name);
SoulBoundNameData memory soulBoundNameData = soulBoundNames[
lowercaseName
];
require(bytes(soulBoundNameData.name).length > 0, "NAME_NOT_FOUND");
SoulNameData memory soulNameData = soulNames[lowercaseName];
require(bytes(soulNameData.name).length > 0, "NAME_NOT_FOUND");

bytes memory dataURI = abi.encodePacked(
"{",
'"name": "',
string(
bytes.concat(bytes(soulBoundNameData.name), bytes(extension))
),
string(bytes.concat(bytes(soulNameData.name), bytes(extension))),
'", ',
'"description": "This is a SoulBoundName',
'"description": "This is a SoulName',
'", ',
'"external_url": "https://soulboundname.com/',
'"external_url": "https://soulname.com/',
tokenId.toString(),
'"',
"}"
Expand Down
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.7;

interface ISoulBoundNameResolver {
interface ISoulNameResolver {
function nameExists(string memory name) external returns (bool exists);

function getIdentityData(string memory name)
Expand Down
16 changes: 8 additions & 8 deletions deploy/SoulBoundIdentityRouter.ts
Expand Up @@ -17,16 +17,16 @@ const func: DeployFunction = async ({
const env = getEnvParams(network.name);

const soulBoundIdentity = await deployments.get("SoulBoundIdentity");
const soulBoundName = await deployments.get("SoulBoundName");
const soulName = await deployments.get("SoulName");

const soulBoundIdentityContract = await ethers.getContractAt(
"SoulBoundIdentity",
soulBoundIdentity.address,
owner
);
const soulBoundNameContract = await ethers.getContractAt(
"SoulBoundName",
soulBoundName.address,
const soulNameContract = await ethers.getContractAt(
"SoulName",
soulName.address,
owner
);

Expand All @@ -37,22 +37,22 @@ const func: DeployFunction = async ({
args: [
env.OWNER || owner.address,
soulBoundIdentity.address,
soulBoundName.address
soulName.address
],
log: true
}
);

// we grant the MINTER_ROLE to the SoulBoundIdentityRouter
const MINTER_ROLE_IDENTITY = await soulBoundIdentityContract.MINTER_ROLE();
const MINTER_ROLE_NAME = await soulBoundNameContract.MINTER_ROLE();
const MINTER_ROLE_NAME = await soulNameContract.MINTER_ROLE();
await soulBoundIdentityContract
.connect(owner)
.grantRole(
MINTER_ROLE_IDENTITY,
soulBoundIdentityRouterDeploymentResult.address
);
await soulBoundNameContract
await soulNameContract
.connect(owner)
.grantRole(
MINTER_ROLE_NAME,
Expand All @@ -66,5 +66,5 @@ const func: DeployFunction = async ({
};

func.tags = ["SoulBoundIdentityRouter"];
func.dependencies = ["SoulBoundIdentity", "SoulBoundName"];
func.dependencies = ["SoulBoundIdentity", "SoulName"];
export default func;
9 changes: 3 additions & 6 deletions deploy/SoulBoundName.ts
Expand Up @@ -18,18 +18,15 @@ const func: DeployFunction = async ({

const soulBoundIdentity = await deployments.get("SoulBoundIdentity");

const soulBoundNameDeploymentResult = await deploy("SoulBoundName", {
const soulNameDeploymentResult = await deploy("SoulName", {
from: deployer,
args: [env.OWNER || owner.address, soulBoundIdentity.address, ".sol", ""],
log: true
});

await ethers.getContractAt(
"SoulBoundName",
soulBoundNameDeploymentResult.address
);
await ethers.getContractAt("SoulName", soulNameDeploymentResult.address);
};

func.tags = ["SoulBoundName"];
func.tags = ["SoulName"];
func.dependencies = ["SoulBoundIdentity"];
export default func;
12 changes: 6 additions & 6 deletions docs/SoulBoundIdentityRouter.md
Expand Up @@ -232,10 +232,10 @@ function setSoulBoundIdentity(contract SoulBoundIdentity _soulBoundIdentity) ext
|---|---|---|
| _soulBoundIdentity | contract SoulBoundIdentity | undefined |

### setSoulBoundName
### setSoulName

```solidity
function setSoulBoundName(contract SoulBoundName _soulBoundName) external nonpayable
function setSoulName(contract SoulName _soulName) external nonpayable
```


Expand All @@ -246,7 +246,7 @@ function setSoulBoundName(contract SoulBoundName _soulBoundName) external nonpay

| Name | Type | Description |
|---|---|---|
| _soulBoundName | contract SoulBoundName | undefined |
| _soulName | contract SoulName | undefined |

### soulBoundIdentity

Expand All @@ -265,10 +265,10 @@ function soulBoundIdentity() external view returns (contract SoulBoundIdentity)
|---|---|---|
| _0 | contract SoulBoundIdentity | undefined |

### soulBoundName
### soulName

```solidity
function soulBoundName() external view returns (contract SoulBoundName)
function soulName() external view returns (contract SoulName)
```


Expand All @@ -280,7 +280,7 @@ function soulBoundName() external view returns (contract SoulBoundName)

| Name | Type | Description |
|---|---|---|
| _0 | contract SoulBoundName | undefined |
| _0 | contract SoulName | undefined |

### tokenOfOwner

Expand Down
2 changes: 1 addition & 1 deletion docs/SoulBoundName.md → docs/SoulName.md
@@ -1,4 +1,4 @@
# SoulBoundName
# SoulName



Expand Down
@@ -1,4 +1,4 @@
# ISoulBoundNameResolver
# ISoulNameResolver



Expand Down

0 comments on commit 4d704be

Please sign in to comment.