Fix errors and make the contract environment ready for compiling.
This commit is contained in:
parent
c9578c88fd
commit
8286b71c84
|
|
@ -11,15 +11,15 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
using Counters for Counters.Counter;
|
using Counters for Counters.Counter;
|
||||||
|
|
||||||
struct Build {
|
struct Build {
|
||||||
string commit;
|
string commit_hash;
|
||||||
string repository;
|
string git_repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Site {
|
struct Site {
|
||||||
string URI; //ipfs hash example
|
bytes32 external_url; //ipfs hash example
|
||||||
string ENS;
|
bytes32 ENS;
|
||||||
uint256 currentBuild;
|
uint256 current_build;
|
||||||
Build[] builds;
|
mapping(uint256 => Build) builds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counters.Counter private _tokenIds;
|
Counters.Counter private _tokenIds;
|
||||||
|
|
@ -40,19 +40,24 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
|
|
||||||
function mint(
|
function mint(
|
||||||
address to,
|
address to,
|
||||||
string memory URI,
|
bytes32 external_url,
|
||||||
string memory ENS,
|
bytes32 ENS,
|
||||||
string memory commit,
|
string memory commit_hash,
|
||||||
string memory repository
|
string memory git_repository
|
||||||
) public payable requireCollectionOwner returns (uint256) {
|
) public payable requireCollectionOwner returns (uint256) {
|
||||||
uint256 tokenId = _tokenIds.current();
|
uint256 tokenId = _tokenIds.current();
|
||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
addTokenController(tokenId, to);
|
addTokenController(tokenId, to);
|
||||||
_tokenIds.increment();
|
_tokenIds.increment();
|
||||||
|
|
||||||
Build[] memory _builds = new Build[](1);
|
Site storage site = _sites[tokenId];
|
||||||
_builds[0] = Build(commit, repository);
|
site.external_url = external_url;
|
||||||
_sites[tokenId] = Site(URI, ENS, 0, _builds);
|
site.ENS = ENS;
|
||||||
|
|
||||||
|
// The mint interaction is considered to be the first build of the site. Updates from now on all increment the current_build by one and update the mapping.
|
||||||
|
site.current_build = 0;
|
||||||
|
site.builds[0] = Build(commit_hash, git_repository);
|
||||||
|
|
||||||
return tokenId;
|
return tokenId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,18 +75,18 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
) public view virtual override returns (string memory) {
|
) public view virtual override returns (string memory) {
|
||||||
_requireMinted(tokenId);
|
_requireMinted(tokenId);
|
||||||
address owner = ownerOf(tokenId);
|
address owner = ownerOf(tokenId);
|
||||||
Site memory site = _sites[tokenId];
|
Site storage site = _sites[tokenId];
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
bytes memory dataURI = abi.encodePacked(
|
bytes memory dataURI = abi.encodePacked(
|
||||||
'{',
|
'{',
|
||||||
'"owner":"', owner, '",',
|
'"owner":"', owner, '",',
|
||||||
'"ENS":"', site.ENS, '",',
|
'"ENS":"', site.ENS, '",',
|
||||||
'"URI":"', site.URI, '",',
|
'"external_url":"', site.external_url, '",',
|
||||||
'"build:{',
|
'"build:{',
|
||||||
'"id":"', site.currentBuild, '",',
|
'"id":"', site.current_build, '",',
|
||||||
'"commit":"', site.builds[site.currentBuild].commit, '",',
|
'"commit_hash":"', site.builds[site.current_build].commit_hash, '",',
|
||||||
'"repository":"', site.builds[site.currentBuild].repository, '"'
|
'"repository":"', site.builds[site.current_build].git_repository, '"'
|
||||||
'}',
|
'}',
|
||||||
'}'
|
'}'
|
||||||
);
|
);
|
||||||
|
|
@ -115,17 +120,17 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
return "data:application/json;base64,";
|
return "data:application/json;base64,";
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setTokenURI(
|
function _setTokenExternalURL(
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
string memory _tokenURI
|
bytes32 _tokenExternalURL
|
||||||
) internal virtual requireTokenController(tokenId) {
|
) internal virtual requireTokenController(tokenId) {
|
||||||
_requireMinted(tokenId);
|
_requireMinted(tokenId);
|
||||||
_sites[tokenId].URI = _tokenURI;
|
_sites[tokenId].external_url = _tokenExternalURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _setTokenENS(
|
function _setTokenENS(
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
string memory _tokenENS
|
bytes32 _tokenENS
|
||||||
) internal virtual requireTokenController(tokenId) {
|
) internal virtual requireTokenController(tokenId) {
|
||||||
_requireMinted(tokenId);
|
_requireMinted(tokenId);
|
||||||
_sites[tokenId].ENS = _tokenENS;
|
_sites[tokenId].ENS = _tokenENS;
|
||||||
|
|
@ -133,12 +138,12 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
|
|
||||||
function _setTokenBuild(
|
function _setTokenBuild(
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
string memory _commit,
|
string memory _commit_hash,
|
||||||
string memory _repository
|
string memory _git_repository
|
||||||
) internal virtual requireTokenController(tokenId) {
|
) internal virtual requireTokenController(tokenId) {
|
||||||
_requireMinted(tokenId);
|
_requireMinted(tokenId);
|
||||||
_sites[tokenId].builds.push(Build(_commit, _repository));
|
_sites[tokenId].builds[_sites[tokenId].current_build] = Build(_commit_hash, _git_repository);
|
||||||
_sites[tokenId].currentBuild = _sites[tokenId].builds.length - 1;
|
_sites[tokenId].current_build = _sites[tokenId].current_build + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _burn(uint256 tokenId) internal virtual override {
|
function _burn(uint256 tokenId) internal virtual override {
|
||||||
|
|
@ -148,7 +153,7 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
);
|
);
|
||||||
super._burn(tokenId);
|
super._burn(tokenId);
|
||||||
|
|
||||||
if (bytes(_sites[tokenId].URI).length != 0) {
|
if (_sites[tokenId].external_url.length != 0) {
|
||||||
delete _sites[tokenId];
|
delete _sites[tokenId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
module.exports = async ({ getNamedAccounts, deployments }) => {
|
||||||
|
const { deploy, log } = deployments;
|
||||||
|
const namedAccounts = await getNamedAccounts();
|
||||||
|
const { deployer } = namedAccounts;
|
||||||
|
|
||||||
|
const deployResult = await deploy('FleekERC721', {
|
||||||
|
from: deployer,
|
||||||
|
args: ['FleekSites', 'FLKSITE'],
|
||||||
|
});
|
||||||
|
if (deployResult.newlyDeployed) {
|
||||||
|
log(
|
||||||
|
`contract FleekSites deployed at ${deployResult.address} using ${deployResult.receipt.gasUsed} gas`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
log(`using pre-existing contract FleekSites at ${deployResult.address}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//You can put an array of tags below. Tags can be anything and say when a this script should be run. So you can write different scripts for local, prod or other deploys
|
||||||
|
//For example when you run 'npx hardhat --network hardhat deploy --tags local' hardhat will run all deploy scripts that have the tag local, could be multiple dif scripts
|
||||||
|
module.exports.tags = [];
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
const argv = require('minimist')(process.argv.slice(2));
|
|
||||||
const contractName = argv.contract;
|
|
||||||
const params = argv.param || [];
|
|
||||||
|
|
||||||
if (!contractName) {
|
|
||||||
console.log('No contract name provided');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log('Deploying contract:', contractName);
|
|
||||||
console.log('With params:', params);
|
|
||||||
|
|
||||||
const [deployer] = await ethers.getSigners();
|
|
||||||
|
|
||||||
console.log('Deploying contracts with the account:', deployer.address);
|
|
||||||
console.log('Account balance:', (await deployer.getBalance()).toString());
|
|
||||||
|
|
||||||
// const factory = await ethers.getContractFactory(contractName);
|
|
||||||
|
|
||||||
// // Start deployment, returning a promise that resolves to a contract object
|
|
||||||
// const contract = await factory.deploy(...params);
|
|
||||||
// console.log('Contract deployed to address:', contract.address);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
.then(() => process.exit(0))
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue