Skip to content

Commit

Permalink
Merge branch 'v2-partial-soulbound-token' into v2-audit
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Aug 31, 2023
2 parents 298029c + 517841d commit a2ff616
Show file tree
Hide file tree
Showing 30 changed files with 1,966 additions and 76 deletions.
54 changes: 27 additions & 27 deletions .storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
| _status | uint256 | 2 | 0 | 32 | src/auction/Auction.sol:Auction |
| _paused | bool | 3 | 0 | 1 | src/auction/Auction.sol:Auction |
| settings | struct AuctionTypesV1.Settings | 4 | 0 | 64 | src/auction/Auction.sol:Auction |
| token | contract Token | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| token | contract IBaseToken | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| auction | struct AuctionTypesV1.Auction | 7 | 0 | 96 | src/auction/Auction.sol:Auction |

=======================
Expand Down Expand Up @@ -67,29 +67,29 @@
➡ Token
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------|------------------------------------------------------------------------|------|--------|-------|---------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/token/Token.sol:Token |
| _initializing | bool | 0 | 1 | 1 | src/token/Token.sol:Token |
| _owner | address | 0 | 2 | 20 | src/token/Token.sol:Token |
| _pendingOwner | address | 1 | 0 | 20 | src/token/Token.sol:Token |
| _status | uint256 | 2 | 0 | 32 | src/token/Token.sol:Token |
| HASHED_NAME | bytes32 | 3 | 0 | 32 | src/token/Token.sol:Token |
| HASHED_VERSION | bytes32 | 4 | 0 | 32 | src/token/Token.sol:Token |
| INITIAL_DOMAIN_SEPARATOR | bytes32 | 5 | 0 | 32 | src/token/Token.sol:Token |
| INITIAL_CHAIN_ID | uint256 | 6 | 0 | 32 | src/token/Token.sol:Token |
| nonces | mapping(address => uint256) | 7 | 0 | 32 | src/token/Token.sol:Token |
| name | string | 8 | 0 | 32 | src/token/Token.sol:Token |
| symbol | string | 9 | 0 | 32 | src/token/Token.sol:Token |
| owners | mapping(uint256 => address) | 10 | 0 | 32 | src/token/Token.sol:Token |
| balances | mapping(address => uint256) | 11 | 0 | 32 | src/token/Token.sol:Token |
| tokenApprovals | mapping(uint256 => address) | 12 | 0 | 32 | src/token/Token.sol:Token |
| operatorApprovals | mapping(address => mapping(address => bool)) | 13 | 0 | 32 | src/token/Token.sol:Token |
| delegation | mapping(address => address) | 14 | 0 | 32 | src/token/Token.sol:Token |
| numCheckpoints | mapping(address => uint256) | 15 | 0 | 32 | src/token/Token.sol:Token |
| checkpoints | mapping(address => mapping(uint256 => struct IERC721Votes.Checkpoint)) | 16 | 0 | 32 | src/token/Token.sol:Token |
| settings | struct TokenTypesV1.Settings | 17 | 0 | 64 | src/token/Token.sol:Token |
| founder | mapping(uint256 => struct TokenTypesV1.Founder) | 19 | 0 | 32 | src/token/Token.sol:Token |
| tokenRecipient | mapping(uint256 => struct TokenTypesV1.Founder) | 20 | 0 | 32 | src/token/Token.sol:Token |
| minter | mapping(address => bool) | 21 | 0 | 32 | src/token/Token.sol:Token |
| reservedUntilTokenId | uint256 | 22 | 0 | 32 | src/token/Token.sol:Token |
| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------|------------------------------------------------------------------------|------|--------|-------|-----------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/token/default/Token.sol:Token |
| _initializing | bool | 0 | 1 | 1 | src/token/default/Token.sol:Token |
| _owner | address | 0 | 2 | 20 | src/token/default/Token.sol:Token |
| _pendingOwner | address | 1 | 0 | 20 | src/token/default/Token.sol:Token |
| _status | uint256 | 2 | 0 | 32 | src/token/default/Token.sol:Token |
| HASHED_NAME | bytes32 | 3 | 0 | 32 | src/token/default/Token.sol:Token |
| HASHED_VERSION | bytes32 | 4 | 0 | 32 | src/token/default/Token.sol:Token |
| INITIAL_DOMAIN_SEPARATOR | bytes32 | 5 | 0 | 32 | src/token/default/Token.sol:Token |
| INITIAL_CHAIN_ID | uint256 | 6 | 0 | 32 | src/token/default/Token.sol:Token |
| nonces | mapping(address => uint256) | 7 | 0 | 32 | src/token/default/Token.sol:Token |
| name | string | 8 | 0 | 32 | src/token/default/Token.sol:Token |
| symbol | string | 9 | 0 | 32 | src/token/default/Token.sol:Token |
| owners | mapping(uint256 => address) | 10 | 0 | 32 | src/token/default/Token.sol:Token |
| balances | mapping(address => uint256) | 11 | 0 | 32 | src/token/default/Token.sol:Token |
| tokenApprovals | mapping(uint256 => address) | 12 | 0 | 32 | src/token/default/Token.sol:Token |
| operatorApprovals | mapping(address => mapping(address => bool)) | 13 | 0 | 32 | src/token/default/Token.sol:Token |
| delegation | mapping(address => address) | 14 | 0 | 32 | src/token/default/Token.sol:Token |
| numCheckpoints | mapping(address => uint256) | 15 | 0 | 32 | src/token/default/Token.sol:Token |
| checkpoints | mapping(address => mapping(uint256 => struct IERC721Votes.Checkpoint)) | 16 | 0 | 32 | src/token/default/Token.sol:Token |
| settings | struct TokenTypesV1.Settings | 17 | 0 | 64 | src/token/default/Token.sol:Token |
| founder | mapping(uint256 => struct TokenTypesV1.Founder) | 19 | 0 | 32 | src/token/default/Token.sol:Token |
| tokenRecipient | mapping(uint256 => struct TokenTypesV1.Founder) | 20 | 0 | 32 | src/token/default/Token.sol:Token |
| minter | mapping(address => bool) | 21 | 0 | 32 | src/token/default/Token.sol:Token |
| reservedUntilTokenId | uint256 | 22 | 0 | 32 | src/token/default/Token.sol:Token |
2 changes: 1 addition & 1 deletion script/DeployContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "forge-std/Script.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IManager, Manager } from "../src/manager/Manager.sol";
import { IToken, Token } from "../src/token/Token.sol";
import { IToken, Token } from "../src/token/default/Token.sol";
import { MetadataRenderer } from "../src/token/metadata/MetadataRenderer.sol";
import { IAuction, Auction } from "../src/auction/Auction.sol";
import { IGovernor, Governor } from "../src/governance/governor/Governor.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/DeployMetadataUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "forge-std/Script.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IManager, Manager } from "../src/manager/Manager.sol";
import { IToken, Token } from "../src/token/Token.sol";
import { IToken, Token } from "../src/token/default/Token.sol";
import { MetadataRenderer } from "../src/token/metadata/MetadataRenderer.sol";
import { IAuction, Auction } from "../src/auction/Auction.sol";
import { IGovernor, Governor } from "../src/governance/governor/Governor.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/DeployTokenUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "forge-std/console2.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IManager, Manager } from "../src/manager/Manager.sol";
import { IToken, Token } from "../src/token/Token.sol";
import { IToken, Token } from "../src/token/default/Token.sol";
import { MetadataRenderer } from "../src/token/metadata/MetadataRenderer.sol";
import { IAuction, Auction } from "../src/auction/Auction.sol";
import { IGovernor, Governor } from "../src/governance/governor/Governor.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/DeployVersion1_1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "forge-std/console2.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IManager, Manager } from "../src/manager/Manager.sol";
import { IToken, Token } from "../src/token/Token.sol";
import { IToken, Token } from "../src/token/default/Token.sol";
import { MetadataRenderer } from "../src/token/metadata/MetadataRenderer.sol";
import { IAuction, Auction } from "../src/auction/Auction.sol";
import { IGovernor, Governor } from "../src/governance/governor/Governor.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Pausable } from "../lib/utils/Pausable.sol";
import { SafeCast } from "../lib/utils/SafeCast.sol";

import { AuctionStorageV1 } from "./storage/AuctionStorageV1.sol";
import { Token } from "../token/Token.sol";
import { IBaseToken } from "../token/interfaces/IBaseToken.sol";
import { IManager } from "../manager/IManager.sol";
import { IAuction } from "./IAuction.sol";
import { IWETH } from "../lib/interfaces/IWETH.sol";
Expand Down Expand Up @@ -78,7 +78,7 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
__Pausable_init(true);

// Store DAO's ERC-721 token
token = Token(_token);
token = IBaseToken(_token);

AuctionParams memory params = abi.decode(_data, (AuctionParams));

Expand Down
4 changes: 2 additions & 2 deletions src/auction/storage/AuctionStorageV1.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import { Token } from "../../token/Token.sol";
import { IBaseToken } from "../../token/interfaces/IBaseToken.sol";
import { AuctionTypesV1 } from "../types/AuctionTypesV1.sol";

/// @title AuctionStorageV1
Expand All @@ -12,7 +12,7 @@ contract AuctionStorageV1 is AuctionTypesV1 {
Settings internal settings;

/// @notice The ERC-721 token
Token public token;
IBaseToken public token;

/// @notice The state of the current auction
Auction public auction;
Expand Down
7 changes: 4 additions & 3 deletions src/governance/governor/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { UUPS } from "../../lib/proxy/UUPS.sol";
import { Ownable } from "../../lib/utils/Ownable.sol";
import { EIP712 } from "../../lib/utils/EIP712.sol";
import { SafeCast } from "../../lib/utils/SafeCast.sol";
import { ERC721 } from "../../lib/token/ERC721.sol";

import { GovernorStorageV1 } from "./storage/GovernorStorageV1.sol";
import { Token } from "../../token/Token.sol";
import { IBaseToken } from "../../token/interfaces/IBaseToken.sol";
import { Treasury } from "../treasury/Treasury.sol";
import { IManager } from "../../manager/IManager.sol";
import { IGovernor } from "./IGovernor.sol";
Expand Down Expand Up @@ -112,14 +113,14 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos

// Store the governor settings
settings.treasury = Treasury(payable(_treasury));
settings.token = Token(_token);
settings.token = IBaseToken(_token);
settings.votingDelay = SafeCast.toUint48(params.votingDelay);
settings.votingPeriod = SafeCast.toUint48(params.votingPeriod);
settings.proposalThresholdBps = SafeCast.toUint16(params.proposalThresholdBps);
settings.quorumThresholdBps = SafeCast.toUint16(params.quorumThresholdBps);

// Initialize EIP-712 support
__EIP712_init(string.concat(settings.token.symbol(), " GOV"), "1");
__EIP712_init(string.concat(ERC721(_token).symbol(), " GOV"), "1");

// Grant ownership to the treasury
__Ownable_init(_treasury);
Expand Down
4 changes: 2 additions & 2 deletions src/governance/governor/types/GovernorTypesV1.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import { Token } from "../../../token/Token.sol";
import { IBaseToken } from "../../../token/interfaces/IBaseToken.sol";
import { Treasury } from "../../treasury/Treasury.sol";

/// @title GovernorTypesV1
Expand All @@ -17,7 +17,7 @@ interface GovernorTypesV1 {
/// @param votingPeriod The time period to vote on a proposal
/// @param vetoer The address with the ability to veto proposals
struct Settings {
Token token;
IBaseToken token;
uint16 proposalThresholdBps;
uint16 quorumThresholdBps;
Treasury treasury;
Expand Down
20 changes: 20 additions & 0 deletions src/lib/interfaces/IERC5192.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;

interface IERC5192 {
/// @notice Emitted when the locking status is changed to locked.
/// @dev If a token is minted and the status is locked, this event should be emitted.
/// @param tokenId The identifier for a token.
event Locked(uint256 tokenId);

/// @notice Emitted when the locking status is changed to unlocked.
/// @dev If a token is minted and the status is unlocked, this event should be emitted.
/// @param tokenId The identifier for a token.
event Unlocked(uint256 tokenId);

/// @notice Returns the locking status of an Soulbound Token
/// @dev SBTs assigned to zero address are considered invalid, and queries
/// about them do throw.
/// @param tokenId The identifier for an SBT.
function locked(uint256 tokenId) external view returns (bool);
}
2 changes: 1 addition & 1 deletion src/manager/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ERC1967Proxy } from "../lib/proxy/ERC1967Proxy.sol";
import { ManagerStorageV1 } from "./storage/ManagerStorageV1.sol";
import { ManagerStorageV2 } from "./storage/ManagerStorageV2.sol";
import { IManager } from "./IManager.sol";
import { IToken } from "../token/IToken.sol";
import { IToken } from "../token/default/IToken.sol";
import { IBaseMetadata } from "../token/metadata/interfaces/IBaseMetadata.sol";
import { IAuction } from "../auction/IAuction.sol";
import { ITreasury } from "../governance/treasury/ITreasury.sol";
Expand Down
9 changes: 5 additions & 4 deletions src/token/IToken.sol → src/token/default/IToken.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import { IUUPS } from "../lib/interfaces/IUUPS.sol";
import { IERC721Votes } from "../lib/interfaces/IERC721Votes.sol";
import { IManager } from "../manager/IManager.sol";
import { IUUPS } from "../../lib/interfaces/IUUPS.sol";
import { IERC721Votes } from "../../lib/interfaces/IERC721Votes.sol";
import { IManager } from "../../manager/IManager.sol";
import { IBaseToken } from "../interfaces/IBaseToken.sol";
import { TokenTypesV1 } from "./types/TokenTypesV1.sol";
import { TokenTypesV2 } from "./types/TokenTypesV2.sol";

/// @title IToken
/// @author Rohan Kulkarni
/// @notice The external Token events, errors and functions
interface IToken is IUUPS, IERC721Votes, TokenTypesV1, TokenTypesV2 {
interface IToken is IUUPS, IERC721Votes, IBaseToken, TokenTypesV1, TokenTypesV2 {
/// ///
/// EVENTS ///
/// ///
Expand Down
19 changes: 10 additions & 9 deletions src/token/Token.sol → src/token/default/Token.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import { UUPS } from "../lib/proxy/UUPS.sol";
import { ReentrancyGuard } from "../lib/utils/ReentrancyGuard.sol";
import { ERC721Votes } from "../lib/token/ERC721Votes.sol";
import { ERC721 } from "../lib/token/ERC721.sol";
import { Ownable } from "../lib/utils/Ownable.sol";
import { UUPS } from "../../lib/proxy/UUPS.sol";
import { ReentrancyGuard } from "../../lib/utils/ReentrancyGuard.sol";
import { ERC721Votes } from "../../lib/token/ERC721Votes.sol";
import { ERC721 } from "../../lib/token/ERC721.sol";
import { Ownable } from "../../lib/utils/Ownable.sol";
import { TokenStorageV1 } from "./storage/TokenStorageV1.sol";
import { TokenStorageV2 } from "./storage/TokenStorageV2.sol";
import { TokenStorageV3 } from "./storage/TokenStorageV3.sol";
import { IBaseMetadata } from "./metadata/interfaces/IBaseMetadata.sol";
import { IManager } from "../manager/IManager.sol";
import { IAuction } from "../auction/IAuction.sol";
import { IBaseMetadata } from "../metadata/interfaces/IBaseMetadata.sol";
import { IManager } from "../../manager/IManager.sol";
import { IAuction } from "../../auction/IAuction.sol";
import { IToken } from "./IToken.sol";
import { VersionedContract } from "../VersionedContract.sol";
import { IBaseToken } from "../interfaces/IBaseToken.sol";
import { VersionedContract } from "../../VersionedContract.sol";

/// @title Token
/// @author Rohan Kulkarni
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import { IBaseMetadata } from "../metadata/interfaces/IBaseMetadata.sol";
import { IBaseMetadata } from "../../metadata/interfaces/IBaseMetadata.sol";

/// @title TokenTypesV1
/// @author Rohan Kulkarni
Expand Down
File renamed without changes.
Loading

0 comments on commit a2ff616

Please sign in to comment.