From 54f665b5720c87295d115631a9ac6d4ebf68ae3d Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Thu, 15 Dec 2022 21:40:57 +0330 Subject: [PATCH] fix --- contracts/FleekERC721.sol | 63 ++- test/foundry/apps.t.sol | 848 ++++++++++++++++++++++---------------- 2 files changed, 536 insertions(+), 375 deletions(-) diff --git a/contracts/FleekERC721.sol b/contracts/FleekERC721.sol index 1013a3b..f8e7cc8 100644 --- a/contracts/FleekERC721.sol +++ b/contracts/FleekERC721.sol @@ -13,9 +13,15 @@ contract FleekERC721 is ERC721, FleekAccessControl { event NewBuild(uint256 indexed token, string indexed commit_hash); event NewTokenName(uint256 indexed token, string indexed name); - event NewTokenDescription(uint256 indexed token, string indexed description); + event NewTokenDescription( + uint256 indexed token, + string indexed description + ); event NewTokenImage(uint256 indexed token, string indexed image); - event NewTokenExternalURL(uint256 indexed token, string indexed external_url); + event NewTokenExternalURL( + uint256 indexed token, + string indexed external_url + ); event NewTokenENS(uint256 indexed token, string indexed ENS); struct Build { @@ -63,7 +69,7 @@ contract FleekERC721 is ERC721, FleekAccessControl { string memory ENS, string memory commit_hash, string memory git_repository - ) public payable requireCollectionOwner returns (uint256) { + ) public payable requireCollectionRole(Roles.Owner) returns (uint256) { uint256 tokenId = _tokenIds.current(); _mint(to, tokenId); _tokenIds.increment(); @@ -90,19 +96,37 @@ contract FleekERC721 is ERC721, FleekAccessControl { App storage app = _apps[tokenId]; bytes memory dataURI = abi.encodePacked( - '{', - '"name":"', app.name, '",', - '"description":"', app.description, '",', - '"owner":"', Strings.toHexString(uint160(owner), 20), '",', - '"external_url":"', app.external_url, '",', - '"image":"', app.image, '",', - '"attributes": [', - '{"trait_type": "ENS", "value":"', app.ENS,'"},', - '{"trait_type": "Commit Hash", "value":"', app.builds[app.current_build].commit_hash,'"},', - '{"trait_type": "Repository", "value":"', app.builds[app.current_build].git_repository,'"},', - '{"trait_type": "Version", "value":"', Strings.toString(app.current_build),'"}', - ']', - '}' + "{", + '"name":"', + app.name, + '",', + '"description":"', + app.description, + '",', + '"owner":"', + Strings.toHexString(uint160(owner), 20), + '",', + '"external_url":"', + app.external_url, + '",', + '"image":"', + app.image, + '",', + '"attributes": [', + '{"trait_type": "ENS", "value":"', + app.ENS, + '"},', + '{"trait_type": "Commit Hash", "value":"', + app.builds[app.current_build].commit_hash, + '"},', + '{"trait_type": "Repository", "value":"', + app.builds[app.current_build].git_repository, + '"},', + '{"trait_type": "Version", "value":"', + Strings.toString(app.current_build), + '"}', + "]", + "}" ); return string(abi.encodePacked(_baseURI(), Base64.encode((dataURI)))); @@ -191,9 +215,12 @@ contract FleekERC721 is ERC721, FleekAccessControl { uint256 tokenId, string memory _commit_hash, string memory _git_repository - ) public virtual requireTokenController(tokenId) { + ) public virtual requireTokenRole(tokenId, Roles.Controller) { _requireMinted(tokenId); - _apps[tokenId].builds[++_apps[tokenId].current_build] = Build(_commit_hash, _git_repository); + _apps[tokenId].builds[++_apps[tokenId].current_build] = Build( + _commit_hash, + _git_repository + ); emit NewBuild(tokenId, _commit_hash); } diff --git a/test/foundry/apps.t.sol b/test/foundry/apps.t.sol index 599ad20..8575949 100644 --- a/test/foundry/apps.t.sol +++ b/test/foundry/apps.t.sol @@ -1,33 +1,34 @@ pragma solidity ^0.8.7; import "forge-std/Test.sol"; -import "../../contracts/FleekERC721.sol"; +import "../../contracts/FleekERC721.sol"; contract FleekTest is Test { FleekERC721 fleekContract; address constant DEPLOYER = 0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496; + function setUp() public { - fleekContract = new FleekERC721('Test Contract', 'FLKAPS'); + fleekContract = new FleekERC721("Test Contract", "FLKAPS"); } function testName() public { - assertEq(fleekContract.name(), 'Test Contract'); + assertEq(fleekContract.name(), "Test Contract"); } function testSymbol() public { - assertEq(fleekContract.symbol(), 'FLKAPS'); + assertEq(fleekContract.symbol(), "FLKAPS"); } function testMint() public { uint256 mint = fleekContract.mint( - DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + DEPLOYER, + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); @@ -37,24 +38,24 @@ contract FleekTest is Test { function testMintingMintedToken() public { uint256 first_mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); uint256 second_mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(first_mint, 0); @@ -64,26 +65,26 @@ contract FleekTest is Test { function testMintingMoreThanOneTokenForTheSameAddress() public { uint256 first_mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(first_mint, 0); uint256 second_mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App 2', - 'This is a test application submitted by foundry tests [2].', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App 2", + "This is a test application submitted by foundry tests [2].", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(second_mint, 1); @@ -92,26 +93,26 @@ contract FleekTest is Test { function testMintingTwoTokensForTwoAddresses() public { uint256 first_mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(first_mint, 0); uint256 second_mint = fleekContract.mint( address(12), - 'Foundry Test App 2', - 'This is a test application submitted by foundry tests[2].', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App 2", + "This is a test application submitted by foundry tests[2].", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(second_mint, 1); @@ -119,14 +120,14 @@ contract FleekTest is Test { function testTokenURI() public { uint256 mint = fleekContract.mint( - DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + DEPLOYER, + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); @@ -134,140 +135,196 @@ contract FleekTest is Test { string memory tokenURI = fleekContract.tokenURI(mint); bytes memory dataURI = abi.encodePacked( - '{', - '"name":"Foundry Test App",', - '"description":"This is a test application submitted by foundry tests.",', - '"owner":"',Strings.toHexString(uint160(DEPLOYER), 20),'",', - '"external_url":"https://fleek.xyz",', - '"image":"https://fleek.xyz",', - '"attributes": [', - '{"trait_type": "ENS", "value":"fleek_xyz"},', - '{"trait_type": "Commit Hash", "value":"afff3f6"},', - '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},', - '{"trait_type": "Version", "value":"0"}', - ']', - '}' + "{", + '"name":"Foundry Test App",', + '"description":"This is a test application submitted by foundry tests.",', + '"owner":"', + Strings.toHexString(uint160(DEPLOYER), 20), + '",', + '"external_url":"https://fleek.xyz",', + '"image":"https://fleek.xyz",', + '"attributes": [', + '{"trait_type": "ENS", "value":"fleek_xyz"},', + '{"trait_type": "Commit Hash", "value":"afff3f6"},', + '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},', + '{"trait_type": "Version", "value":"0"}', + "]", + "}" ); - assertEq(tokenURI, string(abi.encodePacked("data:application/json;base64,", Base64.encode((dataURI))))); + assertEq( + tokenURI, + string( + abi.encodePacked( + "data:application/json;base64,", + Base64.encode((dataURI)) + ) + ) + ); } function testCallingTokenURIAfterChangingAllPossibleFields() public { uint256 mint = fleekContract.mint( - DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + DEPLOYER, + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenName(mint, 'Foundry Test App 2'); - fleekContract.setTokenDescription(mint, 'This is a test application submitted by foundry tests. 2'); - fleekContract.setTokenImage(mint, 'https://fleek2.xyz'); - fleekContract.setTokenExternalURL(mint, 'https://fleek2.xyz'); - fleekContract.setTokenENS(mint, 'fleek_xyz2'); - fleekContract.setTokenBuild(mint, 'afff3f62', 'https://github.com/fleekxyz/contracts2'); + fleekContract.setTokenName(mint, "Foundry Test App 2"); + fleekContract.setTokenDescription( + mint, + "This is a test application submitted by foundry tests. 2" + ); + fleekContract.setTokenImage(mint, "https://fleek2.xyz"); + fleekContract.setTokenExternalURL(mint, "https://fleek2.xyz"); + fleekContract.setTokenENS(mint, "fleek_xyz2"); + fleekContract.setTokenBuild( + mint, + "afff3f62", + "https://github.com/fleekxyz/contracts2" + ); string memory tokenURI = fleekContract.tokenURI(mint); bytes memory dataURI = abi.encodePacked( - '{', - '"name":"Foundry Test App 2",', - '"description":"This is a test application submitted by foundry tests. 2",', - '"owner":"',Strings.toHexString(uint160(DEPLOYER), 20),'",', - '"external_url":"https://fleek2.xyz",', - '"image":"https://fleek2.xyz",', - '"attributes": [', - '{"trait_type": "ENS", "value":"fleek_xyz2"},', - '{"trait_type": "Commit Hash", "value":"afff3f62"},', - '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},', - '{"trait_type": "Version", "value":"1"}', - ']', - '}' + "{", + '"name":"Foundry Test App 2",', + '"description":"This is a test application submitted by foundry tests. 2",', + '"owner":"', + Strings.toHexString(uint160(DEPLOYER), 20), + '",', + '"external_url":"https://fleek2.xyz",', + '"image":"https://fleek2.xyz",', + '"attributes": [', + '{"trait_type": "ENS", "value":"fleek_xyz2"},', + '{"trait_type": "Commit Hash", "value":"afff3f62"},', + '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},', + '{"trait_type": "Version", "value":"1"}', + "]", + "}" ); - assertEq(tokenURI, string(abi.encodePacked("data:application/json;base64,", Base64.encode((dataURI))))); + assertEq( + tokenURI, + string( + abi.encodePacked( + "data:application/json;base64,", + Base64.encode((dataURI)) + ) + ) + ); } -function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess() public { + function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess() + public + { uint256 mint = fleekContract.mint( - DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + DEPLOYER, + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenName(mint, 'Foundry Test App 2'); - fleekContract.setTokenDescription(mint, 'This is a test application submitted by foundry tests. 2'); - fleekContract.setTokenImage(mint, 'https://fleek2.xyz'); - fleekContract.setTokenExternalURL(mint, 'https://fleek2.xyz'); - fleekContract.setTokenENS(mint, 'fleek_xyz2'); - fleekContract.setTokenBuild(mint, 'afff3f62', 'https://github.com/fleekxyz/contracts2'); + fleekContract.setTokenName(mint, "Foundry Test App 2"); + fleekContract.setTokenDescription( + mint, + "This is a test application submitted by foundry tests. 2" + ); + fleekContract.setTokenImage(mint, "https://fleek2.xyz"); + fleekContract.setTokenExternalURL(mint, "https://fleek2.xyz"); + fleekContract.setTokenENS(mint, "fleek_xyz2"); + fleekContract.setTokenBuild( + mint, + "afff3f62", + "https://github.com/fleekxyz/contracts2" + ); string memory tokenURI = fleekContract.tokenURI(mint); bytes memory dataURI = abi.encodePacked( - '{', - '"name":"Foundry Test App 2",', - '"description":"This is a test application submitted by foundry tests. 2",', - '"owner":"',Strings.toHexString(uint160(DEPLOYER), 20),'",', - '"external_url":"https://fleek2.xyz",', - '"image":"https://fleek2.xyz",', - '"attributes": [', - '{"trait_type": "ENS", "value":"fleek_xyz2"},', - '{"trait_type": "Commit Hash", "value":"afff3f62"},', - '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},', - '{"trait_type": "Version", "value":"1"}', - ']', - '}' + "{", + '"name":"Foundry Test App 2",', + '"description":"This is a test application submitted by foundry tests. 2",', + '"owner":"', + Strings.toHexString(uint160(DEPLOYER), 20), + '",', + '"external_url":"https://fleek2.xyz",', + '"image":"https://fleek2.xyz",', + '"attributes": [', + '{"trait_type": "ENS", "value":"fleek_xyz2"},', + '{"trait_type": "Commit Hash", "value":"afff3f62"},', + '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts2"},', + '{"trait_type": "Version", "value":"1"}', + "]", + "}" ); - assertEq(tokenURI, string(abi.encodePacked("data:application/json;base64,", Base64.encode((dataURI))))); + assertEq( + tokenURI, + string( + abi.encodePacked( + "data:application/json;base64,", + Base64.encode((dataURI)) + ) + ) + ); } function testFailCallingTokenURIOnNonExistantToken() public { bytes memory dataURI = abi.encodePacked( - '{', - '"name":"Foundry Test App",', - '"description":"This is a test application submitted by foundry tests.",', - '"owner":"',Strings.toHexString(uint160(DEPLOYER), 20),'",', - '"external_url":"https://fleek.xyz",', - '"image":"https://fleek.xyz",', - '"attributes": [', - '{"trait_type": "ENS", "value":"fleek_xyz"},', - '{"trait_type": "Commit Hash", "value":"afff3f6"},', - '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},', - '{"trait_type": "Version", "value":"0"}', - ']', - '}' + "{", + '"name":"Foundry Test App",', + '"description":"This is a test application submitted by foundry tests.",', + '"owner":"', + Strings.toHexString(uint160(DEPLOYER), 20), + '",', + '"external_url":"https://fleek.xyz",', + '"image":"https://fleek.xyz",', + '"attributes": [', + '{"trait_type": "ENS", "value":"fleek_xyz"},', + '{"trait_type": "Commit Hash", "value":"afff3f6"},', + '{"trait_type": "Repository", "value":"https://github.com/fleekxyz/contracts"},', + '{"trait_type": "Version", "value":"0"}', + "]", + "}" ); - assertEq(fleekContract.tokenURI(0), string(abi.encodePacked("data:application/json;base64,", Base64.encode((dataURI))))); + assertEq( + fleekContract.tokenURI(0), + string( + abi.encodePacked( + "data:application/json;base64,", + Base64.encode((dataURI)) + ) + ) + ); } function testBurn() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); @@ -282,17 +339,17 @@ function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess() pub function testFailBurnAnotherUsersTokenWithoutAccess() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - + vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); fleekContract.burn(mint); @@ -301,390 +358,468 @@ function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess() pub function testFailTokenControllerAttemptsToBurnToken() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); fleekContract.burn(mint); } - function testSetTokenName() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenName(mint, 'NEW TOKEN NAME!'); + fleekContract.setTokenName(mint, "NEW TOKEN NAME!"); } function testFailSetTokenNameOnAnotherUsersTokenWithoutAccess() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenName(mint, 'NEW TOKEN NAME!'); - } + fleekContract.setTokenName(mint, "NEW TOKEN NAME!"); + } function testSetTokenDescription() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenDescription(mint, 'NEW TOKEN NAME!'); + fleekContract.setTokenDescription(mint, "NEW TOKEN NAME!"); } - function testFailSetTokenDescriptionOnAnotherUsersTokenWithoutAccess() public { + function testFailSetTokenDescriptionOnAnotherUsersTokenWithoutAccess() + public + { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenDescription(mint, 'NEW TOKEN NAME!'); + fleekContract.setTokenDescription(mint, "NEW TOKEN NAME!"); } - function testSetTokenImage() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenImage(mint, 'https://ethereum.org'); + fleekContract.setTokenImage(mint, "https://ethereum.org"); } function testFailSetTokenImageOnAnotherUsersTokenWithoutAccess() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenImage(mint, 'https://ethereum.org'); + fleekContract.setTokenImage(mint, "https://ethereum.org"); } function testSetTokenExternalURL() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenExternalURL(mint, 'https://ethereum.org'); + fleekContract.setTokenExternalURL(mint, "https://ethereum.org"); } - function testFailSetTokenExternalURLOnAnotherUsersTokenWithoutAccess() public { + function testFailSetTokenExternalURLOnAnotherUsersTokenWithoutAccess() + public + { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenExternalURL(mint, 'https://ethereum.org'); + fleekContract.setTokenExternalURL(mint, "https://ethereum.org"); } function testSetTokenBuild() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenBuild(mint, 'aaaaaaa', 'https://github.com/fleekxyz/test_contracts'); + fleekContract.setTokenBuild( + mint, + "aaaaaaa", + "https://github.com/fleekxyz/test_contracts" + ); } function testFailSetTokenBuildOnAnotherUsersTokenWithoutAccess() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenBuild(mint, 'aaaaaaa', 'https://github.com/fleekxyz/test_contracts'); + fleekContract.setTokenBuild( + mint, + "aaaaaaa", + "https://github.com/fleekxyz/test_contracts" + ); } function testSetTokenENS() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.setTokenENS(mint, 'fleek_nfts'); + fleekContract.setTokenENS(mint, "fleek_nfts"); } function testFailSetTokenENSOnAnotherUsersTokenWithoutAccess() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.setTokenENS(mint, 'fleek_nfts'); + fleekContract.setTokenENS(mint, "fleek_nfts"); } function testAddTokenController() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } - function testFailAddTokenControllerOnAnotherUsersTokenWithoutAccess() public { + function testFailAddTokenControllerOnAnotherUsersTokenWithoutAccess() + public + { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } function testAddTokenControllerTwice() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } - function testRemoveTokenController() public { + function testRemoveTokenController() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); - fleekContract.removeTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } - function testFailRemoveTokenControllerOnAnotherUsersTokenWithoutAccess() public { + function testFailRemoveTokenControllerOnAnotherUsersTokenWithoutAccess() + public + { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0x91A425C1CA320A99a09BE1bee114Fce5d30153d9); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0x91A425C1CA320A99a09BE1bee114Fce5d30153d9 + ); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.removeTokenController(mint, 0x91A425C1CA320A99a09BE1bee114Fce5d30153d9); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0x91A425C1CA320A99a09BE1bee114Fce5d30153d9 + ); } - - function testRemoveTokenControllerTwice() public { + + function testRemoveTokenControllerTwice() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); - fleekContract.removeTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); - fleekContract.removeTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } - function testRemoveUnknownTokenController() public { + function testRemoveUnknownTokenController() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.removeTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } function testFailRemoveUnknownTokenControllerFromUnknownToken() public { - fleekContract.removeTokenController(0, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.revokeTokenRole( + 0, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); } function testFailRemoveTokenOwnerByTokenController() public { uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); - fleekContract.addTokenController(mint, 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84); + fleekContract.grantTokenRole( + mint, + FleekAccessControl.Roles.Controller, + 0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84 + ); vm.prank(address(0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84)); - fleekContract.removeTokenController(mint, DEPLOYER); + fleekContract.revokeTokenRole( + mint, + FleekAccessControl.Roles.Controller, + DEPLOYER + ); } function testBalanceOfDeployerAfterAndBeforeMinting() public { @@ -692,18 +827,17 @@ function testFailChangingAllPossibleFieldsOnAnotherUsersTokenWithoutAccess() pub uint256 mint = fleekContract.mint( DEPLOYER, - 'Foundry Test App', - 'This is a test application submitted by foundry tests.', - 'https://fleek.xyz', - 'https://fleek.xyz', - 'fleek_xyz', - 'afff3f6', - 'https://github.com/fleekxyz/contracts' + "Foundry Test App", + "This is a test application submitted by foundry tests.", + "https://fleek.xyz", + "https://fleek.xyz", + "fleek_xyz", + "afff3f6", + "https://github.com/fleekxyz/contracts" ); assertEq(mint, 0); assertEq(fleekContract.balanceOf(DEPLOYER), 1); } - }