编译器
0.8.17+commit.8df45f5f
文件 1 的 34:AccessControl.sol
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 2 的 34:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 3 的 34:BitMaps.sol
pragma solidity ^0.8.0;
import "./BitScan.sol";
library BitMaps {
using BitScan for uint256;
uint256 private constant MASK_INDEX_ZERO = (1 << 255);
uint256 private constant MASK_FULL = type(uint256).max;
struct BitMap {
mapping(uint256 => uint256) _data;
}
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index >> 8;
uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
return bitmap._data[bucket] & mask != 0;
}
function setTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal {
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
bitmap._data[bucket] |= mask;
}
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = MASK_INDEX_ZERO >> (index & 0xff);
bitmap._data[bucket] &= ~mask;
}
function setBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {
uint256 bucket = startIndex >> 8;
uint256 bucketStartIndex = (startIndex & 0xff);
unchecked {
if(bucketStartIndex + amount < 256) {
bitmap._data[bucket] |= MASK_FULL << (256 - amount) >> bucketStartIndex;
} else {
bitmap._data[bucket] |= MASK_FULL >> bucketStartIndex;
amount -= (256 - bucketStartIndex);
bucket++;
while(amount > 256) {
bitmap._data[bucket] = MASK_FULL;
amount -= 256;
bucket++;
}
bitmap._data[bucket] |= MASK_FULL << (256 - amount);
}
}
}
function unsetBatch(BitMap storage bitmap, uint256 startIndex, uint256 amount) internal {
uint256 bucket = startIndex >> 8;
uint256 bucketStartIndex = (startIndex & 0xff);
unchecked {
if(bucketStartIndex + amount < 256) {
bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount) >> bucketStartIndex);
} else {
bitmap._data[bucket] &= ~(MASK_FULL >> bucketStartIndex);
amount -= (256 - bucketStartIndex);
bucket++;
while(amount > 256) {
bitmap._data[bucket] = 0;
amount -= 256;
bucket++;
}
bitmap._data[bucket] &= ~(MASK_FULL << (256 - amount));
}
}
}
function scanForward(BitMap storage bitmap, uint256 index) internal view returns (uint256 setBitIndex) {
uint256 bucket = index >> 8;
uint256 bucketIndex = (index & 0xff);
uint256 bb = bitmap._data[bucket];
bb = bb >> (0xff ^ bucketIndex);
if(bb > 0) {
unchecked {
setBitIndex = (bucket << 8) | (bucketIndex - bb.bitScanForward256());
}
} else {
while(true) {
require(bucket > 0, "BitMaps: The set bit before the index doesn't exist.");
unchecked {
bucket--;
}
bb = bitmap._data[bucket];
if(bb > 0) {
unchecked {
setBitIndex = (bucket << 8) | (255 - bb.bitScanForward256());
break;
}
}
}
}
}
function getBucket(BitMap storage bitmap, uint256 bucket) internal view returns (uint256) {
return bitmap._data[bucket];
}
}
文件 4 的 34:BitOperator.sol
pragma solidity ^0.8.17;
library BitOperator{
string private constant ERROR_OVERFLOW = "position should overflow";
function getBitValueUint8(uint256 value, uint256 pos) internal pure returns(uint8){
if (pos > 248) revert(ERROR_OVERFLOW);
return uint8(value >> pos);
}
function getBitValueBool(uint256 value, uint256 pos) internal pure returns(bool){
if (pos > 255) revert(ERROR_OVERFLOW);
return ((value >> pos) & 0x01 == 1);
}
function setBitValueUint8(uint256 value, uint256 pos, uint8 set) internal pure returns(uint256){
if (pos > 248) revert(ERROR_OVERFLOW);
return (value & ~(0xFF << pos)) | (uint256(set) << pos);
}
function setBitValueBool(uint256 value, uint256 pos, bool set) internal pure returns(uint256){
if (pos > 255) revert(ERROR_OVERFLOW);
return (value & ~(0x01 << pos)) | ((set ? uint256(1) : uint256(0)) << pos);
}
}
文件 5 的 34:BitScan.sol
pragma solidity ^0.8.0;
library BitScan {
uint256 constant private DEBRUIJN_256 = 0x818283848586878898a8b8c8d8e8f929395969799a9b9d9e9faaeb6bedeeff;
bytes constant private LOOKUP_TABLE_256 = hex"0001020903110a19042112290b311a3905412245134d2a550c5d32651b6d3a7506264262237d468514804e8d2b95569d0d495ea533a966b11c886eb93bc176c9071727374353637324837e9b47af86c7155181ad4fd18ed32c9096db57d59ee30e2e4a6a5f92a6be3498aae067ddb2eb1d5989b56fd7baf33ca0c2ee77e5caf7ff0810182028303840444c545c646c7425617c847f8c949c48a4a8b087b8c0c816365272829aaec650acd0d28fdad4e22d6991bd97dfdcea58b4d6f29fede4f6fe0f1f2f3f4b5b6b607b8b93a3a7b7bf357199c5abcfd9e168bcdee9b3f1ecf5fd1e3e5a7a8aa2b670c4ced8bbe8f0f4fc3d79a1c3cde7effb78cce6facbf9f8";
function isolateLS1B256(uint256 bb) pure internal returns (uint256) {
require(bb > 0);
unchecked {
return bb & (0 - bb);
}
}
function isolateMS1B256(uint256 bb) pure internal returns (uint256) {
require(bb > 0);
unchecked {
bb |= bb >> 128;
bb |= bb >> 64;
bb |= bb >> 32;
bb |= bb >> 16;
bb |= bb >> 8;
bb |= bb >> 4;
bb |= bb >> 2;
bb |= bb >> 1;
return (bb >> 1) + 1;
}
}
function bitScanForward256(uint256 bb) pure internal returns (uint8) {
unchecked {
return uint8(LOOKUP_TABLE_256[(isolateLS1B256(bb) * DEBRUIJN_256) >> 248]);
}
}
function bitScanReverse256(uint256 bb) pure internal returns (uint8) {
unchecked {
return 255 - uint8(LOOKUP_TABLE_256[((isolateMS1B256(bb) * DEBRUIJN_256) >> 248)]);
}
}
function log2(uint256 bb) pure internal returns (uint8) {
unchecked {
return uint8(LOOKUP_TABLE_256[(isolateMS1B256(bb) * DEBRUIJN_256) >> 248]);
}
}
}
文件 6 的 34:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 7 的 34:DefaultOperatorFilterer.sol
pragma solidity ^0.8.13;
import {OperatorFilterer} from "./OperatorFilterer.sol";
abstract contract DefaultOperatorFilterer is OperatorFilterer {
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
文件 8 的 34:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 9 的 34:ERC721AntiScamSalesInfo.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "./ERC721AntiScamSubset.sol";
abstract contract ERC721AntiScamSalesInfo is ERC721AntiScamSubset{
mapping(address => AddressData) _addressData;
struct AddressData {
uint64 balance;
uint64 numberMinted;
uint64 numberBurned;
uint8 saleIndex;
uint16 numberConsumedInRecentSale;
uint40 aux;
}
function balanceOf(address owner)
public
view
virtual
override
returns (uint)
{
require(owner != address(0), "ERC721Psi: balance query for the zero address");
return uint256(_addressData[owner].balance);
}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal override virtual {
require(quantity < 2 ** 64);
uint64 _quantity = uint64(quantity);
if(from != address(0)){
_addressData[from].balance -= _quantity;
} else {
_addressData[to].numberMinted += _quantity;
}
if(to != address(0)){
_addressData[to].balance += _quantity;
} else {
_addressData[from].numberBurned += _quantity;
}
super._afterTokenTransfers(from, to, startTokenId, quantity);
}
}
文件 10 的 34:ERC721AntiScamSubset.sol
pragma solidity >=0.8.0;
import "contract-allow-list/contracts/ERC721AntiScam/lockable/ERC721Lockable.sol";
import "./ERC721RestrictApproveGlobalOnly.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
abstract contract ERC721AntiScamSubset is
ERC721Lockable,
ERC721RestrictApproveGlobalOnly,
Ownable
{
function isApprovedForAll(address owner, address operator)
public
view
virtual
override(ERC721Lockable, ERC721RestrictApproveGlobalOnly)
returns (bool)
{
if (isLocked(owner) || !_isAllowed(owner, operator)) {
return false;
}
return super.isApprovedForAll(owner, operator);
}
function setApprovalForAll(address operator, bool approved)
public
virtual
override(ERC721Lockable, ERC721RestrictApproveGlobalOnly)
{
require(
isLocked(msg.sender) == false || approved == false,
"Can not approve locked token"
);
require(
_isAllowed(operator) || approved == false,
"RestrictApprove: Can not approve locked token"
);
super.setApprovalForAll(operator, approved);
}
function _beforeApprove(address to, uint256 tokenId)
internal
virtual
override(ERC721Lockable, ERC721RestrictApproveGlobalOnly)
{
ERC721Lockable._beforeApprove(to, tokenId);
ERC721RestrictApproveGlobalOnly._beforeApprove(to, tokenId);
}
function approve(address to, uint256 tokenId)
public
virtual
override(ERC721Lockable, ERC721RestrictApproveGlobalOnly)
{
_beforeApprove(to, tokenId);
ERC721Psi.approve(to, tokenId);
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override(ERC721Psi, ERC721Lockable) {
ERC721Lockable._beforeTokenTransfers(from, to, startTokenId, quantity);
}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override(ERC721Lockable, ERC721RestrictApproveGlobalOnly) {
ERC721Lockable._afterTokenTransfers(from, to, startTokenId, quantity);
ERC721RestrictApproveGlobalOnly._afterTokenTransfers(from, to, startTokenId, quantity);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Lockable, ERC721RestrictApproveGlobalOnly)
returns (bool)
{
return
ERC721Psi.supportsInterface(interfaceId) ||
ERC721Lockable.supportsInterface(interfaceId) ||
ERC721RestrictApproveGlobalOnly.supportsInterface(interfaceId) ;
}
}
文件 11 的 34:ERC721BasicFrame.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "operator-filter-registry/src/DefaultOperatorFilterer.sol";
import "contract-allow-list/contracts/proxy/interface/IContractAllowListProxy.sol";
import "./ERC721AntiScamSalesInfo.sol";
import "./ISalesItem.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
abstract contract ERC721BasicFrameControlable is
IERC2981,
ISalesItem,
DefaultOperatorFilterer,
AccessControl,
Ownable,
ERC721AntiScamSalesInfo
{
uint256 public immutable MAX_SUPPLY;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
bytes32 public constant SELLER_ROLE = keccak256("SELLER_ROLE");
bytes32 public constant UPDATER_ROLE = keccak256("UPDATER_ROLE");
constructor(uint256 maxSupply){
MAX_SUPPLY = maxSupply;
}
mapping(uint256 => uint256) private _tokenAux;
address public royaltyAddress;
uint96 public royaltyFee = 1000;
bool public isSBT;
error ZeroAddress();
error InvlidRoyaltyFee(uint256 fee);
error MaxSupplyExceeded();
error ProhibitedBecauseSBT();
error NotAllowedByCAL(address operator);
error ArrayLengthIsZero();
error NotTokenHolder();
error WalletLockNotAllowedByOthers();
error InvalidRole();
error TokenNonexistent(uint256 tokenId);
function externalMint(address to, uint256 quantity) external onlyRole(MINTER_ROLE) {
_mint(to, quantity);
}
function sellerMint(address to, uint256 quantity) external onlyRole(SELLER_ROLE) {
_mint(to, quantity);
}
function externalBurn(uint256 tokenId) external onlyRole(BURNER_ROLE) {
_burn(tokenId);
}
function sellerBurn(uint256 tokenId) external onlyRole(SELLER_ROLE) {
_burn(tokenId);
}
function _mint(address to, uint256 quantity) internal override {
if (quantity + totalSupply() > MAX_SUPPLY) revert MaxSupplyExceeded();
super._mint(to, quantity);
}
function burned() external view returns(uint256){
return _burned();
}
function setConsumedAllocation(address _target, uint8 _currentSaleIndex, uint16 _consumed)
external
virtual
onlyRole(SELLER_ROLE)
{
AddressData memory data = _addressData[_target];
data.saleIndex = _currentSaleIndex;
data.numberConsumedInRecentSale = _consumed;
_addressData[_target] = data;
}
function addConsumedAllocation(address _target, uint8 _currentSaleIndex, uint16 _consumed)
external
virtual
onlyRole(SELLER_ROLE)
{
AddressData memory data = _addressData[_target];
if (data.saleIndex != _currentSaleIndex){
data.saleIndex = _currentSaleIndex;
data.numberConsumedInRecentSale = _consumed;
} else {
data.numberConsumedInRecentSale += _consumed;
}
_addressData[_target] = data;
}
function _setAddressAux(address _target, uint40 _aux)
internal
virtual
{
_addressData[_target].aux = _aux;
}
function _setTokenAux(uint256 tokenId, uint256 aux) internal virtual{
_tokenAux[tokenId] = aux;
}
function setRoyaltyAddress(address _new) external onlyAdmin {
if (_new == address(0)) revert ZeroAddress();
royaltyAddress = _new;
}
function setRoyaltyFee(uint96 _new) external onlyAdmin {
if (_new > 10000) revert InvlidRoyaltyFee(_new);
royaltyFee = _new;
}
function setIsSBT(bool _state) external onlyAdmin {
isSBT = _state;
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(AccessControl, IERC165, ERC721AntiScamSubset)
returns (bool)
{
return
interfaceId == type(IERC2981).interfaceId ||
interfaceId == type(ISalesItem).interfaceId ||
AccessControl.supportsInterface(interfaceId) ||
super.supportsInterface(interfaceId);
}
function setEnableRestrict(bool value) external onlyAdmin {
enableRestrict = value;
}
function setEnableLock(bool value) external onlyAdmin {
enableLock = value;
}
function setCALLevel(uint256 level) external onlyAdmin{
CALLevel = level;
}
function setCAL(address calAddress) external onlyAdmin{
_setCAL(calAddress);
}
function setTokenLock(uint256[] calldata tokenIds, LockStatus lockStatus)
external
virtual
override
{
for (uint256 i = 0; i < tokenIds.length; i++) {
if (msg.sender != ownerOf(tokenIds[i])) revert NotTokenHolder();
}
_setTokenLock(tokenIds, lockStatus);
}
function setWalletLock(address to, LockStatus lockStatus)
external
virtual
override
{
require(to == msg.sender, "not yourself.");
_setWalletLock(to, lockStatus);
}
function setContractLock(LockStatus lockStatus) external onlyAdmin{
_setContractLock(lockStatus);
}
function _getAddressAux(address _target) internal virtual view returns(uint40){
return _addressData[_target].aux;
}
function _getTokenAux(uint256 tokenId) internal virtual view returns(uint256){
return _tokenAux[tokenId];
}
modifier onlyAdmin() {
_checkRole(DEFAULT_ADMIN_ROLE);
_;
}
}
abstract contract ERC721BasicFrame is ERC721BasicFrameControlable {
using Strings for uint256;
constructor(string memory _name, string memory _symbol, uint256 maxSupply)
ERC721Psi(_name, _symbol)
ERC721BasicFrameControlable(maxSupply)
{
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function getConsumedAllocation(address _target, uint8 _currentSaleIndex) external view virtual returns(uint16){
AddressData memory data = _addressData[_target];
if (data.saleIndex != _currentSaleIndex){
return 0;
}
return data.numberConsumedInRecentSale;
}
function royaltyInfo(
uint256,
uint256 _salePrice
) public view virtual override returns (address, uint256) {
return (royaltyAddress, (_salePrice * uint256(royaltyFee)) / 10000);
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, data);
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override {
if (
isSBT &&
from != address(0) &&
to != address(0x000000000000000000000000000000000000dEaD)
) revert ProhibitedBecauseSBT();
super._beforeTokenTransfers(from, to, startTokenId, quantity);
}
function setApprovalForAll(address operator, bool approved)
public
virtual
override
onlyAllowedOperatorApproval(operator)
{
if (approved){
if (isSBT) revert ProhibitedBecauseSBT();
}
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId)
public
virtual
override
onlyAllowedOperatorApproval(operator)
{
if (operator != address(0)) {
if (isSBT) revert ProhibitedBecauseSBT();
}
super.approve(operator, tokenId);
}
}
文件 12 的 34:ERC721Lockable.sol
pragma solidity >=0.8.0;
import "./IERC721Lockable.sol";
import "erc721psi/contracts/extension/ERC721PsiBurnable.sol";
abstract contract ERC721Lockable is ERC721PsiBurnable, IERC721Lockable {
bool public enableLock = true;
LockStatus public contractLockStatus = LockStatus.UnLock;
mapping(uint256 => LockStatus) public tokenLock;
mapping(address => LockStatus) public walletLock;
modifier existToken(uint256 tokenId) {
require(
_exists(tokenId),
"Lockable: locking query for nonexistent token"
);
_;
}
function isLocked(uint256 tokenId)
public
view
virtual
existToken(tokenId)
returns (bool)
{
if (!enableLock) {
return false;
}
if (
tokenLock[tokenId] == LockStatus.Lock ||
(tokenLock[tokenId] == LockStatus.UnSet &&
isLocked(ownerOf(tokenId)))
) {
return true;
}
return false;
}
function isLocked(address holder) public view virtual returns (bool) {
if (!enableLock) {
return false;
}
if (
walletLock[holder] == LockStatus.Lock ||
(walletLock[holder] == LockStatus.UnSet &&
contractLockStatus == LockStatus.Lock)
) {
return true;
}
return false;
}
function getTokensUnderLock()
public
view
virtual
returns (uint256[] memory)
{
uint256 start = _startTokenId();
uint256 end = _nextTokenId();
return getTokensUnderLock(start, end);
}
function getTokensUnderLock(uint256 start, uint256 end)
public
view
virtual
returns (uint256[] memory)
{
bool[] memory lockList = new bool[](end - start + 1);
uint256 i = 0;
uint256 lockCount = 0;
for (uint256 tokenId = start; tokenId <= end; tokenId++) {
if (_exists(tokenId) && isLocked(tokenId)) {
lockList[i] = true;
lockCount++;
} else {
lockList[i] = false;
}
i++;
}
uint256[] memory tokensUnderLock = new uint256[](lockCount);
i = 0;
uint256 j = 0;
for (uint256 tokenId = start; tokenId <= end; tokenId++) {
if (lockList[i]) {
tokensUnderLock[j] = tokenId;
j++;
}
i++;
}
return tokensUnderLock;
}
function _deleteTokenLock(uint256 tokenId) internal virtual {
delete tokenLock[tokenId];
}
function _setTokenLock(uint256[] calldata tokenIds, LockStatus lockStatus)
internal
virtual
{
for (uint256 i = 0; i < tokenIds.length; i++) {
tokenLock[tokenIds[i]] = lockStatus;
emit TokenLock(
ownerOf(tokenIds[i]),
msg.sender,
lockStatus,
tokenIds[i]
);
}
}
function _setWalletLock(address to, LockStatus lockStatus)
internal
virtual
{
walletLock[to] = lockStatus;
emit WalletLock(to, msg.sender, lockStatus);
}
function _setContractLock(LockStatus lockStatus) internal virtual {
contractLockStatus = lockStatus;
}
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
if (isLocked(owner)) {
return false;
}
return super.isApprovedForAll(owner, operator);
}
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(
isLocked(msg.sender) == false || approved == false,
"Can not approve locked token"
);
super.setApprovalForAll(operator, approved);
}
function _beforeApprove(
address,
uint256 tokenId
) internal virtual {
require(
isLocked(tokenId) == false,
"Lockable: Can not approve locked token"
);
}
function approve(address to, uint256 tokenId) public virtual override {
_beforeApprove(to, tokenId);
super.approve(to, tokenId);
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256
) internal virtual override {
if (from != address(0) && to != address(0)) {
require(
isLocked(startTokenId) == false,
"Lockable: Can not transfer locked token"
);
}
}
function _afterTokenTransfers(
address from,
address,
uint256 startTokenId,
uint256
) internal virtual override {
if (from != address(0)) {
_deleteTokenLock(startTokenId);
}
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IERC721Lockable).interfaceId ||
super.supportsInterface(interfaceId);
}
}
文件 13 的 34:ERC721Psi.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "solidity-bits/contracts/BitMaps.sol";
contract ERC721Psi is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
using BitMaps for BitMaps.BitMap;
BitMaps.BitMap private _batchHead;
string private _name;
string private _symbol;
mapping(uint256 => address) internal _owners;
uint256 private _currentIndex;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
function _startTokenId() internal pure returns (uint256) {
return 0;
}
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
function _totalMinted() internal view virtual returns (uint256) {
return _currentIndex - _startTokenId();
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner)
public
view
virtual
override
returns (uint)
{
require(owner != address(0), "ERC721Psi: balance query for the zero address");
uint count;
for( uint i = _startTokenId(); i < _nextTokenId(); ++i ){
if(_exists(i)){
if( owner == ownerOf(i)){
++count;
}
}
}
return count;
}
function ownerOf(uint256 tokenId)
public
view
virtual
override
returns (address)
{
(address owner, ) = _ownerAndBatchHeadOf(tokenId);
return owner;
}
function _ownerAndBatchHeadOf(uint256 tokenId) internal view returns (address owner, uint256 tokenIdBatchHead){
require(_exists(tokenId), "ERC721Psi: owner query for nonexistent token");
tokenIdBatchHead = _getBatchHead(tokenId);
owner = _owners[tokenIdBatchHead];
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Psi: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721Psi: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721Psi: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId)
public
view
virtual
override
returns (address)
{
require(
_exists(tokenId),
"ERC721Psi: approved query for nonexistent token"
);
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(operator != _msgSender(), "ERC721Psi: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721Psi: transfer caller is not owner nor approved"
);
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721Psi: transfer caller is not owner nor approved"
);
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, 1,_data),
"ERC721Psi: transfer to non ERC721Receiver implementer"
);
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return tokenId < _nextTokenId() && _startTokenId() <= tokenId;
}
function _isApprovedOrOwner(address spender, uint256 tokenId)
internal
view
virtual
returns (bool)
{
require(
_exists(tokenId),
"ERC721Psi: operator query for nonexistent token"
);
address owner = ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, "");
}
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
uint256 nextTokenId = _nextTokenId();
_mint(to, quantity);
require(
_checkOnERC721Received(address(0), to, nextTokenId, quantity, _data),
"ERC721Psi: transfer to non ERC721Receiver implementer"
);
}
function _mint(
address to,
uint256 quantity
) internal virtual {
uint256 nextTokenId = _nextTokenId();
require(quantity > 0, "ERC721Psi: quantity must be greater 0");
require(to != address(0), "ERC721Psi: mint to the zero address");
_beforeTokenTransfers(address(0), to, nextTokenId, quantity);
_currentIndex += quantity;
_owners[nextTokenId] = to;
_batchHead.set(nextTokenId);
_afterTokenTransfers(address(0), to, nextTokenId, quantity);
for(uint256 tokenId=nextTokenId; tokenId < nextTokenId + quantity; tokenId++){
emit Transfer(address(0), to, tokenId);
}
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
(address owner, uint256 tokenIdBatchHead) = _ownerAndBatchHeadOf(tokenId);
require(
owner == from,
"ERC721Psi: transfer of token that is not own"
);
require(to != address(0), "ERC721Psi: transfer to the zero address");
_beforeTokenTransfers(from, to, tokenId, 1);
_approve(address(0), tokenId);
uint256 subsequentTokenId = tokenId + 1;
if(!_batchHead.get(subsequentTokenId) &&
subsequentTokenId < _nextTokenId()
) {
_owners[subsequentTokenId] = from;
_batchHead.set(subsequentTokenId);
}
_owners[tokenId] = to;
if(tokenId != tokenIdBatchHead) {
_batchHead.set(tokenId);
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
function _checkOnERC721Received(
address from,
address to,
uint256 startTokenId,
uint256 quantity,
bytes memory _data
) private returns (bool r) {
if (to.isContract()) {
r = true;
for(uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; tokenId++){
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
r = r && retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721Psi: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
return r;
} else {
return true;
}
}
function _getBatchHead(uint256 tokenId) internal view returns (uint256 tokenIdBatchHead) {
tokenIdBatchHead = _batchHead.scanForward(tokenId);
}
function totalSupply() public virtual view returns (uint256) {
return _totalMinted();
}
function tokensOfOwner(address owner) external view virtual returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
if (_exists(i)) {
if (ownerOf(i) == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
}
return tokenIds;
}
}
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
文件 14 的 34:ERC721PsiBurnable.sol
pragma solidity ^0.8.0;
import "solidity-bits/contracts/BitMaps.sol";
import "../ERC721Psi.sol";
abstract contract ERC721PsiBurnable is ERC721Psi {
using BitMaps for BitMaps.BitMap;
BitMaps.BitMap private _burnedToken;
function _burn(uint256 tokenId) internal virtual {
address from = ownerOf(tokenId);
_beforeTokenTransfers(from, address(0), tokenId, 1);
_burnedToken.set(tokenId);
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
}
function _exists(uint256 tokenId) internal view override virtual returns (bool){
if(_burnedToken.get(tokenId)) {
return false;
}
return super._exists(tokenId);
}
function totalSupply() public view virtual override returns (uint256) {
return _totalMinted() - _burned();
}
function _burned() internal view returns (uint256 burned){
uint256 startBucket = _startTokenId() >> 8;
uint256 lastBucket = (_nextTokenId() >> 8) + 1;
for(uint256 i=startBucket; i < lastBucket; i++) {
uint256 bucket = _burnedToken.getBucket(i);
burned += _popcount(bucket);
}
}
function _popcount(uint256 x) private pure returns (uint256 count) {
unchecked{
for (count=0; x!=0; count++)
x &= x - 1;
}
}
}
文件 15 的 34:ERC721RestrictApproveGlobalOnly.sol
pragma solidity >=0.8.0;
import "erc721psi/contracts/extension/ERC721PsiBurnable.sol";
import "./IERC721RestrictApproveGlobalOnly.sol";
import "contract-allow-list/contracts/proxy/interface/IContractAllowListProxy.sol";
abstract contract ERC721RestrictApproveGlobalOnly is ERC721PsiBurnable, IERC721RestrictApproveGlobalOnly {
IContractAllowListProxy public CAL;
modifier onlyHolder(uint256 tokenId) {
require(
msg.sender == ownerOf(tokenId),
"RestrictApprove: operation is only holder."
);
_;
}
bool public enableRestrict = true;
mapping(uint256 => uint256) public tokenCALLevel;
mapping(address => uint256) public walletCALLevel;
uint256 public CALLevel = 1;
function _isAllowed(address transferer)
internal
view
virtual
returns (bool)
{
return _isAllowed(msg.sender, transferer);
}
function _isAllowed(uint256 tokenId, address transferer)
internal
view
virtual
returns (bool)
{
uint256 level = _getCALLevel(msg.sender, tokenId);
return _isAllowed(transferer, level);
}
function _isAllowed(address holder, address transferer)
internal
view
virtual
returns (bool)
{
uint256 level = _getCALLevel(holder);
return _isAllowed(transferer, level);
}
function _isAllowed(address transferer, uint256 level)
internal
view
virtual
returns (bool)
{
if (!enableRestrict) {
return true;
}
return CAL.isAllowed(transferer, level);
}
function _getCALLevel(address holder, uint256 tokenId)
internal
view
virtual
returns (uint256)
{
if (tokenCALLevel[tokenId] > 0) {
return tokenCALLevel[tokenId];
}
return _getCALLevel(holder);
}
function _getCALLevel(address holder)
internal
view
virtual
returns (uint256)
{
if (walletCALLevel[holder] > 0) {
return walletCALLevel[holder];
}
return CALLevel;
}
function _setCAL(address _cal) internal virtual {
CAL = IContractAllowListProxy(_cal);
}
function _deleteTokenCALLevel(uint256 tokenId) internal virtual {
delete tokenCALLevel[tokenId];
}
function setTokenCALLevel(uint256 tokenId, uint256 level)
external
virtual
onlyHolder(tokenId)
{
tokenCALLevel[tokenId] = level;
}
function setWalletCALLevel(uint256 level)
external
virtual
{
walletCALLevel[msg.sender] = level;
}
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
if (_isAllowed(owner, operator) == false) {
return false;
}
return super.isApprovedForAll(owner, operator);
}
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(
_isAllowed(operator) || approved == false,
"RestrictApprove: Can not approve locked token"
);
super.setApprovalForAll(operator, approved);
}
function _beforeApprove(address to, uint256 tokenId)
internal
virtual
{
if (to != address(0)) {
require(_isAllowed(tokenId, to), "RestrictApprove: The contract is not allowed.");
}
}
function approve(address to, uint256 tokenId)
public
virtual
override
{
_beforeApprove(to, tokenId);
super.approve(to, tokenId);
}
function _afterTokenTransfers(
address from,
address,
uint256 startTokenId,
uint256
) internal virtual override {
if (from != address(0)) {
_deleteTokenCALLevel(startTokenId);
}
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IERC721RestrictApproveGlobalOnly).interfaceId ||
super.supportsInterface(interfaceId);
}
}
文件 16 的 34:IAccessControl.sol
pragma solidity ^0.8.0;
interface IAccessControl {
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
文件 17 的 34:IContractAllowListProxy.sol
pragma solidity >=0.7.0 <0.9.0;
interface IContractAllowListProxy {
function isAllowed(address _transferer, uint256 _level)
external
view
returns (bool);
}
文件 18 的 34:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 19 的 34:IERC2981.sol
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
文件 20 的 34:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool _approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 21 的 34:IERC721Lockable.sol
pragma solidity >=0.8.0;
interface IERC721Lockable {
enum LockStatus {
UnSet,
UnLock,
Lock
}
event TokenLock(address indexed holder, address indexed operator, LockStatus lockStatus, uint256 indexed tokenId);
event WalletLock(address indexed holder, address indexed operator, LockStatus lockStatus);
function setTokenLock(uint256[] calldata tokenIds, LockStatus lockStatus) external;
function setWalletLock(address to, LockStatus lockStatus) external;
function setContractLock(LockStatus lockStatus) external;
function isLocked(uint256 tokenId) external view returns (bool);
function isLocked(address holder) external view returns (bool);
function getTokensUnderLock() external view returns (uint256[] memory);
function getTokensUnderLock(uint256 start, uint256 end) external view returns (uint256[] memory);
}
文件 22 的 34:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 23 的 34:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 24 的 34:IERC721RestrictApproveGlobalOnly.sol
pragma solidity >=0.8.0;
interface IERC721RestrictApproveGlobalOnly {
event CalLevelChanged(address indexed operator, uint256 indexed level);
event LocalCalAdded(address indexed operator, address indexed transferer);
event LocalCalRemoved(address indexed operator, address indexed transferer);
function setCALLevel(uint256 level) external;
function setCAL(address calAddress) external;
}
文件 25 的 34:IMetadataRouter.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
interface IMetadataRouter{
struct SubNFT {
address addr;
uint256 tokenId;
string baseURI;
}
event UpdateSubNFT(uint16 indexed subId, address indexed addr, uint256 indexed tokenId, string key);
event UpdateSubIdForToken(uint256 tokenId, uint16 subId);
event UpdateGlobalPriority();
event UpdateMainNFT(address indexed addr);
function subNFTs(uint16) external view returns(SubNFT memory);
function tokenPriority(uint256 tokenId) external view returns(uint16 subId);
function globalPriorityArray() external view returns(uint16[] memory subIds);
function globalPriority(uint256 index) external view returns(uint16 subId);
function getGlobalPriorityLength() external view returns(uint256);
function mainNFT() external view returns(IERC721);
function getURI(uint256 tokenId, address owner, uint256 param) external view returns(string memory);
function getTotalSubNFTs() external view returns(uint256 total);
function appendSubNFT(SubNFT memory info) external returns(uint16 subId);
function updateSubNFT(uint16 subId, SubNFT memory info) external;
function disableSubNFT(uint16 subId) external;
function setTokenPriority(uint256 tokenId, uint16 subId) external;
function resetTokenPriority(uint256 tokenId) external;
function setGlobalPriority(uint16[] memory subIds) external;
function setMainNFT(IERC721 addr) external;
}
文件 26 的 34:IOperatorFilterRegistry.sol
pragma solidity ^0.8.13;
interface IOperatorFilterRegistry {
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
function register(address registrant) external;
function registerAndSubscribe(address registrant, address subscription) external;
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
function unregister(address addr) external;
function updateOperator(address registrant, address operator, bool filtered) external;
function updateOperators(address registrant, address[] calldata operators, bool filtered) external;
function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;
function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;
function subscribe(address registrant, address registrantToSubscribe) external;
function unsubscribe(address registrant, bool copyExistingEntries) external;
function subscriptionOf(address addr) external returns (address registrant);
function subscribers(address registrant) external returns (address[] memory);
function subscriberAt(address registrant, uint256 index) external returns (address);
function copyEntriesOf(address registrant, address registrantToCopy) external;
function isOperatorFiltered(address registrant, address operator) external returns (bool);
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
function filteredOperators(address addr) external returns (address[] memory);
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
function isRegistered(address addr) external returns (bool);
function codeHashOf(address addr) external returns (bytes32);
}
文件 27 的 34:ISalesItem.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface ISalesItem is IERC165{
function sellerMint(address to, uint256 quantity) external;
function sellerBurn(uint256 tokenId) external;
function burned() external view returns(uint256);
function getConsumedAllocation(address _target, uint8 _currentSaleIndex) external view returns(uint16);
function setConsumedAllocation(address _target, uint8 _currentSaleIndex, uint16 _consumed) external;
function addConsumedAllocation(address _target, uint8 _currentSaleIndex, uint16 _consumed) external;
}
文件 28 的 34:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1);
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
文件 29 的 34:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
文件 30 的 34:OperatorFilterer.sol
pragma solidity ^0.8.13;
import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol";
abstract contract OperatorFilterer {
error OperatorNotAllowed(address operator);
IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy != address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
modifier onlyAllowedOperator(address from) virtual {
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
modifier onlyAllowedOperatorApproval(address operator) virtual {
_checkFilterOperator(operator);
_;
}
function _checkFilterOperator(address operator) internal view virtual {
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
}
}
文件 31 的 34:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 32 的 34:PHVillains.sol
pragma solidity ^0.8.17;
import "./libs/IMetadataRouter.sol";
import "./libs/ERC721BasicFrame.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./libs/BitOperator.sol";
contract PixelHeroesVillains is ERC721BasicFrame {
using Strings for uint256;
using BitOperator for uint256;
uint256 private constant BITPOS_AUX_UPDATE_INDEX = 0;
uint256 private constant BITPOS_LOCK_STATUS = 0;
uint256 private constant BITPOS_UPDATE_INDEX = BITPOS_LOCK_STATUS + 1;
uint8 public currentUpdateIndex;
event UpdateToken(uint256 indexed tokenId, uint8 indexed updateIndex);
event IncreaseUpdateIndex(uint8 indexed updateIndex);
error InvalidUpdateIndex();
error ZeroUpdateIndex();
error RouterNotSet();
IMetadataRouter public router;
constructor() ERC721BasicFrame("Pixel Heroes Villains", "PHV", 10000) {
royaltyAddress = 0x56b75E59Ced86AB9C9eA4A0cAB89Db334620fA15;
_grantRole(MINTER_ROLE, msg.sender);
_grantRole(BURNER_ROLE, msg.sender);
_mint(msg.sender, 1);
}
function setRouter(IMetadataRouter _new) external onlyAdmin {
router = _new;
}
function setTokenLockByAdmin(uint256[] calldata tokenIds, LockStatus lockStatus)
external
onlyAdmin
{
_setTokenLock(tokenIds, lockStatus);
}
function getTokenUpdateIndex(uint256 tokenId) external view virtual returns(uint8){
if (!_exists(tokenId)) revert TokenNonexistent(tokenId);
return _getTokenUpdateIndex(tokenId);
}
function _getTokenUpdateIndex(uint256 tokenId) internal view virtual returns(uint8){
return _getTokenAux(tokenId).getBitValueUint8(BITPOS_AUX_UPDATE_INDEX);
}
function updateToken(uint256 tokenId)
external
virtual
onlyRole(UPDATER_ROLE)
{
uint8 index = currentUpdateIndex;
uint256 aux = _getTokenAux(tokenId);
if (!_exists(tokenId)) revert TokenNonexistent(tokenId);
if (index == 0) revert ZeroUpdateIndex();
if (aux.getBitValueUint8(BITPOS_AUX_UPDATE_INDEX) >= index) revert InvalidUpdateIndex();
emit UpdateToken(tokenId, index);
_setTokenAux(tokenId, aux.setBitValueUint8(BITPOS_AUX_UPDATE_INDEX, index));
}
function increaseCurrentUpdateIndex()
external
virtual
onlyRole(UPDATER_ROLE)
returns(uint8)
{
uint8 newIndex = currentUpdateIndex++;
emit IncreaseUpdateIndex(newIndex);
return newIndex;
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
if (address(router) == address(0)) revert RouterNotSet();
if (!_exists(tokenId)) revert TokenNonexistent(tokenId);
uint256 param = isLocked(tokenId) ? 1 : 0;
param = param.setBitValueUint8(BITPOS_UPDATE_INDEX, _getTokenUpdateIndex(tokenId));
return router.getURI(tokenId, ownerOf(tokenId), param);
}
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override {
if (from != address(0) && address(router) != address(0)) {
router.resetTokenPriority(startTokenId);
}
super._afterTokenTransfers(from, to, startTokenId, quantity);
}
}
文件 33 的 34:StorageSlot.sol
pragma solidity ^0.8.0;
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
文件 34 的 34:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
{
"compilationTarget": {
"contracts/PHVillains.sol": "PixelHeroesVillains"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 20
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArrayLengthIsZero","type":"error"},{"inputs":[],"name":"InvalidRole","type":"error"},{"inputs":[],"name":"InvalidUpdateIndex","type":"error"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"InvlidRoyaltyFee","type":"error"},{"inputs":[],"name":"MaxSupplyExceeded","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"NotAllowedByCAL","type":"error"},{"inputs":[],"name":"NotTokenHolder","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"OperatorNotAllowed","type":"error"},{"inputs":[],"name":"ProhibitedBecauseSBT","type":"error"},{"inputs":[],"name":"RouterNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenNonexistent","type":"error"},{"inputs":[],"name":"WalletLockNotAllowedByOthers","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroUpdateIndex","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"uint256","name":"level","type":"uint256"}],"name":"CalLevelChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint8","name":"updateIndex","type":"uint8"}],"name":"IncreaseUpdateIndex","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"transferer","type":"address"}],"name":"LocalCalAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"transferer","type":"address"}],"name":"LocalCalRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenLock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"updateIndex","type":"uint8"}],"name":"UpdateToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"}],"name":"WalletLock","type":"event"},{"inputs":[],"name":"BURNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CAL","outputs":[{"internalType":"contract IContractAllowListProxy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CALLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_FILTER_REGISTRY","outputs":[{"internalType":"contract IOperatorFilterRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SELLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPDATER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint8","name":"_currentSaleIndex","type":"uint8"},{"internalType":"uint16","name":"_consumed","type":"uint16"}],"name":"addConsumedAllocation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractLockStatus","outputs":[{"internalType":"enum IERC721Lockable.LockStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentUpdateIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableRestrict","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"externalBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"externalMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint8","name":"_currentSaleIndex","type":"uint8"}],"name":"getConsumedAllocation","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenUpdateIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"getTokensUnderLock","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokensUnderLock","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increaseCurrentUpdateIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"}],"name":"isLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSBT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"contract IMetadataRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyFee","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"sellerBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"sellerMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"calAddress","type":"address"}],"name":"setCAL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"level","type":"uint256"}],"name":"setCALLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"uint8","name":"_currentSaleIndex","type":"uint8"},{"internalType":"uint16","name":"_consumed","type":"uint16"}],"name":"setConsumedAllocation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"}],"name":"setContractLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setEnableLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setEnableRestrict","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setIsSBT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMetadataRouter","name":"_new","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_new","type":"address"}],"name":"setRoyaltyAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"_new","type":"uint96"}],"name":"setRoyaltyFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"level","type":"uint256"}],"name":"setTokenCALLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"}],"name":"setTokenLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"}],"name":"setTokenLockByAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"level","type":"uint256"}],"name":"setWalletCALLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"enum IERC721Lockable.LockStatus","name":"lockStatus","type":"uint8"}],"name":"setWalletLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenCALLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenLock","outputs":[{"internalType":"enum IERC721Lockable.LockStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"updateToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"walletCALLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"walletLock","outputs":[{"internalType":"enum IERC721Lockable.LockStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"}]