Skip to content

Commit

Permalink
cleanup + remappings
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeyfuss committed Dec 26, 2023
1 parent 3934799 commit 40b6df9
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compiler_test:
forge test --use 0.8.22

quick_test:
forge test --fuzz-runs 512
forge test

gas_test:
forge test --gas-report
Expand Down
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ optimizer = true
optimizer_runs = 20000
verbosity = 3
wrap_comments = true
fs_permissions = [{ access = "read", path = "./"}]
fs_permissions = [{ access = "read", path = "./"}]

[fuzz]
runs = 1024
12 changes: 12 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@manifoldxyz/libraries-solidity/=lib/royalty-registry-solidity/lib/libraries-solidity/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
create2-helpers/=lib/royalty-registry-solidity/lib/create2-helpers/
create2-scripts/=lib/royalty-registry-solidity/lib/create2-helpers/script/
ds-test/=lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
libraries-solidity/=lib/royalty-registry-solidity/lib/libraries-solidity/contracts/
openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
openzeppelin/=lib/openzeppelin-contracts/contracts/
royalty-registry-solidity/=lib/royalty-registry-solidity/contracts/
4 changes: 2 additions & 2 deletions src/access/OwnableAccessControl.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {EnumerableSet} from "lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol";
import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import {Ownable} from "openzeppelin/access/Ownable.sol";
import {EnumerableSet} from "openzeppelin/utils/structs/EnumerableSet.sol";

/// @title OwnableAccessControl.sol
/// @notice Single owner, flexible access control mechanics
Expand Down
2 changes: 1 addition & 1 deletion src/payments/IWETH.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";

interface IWETH is IERC20 {
function deposit() external payable;
Expand Down
4 changes: 2 additions & 2 deletions src/payments/RoyaltyPayoutHelper.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {TransferHelper} from "src/payments/TransferHelper.sol";
import {IRoyaltyEngineV1} from "royalty-registry-solidity/IRoyaltyEngineV1.sol";
import {SanctionsCompliance} from "src/payments/SanctionsCompliance.sol";
import {IRoyaltyEngineV1} from "lib/royalty-registry-solidity/contracts/IRoyaltyEngineV1.sol";
import {TransferHelper} from "src/payments/TransferHelper.sol";

/// @title Royalty Payout Helper
/// @notice Abstract contract to help payout royalties using the Royalty Registry
Expand Down
2 changes: 1 addition & 1 deletion src/payments/TransferHelper.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {SafeERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {IWETH, IERC20} from "src/payments/IWETH.sol";

/// @title Transfer Helper
Expand Down
4 changes: 2 additions & 2 deletions src/royalties/EIP2981TL.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC165} from "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol";
import {ERC165} from "openzeppelin/utils/introspection/ERC165.sol";
import {IEIP2981} from "src/royalties/IEIP2981.sol";

/// @title EIP2981TL.sol
Expand All @@ -12,7 +12,7 @@ import {IEIP2981} from "src/royalties/IEIP2981.sol";
/// @custom:version 3.0.0
abstract contract EIP2981TL is IEIP2981, ERC165 {
/*//////////////////////////////////////////////////////////////////////////
Royalty Struct
Types
//////////////////////////////////////////////////////////////////////////*/

struct RoyaltySpec {
Expand Down
11 changes: 5 additions & 6 deletions src/upgradeable/access/OwnableAccessControlUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {EnumerableSet} from "lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol";
import {OwnableUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol";
import {OwnableUpgradeable} from "openzeppelin-upgradeable/access/OwnableUpgradeable.sol";
import {EnumerableSet} from "openzeppelin/utils/structs/EnumerableSet.sol";

/// @title OwnableAccessControlUpgradeable.sol
/// @notice Single owner, flexible access control mechanics
Expand All @@ -12,8 +11,7 @@ import {OwnableUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contrac
/// may allow other roles to grant roles by using the internal helper.
/// @author transientlabs.xyz
/// @custom:version 3.0.0
abstract contract OwnableAccessControlUpgradeable is Initializable, OwnableUpgradeable {

abstract contract OwnableAccessControlUpgradeable is OwnableUpgradeable {
/*//////////////////////////////////////////////////////////////////////////
Types
//////////////////////////////////////////////////////////////////////////*/
Expand All @@ -32,7 +30,8 @@ abstract contract OwnableAccessControlUpgradeable is Initializable, OwnableUpgra
}

// keccak256(abi.encode(uint256(keccak256("transientlabs.storage.OwnableAccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableAccessControlStorageLocation = 0x0d0469b3d32e63681b9fc586a5627ad5e70b3d1ad20f31767e4b6c4141c7e300;
bytes32 private constant OwnableAccessControlStorageLocation =
0x0d0469b3d32e63681b9fc586a5627ad5e70b3d1ad20f31767e4b6c4141c7e300;

function _getOwnableAccessControlStorage() private pure returns (OwnableAccessControlStorage storage $) {
assembly {
Expand Down
8 changes: 4 additions & 4 deletions src/upgradeable/payments/RoyaltyPayoutHelperUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {IRoyaltyEngineV1} from "royalty-registry-solidity/IRoyaltyEngineV1.sol";
import {TransferHelper} from "src/payments/TransferHelper.sol";
import {SanctionsComplianceUpgradeable} from "src/upgradeable/payments/SanctionsComplianceUpgradeable.sol";
import {IRoyaltyEngineV1} from "lib/royalty-registry-solidity/contracts/IRoyaltyEngineV1.sol";

/// @title Royalty Payout Helper
/// @notice Abstract contract to help payout royalties using the Royalty Registry
/// @dev Does not manage updating the sanctions oracle and expects the child contract to implement
/// @author transientlabs.xyz
/// @custom:version 3.0.0
abstract contract RoyaltyPayoutHelperUpgradeable is Initializable, TransferHelper, SanctionsComplianceUpgradeable {
abstract contract RoyaltyPayoutHelperUpgradeable is SanctionsComplianceUpgradeable, TransferHelper {
/*//////////////////////////////////////////////////////////////////////////
Storage
//////////////////////////////////////////////////////////////////////////*/
Expand All @@ -23,7 +22,8 @@ abstract contract RoyaltyPayoutHelperUpgradeable is Initializable, TransferHelpe
}

// keccak256(abi.encode(uint256(keccak256("transientlabs.storage.RoyaltyPayoutHelper")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant RoyaltyPayoutHelperStorageLocation = 0x9ab1d1ca9bfa2c669468b724939724262b3f2887db3df18c90168701d6422700;
bytes32 private constant RoyaltyPayoutHelperStorageLocation =
0x9ab1d1ca9bfa2c669468b724939724262b3f2887db3df18c90168701d6422700;

function _getRoyaltyPayoutHelperStorage() private pure returns (RoyaltyPayoutHelperStorage storage $) {
assembly {
Expand Down
7 changes: 4 additions & 3 deletions src/upgradeable/payments/SanctionsComplianceUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {Initializable} from "openzeppelin-upgradeable/proxy/utils/Initializable.sol";
import {IChainalysisSanctionsOracle} from "src/payments/IChainalysisSanctionsOracle.sol";

/// @title Sanctions Compliance
Expand All @@ -20,7 +20,8 @@ contract SanctionsComplianceUpgradeable is Initializable {
}

// keccak256(abi.encode(uint256(keccak256("transientlabs.storage.SanctionsCompliance")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant SanctionComplianceStorageLocation = 0xd66684c5a7747baca4a45cbf84c01526f3b53186fc4aea64a4c6e2fa4447c700;
bytes32 private constant SanctionComplianceStorageLocation =
0xd66684c5a7747baca4a45cbf84c01526f3b53186fc4aea64a4c6e2fa4447c700;

function _getSanctionsComplianceStorage() private pure returns (SanctionComplianceStorage storage $) {
assembly {
Expand Down Expand Up @@ -91,7 +92,7 @@ contract SanctionsComplianceUpgradeable is Initializable {
//////////////////////////////////////////////////////////////////////////*/

/// @notice Function to get chainalysis oracle
function oracle() public view returns(IChainalysisSanctionsOracle) {
function oracle() public view returns (IChainalysisSanctionsOracle) {
SanctionComplianceStorage storage $ = _getSanctionsComplianceStorage();
return $.oracle;
}
Expand Down
9 changes: 4 additions & 5 deletions src/upgradeable/royalties/EIP2981TLUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {ERC165Upgradeable} from
"lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol";
import {ERC165Upgradeable} from "openzeppelin-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import {IEIP2981} from "src/royalties/IEIP2981.sol";

/// @title EIP2981TLUpgradeable.sol
Expand All @@ -12,7 +10,7 @@ import {IEIP2981} from "src/royalties/IEIP2981.sol";
/// @dev Follows EIP-2981 (https://eips.ethereum.org/EIPS/eip-2981)
/// @author transientlabs.xyz
/// @custom:version 3.0.0
abstract contract EIP2981TLUpgradeable is IEIP2981, Initializable, ERC165Upgradeable {
abstract contract EIP2981TLUpgradeable is IEIP2981, ERC165Upgradeable {
/*//////////////////////////////////////////////////////////////////////////
Types
//////////////////////////////////////////////////////////////////////////*/
Expand All @@ -34,7 +32,8 @@ abstract contract EIP2981TLUpgradeable is IEIP2981, Initializable, ERC165Upgrade
}

// keccak256(abi.encode(uint256(keccak256("transientlabs.storage.EIP2981TLStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant EIP2981TLStorageLocation = 0xe9db8e9b56f2e28e12956850f386d9a4c1e886a4f584b61a10a9d0cacee70700;
bytes32 private constant EIP2981TLStorageLocation =
0xe9db8e9b56f2e28e12956850f386d9a4c1e886a4f584b61a10a9d0cacee70700;

function _getEIP2981TLStorage() private pure returns (EIP2981TLStorage storage $) {
assembly {
Expand Down
2 changes: 1 addition & 1 deletion test/payments/RoyaltyPayoutHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pragma solidity ^0.8.20;

import "forge-std/Test.sol";
import {Strings} from "openzeppelin/utils/Strings.sol";
import {Receiver, RevertingReceiver} from "test/utils/Receivers.sol";
import {WETH9} from "test/utils/WETH9.sol";
import {MockERC20, MockERC20WithFee} from "test/utils/MockERC20.sol";
import {RoyaltyPayoutHelper, IRoyaltyEngineV1} from "src/payments/RoyaltyPayoutHelper.sol";
import {IChainalysisSanctionsOracle} from "src/payments/IChainalysisSanctionsOracle.sol";
import {Strings} from "lib/openzeppelin-contracts/contracts/utils/Strings.sol";

contract ExternalRoyaltyPayoutHelper is RoyaltyPayoutHelper {
constructor(address sanctionsAddress, address wethAddress, address royaltyEngineAddress)
Expand Down
2 changes: 1 addition & 1 deletion test/payments/TransferHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity ^0.8.20;

import "forge-std/Test.sol";
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {Receiver, RevertingReceiver, GriefingReceiver} from "test/utils/Receivers.sol";
import {WETH9} from "test/utils/WETH9.sol";
import {MockERC20, MockERC20WithFee} from "test/utils/MockERC20.sol";
import {TransferHelper} from "src/payments/TransferHelper.sol";
import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";

contract ExternalTransferHelper is TransferHelper {
function safeTransferETH(address recipient, uint256 amount, address weth) external {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.20;

import "forge-std/Test.sol";
import {Strings} from "openzeppelin/utils/Strings.sol";
import {Receiver, RevertingReceiver} from "test/utils/Receivers.sol";
import {WETH9} from "test/utils/WETH9.sol";
import {MockERC20, MockERC20WithFee} from "test/utils/MockERC20.sol";
Expand All @@ -10,10 +11,8 @@ import {
IRoyaltyEngineV1
} from "src/upgradeable/payments/RoyaltyPayoutHelperUpgradeable.sol";
import {IChainalysisSanctionsOracle} from "src/payments/IChainalysisSanctionsOracle.sol";
import {Strings} from "lib/openzeppelin-contracts/contracts/utils/Strings.sol";
import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";

contract ExternalRoyaltyPayoutHelper is Initializable, RoyaltyPayoutHelperUpgradeable {
contract ExternalRoyaltyPayoutHelper is RoyaltyPayoutHelperUpgradeable {
function initialize(address sanctionsOracle, address wethAddress, address royaltyEngineAddress)
external
initializer
Expand Down
3 changes: 1 addition & 2 deletions test/utils/MockEIP2981TLUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {EIP2981TLUpgradeable} from "src/upgradeable/royalties/EIP2981TLUpgradeable.sol";

/// @dev this contract does not have proper access control but is only for testing

contract MockEIP2981TLUpgradeable is Initializable, EIP2981TLUpgradeable {
contract MockEIP2981TLUpgradeable is EIP2981TLUpgradeable {
function initialize(address recipient, uint256 percentage) external initializer {
__EIP2981TL_init(recipient, percentage);
}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/MockERC20.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {ERC20} from "openzeppelin/token/ERC20/ERC20.sol";

contract MockERC20 is ERC20 {
constructor(address mintReceiver) ERC20("Test Token", "TEST") {
Expand Down
3 changes: 1 addition & 2 deletions test/utils/MockOwnableAccessControlUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {OwnableAccessControlUpgradeable} from "src/upgradeable/access/OwnableAccessControlUpgradeable.sol";

contract MockOwnableAccessControlUpgradeable is Initializable, OwnableAccessControlUpgradeable {
contract MockOwnableAccessControlUpgradeable is OwnableAccessControlUpgradeable {
uint256 public number;
bytes32 public ADMIN_ROLE = keccak256("ADMIN");
bytes32 public MINTER_ROLE = keccak256("MINTER");
Expand Down

0 comments on commit 40b6df9

Please sign in to comment.