Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Aug 7, 2023
1 parent 921c5f2 commit ff754ea
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 29 deletions.
2 changes: 1 addition & 1 deletion script/DeployContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion script/DeployMetadataUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion script/DeployTokenUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 6 additions & 1 deletion src/auction/IAuction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 25 additions & 4 deletions src/governance/governor/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
21 changes: 18 additions & 3 deletions src/governance/governor/IGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 20 additions & 3 deletions src/governance/treasury/Treasury.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
19 changes: 17 additions & 2 deletions src/manager/IManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions src/manager/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions src/token/metadata/MetadataRenderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;

Expand Down
24 changes: 21 additions & 3 deletions test/Gov.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand Down
18 changes: 15 additions & 3 deletions test/utils/NounsBuilderTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ff754ea

Please sign in to comment.