Skip to content

Commit

Permalink
minimize diff
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Oct 26, 2023
1 parent 5164f20 commit 4e8de50
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
url = https://github.com/foundry-rs/forge-std
58 changes: 29 additions & 29 deletions .storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
| _pendingOwner | address | 1 | 0 | 20 | src/manager/Manager.sol:Manager |
| isUpgrade | mapping(address => mapping(address => bool)) | 2 | 0 | 32 | src/manager/Manager.sol:Manager |
| daoAddressesByToken | mapping(address => struct ManagerTypesV1.DAOAddresses) | 3 | 0 | 32 | src/manager/Manager.sol:Manager |
| isImplementation | mapping(uint8 => mapping(address => bool)) | 4 | 0 | 32 | src/manager/Manager.sol:Manager |
| rewards | struct ManagerTypesV2.RewardConfig | 4 | 0 | 96 | src/manager/Manager.sol:Manager |

=======================
➡ Auction
Expand All @@ -28,10 +28,10 @@
| _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 IBaseToken | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| token | contract Token | 6 | 0 | 20 | src/auction/Auction.sol:Auction |
| auction | struct AuctionTypesV1.Auction | 7 | 0 | 96 | src/auction/Auction.sol:Auction |
| currentBidReferral | address | 10 | 0 | 20 | src/auction/Auction.sol:Auction |
| founderRewardsRecipent | address | 11 | 0 | 20 | src/auction/Auction.sol:Auction |
| founderRewardRecipient | address | 11 | 0 | 20 | src/auction/Auction.sol:Auction |
| founderRewardBPS | uint256 | 12 | 0 | 32 | src/auction/Auction.sol:Auction |

=======================
Expand Down Expand Up @@ -70,29 +70,29 @@
➡ 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 |
| 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 |
2 changes: 1 addition & 1 deletion src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ 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 { AuctionStorageV2 } from "./storage/AuctionStorageV2.sol";
import { IManager } from "../manager/IManager.sol";
import { ManagerTypesV2 } from "../manager/types/ManagerTypesV2.sol";
import { IAuction } from "./IAuction.sol";
import { IWETH } from "../lib/interfaces/IWETH.sol";
import { Token } from "../token/Token.sol";
import { IProtocolRewards } from "../lib/interfaces/IProtocolRewards.sol";

import { VersionedContract } from "../VersionedContract.sol";
Expand Down
4 changes: 2 additions & 2 deletions src/governance/treasury/Treasury.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VersionedContract } from "../../VersionedContract.sol";
/// @title Treasury
/// @author Rohan Kulkarni
/// @notice A DAO's treasury and transaction executor
/// @custom:repo github.com/ourzora/nouns-protocol
/// @custom:repo github.com/ourzora/nouns-protocol
/// Modified from:
/// - OpenZeppelin Contracts v4.7.3 (governance/TimelockController.sol)
/// - NounsDAOExecutor.sol commit 2cbe6c7 - licensed under the BSD-3-Clause license.
Expand Down Expand Up @@ -276,4 +276,4 @@ contract Treasury is ITreasury, VersionedContract, UUPS, Ownable, ProposalHasher
// Ensure the new implementation is a registered upgrade
if (!manager.isRegisteredUpgrade(_getImplementation(), _newImpl)) revert INVALID_UPGRADE(_newImpl);
}
}
}
10 changes: 0 additions & 10 deletions src/manager/IManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ interface IManager is IUUPS, IOwnable {
uint256 reservedUntilTokenId;
}

/// @notice The ERC-721 token parameters
/// @param initStrings The encoded token name, symbol, collection description, collection image uri, renderer base uri
/// @param reservedUntilTokenId The tokenId that a DAO's auctions will start at
/// @param tokenToMirror The token contract to be mirrored
struct MirrorTokenParams {
bytes initStrings;
uint256 reservedUntilTokenId;
address tokenToMirror;
}

/// @notice The auction parameters
/// @param reservePrice The reserve price of each auction
/// @param duration The duration of each auction
Expand Down
9 changes: 7 additions & 2 deletions src/manager/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1
// Ensure at least one founder is provided
if ((founder = _founderParams[0].wallet) == address(0)) revert FOUNDER_REQUIRED();

// Create new local context to fix for stack too deep error
{
// Deploy the DAO's ERC-721 governance token
token = address(new ERC1967Proxy(tokenImpl, ""));
Expand All @@ -117,9 +118,9 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1
auction = address(new ERC1967Proxy{ salt: salt }(auctionImpl, ""));
treasury = address(new ERC1967Proxy{ salt: salt }(treasuryImpl, ""));
governor = address(new ERC1967Proxy{ salt: salt }(governorImpl, ""));
}

daoAddressesByToken[token] = DAOAddresses({ metadata: metadata, auction: auction, treasury: treasury, governor: governor });
daoAddressesByToken[token] = DAOAddresses({ metadata: metadata, auction: auction, treasury: treasury, governor: governor });
}

// Initialize each instance with the provided settings
IToken(token).initialize({
Expand Down Expand Up @@ -154,6 +155,10 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1
emit DAODeployed({ token: token, metadata: metadata, auction: auction, treasury: treasury, governor: governor });
}

/// ///
/// SET METADATA ///
/// ///

/// @notice Set a new metadata renderer
/// @param _newRendererImpl new renderer address to use
/// @param _setupRenderer data to setup new renderer with
Expand Down
10 changes: 5 additions & 5 deletions src/token/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ contract Token is IToken, VersionedContract, UUPS, Ownable, ReentrancyGuard, ERC
/// INITIALIZER ///
/// ///

/// @notice Initializes a DAO's ERC-721 token contract
/// @param _founders The DAO founders
/// @notice Initializes a DAO's ERC-721 token
/// @param _founders The founding members to receive vesting allocations
/// @param _initStrings The encoded token and metadata initialization strings
/// @param _reservedUntilTokenId The tokenId that a DAO's auctions will start at
/// @param _metadataRenderer The token's metadata renderer
Expand Down Expand Up @@ -105,7 +105,7 @@ contract Token is IToken, VersionedContract, UUPS, Ownable, ReentrancyGuard, ERC

/// @notice Called by the auction upon the first unpause / token mint to transfer ownership from founder to treasury
/// @dev Only callable by the auction contract
function onFirstAuctionStarted() external {
function onFirstAuctionStarted() external override {
if (msg.sender != settings.auction) {
revert ONLY_AUCTION();
}
Expand Down Expand Up @@ -315,12 +315,12 @@ contract Token is IToken, VersionedContract, UUPS, Ownable, ReentrancyGuard, ERC

/// @notice The URI for a token
/// @param _tokenId The ERC-721 token id
function tokenURI(uint256 _tokenId) public view override(ERC721, IToken) returns (string memory) {
function tokenURI(uint256 _tokenId) public view override(IToken, ERC721) returns (string memory) {
return settings.metadataRenderer.tokenURI(_tokenId);
}

/// @notice The URI for the contract
function contractURI() public view override(ERC721, IToken) returns (string memory) {
function contractURI() public view override(IToken, ERC721) returns (string memory) {
return settings.metadataRenderer.contractURI();
}

Expand Down
4 changes: 2 additions & 2 deletions src/token/metadata/MetadataRenderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { VersionedContract } from "../../VersionedContract.sol";
/// @title Metadata Renderer
/// @author Iain Nash & Rohan Kulkarni
/// @notice A DAO's artwork generator and renderer
/// @custom:repo github.com/ourzora/nouns-protocol
/// @custom:repo github.com/ourzora/nouns-protocol
contract MetadataRenderer is
IPropertyIPFSMetadataRenderer,
VersionedContract,
Expand Down Expand Up @@ -467,4 +467,4 @@ contract MetadataRenderer is
function _authorizeUpgrade(address _impl) internal view override onlyOwner {
if (!manager.isRegisteredUpgrade(_getImplementation(), _impl)) revert INVALID_UPGRADE(_impl);
}
}
}
8 changes: 6 additions & 2 deletions src/token/metadata/interfaces/IBaseMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.16;

import { IUUPS } from "../../../lib/interfaces/IUUPS.sol";


/// @title IBaseMetadata
/// @author Rohan Kulkarni
/// @notice The external Base Metadata errors and functions
Expand All @@ -21,7 +22,10 @@ interface IBaseMetadata is IUUPS {
/// @notice Initializes a DAO's token metadata renderer
/// @param initStrings The encoded token and metadata initialization strings
/// @param token The associated ERC-721 token address
function initialize(bytes calldata initStrings, address token) external;
function initialize(
bytes calldata initStrings,
address token
) external;

/// @notice Generates attributes for a token upon mint
/// @param tokenId The ERC-721 token id
Expand All @@ -39,4 +43,4 @@ interface IBaseMetadata is IUUPS {

/// @notice Get metadata owner address
function owner() external view returns (address);
}
}
33 changes: 0 additions & 33 deletions test/utils/NounsBuilderTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ contract NounsBuilderTest is Test {

IManager.FounderParams[] internal foundersArr;
IManager.TokenParams internal tokenParams;
IManager.MirrorTokenParams internal mirrorTokenParams;
IManager.AuctionParams internal auctionParams;
IManager.GovParams internal govParams;

Expand Down Expand Up @@ -145,19 +144,6 @@ contract NounsBuilderTest is Test {
);
}

function setMockMirrorTokenParams(uint256 _reservedUntilTokenId, address _tokenToMirror) internal virtual {
setMirrorTokenParams(
"Mock Token",
"MOCK",
"This is a mock token",
"ipfs://Qmew7TdyGnj6YRUjQR68sUJN3239MYXRD8uxowxF6rGK8j",
"https://nouns.build",
"http://localhost:5000/render",
_reservedUntilTokenId,
_tokenToMirror
);
}

function setTokenParams(
string memory _name,
string memory _symbol,
Expand All @@ -172,25 +158,6 @@ contract NounsBuilderTest is Test {
tokenParams = IManager.TokenParams({ initStrings: initStrings, reservedUntilTokenId: _reservedUntilTokenId });
}

function setMirrorTokenParams(
string memory _name,
string memory _symbol,
string memory _description,
string memory _contractImage,
string memory _contractURI,
string memory _rendererBase,
uint256 _reservedUntilTokenId,
address _tokenToMirror
) internal virtual {
bytes memory initStrings = abi.encode(_name, _symbol, _description, _contractImage, _contractURI, _rendererBase);

mirrorTokenParams = IManager.MirrorTokenParams({
initStrings: initStrings,
reservedUntilTokenId: _reservedUntilTokenId,
tokenToMirror: _tokenToMirror
});
}

function setMockAuctionParams() internal virtual {
setAuctionParams(0.01 ether, 10 minutes, address(0), 0);
}
Expand Down

0 comments on commit 4e8de50

Please sign in to comment.