-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from koloz193/flavors
moved deadman trigger to be an extension
- Loading branch information
Showing
9 changed files
with
438 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.15; | ||
|
||
import {ERC1155} from "solmate/tokens/ERC1155.sol"; | ||
import {Owned} from "solmate/auth/Owned.sol"; | ||
import {RoyaltyGuardDeadmanTrigger, RoyaltyGuard, IRoyaltyGuard} from "../../royalty-guard/extensions/RoyaltyGuardDeadmanTrigger.sol"; | ||
|
||
contract DeadmanGuardedERC1155 is ERC1155, Owned, RoyaltyGuardDeadmanTrigger { | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
PRIVATE STORAGE | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
string private baseURI; | ||
string private name_; | ||
string private symbol_; | ||
uint256 private tokenIdCounter; | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
CONSTRUCTOR | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
constructor(string memory _name, string memory _symbol, string memory _baseURI, address _newOwner) | ||
Owned(_newOwner) | ||
{ | ||
baseURI = _baseURI; | ||
name_ = _name; | ||
symbol_ = _symbol; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
ERC1155 LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
function uri(uint256 _id) public view virtual override returns (string memory) { | ||
return string(abi.encodePacked(baseURI, _id)); | ||
} | ||
|
||
/// @notice Returns the name of this 1155 contract. | ||
/// @return name of contract | ||
function name() external view returns (string memory) { | ||
return name_; | ||
} | ||
|
||
/// @notice Returns the symbol of this 1155 contract. | ||
/// @return symbol of contract | ||
function symbol() external view returns (string memory) { | ||
return symbol_; | ||
} | ||
|
||
/// @notice Create a new token sending the full {_amount} to {_to}. | ||
/// @dev Must be contract owner to mint new token. | ||
function mint(address _to, uint256 _amount) external onlyOwner{ | ||
_mint(_to, tokenIdCounter++, _amount, ""); | ||
} | ||
|
||
/// @notice Destroy {_amount} of token with id {_id}. | ||
/// @dev Must have a balance >= {_amount} of {_tokenId}. | ||
function burn(address _from, uint256 _id, uint256 _amount) external { | ||
if (balanceOf[_from][_id] < _amount) revert("INSUFFICIENT BALANCE"); | ||
_burn(_from, _id, _amount); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
ERC165 LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function supportsInterface(bytes4 _interfaceId) public view virtual override (ERC1155, RoyaltyGuard) returns (bool) { | ||
return RoyaltyGuard.supportsInterface(_interfaceId) || ERC1155.supportsInterface(_interfaceId); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
RoyaltyGuard LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
/// @inheritdoc RoyaltyGuard | ||
function hasAdminPermission(address _addr) public view virtual override (IRoyaltyGuard, RoyaltyGuard) returns (bool) { | ||
return _addr == owner; | ||
} | ||
|
||
/// @dev Guards {setApprovalForAll} based on the type of list and depending if {_operator} is on the list. | ||
function setApprovalForAll(address _operator, bool _approved) public virtual override checkList(_operator) { | ||
super.setApprovalForAll(_operator, _approved); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.15; | ||
|
||
import {ERC721} from "solmate/tokens/ERC721.sol"; | ||
import {Owned} from "solmate/auth/Owned.sol"; | ||
import {RoyaltyGuardDeadmanTrigger, RoyaltyGuard, IRoyaltyGuard} from "../../royalty-guard/extensions/RoyaltyGuardDeadmanTrigger.sol"; | ||
|
||
contract DeadmanGuardedERC721 is ERC721, Owned, RoyaltyGuardDeadmanTrigger { | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
PRIVATE STORAGE | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
string private baseURI; | ||
uint256 private tokenCounter; | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
CONSTRUCTOR | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
constructor(string memory _name, string memory _symbol, string memory _baseURI, address _newOwner) | ||
ERC721(_name, _symbol) | ||
Owned(_newOwner) | ||
{ | ||
baseURI = _baseURI; | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
ERC721 LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
/// @notice Retrieve the tokenURI for a token with the supplied _id | ||
/// @dev Wont throw or revert given a nonexistent tokenId | ||
/// @return string token uri | ||
function tokenURI(uint256 _id) public view virtual override returns (string memory) { | ||
return string(abi.encodePacked(baseURI, _id)); | ||
} | ||
|
||
/// @notice Create a new token sending directly to {_to}. | ||
/// @dev Must be contract owner to mint new token. | ||
function mint(address _to) external onlyOwner { | ||
_mint(_to, tokenCounter++); | ||
} | ||
|
||
/// @notice Destroy token with id {_id}. | ||
/// @dev Must be the token owner to call. | ||
function burn(uint256 _id) external { | ||
if (_ownerOf[_id] != msg.sender) revert("NOT_OWNER"); | ||
_burn(_id); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
ERC165 LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
function supportsInterface(bytes4 _interfaceId) public view virtual override (ERC721, RoyaltyGuard) returns (bool) { | ||
return RoyaltyGuard.supportsInterface(_interfaceId) || ERC721.supportsInterface(_interfaceId); | ||
} | ||
|
||
/*////////////////////////////////////////////////////////////////////////// | ||
RoyaltyGuard LOGIC | ||
//////////////////////////////////////////////////////////////////////////*/ | ||
|
||
/// @inheritdoc RoyaltyGuard | ||
function hasAdminPermission(address _addr) public view virtual override (IRoyaltyGuard, RoyaltyGuard) returns (bool) { | ||
return _addr == owner; | ||
} | ||
|
||
/// @dev Guards {approve} based on the type of list and depending if {_spender} is on the list. | ||
function approve(address _spender, uint256 _id) public virtual override checkList(_spender) { | ||
super.approve(_spender, _id); | ||
} | ||
|
||
/// @dev Guards {setApprovalForAll} based on the type of list and depending if {_operator} is on the list. | ||
function setApprovalForAll(address _operator, bool _approved) public virtual override checkList(_operator) { | ||
super.setApprovalForAll(_operator, _approved); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.