fix merge conflicts.

This commit is contained in:
EmperorOrokuSaki 2022-12-12 23:56:10 +03:30
commit d1621cea50
13 changed files with 1484 additions and 62 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ node_modules
# hardhat
cache
artifacts
deployments/localhost
# NPM
package-lock.json

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std

View File

@ -40,10 +40,21 @@ abstract contract FleekAccessControl is AccessControl {
_;
}
function isTokenController(
uint256 tokenId,
address account
) public view returns (bool) {
return hasRole(_tokenRole(tokenId, "CONTROLLER"), account);
}
function _tokenRole(
uint256 tokenId,
string memory role
) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("TOKEN_", role, tokenId));
}
function _clearTokenControllers(uint256 tokenId) internal {
// TODO: Remove token controllers from AccessControl
}
}

View File

@ -12,7 +12,6 @@ contract FleekERC721 is ERC721, FleekAccessControl {
using Counters for Counters.Counter;
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 NewTokenImage(uint256 indexed token, string indexed image);
@ -139,35 +138,31 @@ contract FleekERC721 is ERC721, FleekAccessControl {
return super.supportsInterface(interfaceId);
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
super.transferFrom(from, to, tokenId);
_clearTokenControllers(tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
super.safeTransferFrom(from, to, tokenId, "");
_clearTokenControllers(tokenId);
}
function safeTransferFrom(
/**
* @dev Override of _beforeTokenTransfer of ERC721.
* Here it needs to update the token controller roles for mint, burn and transfer.
* IMPORTANT: The function for clearing token controllers is not implemented yet.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
super._safeTransfer(from, to, tokenId, data);
_clearTokenControllers(tokenId);
uint256 batchSize
) internal virtual override {
if (from != address(0) && to != address(0)) {
// Transfer
_clearTokenControllers(tokenId);
_grantRole(_tokenRole(tokenId, "CONTROLLER"), to);
} else if (from == address(0)) {
// Mint
_grantRole(_tokenRole(tokenId, "CONTROLLER"), to);
} else if (to == address(0)) {
// Burn
_clearTokenControllers(tokenId);
}
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
function _baseURI() internal view virtual override returns (string memory) {
return "data:application/json;base64,";
}
@ -230,21 +225,10 @@ contract FleekERC721 is ERC721, FleekAccessControl {
function burn(
uint256 tokenId
) public virtual requireTokenOwner(tokenId) {
_requireMinted(tokenId);
require(
ownerOf(tokenId) == msg.sender,
"FleekERC721: must be token owner"
);
super._burn(tokenId);
if (bytes(_apps[tokenId].external_url).length != 0) {
delete _apps[tokenId];
}
}
function _clearTokenControllers(
uint256 tokenId
) internal {
// TODO: Remove token controllers from AccessControl
}
}

View File

@ -0,0 +1 @@
80001

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,7 @@ const config: HardhatUserConfig = {
localhost: {
chainId: 31337,
},
polygonMumbai: {
mumbai: {
url: API_URL,
accounts: PRIVATE_KEY ? [PRIVATE_KEY] : [],
saveDeployments: true,

View File

@ -4,12 +4,13 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "hardhat test",
"test": "hardhat test && forge test --via-ir",
"test:foundry": "forge test --via-ir",
"test:hardhat": "hardhat test",
"format": "prettier --write \"./**/*.{js,ts,sol}\"",
"node:hh": "hardhat node --tags local",
"node:hardhat": "hardhat node --tags local",
"deploy:local": "hardhat deploy --tags local",
"deploy:mumbai": "hardhat deploy --tags mumbai",
"interact": "npx hardhat run deploy/interact.js --network hardhat",
"deploy:mumbai": "hardhat deploy --tags mumbai --network mumbai",
"compile": "hardhat compile"
},
"repository": {

View File

@ -1,7 +1,7 @@
// npx hardhat run scripts/mint.js --network polygonMumbai
// npx hardhat run scripts/mint.js --network mumbai
const { getContract } = require('./util');
// TODO: make this arguments
const contractAddress = '0x91A425C1CA320A99a09BE1bee114Fce5d30153d9';
const params = [
'0x7ED735b7095C05d78dF169F991f2b7f1A1F1A049', // to
'Fleek App', // name
@ -15,10 +15,7 @@ const params = [
];
(async () => {
const contract = await hre.ethers.getContractAt(
'FleekERC721',
contractAddress
);
const contract = getContract('FleekERC721');
const transaction = await contract.mint(...params);

View File

@ -1,14 +1,11 @@
// npx hardhat run scripts/tokenURI.js --network polygonMumbai
// npx hardhat run scripts/tokenURI.js --network mumbai
const { getContract } = require('./util');
// TODO: make this arguments
const contractAddress = '0x91A425C1CA320A99a09BE1bee114Fce5d30153d9';
const tokenId = 3;
const tokenId = 1;
(async () => {
const contract = await hre.ethers.getContractAt(
'FleekERC721',
contractAddress
);
const contract = await getContract('FleekERC721');
const transaction = await contract.tokenURI(tokenId);

View File

@ -1,21 +1,18 @@
// npx hardhat run scripts/upgrade.js --network polygonMumbai
// npx hardhat run scripts/upgrade.js --network mumbai
const { getContract } = require('./util');
// TODO: make this arguments
const contractAddress = '0x91A425C1CA320A99a09BE1bee114Fce5d30153d9';
const params = [
3, // tokenId
1, // tokenId
'97e7908f70f0862d753c66689ff09e70caa43df2', // commit hash
'https://github.com/org/new-repo', // repo
'new-author', // author
];
(async () => {
const contract = await hre.ethers.getContractAt(
'FleekERC721',
contractAddress
);
const contract = await getContract('FleekERC721');
const transaction = await contract.upgradeTokenBuild(...params);
const transaction = await contract.setTokenBuild(...params);
console.log('Response: ', transaction);
})();

7
scripts/util.js Normal file
View File

@ -0,0 +1,7 @@
module.exports.getContract = async function (contractName) {
const {
address,
} = require(`../deployments/${hre.network.name}/${contractName}.json`);
return hre.ethers.getContractAt(contractName, address);
};