Skip to content

Commit

Permalink
Update AccessControl to Enumerable
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk committed Dec 14, 2023
1 parent a39d583 commit 4cbdf11
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/tokens/ERC1155/utility/sale/ERC1155Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import {ERC1155Supply} from "@0xsequence/contracts-library/tokens/ERC1155/extensions/supply/ERC1155Supply.sol";
import {
WithdrawControlled,
AccessControl,
AccessControlEnumerable,
SafeERC20,
IERC20
} from "@0xsequence/contracts-library/tokens/common/WithdrawControlled.sol";
Expand Down Expand Up @@ -263,7 +263,7 @@ contract ERC1155Sale is IERC1155Sale, WithdrawControlled, MerkleProofSingleUse {
* @param interfaceId Interface id
* @return True if supported
*/
function supportsInterface(bytes4 interfaceId) public view virtual override (AccessControl) returns (bool) {
function supportsInterface(bytes4 interfaceId) public view virtual override (AccessControlEnumerable) returns (bool) {
return type(IERC1155SaleFunctions).interfaceId == interfaceId || super.supportsInterface(interfaceId);
}
}
6 changes: 3 additions & 3 deletions src/tokens/ERC20/ERC20BaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ pragma solidity ^0.8.19;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

error InvalidInitialization();

/**
* A standard base implementation of ERC-20 for use in Sequence library contracts.
*/
abstract contract ERC20BaseToken is ERC20, AccessControl {
abstract contract ERC20BaseToken is ERC20, AccessControlEnumerable {
string internal _tokenName;
string internal _tokenSymbol;
uint8 private _tokenDecimals;
Expand Down Expand Up @@ -71,7 +71,7 @@ abstract contract ERC20BaseToken is ERC20, AccessControl {
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC20).interfaceId || interfaceId == type(IERC20Metadata).interfaceId
|| AccessControl.supportsInterface(interfaceId) || super.supportsInterface(interfaceId);
|| AccessControlEnumerable.supportsInterface(interfaceId) || super.supportsInterface(interfaceId);
}

//
Expand Down
4 changes: 2 additions & 2 deletions src/tokens/ERC721/utility/sale/ERC721Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@0xsequence/contracts-library/tokens/ERC721/utility/sale/IERC721Sale.sol";
import {
WithdrawControlled,
AccessControl,
AccessControlEnumerable,
SafeERC20,
IERC20
} from "@0xsequence/contracts-library/tokens/common/WithdrawControlled.sol";
Expand Down Expand Up @@ -152,7 +152,7 @@ contract ERC721Sale is IERC721Sale, WithdrawControlled, MerkleProofSingleUse {
* @param interfaceId Interface id
* @return True if supported
*/
function supportsInterface(bytes4 interfaceId) public view virtual override (AccessControl) returns (bool) {
function supportsInterface(bytes4 interfaceId) public view virtual override (AccessControlEnumerable) returns (bool) {
return interfaceId == type(IERC721SaleFunctions).interfaceId || super.supportsInterface(interfaceId);
}
}
8 changes: 4 additions & 4 deletions src/tokens/common/ERC2981Controlled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pragma solidity ^0.8.19;

import {IERC2981Controlled} from "@0xsequence/contracts-library/tokens/common/IERC2981Controlled.sol";
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

/**
* An implementation of ERC-2981 that allows updates by roles.
*/
abstract contract ERC2981Controlled is ERC2981, AccessControl, IERC2981Controlled {
abstract contract ERC2981Controlled is ERC2981, AccessControlEnumerable, IERC2981Controlled {
bytes32 internal constant ROYALTY_ADMIN_ROLE = keccak256("ROYALTY_ADMIN_ROLE");

//
Expand Down Expand Up @@ -51,10 +51,10 @@ abstract contract ERC2981Controlled is ERC2981, AccessControl, IERC2981Controlle
public
view
virtual
override (ERC2981, AccessControl)
override (ERC2981, AccessControlEnumerable)
returns (bool)
{
return ERC2981.supportsInterface(interfaceId) || AccessControl.supportsInterface(interfaceId)
return ERC2981.supportsInterface(interfaceId) || AccessControlEnumerable.supportsInterface(interfaceId)
|| type(IERC2981Controlled).interfaceId == interfaceId || super.supportsInterface(interfaceId);
}
}
4 changes: 2 additions & 2 deletions src/tokens/common/WithdrawControlled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pragma solidity ^0.8.19;

import {IWithdrawControlled} from "@0xsequence/contracts-library/tokens/common/IWithdrawControlled.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

/**
* An abstract contract that allows ETH and ERC20 tokens stored in the contract to be withdrawn.
*/
abstract contract WithdrawControlled is AccessControl, IWithdrawControlled {
abstract contract WithdrawControlled is AccessControlEnumerable, IWithdrawControlled {
bytes32 internal constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE");

//
Expand Down
2 changes: 2 additions & 0 deletions test/tokens/ERC1155/presets/ERC1155Items.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ contract ERC1155ItemsTest is TestHelper, IERC1155ItemsSignals {
checkSelectorCollision(0xe8a3d485); // contractURI()
checkSelectorCollision(0x2d0335ab); // getNonce(address)
checkSelectorCollision(0x248a9ca3); // getRoleAdmin(bytes32)
checkSelectorCollision(0x9010d07c); // getRoleMember(bytes32,uint256)
checkSelectorCollision(0xca15c873); // getRoleMemberCount(bytes32)
checkSelectorCollision(0x2f2ff15d); // grantRole(bytes32,address)
checkSelectorCollision(0x91d14854); // hasRole(bytes32,address)
checkSelectorCollision(0xf8954818); // initialize(address,string,string,string,address,uint96)
Expand Down
2 changes: 2 additions & 0 deletions test/tokens/ERC1155/utility/ERC1155Sale.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ contract ERC1155SaleTest is TestHelper, Merkle, IERC1155SaleSignals, IERC1155Sup
checkSelectorCollision(0xa217fddf); // DEFAULT_ADMIN_ROLE()
checkSelectorCollision(0xf8e4dec5); // checkMerkleProof(bytes32,bytes32[],address)
checkSelectorCollision(0x248a9ca3); // getRoleAdmin(bytes32)
checkSelectorCollision(0x9010d07c); // getRoleMember(bytes32,uint256)
checkSelectorCollision(0xca15c873); // getRoleMemberCount(bytes32)
checkSelectorCollision(0x119cd50c); // globalSaleDetails()
checkSelectorCollision(0x2f2ff15d); // grantRole(bytes32,address)
checkSelectorCollision(0x91d14854); // hasRole(bytes32,address)
Expand Down
2 changes: 2 additions & 0 deletions test/tokens/ERC20/ERC20Items.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ contract ERC20ItemsTest is TestHelper, IERC20ItemsSignals {
checkSelectorCollision(0x313ce567); // decimals()
checkSelectorCollision(0xa457c2d7); // decreaseAllowance(address,uint256)
checkSelectorCollision(0x248a9ca3); // getRoleAdmin(bytes32)
checkSelectorCollision(0x9010d07c); // getRoleMember(bytes32,uint256)
checkSelectorCollision(0xca15c873); // getRoleMemberCount(bytes32)
checkSelectorCollision(0x2f2ff15d); // grantRole(bytes32,address)
checkSelectorCollision(0x91d14854); // hasRole(bytes32,address)
checkSelectorCollision(0x39509351); // increaseAllowance(address,uint256)
Expand Down
2 changes: 2 additions & 0 deletions test/tokens/ERC721/presets/ERC721Items.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ contract ERC721ItemsTest is TestHelper, IERC721ItemsSignals {
checkSelectorCollision(0x5bbb2177); // explicitOwnershipsOf(uint256[])
checkSelectorCollision(0x081812fc); // getApproved(uint256)
checkSelectorCollision(0x248a9ca3); // getRoleAdmin(bytes32)
checkSelectorCollision(0x9010d07c); // getRoleMember(bytes32,uint256)
checkSelectorCollision(0xca15c873); // getRoleMemberCount(bytes32)
checkSelectorCollision(0x2f2ff15d); // grantRole(bytes32,address)
checkSelectorCollision(0x91d14854); // hasRole(bytes32,address)
checkSelectorCollision(0x98dd69c8); // initialize(address,string,string,string,string,address,uint96)
Expand Down
2 changes: 2 additions & 0 deletions test/tokens/ERC721/utility/ERC721Sale.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ contract ERC721SaleTest is TestHelper, Merkle, IERC721SaleSignals, IMerkleProofS
checkSelectorCollision(0xa217fddf); // DEFAULT_ADMIN_ROLE()
checkSelectorCollision(0xf8e4dec5); // checkMerkleProof(bytes32,bytes32[],address)
checkSelectorCollision(0x248a9ca3); // getRoleAdmin(bytes32)
checkSelectorCollision(0x9010d07c); // getRoleMember(bytes32,uint256)
checkSelectorCollision(0xca15c873); // getRoleMemberCount(bytes32)
checkSelectorCollision(0x2f2ff15d); // grantRole(bytes32,address)
checkSelectorCollision(0x91d14854); // hasRole(bytes32,address)
checkSelectorCollision(0x485cc955); // initialize(address,address)
Expand Down

0 comments on commit 4cbdf11

Please sign in to comment.