feat: add token controller control functions
This commit is contained in:
parent
e07d6852ab
commit
7891068b9a
|
|
@ -41,6 +41,20 @@ abstract contract FleekAccessControl is AccessControl {
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addTokenController(
|
||||||
|
uint256 tokenId,
|
||||||
|
address controller
|
||||||
|
) public require requireMinted(tokenId) requireTokenOwner(tokenId) {
|
||||||
|
_grantRole(_tokenRole(tokenId, "CONTROLLER"), controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeTokenController(
|
||||||
|
uint256 tokenId,
|
||||||
|
address controller
|
||||||
|
) public require requireMinted(tokenId) requireTokenOwner(tokenId) {
|
||||||
|
_revokeRole(_tokenRole(tokenId, "CONTROLLER"), controller);
|
||||||
|
}
|
||||||
|
|
||||||
function _tokenRole(
|
function _tokenRole(
|
||||||
uint256 tokenId,
|
uint256 tokenId,
|
||||||
string role
|
string role
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
using Counters for Counters.Counter;
|
using Counters for Counters.Counter;
|
||||||
|
|
||||||
struct Build {
|
struct Build {
|
||||||
string _commit;
|
string commit;
|
||||||
string _repository;
|
string repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Site {
|
struct Site {
|
||||||
|
|
@ -39,8 +39,8 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
string memory repository
|
string memory repository
|
||||||
) public payable requireCollectionOwner returns (uint256) {
|
) public payable requireCollectionOwner returns (uint256) {
|
||||||
uint256 tokenId = _tokenIds.current();
|
uint256 tokenId = _tokenIds.current();
|
||||||
_grantRole(_tokenRole(tokenId), to);
|
|
||||||
_mint(to, tokenId);
|
_mint(to, tokenId);
|
||||||
|
addTokenController(tokenId, to);
|
||||||
_tokenIds.increment();
|
_tokenIds.increment();
|
||||||
_sites[tokenId] = Site(URI, ENS, 0, [Build(commit, repository)]);
|
_sites[tokenId] = Site(URI, ENS, 0, [Build(commit, repository)]);
|
||||||
return tokenId;
|
return tokenId;
|
||||||
|
|
@ -75,8 +75,8 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
'"URI":"', site.URI, '",',
|
'"URI":"', site.URI, '",',
|
||||||
'"build:{',
|
'"build:{',
|
||||||
'"id":"', site.currentBuild, '",',
|
'"id":"', site.currentBuild, '",',
|
||||||
'"commit":"', site.builds[site.currentBuild]._commit, '",',
|
'"commit":"', site.builds[site.currentBuild].commit, '",',
|
||||||
'"repository":"', site.builds[site.currentBuild]._repository, '"'
|
'"repository":"', site.builds[site.currentBuild].repository, '"'
|
||||||
'}',
|
'}',
|
||||||
'}'
|
'}'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue