refactor: remove mint collection owner requirement (#149)
* refactor: remove mint acl modifier * test: fix tests for mint owner requirement
This commit is contained in:
parent
e3a8ae2429
commit
b1887765c1
|
|
@ -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, string[2] value, address indexed triggeredBy);
|
||||||
event MetadataUpdate(uint256 indexed _tokenId, string key, bool 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 NewAccessPoint(string apName, uint256 indexed tokenId, address indexed owner);
|
||||||
event RemoveAccessPoint(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,
|
string memory logo,
|
||||||
uint24 color,
|
uint24 color,
|
||||||
bool accessPointAutoApproval
|
bool accessPointAutoApproval
|
||||||
) public payable requirePayment(Billing.Mint) requireCollectionRole(CollectionRoles.Owner) returns (uint256) {
|
) public payable requirePayment(Billing.Mint) returns (uint256) {
|
||||||
uint256 tokenId = _appIds;
|
uint256 tokenId = _appIds;
|
||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
|
|
||||||
|
|
@ -305,7 +304,7 @@ contract FleekERC721 is Initializable, ERC721Upgradeable, FleekAccessControl, Fl
|
||||||
) public virtual requireTokenOwner(tokenId) {
|
) public virtual requireTokenOwner(tokenId) {
|
||||||
_requireMinted(tokenId);
|
_requireMinted(tokenId);
|
||||||
_apps[tokenId].accessPointAutoApproval = _apAutoApproval;
|
_apps[tokenId].accessPointAutoApproval = _apAutoApproval;
|
||||||
emit MetadataUpdate(tokenId, 'accessPointAutoApproval', _apAutoApproval, msg.sender);
|
emit MetadataUpdate(tokenId, "accessPointAutoApproval", _apAutoApproval, msg.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -127,29 +127,9 @@ contract Test_FleekERC721_AccessControl is Test_FleekERC721_Base, Test_FleekERC7
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_mint() public {
|
function test_mint() public {
|
||||||
address randomAddress = address(99);
|
// Anyone can mint
|
||||||
|
|
||||||
// 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
|
|
||||||
vm.startPrank(anyAddress);
|
vm.startPrank(anyAddress);
|
||||||
expectRevertWithCollectionRole(FleekAccessControl.CollectionRoles.Owner);
|
mintDefault(address(99));
|
||||||
mintDefault(randomAddress);
|
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,29 +26,6 @@ describe('FleekERC721.Minting', () => {
|
||||||
expect(response.value.toNumber()).to.equal(0);
|
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 () => {
|
it('should have address to as owner', async () => {
|
||||||
const { owner, otherAccount, contract } = await loadFixture(
|
const { owner, otherAccount, contract } = await loadFixture(
|
||||||
Fixtures.default
|
Fixtures.default
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue