Verified contractExactMIT
SykyVips
Address0x99a2b56d146bfca762e8fa86e04a7b63483e1f57
- Balance
0 ETH
- Transactions
20
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- Yes, 300 runs
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 18,140,106
- Creation transaction
- 0x8e1bb0449f…df243271c6
12 files
- contracts/syky/SykyVips.solmain1.81 KB
- @thirdweb-dev/contracts/eip/interface/IERC1155.sol7.69 KB
- @thirdweb-dev/contracts/eip/interface/IERC721.sol4.65 KB
- @thirdweb-dev/contracts/eip/interface/IERC721A.sol2.89 KB
- @thirdweb-dev/contracts/eip/interface/IERC721Metadata.sol913 B
- @thirdweb-dev/contracts/extension/Permissions.sol6.67 KB
- @thirdweb-dev/contracts/extension/interface/IPermissions.sol2.89 KB
- @thirdweb-dev/contracts/lib/TWStrings.sol2.01 KB
- contracts/base/VipManager.sol12.37 KB
- contracts/base/interface/IGroupRegistry.sol1.83 KB
- contracts/base/interface/IVipManager.sol1.68 KB
- contracts/eip/interface/IERC721AProduct.sol4.54 KB
contracts/syky/SykyVips.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @author Syky - Nathan Rempel
/*
@@@ @@@@@ @@@@@@@ @@@@ @@@@@@@ @@@@@ @@@@@@@ @@@@
@@@@ @@@ @@@@@@ @@ @@@@@@ @@ @@@@@@ @@
@@@@@ @@ @@@@@ @@ @@@@@ @ @@@@@ @@
@@@@@@ @@ @@@@@ @@ @@@@@ @ @@@@ @@
@@@@@@ @ @@@@@ @@ @@@@@ @ @@@@@ @
@@@@@@@ @@@@@ @@ @@@@@ @@@ @@@@@ @
@@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@
@@@@@@ @@@@@ @@@@@ @@@@@ @@@@@
@@@@@@@ @@@@@ @@@@@ @@@@@ @@@@@
@ @@@@@@ @@@@@ @@@@@ @@@@@ @@@@@
@@ @@@@@ @@@@@ @@@@@ @@@@@ @@@@@
@@@@ @@@@@ @@@@@ @@@@@@ @@@@@@ @@@@@@
@@@@@@ @@@@ @@@@@@@ @@@@@@@ @@@@@@@ @@@@@@@
*/
import "../base/VipManager.sol";
contract SykyVips is VipManager {
/*//////////////////////////////////////////////////////////////
Version Info
//////////////////////////////////////////////////////////////*/
string public constant ENV = "MAINNET";
string public constant VER = "1.0.0";
/*//////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/
constructor(address defaultAdmin_) VipManager(defaultAdmin_) {}
}
@thirdweb-dev/contracts/eip/interface/IERC1155.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/**
@title ERC-1155 Multi Token Standard
@dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md
Note: The ERC-165 identifier for this interface is 0xd9b67a26.
*/
interface IERC1155 {
/**
@dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
The `_operator` argument MUST be msg.sender.
The `_from` argument MUST be the address of the holder whose balance is decreased.
The `_to` argument MUST be the address of the recipient whose balance is increased.
The `_id` argument MUST be the token type being transferred.
The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.
When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
*/
event TransferSingle(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256 _id,
uint256 _value
);
/**
@dev Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
The `_operator` argument MUST be msg.sender.
The `_from` argument MUST be the address of the holder whose balance is decreased.
The `_to` argument MUST be the address of the recipient whose balance is increased.
The `_ids` argument MUST be the list of tokens being transferred.
The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by.
When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
*/
event TransferBatch(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256[] _ids,
uint256[] _values
);
/**
@dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absense of an event assumes disabled).
*/
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
/**
@dev MUST emit when the URI is updated for a token ID.
URIs are defined in RFC 3986.
The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
*/
event URI(string _value, uint256 indexed _id);
/**
@notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).
@dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
MUST revert if `_to` is the zero address.
MUST revert if balance of holder for token `_id` is lower than the `_value` sent.
MUST revert on any other error.
MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
@param _from Source address
@param _to Target address
@param _id ID of the token type
@param _value Transfer amount
@param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
*/
function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes calldata _data
) external;
/**
@notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).
@dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
MUST revert if `_to` is the zero address.
MUST revert if length of `_ids` is not the same as length of `_values`.
MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient.
MUST revert on any other error.
MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
@param _from Source address
@param _to Target address
@param _ids IDs of each token type (order and length must match _values array)
@param _values Transfer amounts per token type (order and length must match _ids array)
@param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`
*/
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
/**
@notice Get the balance of an account's Tokens.
@param _owner The address of the token holder
@param _id ID of the Token
@return The _owner's balance of the Token type requested
*/
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
/**
@notice Get the balance of multiple account/token pairs
@param _owners The addresses of the token holders
@param _ids ID of the Tokens
@return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)
*/
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
external
view
returns (uint256[] memory);
/**
@notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
@dev MUST emit the ApprovalForAll event on success.
@param _operator Address to add to the set of authorized operators
@param _approved True if the operator is approved, false to revoke approval
*/
function setApprovalForAll(address _operator, bool _approved) external;
/**
@notice Queries the approval status of an operator for a given owner.
@param _owner The owner of the Tokens
@param _operator Address of authorized operator
@return True if the operator is approved, false if not
*/
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
@thirdweb-dev/contracts/eip/interface/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
@thirdweb-dev/contracts/eip/interface/IERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v3.3.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import "./IERC721.sol";
import "./IERC721Metadata.sol";
/**
* @dev Interface of an ERC721A compliant contract.
*/
interface IERC721A is IERC721, IERC721Metadata {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* The caller cannot approve to their own address.
*/
error ApproveToCaller();
/**
* The caller cannot approve to the current owner.
*/
error ApprovalToCurrentOwner();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
// For miscellaneous variable(s) pertaining to the address
// (e.g. number of whitelist mint slots used).
// If there are multiple variables, please pack them into a uint64.
uint64 aux;
}
/**
* @dev Returns the total amount of tokens stored by the contract.
*
* Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens.
*/
function totalSupply() external view returns (uint256);
}
@thirdweb-dev/contracts/eip/interface/IERC721Metadata.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// Note: the ERC-165 identifier for this interface is 0x5b5e139f.
/* is ERC721 */
interface IERC721Metadata {
/// @notice A descriptive name for a collection of NFTs in this contract
function name() external view returns (string memory);
/// @notice An abbreviated name for NFTs in this contract
function symbol() external view returns (string memory);
/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
/// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
/// 3986. The URI may point to a JSON file that conforms to the "ERC721
/// Metadata JSON Schema".
function tokenURI(uint256 _tokenId) external view returns (string memory);
}
@thirdweb-dev/contracts/extension/Permissions.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./interface/IPermissions.sol";
import "../lib/TWStrings.sol";
/**
* @title Permissions
* @dev This contracts provides extending-contracts with role-based access control mechanisms
*/
contract Permissions is IPermissions {
/// @dev Map from keccak256 hash of a role => a map from address => whether address has role.
mapping(bytes32 => mapping(address => bool)) private _hasRole;
/// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}.
mapping(bytes32 => bytes32) private _getRoleAdmin;
/// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles.
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @dev Modifier that checks if an account has the specified role; reverts otherwise.
modifier onlyRole(bytes32 role) {
_checkRole(role, msg.sender);
_;
}
/**
* @notice Checks whether an account has a particular role.
* @dev Returns `true` if `account` has been granted `role`.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _hasRole[role][account];
}
/**
* @notice Checks whether an account has a particular role;
* role restrictions can be swtiched on and off.
*
* @dev Returns `true` if `account` has been granted `role`.
* Role restrictions can be swtiched on and off:
* - If address(0) has ROLE, then the ROLE restrictions
* don't apply.
* - If address(0) does not have ROLE, then the ROLE
* restrictions will apply.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) {
if (!_hasRole[role][address(0)]) {
return _hasRole[role][account];
}
return true;
}
/**
* @notice Returns the admin role that controls the specified role.
* @dev See {grantRole} and {revokeRole}.
* To change a role's admin, use {_setRoleAdmin}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
*/
function getRoleAdmin(bytes32 role) external view override returns (bytes32) {
return _getRoleAdmin[role];
}
/**
* @notice Grants a role to an account, if not previously granted.
* @dev Caller must have admin role for the `role`.
* Emits {RoleGranted Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account to which the role is being granted.
*/
function grantRole(bytes32 role, address account) public virtual override {
_checkRole(_getRoleAdmin[role], msg.sender);
if (_hasRole[role][account]) {
revert("Can only grant to non holders");
}
_setupRole(role, account);
}
/**
* @notice Revokes role from an account.
* @dev Caller must have admin role for the `role`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function revokeRole(bytes32 role, address account) public virtual override {
_checkRole(_getRoleAdmin[role], msg.sender);
_revokeRole(role, account);
}
/**
* @notice Revokes role from the account.
* @dev Caller must have the `role`, with caller being the same as `account`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function renounceRole(bytes32 role, address account) public virtual override {
if (msg.sender != account) {
revert("Can only renounce for self");
}
_revokeRole(role, account);
}
/// @dev Sets `adminRole` as `role`'s admin role.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = _getRoleAdmin[role];
_getRoleAdmin[role] = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/// @dev Sets up `role` for `account`
function _setupRole(bytes32 role, address account) internal virtual {
_hasRole[role][account] = true;
emit RoleGranted(role, account, msg.sender);
}
/// @dev Revokes `role` from `account`
function _revokeRole(bytes32 role, address account) internal virtual {
_checkRole(role, account);
delete _hasRole[role][account];
emit RoleRevoked(role, account, msg.sender);
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRole(bytes32 role, address account) internal view virtual {
if (!_hasRole[role][account]) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual {
if (!hasRoleWithSwitch(role, account)) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
}
@thirdweb-dev/contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IPermissions {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
@thirdweb-dev/contracts/lib/TWStrings.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev String operations.
*/
library TWStrings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
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] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
contracts/base/VipManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @author Syky - Nathan Rempel
import "./interface/IVipManager.sol";
import "./interface/IGroupRegistry.sol";
import "../eip/interface/IERC721AProduct.sol";
import "@thirdweb-dev/contracts/extension/Permissions.sol";
import "@thirdweb-dev/contracts/eip/interface/IERC721.sol";
import "@thirdweb-dev/contracts/eip/interface/IERC1155.sol";
contract VipManager is IVipManager, Permissions {
/*//////////////////////////////////////////////////////////////
Constants
//////////////////////////////////////////////////////////////*/
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
/*//////////////////////////////////////////////////////////////
Mappings
//////////////////////////////////////////////////////////////*/
mapping(uint256 => uint256) private _selectors;
mapping(uint256 => VipConditionsData) private _conditions;
/*//////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/
constructor(address defaultAdmin_) {
_setupRole(DEFAULT_ADMIN_ROLE, defaultAdmin_);
_setRoleAdmin(MANAGER_ROLE, DEFAULT_ADMIN_ROLE);
}
/*//////////////////////////////////////////////////////////////
Admin functions
//////////////////////////////////////////////////////////////*/
function setSelectorConditions(
uint256 _selectorId,
uint256 _conditionsId
) external onlyManager {
_selectors[_selectorId] = _conditionsId;
emit VipSelectorConditionsUpdated(_selectorId, _conditionsId);
}
function setConditions(
uint256 _conditionsId,
VipConditions calldata _params
) external onlyManager {
VipConditionsData storage conditions = _conditions[_conditionsId];
conditions.groupConditions = _params.groupConditions;
_setProductConditions(conditions, _params.productConditions);
_setERC721Conditions(conditions, _params.erc721Conditions);
_setERC1155Conditions(conditions, _params.erc1155Conditions);
emit VipConditionsUpdated(_conditionsId, _params);
}
/*//////////////////////////////////////////////////////////////
Public getters
//////////////////////////////////////////////////////////////*/
function isVip(uint256 _selectorId, address _member) external view returns (bool) {
VipConditionsData storage conditions = _conditions[_selectors[_selectorId]];
return _checkConditions(conditions, _member);
}
function getSelectorConditions(uint256 _selectorId) external view returns (uint256) {
return _selectors[_selectorId];
}
function getConditions(
uint256 _conditionsId
) external view returns (VipConditions memory) {
VipConditionsData storage conditions = _conditions[_conditionsId];
return
VipConditions({
groupConditions: conditions.groupConditions,
productConditions: _getProductConditions(conditions),
erc721Conditions: _getERC721Conditions(conditions),
erc1155Conditions: _getERC1155Conditions(conditions)
});
}
/*//////////////////////////////////////////////////////////////
Modifiers
//////////////////////////////////////////////////////////////*/
/// @dev Modifier that checks if an account has admin or manager role; reverts otherwise.
modifier onlyManager() {
_checkManagerAdmin();
_;
}
/*//////////////////////////////////////////////////////////////
Internal functions
//////////////////////////////////////////////////////////////*/
/// @dev Function that checks if an account has admin or manager role; reverts otherwise.
function _checkManagerAdmin() internal view {
if (
!hasRole(DEFAULT_ADMIN_ROLE, msg.sender) && !hasRole(MANAGER_ROLE, msg.sender)
) {
revert ManagerRoleRequired();
}
}
function _checkConditions(
VipConditionsData storage conditions,
address member
) internal view returns (bool) {
GroupConditions memory groupConditions = conditions.groupConditions;
if (groupConditions.groupContract != address(0)) {
if (
IGroupRegistry(groupConditions.groupContract).isGroupMember(
groupConditions.groupId,
member
)
) {
return true;
}
}
uint256 idx = 0;
uint256 length = conditions.productLength;
unchecked {
while (idx < length) {
ProductConditionsData storage _storage = conditions.productConditions[
idx
];
uint256 idsLength = _storage.length;
for (uint256 i; i < idsLength; ) {
if (
0 <
IERC721AProduct(_storage.tokenContract).productBalanceOf(
member,
_storage.productIds[i]
)
) {
return true;
}
++i;
}
++idx;
}
}
idx = 0;
length = conditions.erc721Length;
while (idx < length) {
if (
0 <
IERC721(conditions.erc721Conditions[idx].tokenContract).balanceOf(member)
) {
return true;
}
unchecked {
++idx;
}
}
idx = 0;
length = conditions.erc1155Length;
while (idx < length) {
unchecked {
ERC1155ConditionsData storage _storage = conditions.erc1155Conditions[
idx
];
uint256 idsLength = _storage.length;
for (uint256 i; i < idsLength; ) {
if (
0 <
IERC1155(_storage.tokenContract).balanceOf(
member,
_storage.tokenIds[i]
)
) {
return true;
}
++i;
}
++idx;
}
}
return false;
}
function _setProductConditions(
VipConditionsData storage conditions,
ProductConditions[] memory productConditions
) internal {
uint256 newLength = productConditions.length;
uint256 oldLength = conditions.productLength;
if (newLength == 0 && oldLength == 0) return;
conditions.productLength = newLength;
for (uint256 i; i < newLength; ) {
ProductConditionsData storage _storage = conditions.productConditions[i];
ProductConditions memory _data = productConditions[i];
_storage.tokenContract = _data.tokenContract;
uint256 newIdLength = _data.productIds.length;
uint256 oldIdLength = _storage.length;
unchecked {
_storage.length = uint96(newIdLength);
for (uint256 k; k < newIdLength; ) {
_storage.productIds[k] = _data.productIds[k];
k++;
}
while (newIdLength < oldIdLength) {
delete _storage.productIds[newIdLength];
++newIdLength;
}
++i;
}
}
while (newLength < oldLength) {
delete conditions.productConditions[newLength];
unchecked {
++newLength;
}
}
}
function _getProductConditions(
VipConditionsData storage conditions
) internal view returns (ProductConditions[] memory) {
uint256 length = conditions.productLength;
ProductConditions[] memory _data = new ProductConditions[](length);
for (uint256 i; i < length; ) {
ProductConditionsData storage _storage = conditions.productConditions[i];
uint256 idsLength = _storage.length;
uint256[] memory ids = new uint256[](idsLength);
unchecked {
for (uint256 j; j < idsLength; ) {
ids[j] = _storage.productIds[j];
++j;
}
_data[i] = ProductConditions({
tokenContract: _storage.tokenContract,
productIds: ids
});
++i;
}
}
return _data;
}
function _setERC721Conditions(
VipConditionsData storage conditions,
ERC721Conditions[] memory erc721Conditions
) internal {
uint256 newLength = erc721Conditions.length;
uint256 oldLength = conditions.erc721Length;
if (newLength == 0 && oldLength == 0) return;
conditions.erc721Length = newLength;
unchecked {
for (uint256 i; i < newLength; ) {
conditions.erc721Conditions[i] = erc721Conditions[i];
++i;
}
while (newLength < oldLength) {
delete conditions.erc721Conditions[newLength];
++newLength;
}
}
}
function _getERC721Conditions(
VipConditionsData storage conditions
) internal view returns (ERC721Conditions[] memory) {
uint256 length = conditions.erc721Length;
ERC721Conditions[] memory _data = new ERC721Conditions[](length);
for (uint256 i; i < length; ) {
_data[i] = conditions.erc721Conditions[i];
unchecked {
++i;
}
}
return _data;
}
function _setERC1155Conditions(
VipConditionsData storage conditions,
ERC1155Conditions[] memory erc1155Conditions
) internal {
uint256 newLength = erc1155Conditions.length;
uint256 oldLength = conditions.erc1155Length;
if (newLength == 0 && oldLength == 0) return;
conditions.erc1155Length = newLength;
for (uint256 i; i < newLength; ) {
ERC1155ConditionsData storage _storage = conditions.erc1155Conditions[i];
ERC1155Conditions memory _data = erc1155Conditions[i];
_storage.tokenContract = _data.tokenContract;
uint256 newIdLength = _data.tokenIds.length;
uint256 oldIdLength = _storage.length;
_storage.length = uint96(newIdLength);
unchecked {
for (uint256 k; k < newIdLength; ) {
_storage.tokenIds[k] = _data.tokenIds[k];
++k;
}
while (newIdLength < oldIdLength) {
delete _storage.tokenIds[newIdLength];
++newIdLength;
}
++i;
}
}
while (newLength < oldLength) {
delete conditions.erc1155Conditions[newLength];
unchecked {
++newLength;
}
}
}
function _getERC1155Conditions(
VipConditionsData storage conditions
) internal view returns (ERC1155Conditions[] memory) {
uint256 length = conditions.erc1155Length;
ERC1155Conditions[] memory _data = new ERC1155Conditions[](length);
for (uint256 i; i < length; ) {
ERC1155ConditionsData storage _storage = conditions.erc1155Conditions[i];
uint256 idsLength = _storage.length;
uint256[] memory ids = new uint256[](idsLength);
unchecked {
for (uint256 j; j < idsLength; ) {
ids[j] = _storage.tokenIds[j];
++j;
}
_data[i] = ERC1155Conditions({
tokenContract: _storage.tokenContract,
tokenIds: ids
});
++i;
}
}
return _data;
}
}
contracts/base/interface/IGroupRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @author Syky - Nathan Rempel
interface IGroupRegistry {
struct ItemSet {
uint256 index;
mapping(uint256 => uint256) items;
mapping(uint256 => uint256) indexOf;
}
struct GroupMembersQuery {
uint256 groupId;
SubgroupMembersQuery[] subgroups;
}
struct SubgroupMembersQuery {
uint256 subgroupId;
address[] members;
}
function isGroupMember(
uint256 _groupId,
address _member
) external view returns (bool);
function isSubgroupMember(
uint256 _subgroupId,
address _member
) external view returns (bool);
function groupMembers(
uint256 _groupId
) external view returns (GroupMembersQuery memory);
function groupSubgroups(uint256 _groupId) external view returns (uint256[] memory);
function subgroupMembers(
uint256 _subgroupId
) external view returns (SubgroupMembersQuery memory);
function assignMembers(uint256 _subgroupId, address[] calldata _members) external;
function removeMembers(uint256 _subgroupId, address[] calldata _members) external;
function assignSubgroups(uint256 _groupId, uint256[] calldata _subgroupIds) external;
function removeSubgroups(uint256 _groupId, uint256[] calldata _subgroupIds) external;
event MembersAssigned(uint256 indexed subgroupId, address[] members);
event MembersRemoved(uint256 indexed subgroupId, address[] members);
event SubgroupsAssigned(uint256 indexed groupId, uint256[] subgroupIds);
event SubgroupsRemoved(uint256 indexed groupId, uint256[] subgroupIds);
error ManagerRoleRequired();
error NonZeroIdRequired();
error NonEmptyArrayRequired();
error AlreadyAssigned();
error AlreadyRemoved();
}
contracts/base/interface/IVipManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @author Syky - Nathan Rempel
interface IVipManager {
struct VipConditions {
GroupConditions groupConditions;
ProductConditions[] productConditions;
ERC721Conditions[] erc721Conditions;
ERC1155Conditions[] erc1155Conditions;
}
struct VipConditionsData {
uint256 productLength;
uint256 erc721Length;
uint256 erc1155Length;
GroupConditions groupConditions;
mapping(uint256 => ERC721Conditions) erc721Conditions;
mapping(uint256 => ERC1155ConditionsData) erc1155Conditions;
mapping(uint256 => ProductConditionsData) productConditions;
}
struct GroupConditions {
address groupContract;
uint256 groupId;
}
struct ERC721Conditions {
address tokenContract;
}
struct ProductConditions {
address tokenContract;
uint256[] productIds;
}
struct ERC1155Conditions {
address tokenContract;
uint256[] tokenIds;
}
struct ERC1155ConditionsData {
address tokenContract;
uint96 length;
mapping(uint256 => uint256) tokenIds;
}
struct ProductConditionsData {
address tokenContract;
uint96 length;
mapping(uint256 => uint256) productIds;
}
function isVip(uint256 _selectorId, address _member) external view returns (bool);
error ManagerRoleRequired();
event VipSelectorConditionsUpdated(
uint256 indexed selectorId,
uint256 indexed conditionsId
);
event VipConditionsUpdated(uint256 indexed conditionsId, VipConditions conditions);
}
contracts/eip/interface/IERC721AProduct.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @author Syky - Nathan Rempel
import "@thirdweb-dev/contracts/eip/interface/IERC721A.sol";
interface IERC721AProduct is IERC721A {
/*//////////////////////////////////////////////////////////////
Structs
//////////////////////////////////////////////////////////////*/
// Compiler will pack this into a single 256bit word.
struct ProductData {
// Keeps track of quantity, Realistically, 2**64-1 is more than enough.
uint64 quantity;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
//Toggles if mints are disabled for this product
//Defaults to enabled (locked = false)
bool locked;
//Toggles if transfers are disabled for this product
//Defaults to enabled (frozen = false)
bool frozen;
//Toggles if burns are enabled for this product
//Defaults to disabled (burnable = false)
bool burnable;
//Toggles if tokens within the product have unique metadata
//Defaults to non-unique (uniqueMetadata = false)
bool uniqueMetadata;
}
/*//////////////////////////////////////////////////////////////
Methods
//////////////////////////////////////////////////////////////*/
/**
* @dev Returns the total amount of tokens stored by the contract product.
*
* Burned tokens are calculated here, use `_getProductMinted()` if you want to count just minted tokens.
*/
function productSupply(uint256 productId) external view returns (uint256);
function productBalanceOf(
address owner,
uint256 productId
) external view returns (uint256);
/*//////////////////////////////////////////////////////////////
Events
//////////////////////////////////////////////////////////////*/
/// @dev Emitted when a product is created or has its supply modified
event ProductQuantityUpdated(
uint256 indexed productId,
uint64 indexed oldQuantity,
uint64 indexed newQuantity
);
/// @dev Emitted when specific product mints are enabled or disabled
event ProductMintingRestricted(
uint256 indexed productId,
bool indexed isRestricted
);
/// @dev Emitted when specific product transfers are enabled or disabled
event ProductTransfersRestricted(
uint256 indexed productId,
bool indexed isRestricted
);
/// @dev Emitted when specific product burns are enabled or disabled
event ProductBurningRestricted(
uint256 indexed productId,
bool indexed isRestricted
);
/// @dev Emitted when specific products toggle unique token metadata within product
event ProductUniqueTokenMetadata(
uint256 indexed productId,
bool indexed isUniquePerToken
);
/*//////////////////////////////////////////////////////////////
Errors
//////////////////////////////////////////////////////////////*/
/// @dev The product scale must be set prior to minting.
error ProductOffsetAfterMinting();
/// @dev The product scale must be set prior to minting.
error ProductOffsetOutsideRange(
uint256 requested,
uint256 minumum,
uint256 maximum
);
/// @dev The productId must not exceed the maximum for the scale.
error ProductIdExceedsOffsetMaximum(uint256 requested, uint256 maximum);
/// @dev The product quantity must not exceed the maximum for the scale.
error ProductQuantityExceedsOffsetMaximum(
uint256 requested,
uint256 maximum
);
/// @dev The product quantity must equal or exceed the number minted.
error ProductMintsExceedsQuantity();
/// @dev The product must be configured by setting a quantity.
error ProductNotConfigured();
/// @dev The token ID is impossible given the product scale.
error ProductQueryForImpossibleToken();
/// @dev The token ID cannot exist given configured product
error ProductQueryForNonexistantToken();
/// @dev Minting is disabled for this product
error ProductMintingDisabled();
/// @dev Burning are disabled for this product
error ProductBurningDisabled();
/// @dev Transfers are disabled for this product
error ProductTransfersDisabled();
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 300,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.