From ce5e4b82fe84a552291357253474586ccdb9920f Mon Sep 17 00:00:00 2001 From: cxkoda Date: Mon, 26 Jun 2023 09:48:22 -0700 Subject: [PATCH 1/3] CHange access control on to make it compatible with ERC721ACommon --- contracts/sales/FixedPriceSeller.sol | 2 +- contracts/sales/LinearDutchAuction.sol | 6 ++++-- contracts/sales/Seller.sol | 30 ++++++++++++++------------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/contracts/sales/FixedPriceSeller.sol b/contracts/sales/FixedPriceSeller.sol index 102c029..cdbfb22 100644 --- a/contracts/sales/FixedPriceSeller.sol +++ b/contracts/sales/FixedPriceSeller.sol @@ -22,7 +22,7 @@ abstract contract FixedPriceSeller is Seller { uint256 public price; /// @notice Sets the per-item price. - function setPrice(uint256 _price) public onlyOwner { + function setPrice(uint256 _price) public onlyRole(DEFAULT_STEERING_ROLE) { price = _price; } diff --git a/contracts/sales/LinearDutchAuction.sol b/contracts/sales/LinearDutchAuction.sol index fdd7e5a..2338a6c 100644 --- a/contracts/sales/LinearDutchAuction.sol +++ b/contracts/sales/LinearDutchAuction.sol @@ -72,7 +72,7 @@ abstract contract LinearDutchAuction is Seller { function setAuctionConfig( DutchAuctionConfig memory config, uint256 expectedReserve - ) public onlyOwner { + ) public onlyRole(DEFAULT_STEERING_ROLE) { // Underflow might occur is size/num decreases is too large. unchecked { require( @@ -98,7 +98,9 @@ abstract contract LinearDutchAuction is Seller { @dev The auction can be toggle on and off with this function, without the cost of having to update the entire config. */ - function setAuctionStartPoint(uint256 startPoint) public onlyOwner { + function setAuctionStartPoint( + uint256 startPoint + ) public onlyRole(DEFAULT_STEERING_ROLE) { dutchAuctionConfig.startPoint = startPoint; } diff --git a/contracts/sales/Seller.sol b/contracts/sales/Seller.sol index cea77f0..65061f1 100644 --- a/contracts/sales/Seller.sol +++ b/contracts/sales/Seller.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0 <0.9.0; import "../utils/Monotonic.sol"; -import "../utils/OwnerPausable.sol"; +import "../utils/AccessControlPausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; @@ -15,7 +15,7 @@ import "@openzeppelin/contracts/utils/Strings.sol"; - Enforce per-wallet / per-transaction limits - Calculate required cost, forwarding to a beneficiary, and refunding extra */ -abstract contract Seller is OwnerPausable, ReentrancyGuard { +abstract contract Seller is AccessControlPausable, ReentrancyGuard { using Address for address payable; using Monotonic for Monotonic.Increaser; using Strings for uint256; @@ -53,7 +53,9 @@ abstract contract Seller is OwnerPausable, ReentrancyGuard { SellerConfig public sellerConfig; /// @notice Sets the seller config. - function setSellerConfig(SellerConfig memory config) public onlyOwner { + function setSellerConfig( + SellerConfig memory config + ) public onlyRole(DEFAULT_STEERING_ROLE) { require( config.totalInventory >= config.freeQuota, "Seller: excessive free quota" @@ -85,7 +87,9 @@ abstract contract Seller is OwnerPausable, ReentrancyGuard { address payable public beneficiary; /// @notice Sets the recipient of revenues. - function setBeneficiary(address payable _beneficiary) public onlyOwner { + function setBeneficiary( + address payable _beneficiary + ) public onlyRole(DEFAULT_STEERING_ROLE) { beneficiary = _beneficiary; } @@ -99,11 +103,10 @@ abstract contract Seller is OwnerPausable, ReentrancyGuard { bytes as this allows simple passing of a set cost (see ArbitraryPriceSeller). */ - function cost(uint256 n, uint256 metadata) - public - view - virtual - returns (uint256); + function cost( + uint256 n, + uint256 metadata + ) public view virtual returns (uint256); /** @dev Called by both _purchase() and purchaseFreeOfCharge() after all limits @@ -177,11 +180,10 @@ abstract contract Seller is OwnerPausable, ReentrancyGuard { @notice Allows the contract owner to purchase without payment, within the quota enforced by the SellerConfig. */ - function purchaseFreeOfCharge(address to, uint256 n) - public - onlyOwner - whenNotPaused - { + function purchaseFreeOfCharge( + address to, + uint256 n + ) public onlyRole(DEFAULT_STEERING_ROLE) whenNotPaused { /** * ##### CHECKS */ From d5df87e87ff959b27187419a727012a4202832e2 Mon Sep 17 00:00:00 2001 From: cxkoda Date: Mon, 26 Jun 2023 09:49:09 -0700 Subject: [PATCH 2/3] Make (un)pausing virtual --- contracts/utils/AccessControlPausable.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/utils/AccessControlPausable.sol b/contracts/utils/AccessControlPausable.sol index 5e8028d..cc761bb 100644 --- a/contracts/utils/AccessControlPausable.sol +++ b/contracts/utils/AccessControlPausable.sol @@ -9,12 +9,12 @@ import {AccessControlEnumerable} from "./AccessControlEnumerable.sol"; /// STEERING role. contract AccessControlPausable is AccessControlEnumerable, Pausable { /// @notice Pauses the contract. - function pause() public onlyRole(DEFAULT_STEERING_ROLE) { + function pause() public virtual onlyRole(DEFAULT_STEERING_ROLE) { Pausable._pause(); } /// @notice Unpauses the contract. - function unpause() public onlyRole(DEFAULT_STEERING_ROLE) { + function unpause() public virtual onlyRole(DEFAULT_STEERING_ROLE) { Pausable._unpause(); } } From 0b02ac09543e9a03fdd82d5f26dfc4048cb5deea Mon Sep 17 00:00:00 2001 From: cxkoda Date: Mon, 26 Jun 2023 14:52:54 -0700 Subject: [PATCH 3/3] fmt --- contracts/sales/LinearDutchAuction.sol | 7 +++--- contracts/sales/Seller.sol | 32 +++++++++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/contracts/sales/LinearDutchAuction.sol b/contracts/sales/LinearDutchAuction.sol index 2338a6c..f60fcd7 100644 --- a/contracts/sales/LinearDutchAuction.sol +++ b/contracts/sales/LinearDutchAuction.sol @@ -98,9 +98,10 @@ abstract contract LinearDutchAuction is Seller { @dev The auction can be toggle on and off with this function, without the cost of having to update the entire config. */ - function setAuctionStartPoint( - uint256 startPoint - ) public onlyRole(DEFAULT_STEERING_ROLE) { + function setAuctionStartPoint(uint256 startPoint) + public + onlyRole(DEFAULT_STEERING_ROLE) + { dutchAuctionConfig.startPoint = startPoint; } diff --git a/contracts/sales/Seller.sol b/contracts/sales/Seller.sol index 65061f1..f8c4322 100644 --- a/contracts/sales/Seller.sol +++ b/contracts/sales/Seller.sol @@ -53,9 +53,10 @@ abstract contract Seller is AccessControlPausable, ReentrancyGuard { SellerConfig public sellerConfig; /// @notice Sets the seller config. - function setSellerConfig( - SellerConfig memory config - ) public onlyRole(DEFAULT_STEERING_ROLE) { + function setSellerConfig(SellerConfig memory config) + public + onlyRole(DEFAULT_STEERING_ROLE) + { require( config.totalInventory >= config.freeQuota, "Seller: excessive free quota" @@ -87,9 +88,10 @@ abstract contract Seller is AccessControlPausable, ReentrancyGuard { address payable public beneficiary; /// @notice Sets the recipient of revenues. - function setBeneficiary( - address payable _beneficiary - ) public onlyRole(DEFAULT_STEERING_ROLE) { + function setBeneficiary(address payable _beneficiary) + public + onlyRole(DEFAULT_STEERING_ROLE) + { beneficiary = _beneficiary; } @@ -103,10 +105,11 @@ abstract contract Seller is AccessControlPausable, ReentrancyGuard { bytes as this allows simple passing of a set cost (see ArbitraryPriceSeller). */ - function cost( - uint256 n, - uint256 metadata - ) public view virtual returns (uint256); + function cost(uint256 n, uint256 metadata) + public + view + virtual + returns (uint256); /** @dev Called by both _purchase() and purchaseFreeOfCharge() after all limits @@ -180,10 +183,11 @@ abstract contract Seller is AccessControlPausable, ReentrancyGuard { @notice Allows the contract owner to purchase without payment, within the quota enforced by the SellerConfig. */ - function purchaseFreeOfCharge( - address to, - uint256 n - ) public onlyRole(DEFAULT_STEERING_ROLE) whenNotPaused { + function purchaseFreeOfCharge(address to, uint256 n) + public + onlyRole(DEFAULT_STEERING_ROLE) + whenNotPaused + { /** * ##### CHECKS */