Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- CUBE
- Optimization enabled
- true
- Compiler version
- v0.8.20+commit.a1b79de6
- Optimization runs
- 10000
- EVM Version
- paris
- Verified at
- 2024-08-01T16:16:09.515377Z
src/CUBE.sol
// SPDX-License-Identifier: Apache-2.0
/*
.____ ________
| | _____ ___.__. __________\_____ \
| | \__ \< | |/ __ \_ __ \_(__ <
| |___ / __ \\___ \ ___/| | \/ \
|_______ (____ / ____|\___ >__| /______ /
\/ \/\/ \/ \/
*/
pragma solidity 0.8.20;
import {EIP712Upgradeable} from
"@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {ERC721Upgradeable} from
"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import {AccessControlUpgradeable} from
"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from
"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import {IFactory} from "./escrow/interfaces/IFactory.sol";
import {ITokenType} from "./escrow/interfaces/ITokenType.sol";
/// @title CUBE
/// @dev Implementation of an NFT smart contract with EIP712 signatures.
/// The contract is upgradeable using OpenZeppelin's UUPSUpgradeable pattern.
/// @custom:oz-upgrades-from CUBE
contract CUBE is
Initializable,
ERC721Upgradeable,
AccessControlUpgradeable,
UUPSUpgradeable,
EIP712Upgradeable,
ReentrancyGuardUpgradeable,
ITokenType
{
using ECDSA for bytes32;
error CUBE__IsNotSigner();
error CUBE__MintingIsNotActive();
error CUBE__FeeNotEnough();
error CUBE__SignatureAndCubesInputMismatch();
error CUBE__WithdrawFailed();
error CUBE__NonceAlreadyUsed();
error CUBE__TransferFailed();
error CUBE__BPSTooHigh();
error CUBE__ExcessiveFeePayout();
error CUBE__ExceedsContractBalance();
error CUBE__QuestNotActive();
uint256 internal s_nextTokenId;
bool public s_isMintingActive;
bytes32 public constant SIGNER_ROLE = keccak256("SIGNER");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER");
bytes32 internal constant TX_DATA_HASH =
keccak256("TransactionData(string txHash,string networkChainId)");
bytes32 internal constant RECIPIENT_DATA_HASH =
keccak256("FeeRecipient(address recipient,uint16 BPS)");
bytes32 internal constant REWARD_DATA_HASH = keccak256(
"RewardData(address tokenAddress,uint256 chainId,uint256 amount,uint256 tokenId,uint8 tokenType,uint256 rakeBps,address factoryAddress)"
);
bytes32 internal constant CUBE_DATA_HASH = keccak256(
"CubeData(uint256 questId,uint256 nonce,uint256 price,address toAddress,string walletProvider,string tokenURI,string embedOrigin,TransactionData[] transactions,FeeRecipient[] recipients,RewardData reward)FeeRecipient(address recipient,uint16 BPS)RewardData(address tokenAddress,uint256 chainId,uint256 amount,uint256 tokenId,uint8 tokenType,uint256 rakeBps,address factoryAddress)TransactionData(string txHash,string networkChainId)"
);
mapping(uint256 => uint256) internal s_questIssueNumbers;
mapping(uint256 => string) internal s_tokenURIs;
mapping(uint256 nonce => bool isConsumed) internal s_nonces;
mapping(uint256 => bool) internal s_quests;
enum QuestType {
QUEST,
STREAK
}
enum Difficulty {
BEGINNER,
INTERMEDIATE,
ADVANCED
}
/// @notice Emitted when a new quest is initialized
/// @param questId The unique identifier of the quest
/// @param questType The type of the quest (QUEST, STREAK)
/// @param difficulty The difficulty level of the quest (BEGINNER, INTERMEDIATE, ADVANCED)
/// @param title The title of the quest
/// @param tags An array of tags associated with the quest
/// @param communities An array of communities associated with the quest
event QuestMetadata(
uint256 indexed questId,
QuestType questType,
Difficulty difficulty,
string title,
string[] tags,
string[] communities
);
/// @notice Emitted when a CUBE is claimed
/// @param questId The quest ID associated with the CUBE
/// @param tokenId The token ID of the minted CUBE
/// @param claimer Address of the CUBE claimer
/// @param issueNumber The issue number of the CUBE
/// @param walletProvider The name of the wallet provider used for claiming
/// @param embedOrigin The origin of the embed associated with the CUBE
event CubeClaim(
uint256 indexed questId,
uint256 indexed tokenId,
address indexed claimer,
uint256 issueNumber,
string walletProvider,
string embedOrigin
);
/// @notice Emitted for each transaction associated with a CUBE claim
/// This event is designed to support both EVM and non-EVM blockchains
/// @param cubeTokenId The token ID of the Cube
/// @param txHash The hash of the transaction
/// @param networkChainId The network and chain ID of the transaction in the format <network>:<chain-id>
event CubeTransaction(uint256 indexed cubeTokenId, string txHash, string networkChainId);
/// @notice Emitted when there is a reward associated with a CUBE
/// @param cubeTokenId The token ID of the CUBE giving the reward
/// @param tokenAddress The token address of the reward
/// @param chainId The blockchain chain ID where the transaction occurred
/// @param amount The amount of the reward
/// @param tokenId Token ID of the reward (only applicable for ERC721 and ERC1155)
/// @param tokenType The type of reward token
event TokenReward(
uint256 indexed cubeTokenId,
address indexed tokenAddress,
uint256 indexed chainId,
uint256 amount,
uint256 tokenId,
TokenType tokenType
);
/// @notice Emitted when a fee payout is made
/// @param recipient The address of the payout recipient
/// @param amount The amount of the payout
event FeePayout(address indexed recipient, uint256 amount);
/// @notice Emitted when the minting switch is turned on/off
/// @param isActive The boolean showing if the minting is active or not
event MintingSwitch(bool isActive);
/// @notice Emitted when the contract balance is withdrawn by an admin
/// @param amount The contract's balance that was withdrawn
event ContractWithdrawal(uint256 amount);
event QuestDisabled(uint256 indexed questId);
/// @dev Represents the data needed for minting a CUBE.
/// @param questId The ID of the quest associated with the CUBE
/// @param nonce A unique number to prevent replay attacks
/// @param price The price paid for minting the CUBE
/// @param toAddress The address where the CUBE will be minted
/// @param walletProvider The wallet provider used for the transaction
/// @param tokenURI The URI pointing to the CUBE's metadata
/// @param embedOrigin The origin source of the CUBE's embed content
/// @param transactions An array of transactions related to the CUBE
/// @param recipients An array of recipients for fee payouts
/// @param reward Data about the reward associated with the CUBE
struct CubeData {
uint256 questId;
uint256 nonce;
uint256 price;
address toAddress;
string walletProvider;
string tokenURI;
string embedOrigin;
TransactionData[] transactions;
FeeRecipient[] recipients;
RewardData reward;
}
/// @dev Represents a recipient for fee distribution.
/// @param recipient The address of the fee recipient
/// @param BPS The basis points representing the fee percentage for the recipient
struct FeeRecipient {
address recipient;
uint16 BPS;
}
/// @dev Contains data about the token rewards associated with a CUBE.
/// @param tokenAddress The token address of the reward
/// @param chainId The blockchain chain ID where the transaction occurred
/// @param amount The amount of the reward
/// @param tokenId The token ID
/// @param tokenType The token type
/// @param rakeBps The rake basis points
/// @param factoryAddress The escrow factory address
struct RewardData {
address tokenAddress;
uint256 chainId;
uint256 amount;
uint256 tokenId;
TokenType tokenType;
uint256 rakeBps;
address factoryAddress;
}
/// @dev Contains data about a specific transaction related to a CUBE
/// and is designed to support both EVM and non-EVM data.
/// @param txHash The hash of the transaction
/// @param networkChainId The network and chain ID of the transaction in the format <network>:<chain-id>
struct TransactionData {
string txHash;
string networkChainId;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @notice Returns the version of the CUBE smart contract
function cubeVersion() external pure returns (string memory) {
return "2";
}
/// @notice Initializes the CUBE contract with necessary parameters
/// @dev Sets up the ERC721 token with given name and symbol, and grants initial roles.
/// @param _tokenName Name of the NFT collection
/// @param _tokenSymbol Symbol of the NFT collection
/// @param _signingDomain Domain used for EIP712 signing
/// @param _signatureVersion Version of the EIP712 signature
/// @param _admin Address to be granted the admin roles
function initialize(
string memory _tokenName,
string memory _tokenSymbol,
string memory _signingDomain,
string memory _signatureVersion,
address _admin
) external initializer {
__ERC721_init(_tokenName, _tokenSymbol);
__EIP712_init(_signingDomain, _signatureVersion);
__AccessControl_init();
__UUPSUpgradeable_init();
__ReentrancyGuard_init();
s_isMintingActive = true;
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
/// @notice Authorizes an upgrade to a new contract implementation
/// @dev Overrides the UUPSUpgradeable internal function with access control.
/// @param newImplementation Address of the new contract implementation
function _authorizeUpgrade(address newImplementation)
internal
override
onlyRole(UPGRADER_ROLE)
{}
/// @notice Checks whether a quest is active or not
/// @param questId Unique identifier for the quest
function isQuestActive(uint256 questId) public view returns (bool) {
return s_quests[questId];
}
/// @notice Retrieves the URI for a given token
/// @dev Overrides the ERC721Upgradeable's tokenURI method.
/// @param _tokenId The ID of the token
/// @return _tokenURI The URI of the specified token
function tokenURI(uint256 _tokenId) public view override returns (string memory _tokenURI) {
return s_tokenURIs[_tokenId];
}
/// @notice Mints a CUBE based on the provided data
/// @param cubeData CubeData struct containing minting information
/// @param signature Signature of the CubeData struct
function mintCube(CubeData calldata cubeData, bytes calldata signature)
external
payable
nonReentrant
{
// Check if the minting function is currently active. If not, revert the transaction
if (!s_isMintingActive) {
revert CUBE__MintingIsNotActive();
}
// Check if the sent value is at least equal to the calculated total fee
if (msg.value < cubeData.price) {
revert CUBE__FeeNotEnough();
}
_mintCube(cubeData, signature);
}
/// @notice Mints multiple cubes based on provided data and signatures
/// @dev Checks if minting is active, matches cube data with signatures, and processes each mint.
/// @param cubeData Array of CubeData structures containing minting information
/// @param signatures Array of signatures corresponding to each CubeData
function mintCubes(CubeData[] calldata cubeData, bytes[] calldata signatures)
external
payable
nonReentrant
{
// Check if the minting function is currently active. If not, revert the transaction
if (!s_isMintingActive) {
revert CUBE__MintingIsNotActive();
}
// Ensure that each CubeData entry has a corresponding signature
if (cubeData.length != signatures.length) {
revert CUBE__SignatureAndCubesInputMismatch();
}
// Calculate the total fee required for all the minting requests
uint256 totalFee;
for (uint256 i = 0; i < cubeData.length;) {
totalFee = totalFee + cubeData[i].price;
unchecked {
++i;
}
}
// Check if the sent value is at least equal to the calculated total fee
if (msg.value < totalFee) {
revert CUBE__FeeNotEnough();
}
// Loop through each CubeData entry and mint a CUBE
for (uint256 i = 0; i < cubeData.length;) {
_mintCube(cubeData[i], signatures[i]);
unchecked {
++i;
}
}
}
/// @notice Internal function to handle the logic of minting a single cube
/// @dev Verifies the signer, handles nonce, transactions, referral payments, and minting.
/// @param data The CubeData containing details of the minting
/// @param signature The signature for verification
function _mintCube(CubeData calldata data, bytes calldata signature) internal {
// Cache the tokenId
uint256 tokenId = s_nextTokenId;
// Validate the signature to ensure the mint request is authorized
_validateSignature(data, signature);
// Iterate over all the transactions in the mint request and emit events
for (uint256 i = 0; i < data.transactions.length;) {
emit CubeTransaction(
tokenId, data.transactions[i].txHash, data.transactions[i].networkChainId
);
unchecked {
++i;
}
}
// Set the token URI for the CUBE
s_tokenURIs[tokenId] = data.tokenURI;
// Increment the counters for quest completion, issue numbers, and token IDs
unchecked {
++s_questIssueNumbers[data.questId];
++s_nextTokenId;
}
// Process any payouts to fee recipients if applicable
if (data.recipients.length > 0) {
_processPayouts(data);
}
// Perform the actual minting of the CUBE
_safeMint(data.toAddress, tokenId);
// Emit an event indicating a CUBE has been claimed
emit CubeClaim(
data.questId,
tokenId,
data.toAddress,
s_questIssueNumbers[data.questId],
data.walletProvider,
data.embedOrigin
);
if (data.reward.chainId != 0) {
if (data.reward.factoryAddress != address(0)) {
IFactory(data.reward.factoryAddress).distributeRewards(
data.questId,
data.reward.tokenAddress,
data.toAddress,
data.reward.amount,
data.reward.tokenId,
data.reward.tokenType,
data.reward.rakeBps
);
}
emit TokenReward(
tokenId,
data.reward.tokenAddress,
data.reward.chainId,
data.reward.amount,
data.reward.tokenId,
data.reward.tokenType
);
}
}
/// @notice Validates the signature for a Cube minting request
/// @dev Ensures that the signature is from a valid signer and the nonce hasn't been used before
/// @param data The CubeData struct containing minting details
/// @param signature The signature to be validated
function _validateSignature(CubeData calldata data, bytes calldata signature) internal {
address signer = _getSigner(data, signature);
if (!hasRole(SIGNER_ROLE, signer)) {
revert CUBE__IsNotSigner();
}
if (s_nonces[data.nonce]) {
revert CUBE__NonceAlreadyUsed();
}
s_nonces[data.nonce] = true;
}
/// @notice Processes fee payouts to specified recipients
/// @dev Distributes a portion of the minting fee to designated addresses based on their Basis Points (BPS)
/// @param data The CubeData struct containing payout details
function _processPayouts(CubeData calldata data) internal {
uint256 totalAmount;
// max basis points is 10k (100%)
uint16 maxBps = 10_000;
uint256 contractBalance = address(this).balance;
for (uint256 i = 0; i < data.recipients.length;) {
if (data.recipients[i].BPS > maxBps) {
revert CUBE__BPSTooHigh();
}
// Calculate the referral amount for each recipient
uint256 referralAmount = (data.price * data.recipients[i].BPS) / maxBps;
totalAmount = totalAmount + referralAmount;
// Ensure the total payout does not exceed the cube price or contract balance
if (totalAmount > data.price) {
revert CUBE__ExcessiveFeePayout();
}
if (totalAmount > contractBalance) {
revert CUBE__ExceedsContractBalance();
}
// Transfer the referral amount to the recipient
address recipient = data.recipients[i].recipient;
if (recipient != address(0)) {
(bool success,) = recipient.call{value: referralAmount}("");
if (!success) {
revert CUBE__TransferFailed();
}
emit FeePayout(recipient, referralAmount);
}
unchecked {
++i;
}
}
}
/// @notice Recovers the signer's address from the CubeData and its associated signature
/// @dev Utilizes EIP-712 typed data hashing and ECDSA signature recovery
/// @param data The CubeData struct containing the details of the minting request
/// @param sig The signature associated with the CubeData
/// @return The address of the signer who signed the CubeData
function _getSigner(CubeData calldata data, bytes calldata sig)
internal
view
returns (address)
{
bytes32 digest = _computeDigest(data);
return digest.recover(sig);
}
/// @notice Internal function to compute the EIP712 digest for CubeData
/// @dev Generates the digest that must be signed by the signer.
/// @param data The CubeData to generate a digest for
/// @return The computed EIP712 digest
function _computeDigest(CubeData calldata data) internal view returns (bytes32) {
return _hashTypedDataV4(keccak256(_getStructHash(data)));
}
/// @notice Internal function to generate the struct hash for CubeData
/// @dev Encodes the CubeData struct into a hash as per EIP712 standard.
/// @param data The CubeData struct to hash
/// @return A hash representing the encoded CubeData
function _getStructHash(CubeData calldata data) internal pure returns (bytes memory) {
return abi.encode(
CUBE_DATA_HASH,
data.questId,
data.nonce,
data.price,
data.toAddress,
_encodeString(data.walletProvider),
_encodeString(data.tokenURI),
_encodeString(data.embedOrigin),
_encodeCompletedTxs(data.transactions),
_encodeRecipients(data.recipients),
_encodeReward(data.reward)
);
}
/// @notice Encodes a string into a bytes32 hash
/// @dev Used for converting strings into a consistent format for EIP712 encoding
/// @param _string The string to be encoded
/// @return The keccak256 hash of the encoded string
function _encodeString(string calldata _string) internal pure returns (bytes32) {
return keccak256(bytes(_string));
}
/// @notice Encodes a transaction data into a byte array
/// @dev Used for converting transaction data into a consistent format for EIP712 encoding
/// @param transaction The TransactionData struct to be encoded
/// @return A byte array representing the encoded transaction data
function _encodeTx(TransactionData calldata transaction) internal pure returns (bytes memory) {
return abi.encode(
TX_DATA_HASH,
_encodeString(transaction.txHash),
_encodeString(transaction.networkChainId)
);
}
/// @notice Encodes an array of transaction data into a single bytes32 hash
/// @dev Used to aggregate multiple transactions into a single hash for EIP712 encoding
/// @param txData An array of TransactionData structs to be encoded
/// @return A bytes32 hash representing the aggregated and encoded transaction data
function _encodeCompletedTxs(TransactionData[] calldata txData)
internal
pure
returns (bytes32)
{
bytes32[] memory encodedTxs = new bytes32[](txData.length);
for (uint256 i = 0; i < txData.length;) {
encodedTxs[i] = keccak256(_encodeTx(txData[i]));
unchecked {
++i;
}
}
return keccak256(abi.encodePacked(encodedTxs));
}
/// @notice Encodes a fee recipient data into a byte array
/// @dev Used for converting fee recipient information into a consistent format for EIP712 encoding
/// @param data The FeeRecipient struct to be encoded
/// @return A byte array representing the encoded fee recipient data
function _encodeRecipient(FeeRecipient calldata data) internal pure returns (bytes memory) {
return abi.encode(RECIPIENT_DATA_HASH, data.recipient, data.BPS);
}
/// @notice Encodes an array of fee recipient data into a single bytes32 hash
/// @dev Used to aggregate multiple fee recipient entries into a single hash for EIP712 encoding
/// @param data An array of FeeRecipient structs to be encoded
/// @return A bytes32 hash representing the aggregated and encoded fee recipient data
function _encodeRecipients(FeeRecipient[] calldata data) internal pure returns (bytes32) {
bytes32[] memory encodedRecipients = new bytes32[](data.length);
for (uint256 i = 0; i < data.length;) {
encodedRecipients[i] = keccak256(_encodeRecipient(data[i]));
unchecked {
++i;
}
}
return keccak256(abi.encodePacked(encodedRecipients));
}
/// @notice Encodes the reward data for a CUBE mint
/// @param data An array of FeeRecipient structs to be encoded
/// @return A bytes32 hash representing the encoded reward data
function _encodeReward(RewardData calldata data) internal pure returns (bytes32) {
return keccak256(
abi.encode(
REWARD_DATA_HASH,
data.tokenAddress,
data.chainId,
data.amount,
data.tokenId,
data.tokenType,
data.rakeBps,
data.factoryAddress
)
);
}
/// @notice Enables or disables the minting process
/// @dev Can only be called by an account with the default admin role.
/// @param _isMintingActive Boolean indicating whether minting should be active
function setIsMintingActive(bool _isMintingActive) external onlyRole(DEFAULT_ADMIN_ROLE) {
s_isMintingActive = _isMintingActive;
emit MintingSwitch(_isMintingActive);
}
/// @notice Withdraws the contract's balance to the message sender
/// @dev Can only be called by an account with the default admin role.
function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
(bool success,) = msg.sender.call{value: address(this).balance}("");
if (!success) {
revert CUBE__WithdrawFailed();
}
emit ContractWithdrawal(address(this).balance);
}
/// @notice Initializes a new quest with given parameters
/// @dev Can only be called by an account with the signer role.
/// @param questId Unique identifier for the quest
/// @param communities Array of community names associated with the quest
/// @param title Title of the quest
/// @param difficulty Difficulty level of the quest
/// @param questType Type of the quest
function initializeQuest(
uint256 questId,
string[] memory communities,
string memory title,
Difficulty difficulty,
QuestType questType,
string[] memory tags
) external onlyRole(SIGNER_ROLE) {
s_quests[questId] = true;
emit QuestMetadata(questId, questType, difficulty, title, tags, communities);
}
/// @notice Unpublishes and disables a quest
/// @dev Can only be called by an account with the signer role
/// @param questId Unique identifier for the quest
function unpublishQuest(uint256 questId) external onlyRole(SIGNER_ROLE) {
s_quests[questId] = false;
emit QuestDisabled(questId);
}
/// @notice Checks if the contract implements an interface
/// @dev Overrides the supportsInterface function of ERC721Upgradeable and AccessControlUpgradeable.
/// @param interfaceId The interface identifier, as specified in ERC-165
/// @return True if the contract implements the interface, false otherwise
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Upgradeable, AccessControlUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
lib/openzeppelin-contracts-upgradeable/contracts/access/AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @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.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @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 revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC1967-compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/token/ERC721/ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../../utils/introspection/ERC165Upgradeable.sol";
import {IERC721Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
abstract contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
/// @custom:storage-location erc7201:openzeppelin.storage.ERC721
struct ERC721Storage {
// Token name
string _name;
// Token symbol
string _symbol;
mapping(uint256 tokenId => address) _owners;
mapping(address owner => uint256) _balances;
mapping(uint256 tokenId => address) _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) _operatorApprovals;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC721")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC721StorageLocation = 0x80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300;
function _getERC721Storage() private pure returns (ERC721Storage storage $) {
assembly {
$.slot := ERC721StorageLocation
}
}
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC721Storage storage $ = _getERC721Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual returns (uint256) {
ERC721Storage storage $ = _getERC721Storage();
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return $._balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual returns (string memory) {
ERC721Storage storage $ = _getERC721Storage();
return $._name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual returns (string memory) {
ERC721Storage storage $ = _getERC721Storage();
return $._symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
ERC721Storage storage $ = _getERC721Storage();
return $._operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
// Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
* consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
* `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
return $._owners[tokenId];
}
/**
* @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
*/
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
return $._tokenApprovals[tokenId];
}
/**
* @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
* particular (ignoring whether it is owned by `owner`).
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
/**
* @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
* Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
* the `spender` for the specific `tokenId`.
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increasing an account's balance using this function tends to be paired with an override of the
* {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
* remain consistent with one another.
*/
function _increaseBalance(address account, uint128 value) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
unchecked {
$._balances[account] += value;
}
}
/**
* @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
* (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that
* `auth` is either the owner of the token, or approved to operate on the token (by the owner).
*
* Emits a {Transfer} event.
*
* NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
address from = _ownerOf(tokenId);
// Perform (optional) operator check
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
// Execute the update
if (from != address(0)) {
// Clear approval. No need to re-authorize or emit the Approval event
_approve(address(0), tokenId, address(0), false);
unchecked {
$._balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
$._balances[to] += 1;
}
}
$._owners[tokenId] = to;
emit Transfer(from, to, tokenId);
return from;
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
/**
* @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
_checkOnERC721Received(address(0), to, tokenId, data);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
* are aware of the ERC721 standard to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is like {safeTransferFrom} in the sense that it invokes
* {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `tokenId` token must exist and be owned by `from`.
* - `to` cannot be the zero address.
* - `from` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
* either the owner of the token, or approved to operate on all tokens held by this owner.
*
* Emits an {Approval} event.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
/**
* @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
* emitted in the context of transfers.
*/
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
// Avoid reading the owner unless necessary
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
// We do not use _isAuthorized because single-token approvals should not be able to call approve
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
if (emitEvent) {
emit Approval(owner, to, tokenId);
}
}
$._tokenApprovals[tokenId] = to;
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Requirements:
* - operator can't be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
$._operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
* Returns the owner.
*
* Overrides to ownership logic should be done to {_ownerOf}.
*/
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
* recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
revert ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC721InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/cryptography/EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
* encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
* does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
* produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*/
abstract contract EIP712Upgradeable is Initializable, IERC5267 {
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/// @custom:storage-location erc7201:openzeppelin.storage.EIP712
struct EIP712Storage {
/// @custom:oz-renamed-from _HASHED_NAME
bytes32 _hashedName;
/// @custom:oz-renamed-from _HASHED_VERSION
bytes32 _hashedVersion;
string _name;
string _version;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;
function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
assembly {
$.slot := EIP712StorageLocation
}
}
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
EIP712Storage storage $ = _getEIP712Storage();
$._name = name;
$._version = version;
// Reset prior values in storage if upgrading
$._hashedName = 0;
$._hashedVersion = 0;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator();
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {IERC-5267}.
*/
function eip712Domain()
public
view
virtual
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
EIP712Storage storage $ = _getEIP712Storage();
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Name() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._name;
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Version() internal view virtual returns (string memory) {
EIP712Storage storage $ = _getEIP712Storage();
return $._version;
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
*/
function _EIP712NameHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory name = _EIP712Name();
if (bytes(name).length > 0) {
return keccak256(bytes(name));
} else {
// If the name is empty, the contract may have been upgraded without initializing the new storage.
// We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
bytes32 hashedName = $._hashedName;
if (hashedName != 0) {
return hashedName;
} else {
return keccak256("");
}
}
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
*/
function _EIP712VersionHash() internal view returns (bytes32) {
EIP712Storage storage $ = _getEIP712Storage();
string memory version = _EIP712Version();
if (bytes(version).length > 0) {
return keccak256(bytes(version));
} else {
// If the version is empty, the contract may have been upgraded without initializing the new storage.
// We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = $._hashedVersion;
if (hashedVersion != 0) {
return hashedVersion;
} else {
return keccak256("");
}
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
lib/openzeppelin-contracts/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @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.
*/
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 `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
lib/openzeppelin-contracts/contracts/interfaces/IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.20;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}
lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @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 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @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;
/**
* @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* 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 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 address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @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);
}
lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
lib/openzeppelin-contracts/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}
lib/openzeppelin-contracts/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
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_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.20;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS, s);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}
lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
pragma solidity ^0.8.20;
import {Strings} from "../Strings.sol";
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}
lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
lib/openzeppelin-contracts/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
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);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
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;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
src/escrow/interfaces/IFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import {ITokenType} from "./ITokenType.sol";
import {CUBE} from "../../CUBE.sol";
interface IFactory is ITokenType {
function distributeRewards(
uint256 questId,
address token,
address to,
uint256 amount,
uint256 rewardTokenId,
TokenType tokenType,
uint256 rakeBps
) external;
function withdrawFunds(
uint256 questId,
address to,
address token,
uint256 tokenId,
TokenType tokenType
) external;
function createEscrow(
uint256 questId,
address admin,
address[] memory whitelistedTokens,
address treasury
) external;
function updateEscrowAdmin(uint256 questId, address newAdmin) external;
function addTokenToWhitelist(uint256 questId, address token) external;
function removeTokenFromWhitelist(uint256 questId, address token) external;
function initialize(address admin) external;
}
src/escrow/interfaces/ITokenType.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
interface ITokenType {
enum TokenType {
ERC20,
ERC721,
ERC1155,
NATIVE
}
}
Compiler Settings
{"viaIR":false,"remappings":["@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/","@imtbl/contracts/=lib/contracts/","@solady/src/=lib/solady/src/","@axelar-network/axelar-gmp-sdk-solidity/=lib/contracts/lib/axelar-gmp-sdk-solidity/","@rari-capital/solmate/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/solmate/","axelar-gmp-sdk-solidity/=lib/contracts/lib/axelar-gmp-sdk-solidity/contracts/","contracts/=lib/contracts/contracts/","ds-test/=lib/forge-std/lib/ds-test/src/","forge-std/=lib/forge-std/src/","foundry-devops/=lib/foundry-devops/","immutable-seaport-1.5.0+im1.3/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/","immutable-seaport-core-1.5.0+im1/=lib/contracts/lib/immutable-seaport-core-1.5.0+im1/src/","murky/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/murky/src/","openzeppelin-contracts-4.9.3/=lib/contracts/lib/openzeppelin-contracts-4.9.3/","openzeppelin-contracts-5.0.2/=lib/contracts/lib/openzeppelin-contracts-5.0.2/","openzeppelin-contracts-upgradeable-4.9.3/=lib/contracts/lib/openzeppelin-contracts-upgradeable-4.9.3/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/","openzeppelin/=lib/contracts/lib/openzeppelin-contracts-upgradeable-4.9.3/contracts/","seaport-core/=lib/contracts/lib/immutable-seaport-core-1.5.0+im1/","seaport-sol/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/seaport-sol/","seaport-types/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/seaport-types/","seaport/contracts/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/contracts/","solady/=lib/solady/","solarray/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/solarray/src/","solidity-bits/=lib/contracts/lib/solidity-bits/","solidity-bytes-utils/=lib/contracts/lib/solidity-bytes-utils/","solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/","solmate/=lib/contracts/lib/immutable-seaport-1.5.0+im1.3/lib/solmate/src/"],"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":10000,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"AccessControlBadConfirmation","inputs":[]},{"type":"error","name":"AccessControlUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"neededRole","internalType":"bytes32"}]},{"type":"error","name":"AddressEmptyCode","inputs":[{"type":"address","name":"target","internalType":"address"}]},{"type":"error","name":"CUBE__BPSTooHigh","inputs":[]},{"type":"error","name":"CUBE__ExceedsContractBalance","inputs":[]},{"type":"error","name":"CUBE__ExcessiveFeePayout","inputs":[]},{"type":"error","name":"CUBE__FeeNotEnough","inputs":[]},{"type":"error","name":"CUBE__IsNotSigner","inputs":[]},{"type":"error","name":"CUBE__MintingIsNotActive","inputs":[]},{"type":"error","name":"CUBE__NonceAlreadyUsed","inputs":[]},{"type":"error","name":"CUBE__QuestNotActive","inputs":[]},{"type":"error","name":"CUBE__SignatureAndCubesInputMismatch","inputs":[]},{"type":"error","name":"CUBE__TransferFailed","inputs":[]},{"type":"error","name":"CUBE__WithdrawFailed","inputs":[]},{"type":"error","name":"ECDSAInvalidSignature","inputs":[]},{"type":"error","name":"ECDSAInvalidSignatureLength","inputs":[{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"error","name":"ECDSAInvalidSignatureS","inputs":[{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"error","name":"ERC1967InvalidImplementation","inputs":[{"type":"address","name":"implementation","internalType":"address"}]},{"type":"error","name":"ERC1967NonPayable","inputs":[]},{"type":"error","name":"ERC721IncorrectOwner","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"ERC721InsufficientApproval","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"error","name":"ERC721InvalidApprover","inputs":[{"type":"address","name":"approver","internalType":"address"}]},{"type":"error","name":"ERC721InvalidOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"error","name":"ERC721InvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"ERC721InvalidReceiver","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"error","name":"ERC721InvalidSender","inputs":[{"type":"address","name":"sender","internalType":"address"}]},{"type":"error","name":"ERC721NonexistentToken","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"error","name":"FailedInnerCall","inputs":[]},{"type":"error","name":"InvalidInitialization","inputs":[]},{"type":"error","name":"NotInitializing","inputs":[]},{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"error","name":"UUPSUnauthorizedCallContext","inputs":[]},{"type":"error","name":"UUPSUnsupportedProxiableUUID","inputs":[{"type":"bytes32","name":"slot","internalType":"bytes32"}]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"ContractWithdrawal","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CubeClaim","inputs":[{"type":"uint256","name":"questId","internalType":"uint256","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"address","name":"claimer","internalType":"address","indexed":true},{"type":"uint256","name":"issueNumber","internalType":"uint256","indexed":false},{"type":"string","name":"walletProvider","internalType":"string","indexed":false},{"type":"string","name":"embedOrigin","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"CubeTransaction","inputs":[{"type":"uint256","name":"cubeTokenId","internalType":"uint256","indexed":true},{"type":"string","name":"txHash","internalType":"string","indexed":false},{"type":"string","name":"networkChainId","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"EIP712DomainChanged","inputs":[],"anonymous":false},{"type":"event","name":"FeePayout","inputs":[{"type":"address","name":"recipient","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint64","name":"version","internalType":"uint64","indexed":false}],"anonymous":false},{"type":"event","name":"MintingSwitch","inputs":[{"type":"bool","name":"isActive","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"QuestDisabled","inputs":[{"type":"uint256","name":"questId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"QuestMetadata","inputs":[{"type":"uint256","name":"questId","internalType":"uint256","indexed":true},{"type":"uint8","name":"questType","internalType":"enum CUBE.QuestType","indexed":false},{"type":"uint8","name":"difficulty","internalType":"enum CUBE.Difficulty","indexed":false},{"type":"string","name":"title","internalType":"string","indexed":false},{"type":"string[]","name":"tags","internalType":"string[]","indexed":false},{"type":"string[]","name":"communities","internalType":"string[]","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokenReward","inputs":[{"type":"uint256","name":"cubeTokenId","internalType":"uint256","indexed":true},{"type":"address","name":"tokenAddress","internalType":"address","indexed":true},{"type":"uint256","name":"chainId","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint8","name":"tokenType","internalType":"enum ITokenType.TokenType","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"SIGNER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"UPGRADER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"UPGRADE_INTERFACE_VERSION","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"cubeVersion","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes1","name":"fields","internalType":"bytes1"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"version","internalType":"string"},{"type":"uint256","name":"chainId","internalType":"uint256"},{"type":"address","name":"verifyingContract","internalType":"address"},{"type":"bytes32","name":"salt","internalType":"bytes32"},{"type":"uint256[]","name":"extensions","internalType":"uint256[]"}],"name":"eip712Domain","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"string","name":"_tokenName","internalType":"string"},{"type":"string","name":"_tokenSymbol","internalType":"string"},{"type":"string","name":"_signingDomain","internalType":"string"},{"type":"string","name":"_signatureVersion","internalType":"string"},{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initializeQuest","inputs":[{"type":"uint256","name":"questId","internalType":"uint256"},{"type":"string[]","name":"communities","internalType":"string[]"},{"type":"string","name":"title","internalType":"string"},{"type":"uint8","name":"difficulty","internalType":"enum CUBE.Difficulty"},{"type":"uint8","name":"questType","internalType":"enum CUBE.QuestType"},{"type":"string[]","name":"tags","internalType":"string[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isQuestActive","inputs":[{"type":"uint256","name":"questId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"mintCube","inputs":[{"type":"tuple","name":"cubeData","internalType":"struct CUBE.CubeData","components":[{"type":"uint256","name":"questId","internalType":"uint256"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"toAddress","internalType":"address"},{"type":"string","name":"walletProvider","internalType":"string"},{"type":"string","name":"tokenURI","internalType":"string"},{"type":"string","name":"embedOrigin","internalType":"string"},{"type":"tuple[]","name":"transactions","internalType":"struct CUBE.TransactionData[]","components":[{"type":"string","name":"txHash","internalType":"string"},{"type":"string","name":"networkChainId","internalType":"string"}]},{"type":"tuple[]","name":"recipients","internalType":"struct CUBE.FeeRecipient[]","components":[{"type":"address","name":"recipient","internalType":"address"},{"type":"uint16","name":"BPS","internalType":"uint16"}]},{"type":"tuple","name":"reward","internalType":"struct CUBE.RewardData","components":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"chainId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenType.TokenType"},{"type":"uint256","name":"rakeBps","internalType":"uint256"},{"type":"address","name":"factoryAddress","internalType":"address"}]}]},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"mintCubes","inputs":[{"type":"tuple[]","name":"cubeData","internalType":"struct CUBE.CubeData[]","components":[{"type":"uint256","name":"questId","internalType":"uint256"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"toAddress","internalType":"address"},{"type":"string","name":"walletProvider","internalType":"string"},{"type":"string","name":"tokenURI","internalType":"string"},{"type":"string","name":"embedOrigin","internalType":"string"},{"type":"tuple[]","name":"transactions","internalType":"struct CUBE.TransactionData[]","components":[{"type":"string","name":"txHash","internalType":"string"},{"type":"string","name":"networkChainId","internalType":"string"}]},{"type":"tuple[]","name":"recipients","internalType":"struct CUBE.FeeRecipient[]","components":[{"type":"address","name":"recipient","internalType":"address"},{"type":"uint16","name":"BPS","internalType":"uint16"}]},{"type":"tuple","name":"reward","internalType":"struct CUBE.RewardData","components":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"chainId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint8","name":"tokenType","internalType":"enum ITokenType.TokenType"},{"type":"uint256","name":"rakeBps","internalType":"uint256"},{"type":"address","name":"factoryAddress","internalType":"address"}]}]},{"type":"bytes[]","name":"signatures","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"callerConfirmation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"s_isMintingActive","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIsMintingActive","inputs":[{"type":"bool","name":"_isMintingActive","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"_tokenURI","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpublishQuest","inputs":[{"type":"uint256","name":"questId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]}]
Contract Creation Code
0x60a0604052306080523480156200001557600080fd5b506200002062000026565b620000da565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000775760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d75780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b60805161463162000104600039600081816117ac015281816117d501526119a701526146316000f3fe6080604052600436106102345760003560e01c806386954d5b11610138578063ad170ff7116100b0578063d123b4d81161007f578063e985e9c511610064578063e985e9c51461070a578063f72c0d8b14610772578063f907497c146107a657600080fd5b8063d123b4d8146106d7578063d547741f146106ea57600080fd5b8063ad170ff71461062e578063ad3cb1cc1461064e578063b88d4fde14610697578063c87b56dd146106b757600080fd5b8063a1ebf35d11610107578063a22cb465116100ec578063a22cb465146105d4578063a35d3d86146105f4578063aab416011461061457600080fd5b8063a1ebf35d1461058b578063a217fddf146105bf57600080fd5b806386954d5b146104ce57806389e7217e146104fe57806391d148541461051157806395d89b411461057657600080fd5b80632f2ff15d116101cb5780634f1ef2861161019a5780636352211e1161017f5780636352211e1461046657806370a082311461048657806384b0196e146104a657600080fd5b80634f1ef2861461043e57806352d1902d1461045157600080fd5b80632f2ff15d146103c957806336568abe146103e95780633ccfd60b1461040957806342842e0e1461041e57600080fd5b8063095ea7b311610207578063095ea7b31461030a57806323b872dd1461032c578063248a9ca31461034c5780632e640024146103a957600080fd5b806301ffc9a71461023957806302e4da091461026e57806306fdde03146102bd578063081812fc146102d2575b600080fd5b34801561024557600080fd5b5061025961025436600461360d565b6107c6565b60405190151581526020015b60405180910390f35b34801561027a57600080fd5b5060408051808201909152600181527f320000000000000000000000000000000000000000000000000000000000000060208201525b604051610265919061367a565b3480156102c957600080fd5b506102b06107d7565b3480156102de57600080fd5b506102f26102ed36600461368d565b61088d565b6040516001600160a01b039091168152602001610265565b34801561031657600080fd5b5061032a6103253660046136c2565b6108d5565b005b34801561033857600080fd5b5061032a6103473660046136ec565b6108e4565b34801561035857600080fd5b5061039b61036736600461368d565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b604051908152602001610265565b3480156103b557600080fd5b5061032a6103c43660046137f8565b6109a6565b3480156103d557600080fd5b5061032a6103e43660046138b6565b610b65565b3480156103f557600080fd5b5061032a6104043660046138b6565b610ba9565b34801561041557600080fd5b5061032a610bfa565b34801561042a57600080fd5b5061032a6104393660046136ec565b610cbf565b61032a61044c3660046138e2565b610cda565b34801561045d57600080fd5b5061039b610cf5565b34801561047257600080fd5b506102f261048136600461368d565b610d24565b34801561049257600080fd5b5061039b6104a1366004613930565b610d2f565b3480156104b257600080fd5b506104bb610db6565b604051610265979695949392919061394b565b3480156104da57600080fd5b506102596104e936600461368d565b60009081526005602052604090205460ff1690565b61032a61050c366004613a49565b610eb2565b34801561051d57600080fd5b5061025961052c3660046138b6565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561058257600080fd5b506102b0611040565b34801561059757600080fd5b5061039b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca4081565b3480156105cb57600080fd5b5061039b600081565b3480156105e057600080fd5b5061032a6105ef366004613ac5565b611091565b34801561060057600080fd5b5061032a61060f366004613aef565b61109c565b34801561062057600080fd5b506001546102599060ff1681565b34801561063a57600080fd5b5061032a61064936600461368d565b6110e8565b34801561065a57600080fd5b506102b06040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b3480156106a357600080fd5b5061032a6106b2366004613b0a565b611153565b3480156106c357600080fd5b506102b06106d236600461368d565b61116a565b61032a6106e5366004613b72565b61120c565b3480156106f657600080fd5b5061032a6107053660046138b6565b6112c2565b34801561071657600080fd5b50610259610725366004613c12565b6001600160a01b0391821660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793056020908152604080832093909416825291909152205460ff1690565b34801561077e57600080fd5b5061039b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c81565b3480156107b257600080fd5b5061032a6107c1366004613cea565b611306565b60006107d182611394565b92915050565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300805460609190819061080990613da5565b80601f016020809104026020016040519081016040528092919081815260200182805461083590613da5565b80156108825780601f1061085757610100808354040283529160200191610882565b820191906000526020600020905b81548152906001019060200180831161086557829003601f168201915b505050505091505090565b6000610898826113ea565b5060008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b03166107d1565b6108e082823361145b565b5050565b6001600160a01b03821661092c576040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b6000610939838333611468565b9050836001600160a01b0316816001600160a01b0316146109a0576040517f64283d7b0000000000000000000000000000000000000000000000000000000081526001600160a01b0380861660048301526024820184905282166044820152606401610923565b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156109f15750825b905060008267ffffffffffffffff166001148015610a0e5750303b155b905081158015610a1c575080155b15610a53576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610ab45784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610abe8a8a6115e1565b610ac888886115f3565b610ad0611605565b610ad8611605565b610ae061160f565b6001805460ff191681179055610af760008761161f565b508315610b595784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610b9f816116ee565b6109a0838361161f565b6001600160a01b0381163314610beb576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bf582826116fb565b505050565b6000610c05816116ee565b604051600090339047908381818185875af1925050503d8060008114610c47576040519150601f19603f3d011682016040523d82523d6000602084013e610c4c565b606091505b5050905080610c87576040517f2baafbf900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040514781527f6c9cf7ce96a10a51ae8b3fc5aca25e4754a77b3e821c133c5cebb1d30abe7e8e906020015b60405180910390a15050565b610bf583838360405180602001604052806000815250611153565b610ce26117a1565b610ceb82611871565b6108e0828261189b565b6000610cff61199c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60006107d1826113ea565b60007f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793006001600160a01b038316610d95576040517f89c62b6400000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b6001600160a01b039092166000908152600390920160205250604090205490565b600060608082808083817fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1008054909150158015610df557506001810154155b610e5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152606401610923565b610e636119fe565b610e6b611a4f565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009c939b5091995046985030975095509350915050565b610eba611aa0565b60015460ff16610ef6576040517f9d2c8e7300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828114610f2f576040517fc70ea82800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b84811015610f7757858582818110610f4d57610f4d613df8565b9050602002810190610f5f9190613e27565b610f6d906040013583613e94565b9150600101610f33565b5080341015610fb2576040517fea259f9100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b848110156110155761100d868683818110610fd257610fd2613df8565b9050602002810190610fe49190613e27565b858584818110610ff657610ff6613df8565b90506020028101906110089190613ea7565b611b21565b600101610fb5565b50506109a060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930180546060917f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793009161080990613da5565b6108e0338383611eaf565b60006110a7816116ee565b6001805460ff19168315159081179091556040519081527f7d16763644b2f7d5a11e2b05fe3a9cc4edb4568049295f4e62024269ae2f6eab90602001610cb3565b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca40611112816116ee565b600082815260056020526040808220805460ff191690555183917f5de3fc4fb6d1f5f0d44014df7fcc3824b081ef3fc3946a361a7cc926a499035191a25050565b61115e8484846108e4565b6109a084848484611f8b565b600081815260036020526040902080546060919061118790613da5565b80601f01602080910402602001604051908101604052809291908181526020018280546111b390613da5565b80156112005780601f106111d557610100808354040283529160200191611200565b820191906000526020600020905b8154815290600101906020018083116111e357829003601f168201915b50505050509050919050565b611214611aa0565b60015460ff16611250576040517f9d2c8e7300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826040013534101561128e576040517fea259f9100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611299838383611b21565b610bf560017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546112fc816116ee565b6109a083836116fb565b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca40611330816116ee565b60008781526005602052604090819020805460ff191660011790555187907f8a2c815542d43af541960cd9124f5ec6a55c4b8c69f0dda02ed413b401e309cd9061138390869088908a9088908d90613f90565b60405180910390a250505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d157506107d182612130565b60008181527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260408120546001600160a01b0316806107d1576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101849052602401610923565b610bf58383836001612213565b60008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260408120547f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300906001600160a01b03908116908416156114d6576114d68185876123aa565b6001600160a01b03811615611534576114f3600086600080612213565b6001600160a01b0381166000908152600383016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190555b6001600160a01b03861615611565576001600160a01b03861660009081526003830160205260409020805460010190555b600085815260028301602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a49150505b9392505050565b6115e9612440565b6108e082826124a7565b6115fb612440565b6108e082826124ea565b61160d612440565b565b611617612440565b61160d61255d565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff166116e4576000848152602082815260408083206001600160a01b03871684529091529020805460ff1916600117905561169a3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506107d1565b60009150506107d1565b6116f88133612565565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16156116e4576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506107d1565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061183a57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661182e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b1561160d576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c6108e0816116ee565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156118f5575060408051601f3d908101601f191682019092526118f291810190613ff5565b60015b611936576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610923565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611992576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b610bf583836125f2565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461160d576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1009161080990613da5565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10380546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1009161080990613da5565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01611b1b576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b600054611b2f848484612648565b60005b611b3f60e086018661400e565b9050811015611c0057817fabd48d213cb20ec6f191e95c191131c8fc3832f194f53febcb53d4834baae507611b7760e088018861400e565b84818110611b8757611b87613df8565b9050602002810190611b999190614076565b611ba39080613ea7565b611bb060e08a018a61400e565b86818110611bc057611bc0613df8565b9050602002810190611bd29190614076565b611be0906020810190613ea7565b604051611bf094939291906140d5565b60405180910390a2600101611b32565b50611c0e60a0850185613ea7565b600083815260036020526040902091611c28919083614155565b5083356000908152600260205260408120805460019081019091558154018155611c56610100860186614251565b90501115611c6757611c678461273c565b611c80611c7a6080860160608701613930565b826129d4565b611c906080850160608601613930565b84356000818152600260205260409020546001600160a01b0392909216918391907ffe94555d033bd3fc0f75671674d030640f03095d8345426fcab3a9a0bffdc4fb90611ce060808a018a613ea7565b611ced60c08c018c613ea7565b604051611cfe9594939291906142b9565b60405180910390a4610140840135156109a0576000611d2561020086016101e08701613930565b6001600160a01b031614611e0d57611d4561020085016101e08601613930565b6001600160a01b031663e836239c8535611d6761014088016101208901613930565b611d776080890160608a01613930565b6101608901356101808a0135611d956101c08c016101a08d016142e6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152611dda969594939291906101c08e01359060040161431b565b600060405180830381600087803b158015611df457600080fd5b505af1158015611e08573d6000803e3d6000fd5b505050505b6101408401803590611e23906101208701613930565b6001600160a01b0316827f6d6039156ec873b5c217b996d727775a9eea208e1329e87aaa4b617c76d2bb94610160880135610180890135611e6c6101c08b016101a08c016142e6565b604051611e7b93929190614366565b60405180910390a450505050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793006001600160a01b038316611f1b576040517f5b08ba180000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610923565b6001600160a01b038481166000818152600584016020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a350505050565b6001600160a01b0383163b156109a0576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063150b7a0290611fe6903390889087908790600401614381565b6020604051808303816000875af1925050508015612021575060408051601f3d908101601f1916820190925261201e918101906143bd565b60015b6120a3573d80801561204f576040519150601f19603f3d011682016040523d82523d6000602084013e612054565b606091505b50805160000361209b576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b805181602001fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081167f150b7a020000000000000000000000000000000000000000000000000000000014612129576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b5050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806121c357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107d157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d1565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300818061224857506001600160a01b03831615155b15612361576000612258856113ea565b90506001600160a01b038416158015906122845750836001600160a01b0316816001600160a01b031614155b80156122d557506001600160a01b0380821660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079305602090815260408083209388168352929052205460ff16155b15612317576040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b821561235f5784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b600093845260040160205250506040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6123b58383836129ee565b610bf5576001600160a01b0383166123fc576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b6040517f177e802f0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260248101829052604401610923565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff1661160d576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6124af612440565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300806124db84826143da565b50600181016109a083826143da565b6124f2612440565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10261253e84826143da565b506003810161254d83826143da565b5060008082556001909101555050565b611e89612440565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff166108e0576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610923565b6125fb82612ab2565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561264057610bf58282612b5a565b6108e0612bd0565b6000612655848484612c08565b6001600160a01b03811660009081527fbc6704768de17ac743a4c41122099f7a3464fc20363467b8527e22c7572f5d3a602052604090205490915060ff166126c9576040517f0f3c13fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60208085013560009081526004909152604090205460ff1615612718576040517f76abf21400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050506020908101356000908152600490915260409020805460ff19166001179055565b600061271047825b612752610100860186614251565b90508110156121295761ffff831661276e610100870187614251565b8381811061277e5761277e613df8565b905060400201602001602081019061279691906144d6565b61ffff1611156127d2576040517f635015ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061ffff84166127e7610100880188614251565b848181106127f7576127f7613df8565b905060400201602001602081019061280f91906144d6565b6128219061ffff1660408901356144fa565b61282b9190614511565b90506128378186613e94565b94508560400135851115612877576040517fcc3b3ebc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828511156128b1576040517f2c2cae9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128c1610100880188614251565b848181106128d1576128d1613df8565b6128e79260206040909202019081019150613930565b90506001600160a01b038116156129ca576000816001600160a01b03168360405160006040518083038185875af1925050503d8060008114612945576040519150601f19603f3d011682016040523d82523d6000602084013e61294a565b606091505b5050905080612985576040517f7327470c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b03167fc9a9861643a061bfa3739f3b26e5d64578cd78bb863dbd5dac0aca396728d9a7846040516129c091815260200190565b60405180910390a2505b5050600101612744565b6108e0828260405180602001604052806000815250612c58565b60006001600160a01b03831615801590612aaa5750826001600160a01b0316846001600160a01b03161480612a6757506001600160a01b0380851660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079305602090815260408083209387168352929052205460ff165b80612aaa575060008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b038481169116145b949350505050565b806001600160a01b03163b600003612b01576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610923565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051612b77919061454c565b600060405180830381855af49150503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b5091509150612bc7858383612c6f565b95945050505050565b341561160d576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080612c1485612ce4565b9050612bc784848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508593925050612cfe9050565b612c628383612d28565b610bf56000848484611f8b565b606082612c8457612c7f82612dbf565b6115da565b8151158015612c9b57506001600160a01b0384163b155b15612cdd576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b50806115da565b60006107d1612cf283612e01565b80519060200120612f1e565b600080600080612d0e8686612f66565b925092509250612d1e8282612fb3565b5090949350505050565b6001600160a01b038216612d6b576040517f64a0ae9200000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b6000612d7983836000611468565b90506001600160a01b03811615610bf5576040517f73c6ac6e00000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b805115612dcf5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60607fe078867cdfa0acd2e4d8e43793b771c2d3670af784116b0765aa2425c5bbb021823560208401356040850135612e3f60808701878701613930565b612e54612e4f6080890189613ea7565b6130b7565b612e64612e4f60a08a018a613ea7565b612e74612e4f60c08b018b613ea7565b612e89612e8460e08c018c61400e565b6130d9565b612e9f612e9a6101008d018d614251565b6131b5565b612eac8c61012001613254565b60408051602081019c909c528b019990995260608a019790975260808901959095526001600160a01b0390931660a088015260c087019190915260e0860152610100850152610120840152610140830152610160820152610180015b6040516020818303038152906040529050919050565b60006107d1612f2b6132ec565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060008351604103612fa05760208401516040850151606086015160001a612f92888285856132fb565b955095509550505050612fac565b50508151600091506002905b9250925092565b6000826003811115612fc757612fc7613f0c565b03612fd0575050565b6001826003811115612fe457612fe4613f0c565b0361301b576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561302f5761302f613f0c565b03613069576040517ffce698f700000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b600382600381111561307d5761307d613f0c565b036108e0576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b600082826040516130c992919061455e565b6040518091039020905092915050565b6000808267ffffffffffffffff8111156130f5576130f5613728565b60405190808252806020026020018201604052801561311e578160200160208202803683370190505b50905060005b838110156131845761315885858381811061314157613141613df8565b90506020028101906131539190614076565b6133ca565b8051906020012082828151811061317157613171613df8565b6020908102919091010152600101613124565b5080604051602001613196919061456e565b6040516020818303038152906040528051906020012091505092915050565b6000808267ffffffffffffffff8111156131d1576131d1613728565b6040519080825280602002602001820160405280156131fa578160200160208202803683370190505b50905060005b838110156131845761322885858381811061321d5761321d613df8565b905060400201613429565b8051906020012082828151811061324157613241613df8565b6020908102919091010152600101613200565b60007f07dcd7fc8540e6630daaa95c4bf6d1951796f3e22e2e1c1bcbdbd5055c7ab37c6132846020840184613930565b6020840135604085013560608601356132a360a08801608089016142e6565b60a08801356132b860e08a0160c08b01613930565b6040516020016132cf9897969594939291906145a4565b604051602081830303815290604052805190602001209050919050565b60006132f6613499565b905090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561333657506000915060039050826133c0565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561338a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166133b6575060009250600191508290506133c0565b9250600091508190505b9450945094915050565b60607f93dc1bac6b117acdbb889b9a825b9bc731449f703cc02b69049722fcba5dbe346133fa612e4f8480613ea7565b61340a612e4f6020860186613ea7565b6040805160208101949094528301919091526060820152608001612f08565b60607fdf3d1189f68f42c28f9fad9d69ff7a974d0a800a2e4420ed400e45a46d2fac2f6134596020840184613930565b61346960408501602086016144d6565b604051602001612f08939291909283526001600160a01b0391909116602083015261ffff16604082015260600190565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6134c461350d565b6134cc613589565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100816135396119fe565b80519091501561355157805160209091012092915050565b81548015613560579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100816135b5611a4f565b8051909150156135cd57805160209091012092915050565b60018201548015613560579392505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146116f857600080fd5b60006020828403121561361f57600080fd5b81356115da816135df565b60005b8381101561364557818101518382015260200161362d565b50506000910152565b6000815180845261366681602086016020860161362a565b601f01601f19169290920160200192915050565b6020815260006115da602083018461364e565b60006020828403121561369f57600080fd5b5035919050565b80356001600160a01b03811681146136bd57600080fd5b919050565b600080604083850312156136d557600080fd5b6136de836136a6565b946020939093013593505050565b60008060006060848603121561370157600080fd5b61370a846136a6565b9250613718602085016136a6565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561378057613780613728565b604052919050565b600082601f83011261379957600080fd5b813567ffffffffffffffff8111156137b3576137b3613728565b6137c66020601f19601f84011601613757565b8181528460208386010111156137db57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561381057600080fd5b853567ffffffffffffffff8082111561382857600080fd5b61383489838a01613788565b9650602088013591508082111561384a57600080fd5b61385689838a01613788565b9550604088013591508082111561386c57600080fd5b61387889838a01613788565b9450606088013591508082111561388e57600080fd5b5061389b88828901613788565b9250506138aa608087016136a6565b90509295509295909350565b600080604083850312156138c957600080fd5b823591506138d9602084016136a6565b90509250929050565b600080604083850312156138f557600080fd5b6138fe836136a6565b9150602083013567ffffffffffffffff81111561391a57600080fd5b61392685828601613788565b9150509250929050565b60006020828403121561394257600080fd5b6115da826136a6565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e08184015261398760e084018a61364e565b8381036040850152613999818a61364e565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156139eb578351835292840192918401916001016139cf565b50909c9b505050505050505050505050565b60008083601f840112613a0f57600080fd5b50813567ffffffffffffffff811115613a2757600080fd5b6020830191508360208260051b8501011115613a4257600080fd5b9250929050565b60008060008060408587031215613a5f57600080fd5b843567ffffffffffffffff80821115613a7757600080fd5b613a83888389016139fd565b90965094506020870135915080821115613a9c57600080fd5b50613aa9878288016139fd565b95989497509550505050565b803580151581146136bd57600080fd5b60008060408385031215613ad857600080fd5b613ae1836136a6565b91506138d960208401613ab5565b600060208284031215613b0157600080fd5b6115da82613ab5565b60008060008060808587031215613b2057600080fd5b613b29856136a6565b9350613b37602086016136a6565b925060408501359150606085013567ffffffffffffffff811115613b5a57600080fd5b613b6687828801613788565b91505092959194509250565b600080600060408486031215613b8757600080fd5b833567ffffffffffffffff80821115613b9f57600080fd5b908501906102008288031215613bb457600080fd5b90935060208501359080821115613bca57600080fd5b818601915086601f830112613bde57600080fd5b813581811115613bed57600080fd5b876020828501011115613bff57600080fd5b6020830194508093505050509250925092565b60008060408385031215613c2557600080fd5b613c2e836136a6565b91506138d9602084016136a6565b600082601f830112613c4d57600080fd5b8135602067ffffffffffffffff80831115613c6a57613c6a613728565b8260051b613c79838201613757565b9384528581018301938381019088861115613c9357600080fd5b84880192505b85831015613ccf57823584811115613cb15760008081fd5b613cbf8a87838c0101613788565b8352509184019190840190613c99565b98975050505050505050565b8035600281106136bd57600080fd5b60008060008060008060c08789031215613d0357600080fd5b86359550602087013567ffffffffffffffff80821115613d2257600080fd5b613d2e8a838b01613c3c565b96506040890135915080821115613d4457600080fd5b613d508a838b01613788565b95506060890135915060038210613d6657600080fd5b819450613d7560808a01613cdb565b935060a0890135915080821115613d8b57600080fd5b50613d9889828a01613c3c565b9150509295509295509295565b600181811c90821680613db957607f821691505b602082108103613df2577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01833603018112613e5b57600080fd5b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156107d1576107d1613e65565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613edc57600080fd5b83018035915067ffffffffffffffff821115613ef757600080fd5b602001915036819003821315613a4257600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600081518084526020808501808196508360051b8101915082860160005b85811015613f83578284038952613f7184835161364e565b98850198935090840190600101613f59565b5091979650505050505050565b600060028710613fa257613fa2613f0c565b86825260038610613fb557613fb5613f0c565b85602083015260a06040830152613fcf60a083018661364e565b8281036060840152613fe18186613f3b565b90508281036080840152613ccf8185613f3b565b60006020828403121561400757600080fd5b5051919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261404357600080fd5b83018035915067ffffffffffffffff82111561405e57600080fd5b6020019150600581901b3603821315613a4257600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112613e5b57600080fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6040815260006140e96040830186886140aa565b82810360208401526140fc8185876140aa565b979650505050505050565b601f821115610bf557600081815260208120601f850160051c8101602086101561412e5750805b601f850160051c820191505b8181101561414d5782815560010161413a565b505050505050565b67ffffffffffffffff83111561416d5761416d613728565b6141818361417b8354613da5565b83614107565b6000601f8411600181146141d3576000851561419d5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612129565b600083815260209020601f19861690835b8281101561420457868501358255602094850194600190920191016141e4565b508682101561423f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261428657600080fd5b83018035915067ffffffffffffffff8211156142a157600080fd5b6020019150600681901b3603821315613a4257600080fd5b8581526060602082015260006142d36060830186886140aa565b8281036040840152613ccf8185876140aa565b6000602082840312156142f857600080fd5b8135600481106115da57600080fd5b6004811061431757614317613f0c565b9052565b8781526001600160a01b03878116602083015286166040820152606081018590526080810184905260e0810161435460a0830185614307565b8260c083015298975050505050505050565b8381526020810183905260608101612aaa6040830184614307565b60006001600160a01b038087168352808616602084015250836040830152608060608301526143b3608083018461364e565b9695505050505050565b6000602082840312156143cf57600080fd5b81516115da816135df565b815167ffffffffffffffff8111156143f4576143f4613728565b614408816144028454613da5565b84614107565b602080601f83116001811461445b57600084156144255750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561414d565b600085815260208120601f198616915b8281101561448a5788860151825594840194600190910190840161446b565b50858210156144c657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156144e857600080fd5b813561ffff811681146115da57600080fd5b80820281158282048414176107d1576107d1613e65565b600082614547577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008251613e5b81846020870161362a565b8183823760009101908152919050565b815160009082906020808601845b838110156145985781518552938201939082019060010161457c565b50929695505050505050565b6000610100820190508982526001600160a01b03808a1660208401528860408401528760608401528660808401526145df60a0840187614307565b8460c084015280841660e084015250999850505050505050505056fea26469706673582212204b665976ccd982caa763cc00e925716fad7b4ef70fa924e611a7c178a7b558ee64736f6c63430008140033
Deployed ByteCode
0x6080604052600436106102345760003560e01c806386954d5b11610138578063ad170ff7116100b0578063d123b4d81161007f578063e985e9c511610064578063e985e9c51461070a578063f72c0d8b14610772578063f907497c146107a657600080fd5b8063d123b4d8146106d7578063d547741f146106ea57600080fd5b8063ad170ff71461062e578063ad3cb1cc1461064e578063b88d4fde14610697578063c87b56dd146106b757600080fd5b8063a1ebf35d11610107578063a22cb465116100ec578063a22cb465146105d4578063a35d3d86146105f4578063aab416011461061457600080fd5b8063a1ebf35d1461058b578063a217fddf146105bf57600080fd5b806386954d5b146104ce57806389e7217e146104fe57806391d148541461051157806395d89b411461057657600080fd5b80632f2ff15d116101cb5780634f1ef2861161019a5780636352211e1161017f5780636352211e1461046657806370a082311461048657806384b0196e146104a657600080fd5b80634f1ef2861461043e57806352d1902d1461045157600080fd5b80632f2ff15d146103c957806336568abe146103e95780633ccfd60b1461040957806342842e0e1461041e57600080fd5b8063095ea7b311610207578063095ea7b31461030a57806323b872dd1461032c578063248a9ca31461034c5780632e640024146103a957600080fd5b806301ffc9a71461023957806302e4da091461026e57806306fdde03146102bd578063081812fc146102d2575b600080fd5b34801561024557600080fd5b5061025961025436600461360d565b6107c6565b60405190151581526020015b60405180910390f35b34801561027a57600080fd5b5060408051808201909152600181527f320000000000000000000000000000000000000000000000000000000000000060208201525b604051610265919061367a565b3480156102c957600080fd5b506102b06107d7565b3480156102de57600080fd5b506102f26102ed36600461368d565b61088d565b6040516001600160a01b039091168152602001610265565b34801561031657600080fd5b5061032a6103253660046136c2565b6108d5565b005b34801561033857600080fd5b5061032a6103473660046136ec565b6108e4565b34801561035857600080fd5b5061039b61036736600461368d565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b604051908152602001610265565b3480156103b557600080fd5b5061032a6103c43660046137f8565b6109a6565b3480156103d557600080fd5b5061032a6103e43660046138b6565b610b65565b3480156103f557600080fd5b5061032a6104043660046138b6565b610ba9565b34801561041557600080fd5b5061032a610bfa565b34801561042a57600080fd5b5061032a6104393660046136ec565b610cbf565b61032a61044c3660046138e2565b610cda565b34801561045d57600080fd5b5061039b610cf5565b34801561047257600080fd5b506102f261048136600461368d565b610d24565b34801561049257600080fd5b5061039b6104a1366004613930565b610d2f565b3480156104b257600080fd5b506104bb610db6565b604051610265979695949392919061394b565b3480156104da57600080fd5b506102596104e936600461368d565b60009081526005602052604090205460ff1690565b61032a61050c366004613a49565b610eb2565b34801561051d57600080fd5b5061025961052c3660046138b6565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561058257600080fd5b506102b0611040565b34801561059757600080fd5b5061039b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca4081565b3480156105cb57600080fd5b5061039b600081565b3480156105e057600080fd5b5061032a6105ef366004613ac5565b611091565b34801561060057600080fd5b5061032a61060f366004613aef565b61109c565b34801561062057600080fd5b506001546102599060ff1681565b34801561063a57600080fd5b5061032a61064936600461368d565b6110e8565b34801561065a57600080fd5b506102b06040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b3480156106a357600080fd5b5061032a6106b2366004613b0a565b611153565b3480156106c357600080fd5b506102b06106d236600461368d565b61116a565b61032a6106e5366004613b72565b61120c565b3480156106f657600080fd5b5061032a6107053660046138b6565b6112c2565b34801561071657600080fd5b50610259610725366004613c12565b6001600160a01b0391821660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793056020908152604080832093909416825291909152205460ff1690565b34801561077e57600080fd5b5061039b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c81565b3480156107b257600080fd5b5061032a6107c1366004613cea565b611306565b60006107d182611394565b92915050565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300805460609190819061080990613da5565b80601f016020809104026020016040519081016040528092919081815260200182805461083590613da5565b80156108825780601f1061085757610100808354040283529160200191610882565b820191906000526020600020905b81548152906001019060200180831161086557829003601f168201915b505050505091505090565b6000610898826113ea565b5060008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b03166107d1565b6108e082823361145b565b5050565b6001600160a01b03821661092c576040517f64a0ae92000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b6000610939838333611468565b9050836001600160a01b0316816001600160a01b0316146109a0576040517f64283d7b0000000000000000000000000000000000000000000000000000000081526001600160a01b0380861660048301526024820184905282166044820152606401610923565b50505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156109f15750825b905060008267ffffffffffffffff166001148015610a0e5750303b155b905081158015610a1c575080155b15610a53576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610ab45784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610abe8a8a6115e1565b610ac888886115f3565b610ad0611605565b610ad8611605565b610ae061160f565b6001805460ff191681179055610af760008761161f565b508315610b595784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610b9f816116ee565b6109a0838361161f565b6001600160a01b0381163314610beb576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bf582826116fb565b505050565b6000610c05816116ee565b604051600090339047908381818185875af1925050503d8060008114610c47576040519150601f19603f3d011682016040523d82523d6000602084013e610c4c565b606091505b5050905080610c87576040517f2baafbf900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040514781527f6c9cf7ce96a10a51ae8b3fc5aca25e4754a77b3e821c133c5cebb1d30abe7e8e906020015b60405180910390a15050565b610bf583838360405180602001604052806000815250611153565b610ce26117a1565b610ceb82611871565b6108e0828261189b565b6000610cff61199c565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60006107d1826113ea565b60007f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793006001600160a01b038316610d95576040517f89c62b6400000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b6001600160a01b039092166000908152600390920160205250604090205490565b600060608082808083817fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1008054909150158015610df557506001810154155b610e5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152606401610923565b610e636119fe565b610e6b611a4f565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009c939b5091995046985030975095509350915050565b610eba611aa0565b60015460ff16610ef6576040517f9d2c8e7300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828114610f2f576040517fc70ea82800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000805b84811015610f7757858582818110610f4d57610f4d613df8565b9050602002810190610f5f9190613e27565b610f6d906040013583613e94565b9150600101610f33565b5080341015610fb2576040517fea259f9100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b848110156110155761100d868683818110610fd257610fd2613df8565b9050602002810190610fe49190613e27565b858584818110610ff657610ff6613df8565b90506020028101906110089190613ea7565b611b21565b600101610fb5565b50506109a060017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930180546060917f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793009161080990613da5565b6108e0338383611eaf565b60006110a7816116ee565b6001805460ff19168315159081179091556040519081527f7d16763644b2f7d5a11e2b05fe3a9cc4edb4568049295f4e62024269ae2f6eab90602001610cb3565b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca40611112816116ee565b600082815260056020526040808220805460ff191690555183917f5de3fc4fb6d1f5f0d44014df7fcc3824b081ef3fc3946a361a7cc926a499035191a25050565b61115e8484846108e4565b6109a084848484611f8b565b600081815260036020526040902080546060919061118790613da5565b80601f01602080910402602001604051908101604052809291908181526020018280546111b390613da5565b80156112005780601f106111d557610100808354040283529160200191611200565b820191906000526020600020905b8154815290600101906020018083116111e357829003601f168201915b50505050509050919050565b611214611aa0565b60015460ff16611250576040517f9d2c8e7300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b826040013534101561128e576040517fea259f9100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611299838383611b21565b610bf560017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546112fc816116ee565b6109a083836116fb565b7f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca40611330816116ee565b60008781526005602052604090819020805460ff191660011790555187907f8a2c815542d43af541960cd9124f5ec6a55c4b8c69f0dda02ed413b401e309cd9061138390869088908a9088908d90613f90565b60405180910390a250505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d157506107d182612130565b60008181527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260408120546001600160a01b0316806107d1576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101849052602401610923565b610bf58383836001612213565b60008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260408120547f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300906001600160a01b03908116908416156114d6576114d68185876123aa565b6001600160a01b03811615611534576114f3600086600080612213565b6001600160a01b0381166000908152600383016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190555b6001600160a01b03861615611565576001600160a01b03861660009081526003830160205260409020805460010190555b600085815260028301602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a49150505b9392505050565b6115e9612440565b6108e082826124a7565b6115fb612440565b6108e082826124ea565b61160d612440565b565b611617612440565b61160d61255d565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff166116e4576000848152602082815260408083206001600160a01b03871684529091529020805460ff1916600117905561169a3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a460019150506107d1565b60009150506107d1565b6116f88133612565565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16156116e4576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a460019150506107d1565b306001600160a01b037f000000000000000000000000d0ab2d3621dc8a862389f89f52f08c097e3fe8b516148061183a57507f000000000000000000000000d0ab2d3621dc8a862389f89f52f08c097e3fe8b56001600160a01b031661182e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b1561160d576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c6108e0816116ee565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156118f5575060408051601f3d908101601f191682019092526118f291810190613ff5565b60015b611936576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610923565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611992576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b610bf583836125f2565b306001600160a01b037f000000000000000000000000d0ab2d3621dc8a862389f89f52f08c097e3fe8b5161461160d576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1009161080990613da5565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10380546060917fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1009161080990613da5565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01611b1b576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b600054611b2f848484612648565b60005b611b3f60e086018661400e565b9050811015611c0057817fabd48d213cb20ec6f191e95c191131c8fc3832f194f53febcb53d4834baae507611b7760e088018861400e565b84818110611b8757611b87613df8565b9050602002810190611b999190614076565b611ba39080613ea7565b611bb060e08a018a61400e565b86818110611bc057611bc0613df8565b9050602002810190611bd29190614076565b611be0906020810190613ea7565b604051611bf094939291906140d5565b60405180910390a2600101611b32565b50611c0e60a0850185613ea7565b600083815260036020526040902091611c28919083614155565b5083356000908152600260205260408120805460019081019091558154018155611c56610100860186614251565b90501115611c6757611c678461273c565b611c80611c7a6080860160608701613930565b826129d4565b611c906080850160608601613930565b84356000818152600260205260409020546001600160a01b0392909216918391907ffe94555d033bd3fc0f75671674d030640f03095d8345426fcab3a9a0bffdc4fb90611ce060808a018a613ea7565b611ced60c08c018c613ea7565b604051611cfe9594939291906142b9565b60405180910390a4610140840135156109a0576000611d2561020086016101e08701613930565b6001600160a01b031614611e0d57611d4561020085016101e08601613930565b6001600160a01b031663e836239c8535611d6761014088016101208901613930565b611d776080890160608a01613930565b6101608901356101808a0135611d956101c08c016101a08d016142e6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b168152611dda969594939291906101c08e01359060040161431b565b600060405180830381600087803b158015611df457600080fd5b505af1158015611e08573d6000803e3d6000fd5b505050505b6101408401803590611e23906101208701613930565b6001600160a01b0316827f6d6039156ec873b5c217b996d727775a9eea208e1329e87aaa4b617c76d2bb94610160880135610180890135611e6c6101c08b016101a08c016142e6565b604051611e7b93929190614366565b60405180910390a450505050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793006001600160a01b038316611f1b576040517f5b08ba180000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610923565b6001600160a01b038481166000818152600584016020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a350505050565b6001600160a01b0383163b156109a0576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0384169063150b7a0290611fe6903390889087908790600401614381565b6020604051808303816000875af1925050508015612021575060408051601f3d908101601f1916820190925261201e918101906143bd565b60015b6120a3573d80801561204f576040519150601f19603f3d011682016040523d82523d6000602084013e612054565b606091505b50805160000361209b576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b805181602001fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081167f150b7a020000000000000000000000000000000000000000000000000000000014612129576040517f64a0ae920000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b5050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806121c357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107d157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d1565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300818061224857506001600160a01b03831615155b15612361576000612258856113ea565b90506001600160a01b038416158015906122845750836001600160a01b0316816001600160a01b031614155b80156122d557506001600160a01b0380821660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079305602090815260408083209388168352929052205460ff16155b15612317576040517fa9fbf51f0000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b821561235f5784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b600093845260040160205250506040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6123b58383836129ee565b610bf5576001600160a01b0383166123fc576040517f7e27328900000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b6040517f177e802f0000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260248101829052604401610923565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff1661160d576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6124af612440565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300806124db84826143da565b50600181016109a083826143da565b6124f2612440565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d1007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10261253e84826143da565b506003810161254d83826143da565b5060008082556001909101555050565b611e89612440565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602090815260408083206001600160a01b038516845290915290205460ff166108e0576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610923565b6125fb82612ab2565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561264057610bf58282612b5a565b6108e0612bd0565b6000612655848484612c08565b6001600160a01b03811660009081527fbc6704768de17ac743a4c41122099f7a3464fc20363467b8527e22c7572f5d3a602052604090205490915060ff166126c9576040517f0f3c13fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60208085013560009081526004909152604090205460ff1615612718576040517f76abf21400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050506020908101356000908152600490915260409020805460ff19166001179055565b600061271047825b612752610100860186614251565b90508110156121295761ffff831661276e610100870187614251565b8381811061277e5761277e613df8565b905060400201602001602081019061279691906144d6565b61ffff1611156127d2576040517f635015ff00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061ffff84166127e7610100880188614251565b848181106127f7576127f7613df8565b905060400201602001602081019061280f91906144d6565b6128219061ffff1660408901356144fa565b61282b9190614511565b90506128378186613e94565b94508560400135851115612877576040517fcc3b3ebc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828511156128b1576040517f2c2cae9800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006128c1610100880188614251565b848181106128d1576128d1613df8565b6128e79260206040909202019081019150613930565b90506001600160a01b038116156129ca576000816001600160a01b03168360405160006040518083038185875af1925050503d8060008114612945576040519150601f19603f3d011682016040523d82523d6000602084013e61294a565b606091505b5050905080612985576040517f7327470c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b816001600160a01b03167fc9a9861643a061bfa3739f3b26e5d64578cd78bb863dbd5dac0aca396728d9a7846040516129c091815260200190565b60405180910390a2505b5050600101612744565b6108e0828260405180602001604052806000815250612c58565b60006001600160a01b03831615801590612aaa5750826001600160a01b0316846001600160a01b03161480612a6757506001600160a01b0380851660009081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079305602090815260408083209387168352929052205460ff165b80612aaa575060008281527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b038481169116145b949350505050565b806001600160a01b03163b600003612b01576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610923565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051612b77919061454c565b600060405180830381855af49150503d8060008114612bb2576040519150601f19603f3d011682016040523d82523d6000602084013e612bb7565b606091505b5091509150612bc7858383612c6f565b95945050505050565b341561160d576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080612c1485612ce4565b9050612bc784848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508593925050612cfe9050565b612c628383612d28565b610bf56000848484611f8b565b606082612c8457612c7f82612dbf565b6115da565b8151158015612c9b57506001600160a01b0384163b155b15612cdd576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610923565b50806115da565b60006107d1612cf283612e01565b80519060200120612f1e565b600080600080612d0e8686612f66565b925092509250612d1e8282612fb3565b5090949350505050565b6001600160a01b038216612d6b576040517f64a0ae9200000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b6000612d7983836000611468565b90506001600160a01b03811615610bf5576040517f73c6ac6e00000000000000000000000000000000000000000000000000000000815260006004820152602401610923565b805115612dcf5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60607fe078867cdfa0acd2e4d8e43793b771c2d3670af784116b0765aa2425c5bbb021823560208401356040850135612e3f60808701878701613930565b612e54612e4f6080890189613ea7565b6130b7565b612e64612e4f60a08a018a613ea7565b612e74612e4f60c08b018b613ea7565b612e89612e8460e08c018c61400e565b6130d9565b612e9f612e9a6101008d018d614251565b6131b5565b612eac8c61012001613254565b60408051602081019c909c528b019990995260608a019790975260808901959095526001600160a01b0390931660a088015260c087019190915260e0860152610100850152610120840152610140830152610160820152610180015b6040516020818303038152906040529050919050565b60006107d1612f2b6132ec565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060008351604103612fa05760208401516040850151606086015160001a612f92888285856132fb565b955095509550505050612fac565b50508151600091506002905b9250925092565b6000826003811115612fc757612fc7613f0c565b03612fd0575050565b6001826003811115612fe457612fe4613f0c565b0361301b576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561302f5761302f613f0c565b03613069576040517ffce698f700000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b600382600381111561307d5761307d613f0c565b036108e0576040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260048101829052602401610923565b600082826040516130c992919061455e565b6040518091039020905092915050565b6000808267ffffffffffffffff8111156130f5576130f5613728565b60405190808252806020026020018201604052801561311e578160200160208202803683370190505b50905060005b838110156131845761315885858381811061314157613141613df8565b90506020028101906131539190614076565b6133ca565b8051906020012082828151811061317157613171613df8565b6020908102919091010152600101613124565b5080604051602001613196919061456e565b6040516020818303038152906040528051906020012091505092915050565b6000808267ffffffffffffffff8111156131d1576131d1613728565b6040519080825280602002602001820160405280156131fa578160200160208202803683370190505b50905060005b838110156131845761322885858381811061321d5761321d613df8565b905060400201613429565b8051906020012082828151811061324157613241613df8565b6020908102919091010152600101613200565b60007f07dcd7fc8540e6630daaa95c4bf6d1951796f3e22e2e1c1bcbdbd5055c7ab37c6132846020840184613930565b6020840135604085013560608601356132a360a08801608089016142e6565b60a08801356132b860e08a0160c08b01613930565b6040516020016132cf9897969594939291906145a4565b604051602081830303815290604052805190602001209050919050565b60006132f6613499565b905090565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561333657506000915060039050826133c0565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561338a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166133b6575060009250600191508290506133c0565b9250600091508190505b9450945094915050565b60607f93dc1bac6b117acdbb889b9a825b9bc731449f703cc02b69049722fcba5dbe346133fa612e4f8480613ea7565b61340a612e4f6020860186613ea7565b6040805160208101949094528301919091526060820152608001612f08565b60607fdf3d1189f68f42c28f9fad9d69ff7a974d0a800a2e4420ed400e45a46d2fac2f6134596020840184613930565b61346960408501602086016144d6565b604051602001612f08939291909283526001600160a01b0391909116602083015261ffff16604082015260600190565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6134c461350d565b6134cc613589565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100816135396119fe565b80519091501561355157805160209091012092915050565b81548015613560579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b60007fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100816135b5611a4f565b8051909150156135cd57805160209091012092915050565b60018201548015613560579392505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146116f857600080fd5b60006020828403121561361f57600080fd5b81356115da816135df565b60005b8381101561364557818101518382015260200161362d565b50506000910152565b6000815180845261366681602086016020860161362a565b601f01601f19169290920160200192915050565b6020815260006115da602083018461364e565b60006020828403121561369f57600080fd5b5035919050565b80356001600160a01b03811681146136bd57600080fd5b919050565b600080604083850312156136d557600080fd5b6136de836136a6565b946020939093013593505050565b60008060006060848603121561370157600080fd5b61370a846136a6565b9250613718602085016136a6565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561378057613780613728565b604052919050565b600082601f83011261379957600080fd5b813567ffffffffffffffff8111156137b3576137b3613728565b6137c66020601f19601f84011601613757565b8181528460208386010111156137db57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561381057600080fd5b853567ffffffffffffffff8082111561382857600080fd5b61383489838a01613788565b9650602088013591508082111561384a57600080fd5b61385689838a01613788565b9550604088013591508082111561386c57600080fd5b61387889838a01613788565b9450606088013591508082111561388e57600080fd5b5061389b88828901613788565b9250506138aa608087016136a6565b90509295509295909350565b600080604083850312156138c957600080fd5b823591506138d9602084016136a6565b90509250929050565b600080604083850312156138f557600080fd5b6138fe836136a6565b9150602083013567ffffffffffffffff81111561391a57600080fd5b61392685828601613788565b9150509250929050565b60006020828403121561394257600080fd5b6115da826136a6565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e08184015261398760e084018a61364e565b8381036040850152613999818a61364e565b606085018990526001600160a01b038816608086015260a0850187905284810360c0860152855180825283870192509083019060005b818110156139eb578351835292840192918401916001016139cf565b50909c9b505050505050505050505050565b60008083601f840112613a0f57600080fd5b50813567ffffffffffffffff811115613a2757600080fd5b6020830191508360208260051b8501011115613a4257600080fd5b9250929050565b60008060008060408587031215613a5f57600080fd5b843567ffffffffffffffff80821115613a7757600080fd5b613a83888389016139fd565b90965094506020870135915080821115613a9c57600080fd5b50613aa9878288016139fd565b95989497509550505050565b803580151581146136bd57600080fd5b60008060408385031215613ad857600080fd5b613ae1836136a6565b91506138d960208401613ab5565b600060208284031215613b0157600080fd5b6115da82613ab5565b60008060008060808587031215613b2057600080fd5b613b29856136a6565b9350613b37602086016136a6565b925060408501359150606085013567ffffffffffffffff811115613b5a57600080fd5b613b6687828801613788565b91505092959194509250565b600080600060408486031215613b8757600080fd5b833567ffffffffffffffff80821115613b9f57600080fd5b908501906102008288031215613bb457600080fd5b90935060208501359080821115613bca57600080fd5b818601915086601f830112613bde57600080fd5b813581811115613bed57600080fd5b876020828501011115613bff57600080fd5b6020830194508093505050509250925092565b60008060408385031215613c2557600080fd5b613c2e836136a6565b91506138d9602084016136a6565b600082601f830112613c4d57600080fd5b8135602067ffffffffffffffff80831115613c6a57613c6a613728565b8260051b613c79838201613757565b9384528581018301938381019088861115613c9357600080fd5b84880192505b85831015613ccf57823584811115613cb15760008081fd5b613cbf8a87838c0101613788565b8352509184019190840190613c99565b98975050505050505050565b8035600281106136bd57600080fd5b60008060008060008060c08789031215613d0357600080fd5b86359550602087013567ffffffffffffffff80821115613d2257600080fd5b613d2e8a838b01613c3c565b96506040890135915080821115613d4457600080fd5b613d508a838b01613788565b95506060890135915060038210613d6657600080fd5b819450613d7560808a01613cdb565b935060a0890135915080821115613d8b57600080fd5b50613d9889828a01613c3c565b9150509295509295509295565b600181811c90821680613db957607f821691505b602082108103613df2577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01833603018112613e5b57600080fd5b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156107d1576107d1613e65565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112613edc57600080fd5b83018035915067ffffffffffffffff821115613ef757600080fd5b602001915036819003821315613a4257600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600081518084526020808501808196508360051b8101915082860160005b85811015613f83578284038952613f7184835161364e565b98850198935090840190600101613f59565b5091979650505050505050565b600060028710613fa257613fa2613f0c565b86825260038610613fb557613fb5613f0c565b85602083015260a06040830152613fcf60a083018661364e565b8281036060840152613fe18186613f3b565b90508281036080840152613ccf8185613f3b565b60006020828403121561400757600080fd5b5051919050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261404357600080fd5b83018035915067ffffffffffffffff82111561405e57600080fd5b6020019150600581901b3603821315613a4257600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112613e5b57600080fd5b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b6040815260006140e96040830186886140aa565b82810360208401526140fc8185876140aa565b979650505050505050565b601f821115610bf557600081815260208120601f850160051c8101602086101561412e5750805b601f850160051c820191505b8181101561414d5782815560010161413a565b505050505050565b67ffffffffffffffff83111561416d5761416d613728565b6141818361417b8354613da5565b83614107565b6000601f8411600181146141d3576000851561419d5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612129565b600083815260209020601f19861690835b8281101561420457868501358255602094850194600190920191016141e4565b508682101561423f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261428657600080fd5b83018035915067ffffffffffffffff8211156142a157600080fd5b6020019150600681901b3603821315613a4257600080fd5b8581526060602082015260006142d36060830186886140aa565b8281036040840152613ccf8185876140aa565b6000602082840312156142f857600080fd5b8135600481106115da57600080fd5b6004811061431757614317613f0c565b9052565b8781526001600160a01b03878116602083015286166040820152606081018590526080810184905260e0810161435460a0830185614307565b8260c083015298975050505050505050565b8381526020810183905260608101612aaa6040830184614307565b60006001600160a01b038087168352808616602084015250836040830152608060608301526143b3608083018461364e565b9695505050505050565b6000602082840312156143cf57600080fd5b81516115da816135df565b815167ffffffffffffffff8111156143f4576143f4613728565b614408816144028454613da5565b84614107565b602080601f83116001811461445b57600084156144255750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b17855561414d565b600085815260208120601f198616915b8281101561448a5788860151825594840194600190910190840161446b565b50858210156144c657878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156144e857600080fd5b813561ffff811681146115da57600080fd5b80820281158282048414176107d1576107d1613e65565b600082614547577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60008251613e5b81846020870161362a565b8183823760009101908152919050565b815160009082906020808601845b838110156145985781518552938201939082019060010161457c565b50929695505050505050565b6000610100820190508982526001600160a01b03808a1660208401528860408401528760608401528660808401526145df60a0840187614307565b8460c084015280841660e084015250999850505050505050505056fea26469706673582212204b665976ccd982caa763cc00e925716fad7b4ef70fa924e611a7c178a7b558ee64736f6c63430008140033