From 1b2bad0bd1511b2376584e8b7957ab9d332cf741 Mon Sep 17 00:00:00 2001 From: neokry Date: Mon, 7 Aug 2023 11:31:29 +0900 Subject: [PATCH 1/3] Fix typo --- src/manager/IManager.sol | 2 +- src/manager/Manager.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manager/IManager.sol b/src/manager/IManager.sol index 19e535a..1a011a7 100644 --- a/src/manager/IManager.sol +++ b/src/manager/IManager.sol @@ -28,7 +28,7 @@ interface IManager is IUUPS, IOwnable { /// @notice Emitted when an implementation is unregistered by the Builder DAO /// @param implType The type of implementation /// @param implAddress The implementation address - event ImplemenetationRemoved(uint8 implType, address implAddress); + event ImplementationRemoved(uint8 implType, address implAddress); /// @notice Emitted when an upgrade is registered by the Builder DAO /// @param baseImpl The base implementation address diff --git a/src/manager/Manager.sol b/src/manager/Manager.sol index f5c82bb..defa7b9 100644 --- a/src/manager/Manager.sol +++ b/src/manager/Manager.sol @@ -160,7 +160,7 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1 if (_isInvalidImplementationType(_implType)) revert INVALID_IMPLEMENTATION_TYPE(); delete isImplementation[_implType][_implAddress]; - emit ImplemenetationRemoved(_implType, _implAddress); + emit ImplementationRemoved(_implType, _implAddress); } /// /// From 921c5f20865ee27c0c06bc9715b0b6a1158a552b Mon Sep 17 00:00:00 2001 From: neokry Date: Mon, 7 Aug 2023 11:43:17 +0900 Subject: [PATCH 2/3] Fix if statement formatting and impl type comment --- src/governance/governor/Governor.sol | 18 +++++++++++++----- src/manager/Manager.sol | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/governance/governor/Governor.sol b/src/governance/governor/Governor.sol index 6558aab..ec58bb2 100644 --- a/src/governance/governor/Governor.sol +++ b/src/governance/governor/Governor.sol @@ -90,13 +90,21 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos if (params.vetoer != address(0)) settings.vetoer = params.vetoer; // Ensure the specified governance settings are valid - if (params.proposalThresholdBps < MIN_PROPOSAL_THRESHOLD_BPS || params.proposalThresholdBps > MAX_PROPOSAL_THRESHOLD_BPS) + if (params.proposalThresholdBps < MIN_PROPOSAL_THRESHOLD_BPS || params.proposalThresholdBps > MAX_PROPOSAL_THRESHOLD_BPS) { revert INVALID_PROPOSAL_THRESHOLD_BPS(); - if (params.quorumThresholdBps < MIN_QUORUM_THRESHOLD_BPS || params.quorumThresholdBps > MAX_QUORUM_THRESHOLD_BPS) + } + if (params.quorumThresholdBps < MIN_QUORUM_THRESHOLD_BPS || params.quorumThresholdBps > MAX_QUORUM_THRESHOLD_BPS) { revert INVALID_QUORUM_THRESHOLD_BPS(); - if (params.proposalThresholdBps >= params.quorumThresholdBps) revert INVALID_PROPOSAL_THRESHOLD_BPS(); - if (params.votingDelay < MIN_VOTING_DELAY || params.votingDelay > MAX_VOTING_DELAY) revert INVALID_VOTING_DELAY(); - if (params.votingPeriod < MIN_VOTING_PERIOD || params.votingPeriod > MAX_VOTING_PERIOD) revert INVALID_VOTING_PERIOD(); + } + if (params.proposalThresholdBps >= params.quorumThresholdBps) { + revert INVALID_PROPOSAL_THRESHOLD_BPS(); + } + if (params.votingDelay < MIN_VOTING_DELAY || params.votingDelay > MAX_VOTING_DELAY) { + revert INVALID_VOTING_DELAY(); + } + if (params.votingPeriod < MIN_VOTING_PERIOD || params.votingPeriod > MAX_VOTING_PERIOD) { + revert INVALID_VOTING_PERIOD(); + } // Store the governor settings settings.treasury = Treasury(payable(_treasury)); diff --git a/src/manager/Manager.sol b/src/manager/Manager.sol index defa7b9..69a702c 100644 --- a/src/manager/Manager.sol +++ b/src/manager/Manager.sol @@ -30,7 +30,7 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1 uint8 public constant IMPLEMENTATION_TYPE_COUNT = 5; // Public constants for implementation types. - // Allows for adding new types later easily compared to a enum. + // Allows for more clarity when adding new types compared to a enum. uint8 public constant IMPLEMENTATION_TYPE_TOKEN = 0; uint8 public constant IMPLEMENTATION_TYPE_METADATA = 1; uint8 public constant IMPLEMENTATION_TYPE_AUCTION = 2; From ff754ea3685ad8868636c5e4406464d5fb2d0414 Mon Sep 17 00:00:00 2001 From: neokry Date: Mon, 7 Aug 2023 11:54:02 +0900 Subject: [PATCH 3/3] Fix formatting --- script/DeployContracts.s.sol | 2 +- script/DeployMetadataUpgrade.s.sol | 2 +- script/DeployTokenUpgrade.s.sol | 2 +- script/DeployVersion1_1.s.sol | 2 +- src/auction/Auction.sol | 7 +++++- src/auction/IAuction.sol | 7 +++++- src/governance/governor/Governor.sol | 29 +++++++++++++++++++++---- src/governance/governor/IGovernor.sol | 21 +++++++++++++++--- src/governance/treasury/Treasury.sol | 23 +++++++++++++++++--- src/manager/IManager.sol | 19 ++++++++++++++-- src/manager/Manager.sol | 22 +++++++++++++++++-- src/token/metadata/MetadataRenderer.sol | 18 ++++++++++++--- test/Gov.t.sol | 24 +++++++++++++++++--- test/utils/NounsBuilderTest.sol | 18 ++++++++++++--- 14 files changed, 167 insertions(+), 29 deletions(-) diff --git a/script/DeployContracts.s.sol b/script/DeployContracts.s.sol index 224501d..d386443 100644 --- a/script/DeployContracts.s.sol +++ b/script/DeployContracts.s.sol @@ -104,7 +104,7 @@ contract DeployContracts is Script { function addressToString(address _addr) private pure returns (string memory) { bytes memory s = new bytes(40); for (uint256 i = 0; i < 20; i++) { - bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2 ** (8 * (19 - i))))); + bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2**(8 * (19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2 * i] = char(hi); diff --git a/script/DeployMetadataUpgrade.s.sol b/script/DeployMetadataUpgrade.s.sol index aa48421..73192b4 100644 --- a/script/DeployMetadataUpgrade.s.sol +++ b/script/DeployMetadataUpgrade.s.sol @@ -77,7 +77,7 @@ contract DeployMetadataUpgrade is Script { function addressToString(address _addr) private pure returns (string memory) { bytes memory s = new bytes(40); for (uint256 i = 0; i < 20; i++) { - bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2 ** (8 * (19 - i))))); + bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2**(8 * (19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2 * i] = char(hi); diff --git a/script/DeployTokenUpgrade.s.sol b/script/DeployTokenUpgrade.s.sol index c89f99c..58753fa 100644 --- a/script/DeployTokenUpgrade.s.sol +++ b/script/DeployTokenUpgrade.s.sol @@ -88,7 +88,7 @@ contract DeployTokenUpgrade is Script { function addressToString(address _addr) private pure returns (string memory) { bytes memory s = new bytes(40); for (uint256 i = 0; i < 20; i++) { - bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2 ** (8 * (19 - i))))); + bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2**(8 * (19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2 * i] = char(hi); diff --git a/script/DeployVersion1_1.s.sol b/script/DeployVersion1_1.s.sol index 115d19b..6620dba 100644 --- a/script/DeployVersion1_1.s.sol +++ b/script/DeployVersion1_1.s.sol @@ -77,7 +77,7 @@ contract DeployVersion1_1 is Script { function addressToString(address _addr) private pure returns (string memory) { bytes memory s = new bytes(40); for (uint256 i = 0; i < 20; i++) { - bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2 ** (8 * (19 - i))))); + bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2**(8 * (19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2 * i] = char(hi); diff --git a/src/auction/Auction.sol b/src/auction/Auction.sol index 1dcf249..55527e1 100644 --- a/src/auction/Auction.sol +++ b/src/auction/Auction.sol @@ -59,7 +59,12 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard, /// @param _founder The founder responsible for starting the first auction /// @param _treasury The treasury address where ETH will be sent /// @param _data The encoded auction settings - function initialize(address _token, address _founder, address _treasury, bytes calldata _data) external initializer { + function initialize( + address _token, + address _founder, + address _treasury, + bytes calldata _data + ) external initializer { // Ensure the caller is the contract manager if (msg.sender != address(manager)) revert ONLY_MANAGER(); diff --git a/src/auction/IAuction.sol b/src/auction/IAuction.sol index f501d20..c5ddfbe 100644 --- a/src/auction/IAuction.sol +++ b/src/auction/IAuction.sol @@ -107,7 +107,12 @@ interface IAuction is IUUPS, IOwnable, IPausable { /// @param founder The founder responsible for starting the first auction /// @param treasury The treasury address where ETH will be sent /// @param data The encoded auction initialization data - function initialize(address token, address founder, address treasury, bytes calldata data) external; + function initialize( + address token, + address founder, + address treasury, + bytes calldata data + ) external; /// @notice Creates a bid for the current token /// @param tokenId The ERC-721 token id diff --git a/src/governance/governor/Governor.sol b/src/governance/governor/Governor.sol index ec58bb2..87516f4 100644 --- a/src/governance/governor/Governor.sol +++ b/src/governance/governor/Governor.sol @@ -76,7 +76,11 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos /// @param _treasury The DAO's treasury address /// @param _token The DAO's governance token address /// @param _data The encoded governor parameters - function initialize(address _treasury, address _token, bytes calldata _data) external initializer { + function initialize( + address _treasury, + address _token, + bytes calldata _data + ) external initializer { // Ensure the caller is the contract manager if (msg.sender != address(manager)) revert ONLY_MANAGER(); @@ -208,7 +212,11 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos /// @param _proposalId The proposal id /// @param _support The support value (0 = Against, 1 = For, 2 = Abstain) /// @param _reason The vote reason - function castVoteWithReason(bytes32 _proposalId, uint256 _support, string memory _reason) external returns (uint256) { + function castVoteWithReason( + bytes32 _proposalId, + uint256 _support, + string memory _reason + ) external returns (uint256) { return _castVote(_proposalId, msg.sender, _support, _reason); } @@ -260,7 +268,12 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos /// @param _proposalId The proposal id /// @param _voter The voter address /// @param _support The vote choice - function _castVote(bytes32 _proposalId, address _voter, uint256 _support, string memory _reason) internal returns (uint256) { + function _castVote( + bytes32 _proposalId, + address _voter, + uint256 _support, + string memory _reason + ) internal returns (uint256) { // Ensure voting is active if (state(_proposalId) != ProposalState.Active) revert VOTING_NOT_STARTED(); @@ -508,7 +521,15 @@ contract Governor is IGovernor, VersionedContract, UUPS, Ownable, EIP712, Propos /// @notice The vote counts for a proposal /// @param _proposalId The proposal id - function proposalVotes(bytes32 _proposalId) external view returns (uint256, uint256, uint256) { + function proposalVotes(bytes32 _proposalId) + external + view + returns ( + uint256, + uint256, + uint256 + ) + { Proposal memory proposal = proposals[_proposalId]; return (proposal.againstVotes, proposal.forVotes, proposal.abstainVotes); diff --git a/src/governance/governor/IGovernor.sol b/src/governance/governor/IGovernor.sol index 61e4e54..131d752 100644 --- a/src/governance/governor/IGovernor.sol +++ b/src/governance/governor/IGovernor.sol @@ -139,7 +139,11 @@ interface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 { /// @param treasury The DAO's treasury address /// @param token The DAO's governance token address /// @param data The encoded governance parameters - function initialize(address treasury, address token, bytes calldata data) external; + function initialize( + address treasury, + address token, + bytes calldata data + ) external; /// @notice Creates a proposal /// @param targets The target addresses to call @@ -162,7 +166,11 @@ interface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 { /// @param proposalId The proposal id /// @param support The support value (0 = Against, 1 = For, 2 = Abstain) /// @param reason The vote reason - function castVoteWithReason(bytes32 proposalId, uint256 support, string memory reason) external returns (uint256); + function castVoteWithReason( + bytes32 proposalId, + uint256 support, + string memory reason + ) external returns (uint256); /// @notice Casts a signed vote /// @param voter The voter address @@ -237,7 +245,14 @@ interface IGovernor is IUUPS, IOwnable, IEIP712, GovernorTypesV1 { /// @notice The vote counts for a proposal /// @param proposalId The proposal id - function proposalVotes(bytes32 proposalId) external view returns (uint256 againstVotes, uint256 forVotes, uint256 abstainVotes); + function proposalVotes(bytes32 proposalId) + external + view + returns ( + uint256 againstVotes, + uint256 forVotes, + uint256 abstainVotes + ); /// @notice The timestamp valid to execute a proposal /// @param proposalId The proposal id diff --git a/src/governance/treasury/Treasury.sol b/src/governance/treasury/Treasury.sol index 2c27c82..c8b02ba 100644 --- a/src/governance/treasury/Treasury.sol +++ b/src/governance/treasury/Treasury.sol @@ -230,17 +230,34 @@ contract Treasury is ITreasury, VersionedContract, UUPS, Ownable, ProposalHasher /// /// /// @dev Accepts all ERC-721 transfers - function onERC721Received(address, address, uint256, bytes memory) public pure returns (bytes4) { + function onERC721Received( + address, + address, + uint256, + bytes memory + ) public pure returns (bytes4) { return ERC721TokenReceiver.onERC721Received.selector; } /// @dev Accepts all ERC-1155 single id transfers - function onERC1155Received(address, address, uint256, uint256, bytes memory) public pure returns (bytes4) { + function onERC1155Received( + address, + address, + uint256, + uint256, + bytes memory + ) public pure returns (bytes4) { return ERC1155TokenReceiver.onERC1155Received.selector; } /// @dev Accept all ERC-1155 batch id transfers - function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public pure returns (bytes4) { + function onERC1155BatchReceived( + address, + address, + uint256[] memory, + uint256[] memory, + bytes memory + ) public pure returns (bytes4) { return ERC1155TokenReceiver.onERC1155BatchReceived.selector; } diff --git a/src/manager/IManager.sol b/src/manager/IManager.sol index 1a011a7..3414c62 100644 --- a/src/manager/IManager.sol +++ b/src/manager/IManager.sol @@ -99,11 +99,26 @@ interface IManager is IUUPS, IOwnable { FounderParams[] calldata founderParams, address[] calldata implAddresses, bytes[] calldata implData - ) external returns (address token, address metadataRenderer, address auction, address treasury, address governor); + ) + external + returns ( + address token, + address metadataRenderer, + address auction, + address treasury, + address governor + ); /// @notice A DAO's remaining contract addresses from its token address /// @param token The ERC-721 token address - function getAddresses(address token) external returns (address metadataRenderer, address auction, address treasury, address governor); + function getAddresses(address token) + external + returns ( + address metadataRenderer, + address auction, + address treasury, + address governor + ); /// @notice If an implementation is registered by the Builder DAO as an optional upgrade /// @param baseImpl The base implementation address diff --git a/src/manager/Manager.sol b/src/manager/Manager.sol index 69a702c..04dcf13 100644 --- a/src/manager/Manager.sol +++ b/src/manager/Manager.sol @@ -63,7 +63,16 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1 FounderParams[] calldata _founderParams, address[] calldata _implAddresses, bytes[] calldata _implData - ) external returns (address token, address metadata, address auction, address treasury, address governor) { + ) + external + returns ( + address token, + address metadata, + address auction, + address treasury, + address governor + ) + { // Used to store the address of the first (or only) founder // This founder is responsible for adding token artwork and launching the first auction -- they're also free to transfer this responsiblity address founder; @@ -123,7 +132,16 @@ contract Manager is IManager, VersionedContract, UUPS, Ownable, ManagerStorageV1 /// @return auction Auction deployed address /// @return treasury Treasury deployed address /// @return governor Governor deployed address - function getAddresses(address _token) public view returns (address metadata, address auction, address treasury, address governor) { + function getAddresses(address _token) + public + view + returns ( + address metadata, + address auction, + address treasury, + address governor + ) + { DAOAddresses storage addresses = daoAddressesByToken[_token]; metadata = addresses.metadata; diff --git a/src/token/metadata/MetadataRenderer.sol b/src/token/metadata/MetadataRenderer.sol index 6c28481..c651a25 100644 --- a/src/token/metadata/MetadataRenderer.sol +++ b/src/token/metadata/MetadataRenderer.sol @@ -124,7 +124,11 @@ contract MetadataRenderer is /// @param _names The names of the properties to add /// @param _items The items to add to each property /// @param _ipfsGroup The IPFS base URI and extension - function addProperties(string[] calldata _names, ItemParam[] calldata _items, IPFSGroup calldata _ipfsGroup) external onlyOwner { + function addProperties( + string[] calldata _names, + ItemParam[] calldata _items, + IPFSGroup calldata _ipfsGroup + ) external onlyOwner { _addProperties(_names, _items, _ipfsGroup); } @@ -133,13 +137,21 @@ contract MetadataRenderer is /// @param _names The names of the properties to add /// @param _items The items to add to each property /// @param _ipfsGroup The IPFS base URI and extension - function deleteAndRecreateProperties(string[] calldata _names, ItemParam[] calldata _items, IPFSGroup calldata _ipfsGroup) external onlyOwner { + function deleteAndRecreateProperties( + string[] calldata _names, + ItemParam[] calldata _items, + IPFSGroup calldata _ipfsGroup + ) external onlyOwner { delete ipfsData; delete properties; _addProperties(_names, _items, _ipfsGroup); } - function _addProperties(string[] calldata _names, ItemParam[] calldata _items, IPFSGroup calldata _ipfsGroup) internal { + function _addProperties( + string[] calldata _names, + ItemParam[] calldata _items, + IPFSGroup calldata _ipfsGroup + ) internal { // Cache the existing amount of IPFS data stored uint256 dataLength = ipfsData.length; diff --git a/test/Gov.t.sol b/test/Gov.t.sol index cd7297c..b9cec5d 100644 --- a/test/Gov.t.sol +++ b/test/Gov.t.sol @@ -119,7 +119,12 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 { vm.warp(block.timestamp + 20); } - function castVotes(bytes32 _proposalId, uint256 _numAgainst, uint256 _numFor, uint256 _numAbstain) internal { + function castVotes( + bytes32 _proposalId, + uint256 _numAgainst, + uint256 _numFor, + uint256 _numAbstain + ) internal { uint256 currentVoterIndex; for (uint256 i = 0; i < _numAgainst; ++i) { @@ -144,7 +149,15 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 { } } - function mockProposal() internal view returns (address[] memory targets, uint256[] memory values, bytes[] memory calldatas) { + function mockProposal() + internal + view + returns ( + address[] memory targets, + uint256[] memory values, + bytes[] memory calldatas + ) + { targets = new address[](1); values = new uint256[](1); calldatas = new bytes[](1); @@ -170,7 +183,12 @@ contract GovTest is NounsBuilderTest, GovernorTypesV1 { proposalId = governor.propose(targets, values, calldatas, ""); } - function createProposal(address _proposer, address _target, uint256 _value, bytes memory _calldata) internal returns (bytes32 proposalId) { + function createProposal( + address _proposer, + address _target, + uint256 _value, + bytes memory _calldata + ) internal returns (bytes32 proposalId) { deployMock(); address[] memory targets = new address[](1); diff --git a/test/utils/NounsBuilderTest.sol b/test/utils/NounsBuilderTest.sol index 548c468..5c53d3f 100644 --- a/test/utils/NounsBuilderTest.sol +++ b/test/utils/NounsBuilderTest.sol @@ -110,7 +110,11 @@ contract NounsBuilderTest is Test { setFounderParams(wallets, percents, vestingEnds); } - function setFounderParams(address[] memory _wallets, uint256[] memory _percents, uint256[] memory _vestingEnds) internal virtual { + function setFounderParams( + address[] memory _wallets, + uint256[] memory _percents, + uint256[] memory _vestingEnds + ) internal virtual { uint256 numFounders = _wallets.length; require(numFounders == _percents.length && numFounders == _vestingEnds.length); @@ -252,7 +256,11 @@ contract NounsBuilderTest is Test { setMockMetadata(); } - function deployWithCustomFounders(address[] memory _wallets, uint256[] memory _percents, uint256[] memory _vestExpirys) internal virtual { + function deployWithCustomFounders( + address[] memory _wallets, + uint256[] memory _percents, + uint256[] memory _vestExpirys + ) internal virtual { setFounderParams(_wallets, _percents, _vestExpirys); setMockTokenParams(); @@ -305,7 +313,11 @@ contract NounsBuilderTest is Test { deploy(foundersArr, implAddresses, implData); } - function deploy(IManager.FounderParams[] memory _founderParams, address[] memory _implAddresses, bytes[] memory _implData) internal virtual { + function deploy( + IManager.FounderParams[] memory _founderParams, + address[] memory _implAddresses, + bytes[] memory _implData + ) internal virtual { (address _token, address _metadata, address _auction, address _treasury, address _governor) = manager.deploy( _founderParams, _implAddresses,