refactor: remove mint collection owner requirement (#149)

* refactor: remove mint acl modifier

* test: fix tests for mint owner requirement
This commit is contained in:
Felipe Mendes 2023-03-01 11:31:46 -03:00 committed by GitHub
parent e3a8ae2429
commit b1887765c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 48 deletions

View File

@ -45,7 +45,6 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
event MetadataUpdate(uint256 indexed _tokenId, string key, string[2] value, address indexed triggeredBy);
event MetadataUpdate(uint256 indexed _tokenId, string key, bool value, address indexed triggeredBy);
event NewAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
event RemoveAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
@ -166,7 +165,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
string memory logo,
uint24 color,
bool accessPointAutoApproval
) public payable requirePayment(Billing.Mint) requireCollectionRole(CollectionRoles.Owner) returns (uint256) {
) public payable requirePayment(Billing.Mint) returns (uint256) {
uint256 tokenId = _appIds;
_mint(to, tokenId);
@ -305,7 +304,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
) public virtual requireTokenOwner(tokenId) {
_requireMinted(tokenId);
_apps[tokenId].accessPointAutoApproval = _apAutoApproval;
emit MetadataUpdate(tokenId, 'accessPointAutoApproval', _apAutoApproval, msg.sender);
emit MetadataUpdate(tokenId, "accessPointAutoApproval", _apAutoApproval, msg.sender);
}
/**

View File

@ -127,29 +127,9 @@ contract Test_FleekERC721_AccessControl is Test_FleekERC721_Base, Test_FleekERC7
}
function test_mint() public {
address randomAddress = address(99);
// CollectionOwner
vm.startPrank(collectionOwner);
mintDefault(randomAddress);
vm.stopPrank();
// TokenOwner
vm.startPrank(tokenOwner);
expectRevertWithCollectionRole(FleekAccessControl.CollectionRoles.Owner);
mintDefault(randomAddress);
vm.stopPrank();
// TokenController
vm.startPrank(tokenController);
expectRevertWithCollectionRole(FleekAccessControl.CollectionRoles.Owner);
mintDefault(randomAddress);
vm.stopPrank();
// AnyAddress
// Anyone can mint
vm.startPrank(anyAddress);
expectRevertWithCollectionRole(FleekAccessControl.CollectionRoles.Owner);
mintDefault(randomAddress);
mintDefault(address(99));
vm.stopPrank();
}

View File

@ -26,29 +26,6 @@ describe('FleekERC721.Minting', () => {
expect(response.value.toNumber()).to.equal(0);
});
it('should not be able to mint a new token if not the owner', async () => {
const { otherAccount, contract } = await loadFixture(Fixtures.default);
await expect(
contract
.connect(otherAccount)
.mint(
otherAccount.address,
MintParams.name,
MintParams.description,
MintParams.externalUrl,
MintParams.ens,
MintParams.commitHash,
MintParams.gitRepository,
MintParams.logo,
MintParams.color,
MintParams.accessPointAutoApprovalSettings
)
)
.to.be.revertedWithCustomError(contract, Errors.MustHaveCollectionRole)
.withArgs(CollectionRoles.Owner);
});
it('should have address to as owner', async () => {
const { owner, otherAccount, contract } = await loadFixture(
Fixtures.default