Skip to content

Commit

Permalink
reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Oct 26, 2023
1 parent 5089876 commit 5164f20
Show file tree
Hide file tree
Showing 39 changed files with 102 additions and 981 deletions.
2 changes: 1 addition & 1 deletion script/DeployNewDAO.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 } from "../src/manager/IManager.sol";
import { IBaseMetadata } from "../src/metadata/interfaces/IBaseMetadata.sol";
import { IBaseMetadata } from "../src/token/metadata/interfaces/IBaseMetadata.sol";
import { IAuction } from "../src/auction/IAuction.sol";
import { IGovernor } from "../src/governance/governor/IGovernor.sol";
import { ITreasury } from "../src/governance/treasury/ITreasury.sol";
Expand Down
6 changes: 3 additions & 3 deletions script/DeployV2Core.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ 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/default/Token.sol";
import { IToken, Token } from "../src/token/Token.sol";
import { IAuction, Auction } from "../src/auction/Auction.sol";
import { IGovernor, Governor } from "../src/governance/governor/Governor.sol";
import { ITreasury, Treasury } from "../src/governance/treasury/Treasury.sol";
import { MetadataRenderer } from "../src/metadata/MetadataRenderer.sol";
import { MetadataRendererTypesV1 } from "../src/metadata/types/MetadataRendererTypesV1.sol";
import { MetadataRenderer } from "../src/token/metadata/MetadataRenderer.sol";
import { MetadataRendererTypesV1 } from "../src/token/metadata/types/MetadataRendererTypesV1.sol";
import { ERC1967Proxy } from "../src/lib/proxy/ERC1967Proxy.sol";

contract DeployContracts is Script {
Expand Down
7 changes: 0 additions & 7 deletions script/DeployV2New.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IManager, Manager } from "../src/manager/Manager.sol";
import { ERC1967Proxy } from "../src/lib/proxy/ERC1967Proxy.sol";
import { ERC721RedeemMinter } from "../src/minters/ERC721RedeemMinter.sol";
import { MerkleReserveMinter } from "../src/minters/MerkleReserveMinter.sol";
import { MigrationDeployer } from "../src/deployers/MigrationDeployer.sol";

Expand Down Expand Up @@ -43,8 +42,6 @@ contract DeployContracts is Script {

vm.startBroadcast(deployerAddress);

address erc721Minter = address(new ERC721RedeemMinter(manager, builderDAO));

address merkleMinter = address(new MerkleReserveMinter(manager));

address migrationDeployer = address(new MigrationDeployer(address(manager), merkleMinter, crossDomainMessenger));
Expand All @@ -54,13 +51,9 @@ contract DeployContracts is Script {
string memory filePath = string(abi.encodePacked("deploys/", chainID.toString(), ".version2_new.txt"));

vm.writeFile(filePath, "");
vm.writeLine(filePath, string(abi.encodePacked("ERC721 Redeem Minter: ", addressToString(erc721Minter))));
vm.writeLine(filePath, string(abi.encodePacked("Merkle Reserve Minter: ", addressToString(merkleMinter))));
vm.writeLine(filePath, string(abi.encodePacked("Migration Deployer: ", addressToString(migrationDeployer))));

console2.log("~~~~~~~~~~ ERC721 REDEEM MINTER ~~~~~~~~~~~");
console2.logAddress(erc721Minter);

console2.log("~~~~~~~~~~ MERKLE RESERVE MINTER ~~~~~~~~~~~");
console2.logAddress(merkleMinter);

Expand Down
6 changes: 2 additions & 4 deletions script/GetInterfaceIds.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import "forge-std/console2.sol";

import { IBaseMetadata } from "../src/metadata/interfaces/IBaseMetadata.sol";
import { IPropertyIPFSMetadataRenderer } from "../src/metadata/interfaces/IPropertyIPFSMetadataRenderer.sol";
import { IMirrorToken } from "../src/token/interfaces/IMirrorToken.sol";
import { IBaseMetadata } from "../src/token/metadata/interfaces/IBaseMetadata.sol";
import { IPropertyIPFSMetadataRenderer } from "../src/token/metadata/interfaces/IPropertyIPFSMetadataRenderer.sol";

contract GetInterfaceIds is Script {
function run() public view {
console2.logBytes4(type(IBaseMetadata).interfaceId);
console2.logBytes4(type(IPropertyIPFSMetadataRenderer).interfaceId);
console2.logBytes4(type(IMirrorToken).interfaceId);
}
}
4 changes: 2 additions & 2 deletions src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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/default/Token.sol";
import { Token } from "../token/Token.sol";
import { IProtocolRewards } from "../lib/interfaces/IProtocolRewards.sol";

import { VersionedContract } from "../VersionedContract.sol";
Expand Down Expand Up @@ -433,9 +433,9 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
/// @param finalBidAmount The final bid amount
/// @param founderRewardBPS The reward to be paid to the founder in BPS
function _computeTotalRewards(uint256 finalBidAmount, uint256 founderRewardBPS) internal view returns (RewardSplits memory split) {
// Cache values from storage
ManagerTypesV2.RewardConfig memory rewardsConfig = manager.getRewardsConfig();

// Cache values from storage
address referralCached = currentBidReferral;
address builderRecipientCached = rewardsConfig.builderRewardRecipient;
uint256 referralBPSCached = rewardsConfig.referralRewardBPS;
Expand Down
2 changes: 1 addition & 1 deletion 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/default/Token.sol";
import { Token } from "../../token/Token.sol";
import { AuctionTypesV1 } from "../types/AuctionTypesV1.sol";

/// @title AuctionStorageV1
Expand Down
8 changes: 4 additions & 4 deletions src/deployers/MigrationDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity 0.8.16;

import { IManager } from "../manager/IManager.sol";
import { IBaseToken } from "../token/interfaces/IBaseToken.sol";
import { IPropertyIPFSMetadataRenderer } from "../metadata/interfaces/IPropertyIPFSMetadataRenderer.sol";
import { IToken } from "../token/IToken.sol";
import { IPropertyIPFSMetadataRenderer } from "../token/metadata/interfaces/IPropertyIPFSMetadataRenderer.sol";
import { MerkleReserveMinter } from "../minters/MerkleReserveMinter.sol";
import { TokenTypesV2 } from "../token/default/types/TokenTypesV2.sol";
import { TokenTypesV2 } from "../token/types/TokenTypesV2.sol";
import { Ownable } from "../lib/utils/Ownable.sol";
import { ICrossDomainMessenger } from "./interfaces/ICrossDomainMessenger.sol";

Expand Down Expand Up @@ -110,7 +110,7 @@ contract MigrationDeployer {
minters[0] = TokenTypesV2.MinterParams({ minter: address(merkleMinter), allowed: true });

// Add new minter
IBaseToken(_token).updateMinters(minters);
IToken(_token).updateMinters(minters);

// Initilize minter with given params
MerkleReserveMinter(merkleMinter).setMintSettings(_token, _minterParams);
Expand Down
2 changes: 1 addition & 1 deletion src/governance/governor/Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EIP712 } from "../../lib/utils/EIP712.sol";
import { SafeCast } from "../../lib/utils/SafeCast.sol";

import { GovernorStorageV1 } from "./storage/GovernorStorageV1.sol";
import { Token } from "../../token/default/Token.sol";
import { Token } from "../../token/Token.sol";
import { Treasury } from "../treasury/Treasury.sol";
import { IManager } from "../../manager/IManager.sol";
import { IGovernor } from "./IGovernor.sol";
Expand Down
2 changes: 1 addition & 1 deletion 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/default/Token.sol";
import { Token } from "../../../token/Token.sol";
import { Treasury } from "../../treasury/Treasury.sol";

/// @title GovernorTypesV1
Expand Down
66 changes: 9 additions & 57 deletions src/lib/token/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import { ERC721TokenReceiver } from "../utils/TokenReceiver.sol";
import { Address } from "../utils/Address.sol";

/// @title ERC721
/// @author Rohan Kulkarni & Neokry
/// @author Rohan Kulkarni
/// @notice Modified from OpenZeppelin Contracts v4.7.3 (token/ERC721/ERC721Upgradeable.sol)
/// - Uses custom errors declared in IERC721
/// - Uses _transfer from Openzepplin Contracts v4.9.3
abstract contract ERC721 is IERC721, Initializable {
/// ///
/// STORAGE ///
Expand Down Expand Up @@ -59,7 +58,7 @@ abstract contract ERC721 is IERC721, Initializable {

/// @notice If the contract implements an interface
/// @param _interfaceId The interface id
function supportsInterface(bytes4 _interfaceId) public pure virtual returns (bool) {
function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
return
_interfaceId == 0x01ffc9a7 || // ERC165 Interface ID
_interfaceId == 0x80ac58cd || // ERC721 Interface ID
Expand All @@ -68,14 +67,14 @@ abstract contract ERC721 is IERC721, Initializable {

/// @notice The account approved to manage a token
/// @param _tokenId The ERC-721 token id
function getApproved(uint256 _tokenId) public view virtual returns (address) {
function getApproved(uint256 _tokenId) external view returns (address) {
return tokenApprovals[_tokenId];
}

/// @notice If an operator is authorized to manage all of an owner's tokens
/// @param _owner The owner address
/// @param _operator The operator address
function isApprovedForAll(address _owner, address _operator) public view virtual returns (bool) {
function isApprovedForAll(address _owner, address _operator) external view returns (bool) {
return operatorApprovals[_owner][_operator];
}

Expand All @@ -100,7 +99,7 @@ abstract contract ERC721 is IERC721, Initializable {
/// @notice Authorizes an account to manage a token
/// @param _to The account address
/// @param _tokenId The ERC-721 token id
function approve(address _to, uint256 _tokenId) public virtual {
function approve(address _to, uint256 _tokenId) external {
address owner = owners[_tokenId];

if (msg.sender != owner && !operatorApprovals[owner][msg.sender]) revert INVALID_APPROVAL();
Expand All @@ -113,7 +112,7 @@ abstract contract ERC721 is IERC721, Initializable {
/// @notice Authorizes an account to manage all tokens
/// @param _operator The account address
/// @param _approved If permission is being given or removed
function setApprovalForAll(address _operator, bool _approved) public virtual {
function setApprovalForAll(address _operator, bool _approved) external {
operatorApprovals[msg.sender][_operator] = _approved;

emit ApprovalForAll(msg.sender, _operator, _approved);
Expand All @@ -127,7 +126,7 @@ abstract contract ERC721 is IERC721, Initializable {
address _from,
address _to,
uint256 _tokenId
) public virtual {
) public {
if (_from != owners[_tokenId]) revert INVALID_OWNER();

if (_to == address(0)) revert ADDRESS_ZERO();
Expand Down Expand Up @@ -159,7 +158,7 @@ abstract contract ERC721 is IERC721, Initializable {
address _from,
address _to,
uint256 _tokenId
) public virtual {
) external {
transferFrom(_from, _to, _tokenId);

if (
Expand All @@ -177,7 +176,7 @@ abstract contract ERC721 is IERC721, Initializable {
address _to,
uint256 _tokenId,
bytes calldata _data
) public virtual {
) external {
transferFrom(_from, _to, _tokenId);

if (
Expand Down Expand Up @@ -207,53 +206,6 @@ abstract contract ERC721 is IERC721, Initializable {
_afterTokenTransfer(address(0), _to, _tokenId);
}

/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
* @param _from The sender address
* @param _to The recipient address
* @param _tokenId The ERC-721 token id
*/
function _transfer(
address _from,
address _to,
uint256 _tokenId
) internal virtual {
if (_from != owners[_tokenId]) revert INVALID_OWNER();

if (_to == address(0)) revert ADDRESS_ZERO();

_beforeTokenTransfer(_from, _to, _tokenId);

// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
if (_from != owners[_tokenId]) revert INVALID_OWNER();

// Clear approvals from the previous owner
delete tokenApprovals[_tokenId];

unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
balances[_from] -= 1;
balances[_to] += 1;
}
owners[_tokenId] = _to;

emit Transfer(_from, _to, _tokenId);

_afterTokenTransfer(_from, _to, _tokenId);
}

/// @dev Burns a token to a recipient
/// @param _tokenId The ERC-721 token id
function _burn(uint256 _tokenId) internal virtual {
Expand Down
Loading

0 comments on commit 5164f20

Please sign in to comment.