Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Rubyscore_Achievement
- Optimization enabled
- true
- Compiler version
- v0.8.21+commit.d9974bed
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2024-05-27T13:42:52.576106Z
Constructor Arguments
0x0000000000000000000000000d0d5ff3cfef8b7b2b1cac6b6c27fd0846c09361000000000000000000000000381c031baa5995d0cc52386508050ac947780815000000000000000000000000381c031baa5995d0cc52386508050ac94778081500000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000007697066733a2f2f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5275627973636f72655f5461696b6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5275627973636f72655f5461696b6f0000000000000000000000000000000000
Arg [0] (address) : 0x0d0d5ff3cfef8b7b2b1cac6b6c27fd0846c09361
Arg [1] (address) : 0x381c031baa5995d0cc52386508050ac947780815
Arg [2] (address) : 0x381c031baa5995d0cc52386508050ac947780815
Arg [3] (string) : ipfs://
Arg [4] (string) : Rubyscore_Taiko
Arg [5] (string) : Rubyscore_Taiko
contracts/Rubyscore_Achievement.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {IRubyscore_Achievement} from "./interfaces/IRubyscore_Achievement.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {ERC1155URIStorage} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ERC1155, ERC1155Supply} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
/**
* @title Rubyscore_Achievement
* @dev An ERC1155 token contract for minting and managing achievements with URI support.
* @dev Rubyscore_Achievement can be minted by users with the MINTER_ROLE after proper authorization.
* @dev Rubyscore_Achievement can have their URIs set by operators with the MINTER_ROLE.
* @dev Rubyscore_Achievement can be safely transferred with restrictions on certain tokens.
*/
contract Rubyscore_Achievement is
ERC1155,
EIP712,
AccessControl,
ERC1155Supply,
ERC1155URIStorage,
ReentrancyGuard,
IRubyscore_Achievement
{
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
string public constant NAME = "Rubyscore_Achievement";
string public constant VERSION = "0.0.1";
uint256 private price;
string public name;
string public symbol;
mapping(uint256 => bool) private transferUnlock;
mapping(address => uint256) private userNonce;
/**
* @dev See {IRubyscore_Achievement}
*/
function supportsInterface(
bytes4 interfaceId
) public view override(ERC1155, AccessControl, IRubyscore_Achievement) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function uri(
uint256 tokenId
) public view override(ERC1155, ERC1155URIStorage, IRubyscore_Achievement) returns (string memory) {
return super.uri(tokenId);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function getTransferStatus(uint256 tokenId) external view returns (bool) {
return transferUnlock[tokenId];
}
/**
* @dev See {IRubyscore_Achievement}
*/
function getPrice() external view returns (uint256) {
return price;
}
/**
* @dev See {IRubyscore_Achievement}
*/
function getUserNonce(address userAddress) external view returns (uint256) {
return userNonce[userAddress];
}
/**
* @dev See {IRubyscore_Achievement}
*/
function tokenURI(uint256 tokenId) public view returns (string memory) {
return uri(tokenId);
}
//TODO: use ERC1155("https://xproject.api/achivments/") like error URI and set new for ERC1155URIStorage
/**
* @notice Constructor for the Rubyscore_Achievement contract.
* @dev Initializes the contract with roles and settings.
* @param admin The address of the admin role, which has overall control.
* @param operator The address of the operator role, responsible for unlock tokens and set base URI.
* @param minter The address of the minter role, authorized to mint achievements and responsible for setting token URIs.
* @param baseURI The base URI for token metadata.
* @dev It sets the base URI for token metadata to the provided `baseURI`.
* @dev It grants the DEFAULT_ADMIN_ROLE, OPERATOR_ROLE, and MINTER_ROLE to the specified addresses.
* @dev It also initializes the contract with EIP712 support and ERC1155 functionality.
*/
constructor(
address admin,
address operator,
address minter,
string memory baseURI,
string memory _name,
string memory _symbol
) ERC1155("ipfs://") EIP712(NAME, VERSION) {
require(admin != address(0), "Zero address check");
require(operator != address(0), "Zero address check");
require(minter != address(0), "Zero address check");
name = _name;
symbol = _symbol;
_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(OPERATOR_ROLE, msg.sender);
_grantRole(OPERATOR_ROLE, operator);
_grantRole(MINTER_ROLE, minter);
_setBaseURI(baseURI);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function setTokenURI(uint256 tokenId, string memory newTokenURI) public onlyRole(MINTER_ROLE) {
super._setURI(tokenId, newTokenURI);
emit TokenURISet(tokenId, newTokenURI);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function setBatchTokenURI(
uint256[] calldata tokenIds,
string[] calldata newTokenURIs
) external onlyRole(MINTER_ROLE) {
require(tokenIds.length == newTokenURIs.length, "Invalid params");
for (uint256 i = 0; i < tokenIds.length; i++) {
setTokenURI(tokenIds[i], newTokenURIs[i]);
}
}
/**
* @dev See {IRubyscore_Achievement}
*/
function setBaseURI(string memory newBaseURI) external onlyRole(OPERATOR_ROLE) {
super._setBaseURI(newBaseURI);
emit BaseURISet(newBaseURI);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function setPrice(uint256 newPrice) external onlyRole(OPERATOR_ROLE) {
price = newPrice;
emit PriceUpdated(newPrice);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function safeMint(MintParams memory mintParams, bytes calldata operatorSignature) external payable nonReentrant {
require(mintParams.nftIds.length >= 1, "Invalid NFT ids");
require(msg.value == price, "Wrong payment amount");
bytes32 digest = _hashTypedDataV4(
keccak256(
abi.encode(
keccak256("MintParams(address userAddress,uint256 userNonce,uint256[] nftIds)"),
msg.sender,
userNonce[msg.sender],
keccak256(abi.encodePacked(mintParams.nftIds))
)
)
);
_checkRole(MINTER_ROLE, ECDSA.recover(digest, operatorSignature));
userNonce[mintParams.userAddress] += 1;
if (mintParams.nftIds.length > 1) _mintBatch(mintParams.userAddress, mintParams.nftIds, "");
else _mint(mintParams.userAddress, mintParams.nftIds[0], "");
emit Minted(mintParams.userAddress, mintParams.userNonce, mintParams.nftIds);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function setTransferUnlock(uint256 tokenId, bool lock) external onlyRole(OPERATOR_ROLE) {
transferUnlock[tokenId] = lock;
emit TokenUnlockSet(tokenId, lock);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 amount = address(this).balance;
require(amount > 0, "Zero amount to withdraw");
(bool sent, ) = payable(msg.sender).call{value: amount}("");
require(sent, "Failed to send Ether");
emit Withdrawed(amount);
}
/**
* @dev See {IRubyscore_Achievement}
*/
function _mint(address to, uint256 id, bytes memory data) internal {
require(balanceOf(to, id) == 0, "You already have this achievement");
super._mint(to, id, 1, data);
}
/**
* @notice Internal function to safely mint multiple NFTs in a batch for a specified recipient.
* @param to The address of the recipient to mint the NFTs for.
* @param ids An array of NFT IDs to mint.
* @param data Additional data to include in the minting transaction.
* @dev This function checks if the recipient already owns any of the specified NFTs to prevent duplicates.
* @dev It is intended for batch minting operations where multiple NFTs can be minted at once.
*/
function _mintBatch(address to, uint256[] memory ids, bytes memory data) internal {
uint256[] memory amounts = new uint256[](ids.length);
for (uint8 i = 0; i < ids.length; i++) {
require(balanceOf(to, ids[i]) == 0, "You already have this achievement"); // TODO: custom error with problem token id
amounts[i] = 1;
}
super._mintBatch(to, ids, amounts, data);
}
// The following functions are overrides required by Solidity.
function _update(
address from,
address to,
uint256[] memory ids,
uint256[] memory values
) internal override(ERC1155, ERC1155Supply) {
for (uint256 i = 0; i < ids.length; i++) {
if (!transferUnlock[ids[i]] && from != address(0)) revert("This token only for you");
}
super._update(from, to, ids, values);
}
}
@openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.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 AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @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);
_;
}
/**
* @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) {
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) {
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 {
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) {
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) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
@openzeppelin/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;
}
@openzeppelin/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
);
}
@openzeppelin/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);
}
@openzeppelin/contracts/token/ERC1155/ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "./IERC1155.sol";
import {IERC1155Receiver} from "./IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*/
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
using Arrays for uint256[];
using Arrays for address[];
mapping(uint256 id => mapping(address account => uint256)) private _balances;
mapping(address account => mapping(address operator => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 /* id */) public view virtual returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*/
function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual returns (uint256[] memory) {
if (accounts.length != ids.length) {
revert ERC1155InvalidArrayLength(ids.length, accounts.length);
}
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i));
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeTransferFrom(from, to, id, value, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeBatchTransferFrom(from, to, ids, values, data);
}
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
* (or `to`) is the zero address.
*
* Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
* or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
* - `ids` and `values` must have the same length.
*
* NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
*/
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
// Overflow not possible: value <= fromBalance
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
/**
* @dev Version of {_update} that performs the token acceptance check by calling
* {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
* contains code (eg. is a smart contract at the moment of execution).
*
* IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
* update to the contract state after this function would break the check-effect-interaction pattern. Consider
* overriding {_update} instead.
*/
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual {
_update(from, to, ids, values);
if (to != address(0)) {
address operator = _msgSender();
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
_doSafeTransferAcceptanceCheck(operator, from, to, id, value, data);
} else {
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data);
}
}
}
/**
* @dev Transfers a `value` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
* - `ids` and `values` must have the same length.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the values in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev Destroys a `value` amount of tokens of type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
*/
function _burn(address from, uint256 id, uint256 value) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
* - `ids` and `values` must have the same length.
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC1155InvalidOperator(address(0));
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address
* if it contains code at the moment of execution.
*/
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) private {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
// Tokens rejected
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-ERC1155Receiver implementer
revert ERC1155InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
/**
* @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address
* if it contains code at the moment of execution.
*/
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) private {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
// Tokens rejected
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-ERC1155Receiver implementer
revert ERC1155InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
/**
* @dev Creates an array in memory with only one value for each of the elements provided.
*/
function _asSingletonArrays(
uint256 element1,
uint256 element2
) private pure returns (uint256[] memory array1, uint256[] memory array2) {
/// @solidity memory-safe-assembly
assembly {
// Load the free memory pointer
array1 := mload(0x40)
// Set array length to 1
mstore(array1, 1)
// Store the single element at the next word after the length (where content starts)
mstore(add(array1, 0x20), element1)
// Repeat for next array locating it right after the first array
array2 := add(array1, 0x40)
mstore(array2, 1)
mstore(add(array2, 0x20), element2)
// Update the free memory pointer by pointing after the second array
mstore(0x40, add(array2, 0x40))
}
}
}
@openzeppelin/contracts/token/ERC1155/IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}
@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/ERC1155Supply.sol)
pragma solidity ^0.8.20;
import {ERC1155} from "../ERC1155.sol";
/**
* @dev Extension of ERC1155 that adds tracking of total supply per id.
*
* Useful for scenarios where Fungible and Non-fungible tokens have to be
* clearly identified. Note: While a totalSupply of 1 might mean the
* corresponding is an NFT, there is no guarantees that no other token with the
* same id are not going to be minted.
*
* NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens
* that can be minted.
*
* CAUTION: This extension should not be added in an upgrade to an already deployed contract.
*/
abstract contract ERC1155Supply is ERC1155 {
mapping(uint256 id => uint256) private _totalSupply;
uint256 private _totalSupplyAll;
/**
* @dev Total value of tokens in with a given id.
*/
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply[id];
}
/**
* @dev Total value of tokens.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupplyAll;
}
/**
* @dev Indicates whether any token exist with a given id, or not.
*/
function exists(uint256 id) public view virtual returns (bool) {
return totalSupply(id) > 0;
}
/**
* @dev See {ERC1155-_update}.
*/
function _update(
address from,
address to,
uint256[] memory ids,
uint256[] memory values
) internal virtual override {
super._update(from, to, ids, values);
if (from == address(0)) {
uint256 totalMintValue = 0;
for (uint256 i = 0; i < ids.length; ++i) {
uint256 value = values[i];
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply[ids[i]] += value;
totalMintValue += value;
}
// Overflow check required: The rest of the code assumes that totalSupplyAll never overflows
_totalSupplyAll += totalMintValue;
}
if (to == address(0)) {
uint256 totalBurnValue = 0;
for (uint256 i = 0; i < ids.length; ++i) {
uint256 value = values[i];
unchecked {
// Overflow not possible: values[i] <= balanceOf(from, ids[i]) <= totalSupply(ids[i])
_totalSupply[ids[i]] -= value;
// Overflow not possible: sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll
totalBurnValue += value;
}
}
unchecked {
// Overflow not possible: totalBurnValue = sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll
_totalSupplyAll -= totalBurnValue;
}
}
}
}
@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/ERC1155URIStorage.sol)
pragma solidity ^0.8.20;
import {Strings} from "../../../utils/Strings.sol";
import {ERC1155} from "../ERC1155.sol";
/**
* @dev ERC1155 token with storage based token URI management.
* Inspired by the ERC721URIStorage extension
*/
abstract contract ERC1155URIStorage is ERC1155 {
using Strings for uint256;
// Optional base URI
string private _baseURI = "";
// Optional mapping for token URIs
mapping(uint256 tokenId => string) private _tokenURIs;
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the concatenation of the `_baseURI`
* and the token-specific uri if the latter is set
*
* This enables the following behaviors:
*
* - if `_tokenURIs[tokenId]` is set, then the result is the concatenation
* of `_baseURI` and `_tokenURIs[tokenId]` (keep in mind that `_baseURI`
* is empty per default);
*
* - if `_tokenURIs[tokenId]` is NOT set then we fallback to `super.uri()`
* which in most cases will contain `ERC1155._uri`;
*
* - if `_tokenURIs[tokenId]` is NOT set, and if the parents do not have a
* uri value set, then the result is empty.
*/
function uri(uint256 tokenId) public view virtual override returns (string memory) {
string memory tokenURI = _tokenURIs[tokenId];
// If token URI is set, concatenate base URI and tokenURI (via string.concat).
return bytes(tokenURI).length > 0 ? string.concat(_baseURI, tokenURI) : super.uri(tokenId);
}
/**
* @dev Sets `tokenURI` as the tokenURI of `tokenId`.
*/
function _setURI(uint256 tokenId, string memory tokenURI) internal virtual {
_tokenURIs[tokenId] = tokenURI;
emit URI(uri(tokenId), tokenId);
}
/**
* @dev Sets `baseURI` as the `_baseURI` for all tokens
*/
function _setBaseURI(string memory baseURI) internal virtual {
_baseURI = baseURI;
}
}
@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
@openzeppelin/contracts/utils/Arrays.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
using StorageSlot for bytes32;
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* `array` is expected to be sorted in ascending order, and to contain no
* repeated elements.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
// We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
// following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.
/// @solidity memory-safe-assembly
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getAddressSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
// We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
// following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.
/// @solidity memory-safe-assembly
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getBytes32Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
// We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
// following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.
/// @solidity memory-safe-assembly
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getUint256Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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 Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
@openzeppelin/contracts/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @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 ReentrancyGuard {
// 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;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_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 {
// 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 {
// 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) {
return _status == ENTERED;
}
}
@openzeppelin/contracts/utils/ShortStrings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
/// @solidity memory-safe-assembly
assembly {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using
* {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}
@openzeppelin/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
}
}
}
@openzeppelin/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));
}
}
@openzeppelin/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);
}
}
}
@openzeppelin/contracts/utils/cryptography/EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.20;
import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.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.
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @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].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, 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
)
{
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: By default this function reads _name which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Name() internal view returns (string memory) {
return _name.toStringWithFallback(_nameFallback);
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: By default this function reads _version which is an immutable value.
* It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
*/
// solhint-disable-next-line func-name-mixedcase
function _EIP712Version() internal view returns (string memory) {
return _version.toStringWithFallback(_versionFallback);
}
}
@openzeppelin/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)
}
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.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 ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
@openzeppelin/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);
}
@openzeppelin/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;
}
}
@openzeppelin/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);
}
}
}
contracts/interfaces/IRubyscore_Achievement.sol
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.21;
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
/**
* @title IRubyscore_Achievement
* @dev IRubyscore_Achievement is an interface for Rubyscore_Achievement contract
*/
interface IRubyscore_Achievement is IERC1155 {
struct MintParams {
address userAddress; // Address of the buyer.
uint256 userNonce; // Nonce associated with the user's address for preventing replay attacks.
uint256[] nftIds; // ids of NFTs to mint
}
/**
* @notice Emitted when the base URI for token metadata is updated.
* @param newBaseURI The new base URI that will be used to construct token metadata URIs.
* @dev This event is triggered when the contract operator updates the base URI
* for retrieving metadata associated with tokens. The 'newBaseURI' parameter represents
* the updated base URI.
*/
event BaseURISet(string indexed newBaseURI);
/**
* @notice Emitted when NFTs are minted for a user.
* @param userAddress The address of the user receiving the NFTs.
* @param userNonce The user's nonce used to prevent replay attacks.
* @param nftIds An array of NFT IDs that were minted.
* @dev This event is emitted when new NFTs are created and assigned to a user.
* @dev It includes the user's address, nonce, and the IDs of the minted NFTs for transparency.
*/
event Minted(address indexed userAddress, uint256 indexed userNonce, uint256[] nftIds);
/**
* @notice Emitted when the URI for a specific token is updated.
* @param tokenId The ID of the token for which the URI is updated.
* @param newTokenURI The new URI assigned to the token.
* @dev This event is emitted when the URI for a token is modified, providing transparency
* when metadata URIs are changed for specific tokens.
*/
event TokenURISet(uint256 indexed tokenId, string indexed newTokenURI);
/**
* @notice Emitted when the transfer lock status for a token is updated.
* @param tokenId The ID of the token for which the transfer lock status changes.
* @param lock The new transfer lock status (true for locked, false for unlocked).
* @dev This event is emitted when the transfer lock status of a specific token is modified.
* @dev It provides transparency regarding whether a token can be transferred or not.
*/
event TokenUnlockSet(uint256 indexed tokenId, bool indexed lock);
/**
* @notice Emitted when the price for a token mint is updated.
* @param newPrice The new price for mint.
* @dev This event is emitted when the price for mint a token is modified.
*/
event PriceUpdated(uint256 newPrice);
/**
* @notice Get token name.
* @return Token name.
*/
function name() external view returns (string memory);
/**
* @notice Get token symbol.
* @return Token symbol.
*/
function symbol() external view returns (string memory);
/**
* @notice Get the URI of a token.
* @param tokenId The ID of the token.
* @return The URI of the token.
*/
function uri(uint256 tokenId) external view returns (string memory);
/**
* @notice Get the transfer status of a token.
* @param tokenId The ID of the token.
* @return Whether the token's transfer is unlocked (true) or restricted (false).
*/
function getTransferStatus(uint256 tokenId) external view returns (bool);
/**
* @notice Get the user's nonce associated with their address.
* @param userAddress The address of the user.
* @return The user's nonce.
*/
function getUserNonce(address userAddress) external view returns (uint256);
/**
* @notice Get the token URI for a given tokenId.
* @param tokenId The ID of the token.
* @return The URI of the token.
* @dev Diblicate for uri() method
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
/**
* @notice Set the URI for a token.
* @param tokenId The ID of the token.
* @param newTokenURI The new URI to set for the token.
* @dev Requires the MINTER_ROLE.
*/
function setTokenURI(uint256 tokenId, string memory newTokenURI) external;
/**
* @notice Set the URIs for multiple tokens in a batch.
* @param tokenIds An array of token IDs to set URIs for.
* @param newTokenURIs An array of new URIs to set for the tokens.
* @dev Requires the MINTER_ROLE.
* @dev Requires that the tokenIds and newTokenURIs arrays have the same length.
*/
function setBatchTokenURI(uint256[] calldata tokenIds, string[] calldata newTokenURIs) external;
/**
* @notice Set the base URI for all tokens.
* @param newBaseURI The new base URI to set.
* @dev Requires the OPERATOR_ROLE.
*/
function setBaseURI(string memory newBaseURI) external;
/**
* @notice Safely mints NFTs for a user based on provided parameters and a valid minter signature.
* @param mintParams The struct containing user address, user nonce, and NFT IDs to mint.
* @param operatorSignature The ECDSA signature of the data, validating the operator's role.
* @dev This function safely mints NFTs for a user while ensuring the validity of the operator's signature.
* @dev It requires that the provided NFT IDs are valid and that the operator has the MINTER_ROLE.
* @dev User nonces are used to prevent replay attacks.
* @dev Multiple NFTs can be minted in a batch or a single NFT can be minted based on the number of NFT IDs provided.
* @dev Emits the 'Minted' event to indicate the successful minting of NFTs.
*/
function safeMint(MintParams memory mintParams, bytes calldata operatorSignature) external payable;
event Withdrawed(uint256 amount);
/**
* @notice Sets the transfer lock status for a specific token ID.
* @param tokenId The ID of the token to set the transfer lock status for.
* @param lock The boolean value to determine whether transfers of this token are locked or unlocked.
* @dev This function can only be called by an operator with the OPERATOR_ROLE.
* @dev It allows operators to control the transferability of specific tokens.
* @dev Emits the 'tokenUnlockSet' event to indicate the change in transfer lock status.
*/
function setTransferUnlock(uint256 tokenId, bool lock) external;
/**
* @notice Check if a given interface is supported by this contract.
* @param interfaceId The interface identifier to check for support.
* @return Whether the contract supports the specified interface.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function withdraw() external;
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"admin","internalType":"address"},{"type":"address","name":"operator","internalType":"address"},{"type":"address","name":"minter","internalType":"address"},{"type":"string","name":"baseURI","internalType":"string"},{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"}]},{"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":"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":"ERC1155InsufficientBalance","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"error","name":"ERC1155InvalidApprover","inputs":[{"type":"address","name":"approver","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidArrayLength","inputs":[{"type":"uint256","name":"idsLength","internalType":"uint256"},{"type":"uint256","name":"valuesLength","internalType":"uint256"}]},{"type":"error","name":"ERC1155InvalidOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidReceiver","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"error","name":"ERC1155InvalidSender","inputs":[{"type":"address","name":"sender","internalType":"address"}]},{"type":"error","name":"ERC1155MissingApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"InvalidShortString","inputs":[]},{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"error","name":"StringTooLong","inputs":[{"type":"string","name":"str","internalType":"string"}]},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"account","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":"BaseURISet","inputs":[{"type":"string","name":"newBaseURI","internalType":"string","indexed":true}],"anonymous":false},{"type":"event","name":"EIP712DomainChanged","inputs":[],"anonymous":false},{"type":"event","name":"Minted","inputs":[{"type":"address","name":"userAddress","internalType":"address","indexed":true},{"type":"uint256","name":"userNonce","internalType":"uint256","indexed":true},{"type":"uint256[]","name":"nftIds","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"PriceUpdated","inputs":[{"type":"uint256","name":"newPrice","internalType":"uint256","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":"TokenURISet","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"string","name":"newTokenURI","internalType":"string","indexed":true}],"anonymous":false},{"type":"event","name":"TokenUnlockSet","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"bool","name":"lock","internalType":"bool","indexed":true}],"anonymous":false},{"type":"event","name":"TransferBatch","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256[]","name":"ids","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"values","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"TransferSingle","inputs":[{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"URI","inputs":[{"type":"string","name":"value","internalType":"string","indexed":false},{"type":"uint256","name":"id","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Withdrawed","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"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":"MINTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"NAME","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"OPERATOR_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"VERSION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"balanceOfBatch","inputs":[{"type":"address[]","name":"accounts","internalType":"address[]"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"}]},{"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":"bool","name":"","internalType":"bool"}],"name":"exists","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getTransferStatus","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUserNonce","inputs":[{"type":"address","name":"userAddress","internalType":"address"}]},{"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":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","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":"nonpayable","outputs":[],"name":"safeBatchTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"},{"type":"uint256[]","name":"values","internalType":"uint256[]"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"safeMint","inputs":[{"type":"tuple","name":"mintParams","internalType":"struct IRubyscore_Achievement.MintParams","components":[{"type":"address","name":"userAddress","internalType":"address"},{"type":"uint256","name":"userNonce","internalType":"uint256"},{"type":"uint256[]","name":"nftIds","internalType":"uint256[]"}]},{"type":"bytes","name":"operatorSignature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"value","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":"setBaseURI","inputs":[{"type":"string","name":"newBaseURI","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBatchTokenURI","inputs":[{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"},{"type":"string[]","name":"newTokenURIs","internalType":"string[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPrice","inputs":[{"type":"uint256","name":"newPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTokenURI","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"string","name":"newTokenURI","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTransferUnlock","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bool","name":"lock","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":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"uri","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]}]
Contract Creation Code
0x61018060405260006101609081526008906200001c908262000513565b503480156200002a57600080fd5b50604051620037da380380620037da8339810160408190526200004d91620006b3565b6040518060400160405280601581526020017f5275627973636f72655f416368696576656d656e74000000000000000000000081525060405180604001604052806005815260200164302e302e3160d81b81525060405180604001604052806007815260200166697066733a2f2f60c81b815250620000d2816200032060201b60201c565b50620000e082600362000332565b61012052620000f181600462000332565b61014052815160208084019190912060e052815190820120610100524660a0526200017f60e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526001600a556001600160a01b038616620001de5760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b60448201526064015b60405180910390fd5b6001600160a01b0385166200022b5760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b6044820152606401620001d5565b6001600160a01b038416620002785760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b6044820152606401620001d5565b600c62000286838262000513565b50600d62000295828262000513565b50620002a36000876200036b565b50620002bf600080516020620037ba833981519152336200036b565b50620002db600080516020620037ba833981519152866200036b565b50620003087f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6856200036b565b5062000314836200041d565b505050505050620007d6565b60026200032e828262000513565b5050565b600060208351101562000352576200034a836200042b565b905062000365565b816200035f848262000513565b5060ff90505b92915050565b60008281526005602090815260408083206001600160a01b038516845290915281205460ff16620004145760008381526005602090815260408083206001600160a01b03861684529091529020805460ff19166001179055620003cb3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600162000365565b50600062000365565b60086200032e828262000513565b600080829050601f8151111562000459578260405163305a27a960e01b8152600401620001d591906200077c565b80516200046682620007b1565b179392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200049957607f821691505b602082108103620004ba57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200050e57600081815260208120601f850160051c81016020861015620004e95750805b601f850160051c820191505b818110156200050a57828155600101620004f5565b5050505b505050565b81516001600160401b038111156200052f576200052f6200046e565b620005478162000540845462000484565b84620004c0565b602080601f8311600181146200057f5760008415620005665750858301515b600019600386901b1c1916600185901b1785556200050a565b600085815260208120601f198616915b82811015620005b0578886015182559484019460019091019084016200058f565b5085821015620005cf5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b80516001600160a01b0381168114620005f757600080fd5b919050565b60005b8381101562000619578181015183820152602001620005ff565b50506000910152565b600082601f8301126200063457600080fd5b81516001600160401b03808211156200065157620006516200046e565b604051601f8301601f19908116603f011681019082821181831017156200067c576200067c6200046e565b816040528381528660208588010111156200069657600080fd5b620006a9846020830160208901620005fc565b9695505050505050565b60008060008060008060c08789031215620006cd57600080fd5b620006d887620005df565b9550620006e860208801620005df565b9450620006f860408801620005df565b60608801519094506001600160401b03808211156200071657600080fd5b620007248a838b0162000622565b945060808901519150808211156200073b57600080fd5b620007498a838b0162000622565b935060a08901519150808211156200076057600080fd5b506200076f89828a0162000622565b9150509295509295509295565b60208152600082518060208401526200079d816040850160208701620005fc565b601f01601f19169190910160400192915050565b80516020808301519190811015620004ba5760001960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051612f896200083160003960006115c60152600061159401526000611921015260006118f9015260006118540152600061187e015260006118a80152612f896000f3fe6080604052600436106102035760003560e01c806391b7f5ed11610118578063ba772d8b116100a0578063d547741f1161006f578063d547741f14610635578063e985e9c514610655578063f242432a14610675578063f5b541a614610695578063ffa1ad74146106b757600080fd5b8063ba772d8b146105a6578063bd85b039146105c6578063c87b56dd146105f3578063d53913931461061357600080fd5b80639b3e5573116100e75780639b3e5573146104e0578063a217fddf14610500578063a22cb46514610515578063a3f4df7e14610535578063b93c37701461057657600080fd5b806391b7f5ed1461047657806391d148541461049657806395d89b41146104b657806398d5fdca146104cb57600080fd5b80632f2ff15d1161019b5780634f558e791161016a5780634f558e79146103b657806355f804b3146103e55780636834e3a8146104055780637c2ccc451461043b57806384b0196e1461044e57600080fd5b80632f2ff15d1461033457806336568abe146103545780633ccfd60b146103745780634e1273f41461038957600080fd5b8063162094c4116101d7578063162094c4146102ad57806318160ddd146102cf578063248a9ca3146102e45780632eb2c2d61461031457600080fd5b8062fdd58e1461020857806301ffc9a71461023b57806306fdde031461026b5780630e89341c1461028d575b600080fd5b34801561021457600080fd5b5061022861022336600461234f565b6106e8565b6040519081526020015b60405180910390f35b34801561024757600080fd5b5061025b61025636600461238f565b610710565b6040519015158152602001610232565b34801561027757600080fd5b5061028061071b565b60405161023291906123fc565b34801561029957600080fd5b506102806102a836600461240f565b6107a9565b3480156102b957600080fd5b506102cd6102c83660046124dd565b6107b4565b005b3480156102db57600080fd5b50600754610228565b3480156102f057600080fd5b506102286102ff36600461240f565b60009081526005602052604090206001015490565b34801561032057600080fd5b506102cd61032f3660046125b1565b61081b565b34801561034057600080fd5b506102cd61034f36600461265a565b610887565b34801561036057600080fd5b506102cd61036f36600461265a565b6108b2565b34801561038057600080fd5b506102cd6108ea565b34801561039557600080fd5b506103a96103a4366004612686565b610a0a565b6040516102329190612776565b3480156103c257600080fd5b5061025b6103d136600461240f565b600090815260066020526040902054151590565b3480156103f157600080fd5b506102cd610400366004612789565b610ade565b34801561041157600080fd5b506102286104203660046127c5565b6001600160a01b03166000908152600f602052604090205490565b6102cd610449366004612828565b610b41565b34801561045a57600080fd5b50610463610df0565b60405161023297969594939291906128ef565b34801561048257600080fd5b506102cd61049136600461240f565b610e36565b3480156104a257600080fd5b5061025b6104b136600461265a565b610e8a565b3480156104c257600080fd5b50610280610eb5565b3480156104d757600080fd5b50600b54610228565b3480156104ec57600080fd5b506102cd6104fb36600461296f565b610ec2565b34801561050c57600080fd5b50610228600081565b34801561052157600080fd5b506102cd610530366004612992565b610f27565b34801561054157600080fd5b5061028060405180604001604052806015815260200174149d589e5cd8dbdc9957d058da1a595d995b595b9d605a1b81525081565b34801561058257600080fd5b5061025b61059136600461240f565b6000908152600e602052604090205460ff1690565b3480156105b257600080fd5b506102cd6105c1366004612a00565b610f36565b3480156105d257600080fd5b506102286105e136600461240f565b60009081526006602052604090205490565b3480156105ff57600080fd5b5061028061060e36600461240f565b611025565b34801561061f57600080fd5b50610228600080516020612f3483398151915281565b34801561064157600080fd5b506102cd61065036600461265a565b611030565b34801561066157600080fd5b5061025b610670366004612a6b565b611055565b34801561068157600080fd5b506102cd610690366004612a95565b611083565b3480156106a157600080fd5b50610228600080516020612f1483398151915281565b3480156106c357600080fd5b5061028060405180604001604052806005815260200164302e302e3160d81b81525081565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b600061070a826110e2565b600c805461072890612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461075490612af9565b80156107a15780601f10610776576101008083540402835291602001916107a1565b820191906000526020600020905b81548152906001019060200180831161078457829003601f168201915b505050505081565b606061070a82611107565b600080516020612f348339815191526107cc816111e7565b6107d683836111f4565b816040516107e49190612b33565b6040519081900381209084907fda84ca2183491f179a603e877b2cb058e42195041c2b9c53d746427e519a34df90600090a3505050565b336001600160a01b038616811480159061083c575061083a8682611055565b155b156108725760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b61087f8686868686611251565b505050505050565b6000828152600560205260409020600101546108a2816111e7565b6108ac83836112b8565b50505050565b6001600160a01b03811633146108db5760405163334bd91960e11b815260040160405180910390fd5b6108e5828261134c565b505050565b60006108f5816111e7565b47806109435760405162461bcd60e51b815260206004820152601760248201527f5a65726f20616d6f756e7420746f2077697468647261770000000000000000006044820152606401610869565b604051600090339083908381818185875af1925050503d8060008114610985576040519150601f19603f3d011682016040523d82523d6000602084013e61098a565b606091505b50509050806109d25760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610869565b6040518281527f11e9d9f7a772129e26cb0560945658c96b41c42ac6712d233e20c894bfcd00fd9060200160405180910390a1505050565b60608151835114610a3b5781518351604051635b05999160e01b815260048101929092526024820152604401610869565b600083516001600160401b03811115610a5657610a56612428565b604051908082528060200260200182016040528015610a7f578160200160208202803683370190505b50905060005b8451811015610ad657602080820286010151610aa9906020808402870101516106e8565b828281518110610abb57610abb612b4f565b6020908102919091010152610acf81612b7b565b9050610a85565b509392505050565b600080516020612f14833981519152610af6816111e7565b610aff826113b9565b81604051610b0d9190612b33565b604051908190038120907ff9c7803e94e0d3c02900d8a90893a6d5e90dd04d32a4cfe825520f82bf9f32f690600090a25050565b610b496113c5565b60018360400151511015610b915760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964204e46542069647360881b6044820152606401610869565b600b543414610bd95760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81c185e5b595b9d08185b5bdd5b9d60621b6044820152606401610869565b6000610c9e7f66fe4d8b6c8e0542c70e2a244bf04681bb936b001f1be0f079a80e77158a847433600f6000336001600160a01b03166001600160a01b03168152602001908152602001600020548760400151604051602001610c3b9190612b94565b60405160208183030381529060405280519060200120604051602001610c8394939291909384526001600160a01b039290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001206113ef565b9050610cf7600080516020612f34833981519152610cf28386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061141c92505050565b611446565b83516001600160a01b03166000908152600f60205260408120805460019290610d21908490612bca565b909155505060408401515160011015610d5b57610d56846000015185604001516040518060200160405280600081525061147f565b610d97565b610d9784600001518560400151600081518110610d7a57610d7a612b4f565b602002602001015160405180602001604052806000815250611559565b836020015184600001516001600160a01b03167fff0a1dc048ef1a5e9e2845c6bb6cafd8b8531f3cb15368f4a708dec7d7bc789f8660400151604051610ddd9190612776565b60405180910390a3506108e56001600a55565b600060608060008060006060610e0461158d565b610e0c6115bf565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600080516020612f14833981519152610e4e816111e7565b600b8290556040518281527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a15050565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600d805461072890612af9565b600080516020612f14833981519152610eda816111e7565b6000838152600e6020526040808220805460ff19168515159081179091559051909185917f784afb92b74f2c9ccd3cb1b9697580a90fadab59d6640bbb915d1637bfbbf0089190a3505050565b610f323383836115ec565b5050565b600080516020612f34833981519152610f4e816111e7565b838214610f8e5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c696420706172616d7360901b6044820152606401610869565b60005b8481101561087f57611013868683818110610fae57610fae612b4f565b90506020020135858584818110610fc757610fc7612b4f565b9050602002810190610fd99190612bdd565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506107b492505050565b8061101d81612b7b565b915050610f91565b606061070a826107a9565b60008281526005602052604090206001015461104b816111e7565b6108ac838361134c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b336001600160a01b03861681148015906110a457506110a28682611055565b155b156110d55760405163711bec9160e11b81526001600160a01b03808316600483015287166024820152604401610869565b61087f8686868686611682565b60006001600160e01b03198216637965db0b60e01b148061070a575061070a82611710565b60008181526009602052604081208054606092919061112590612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461115190612af9565b801561119e5780601f106111735761010080835404028352916020019161119e565b820191906000526020600020905b81548152906001019060200180831161118157829003601f168201915b5050505050905060008151116111bc576111b783611760565b6111e0565b6008816040516020016111d0929190612c23565b6040516020818303038152906040525b9392505050565b6111f18133611446565b50565b600082815260096020526040902061120c8282612cf0565b50817f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b611238846107a9565b60405161124591906123fc565b60405180910390a25050565b6001600160a01b03841661127b57604051632bfa23e760e11b815260006004820152602401610869565b6001600160a01b0385166112a457604051626a0d4560e21b815260006004820152602401610869565b6112b185858585856117f4565b5050505050565b60006112c48383610e8a565b6113445760008381526005602090815260408083206001600160a01b03861684529091529020805460ff191660011790556112fc3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161070a565b50600061070a565b60006113588383610e8a565b156113445760008381526005602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161070a565b6008610f328282612cf0565b6002600a54036113e857604051633ee5aeb560e01b815260040160405180910390fd5b6002600a55565b600061070a6113fc611847565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008061142c8686611972565b92509250925061143c82826119bf565b5090949350505050565b6114508282610e8a565b610f325760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610869565b600082516001600160401b0381111561149a5761149a612428565b6040519080825280602002602001820160405280156114c3578160200160208202803683370190505b50905060005b83518160ff16101561154c576114fb85858360ff16815181106114ee576114ee612b4f565b60200260200101516106e8565b156115185760405162461bcd60e51b815260040161086990612daf565b6001828260ff168151811061152f5761152f612b4f565b60209081029190910101528061154481612df0565b9150506114c9565b506108ac84848385611a78565b61156383836106e8565b156115805760405162461bcd60e51b815260040161086990612daf565b6108e58383600184611ab0565b60606115ba7f00000000000000000000000000000000000000000000000000000000000000006003611b0d565b905090565b60606115ba7f00000000000000000000000000000000000000000000000000000000000000006004611b0d565b6001600160a01b0382166116155760405162ced3e160e81b815260006004820152602401610869565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0384166116ac57604051632bfa23e760e11b815260006004820152602401610869565b6001600160a01b0385166116d557604051626a0d4560e21b815260006004820152602401610869565b6040805160018082526020820186905281830190815260608201859052608082019092529061170787878484876117f4565b50505050505050565b60006001600160e01b03198216636cdb3d1360e11b148061174157506001600160e01b031982166303a24d0760e21b145b8061070a57506301ffc9a760e01b6001600160e01b031983161461070a565b60606002805461176f90612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461179b90612af9565b80156117e85780601f106117bd576101008083540402835291602001916117e8565b820191906000526020600020905b8154815290600101906020018083116117cb57829003601f168201915b50505050509050919050565b61180085858585611bb8565b6001600160a01b038416156112b157825133906001036118395760208481015190840151611832838989858589611c79565b505061087f565b61087f818787878787611d9d565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156118a057507f000000000000000000000000000000000000000000000000000000000000000046145b156118ca57507f000000000000000000000000000000000000000000000000000000000000000090565b6115ba604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036119ac5760208401516040850151606086015160001a61199e88828585611e86565b9550955095505050506119b8565b50508151600091506002905b9250925092565b60008260038111156119d3576119d3612e0f565b036119dc575050565b60018260038111156119f0576119f0612e0f565b03611a0e5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611a2257611a22612e0f565b03611a435760405163fce698f760e01b815260048101829052602401610869565b6003826003811115611a5757611a57612e0f565b03610f32576040516335e2f38360e21b815260048101829052602401610869565b6001600160a01b038416611aa257604051632bfa23e760e11b815260006004820152602401610869565b6108ac6000858585856117f4565b6001600160a01b038416611ada57604051632bfa23e760e11b815260006004820152602401610869565b6040805160018082526020820186905281830190815260608201859052608082019092529061087f6000878484876117f4565b606060ff8314611b2757611b2083611f55565b905061070a565b818054611b3390612af9565b80601f0160208091040260200160405190810160405280929190818152602001828054611b5f90612af9565b8015611bac5780601f10611b8157610100808354040283529160200191611bac565b820191906000526020600020905b815481529060010190602001808311611b8f57829003601f168201915b5050505050905061070a565b60005b8251811015611c6c57600e6000848381518110611bda57611bda612b4f565b60209081029190910181015182528101919091526040016000205460ff16158015611c0d57506001600160a01b03851615155b15611c5a5760405162461bcd60e51b815260206004820152601760248201527f5468697320746f6b656e206f6e6c7920666f7220796f750000000000000000006044820152606401610869565b80611c6481612b7b565b915050611bbb565b506108ac84848484611f94565b6001600160a01b0384163b1561087f5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611cbd9089908990889088908890600401612e25565b6020604051808303816000875af1925050508015611cf8575060408051601f3d908101601f19168201909252611cf591810190612e6a565b60015b611d61573d808015611d26576040519150601f19603f3d011682016040523d82523d6000602084013e611d2b565b606091505b508051600003611d5957604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b1461170757604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b6001600160a01b0384163b1561087f5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190611de19089908990889088908890600401612e87565b6020604051808303816000875af1925050508015611e1c575060408051601f3d908101601f19168201909252611e1991810190612e6a565b60015b611e4a573d808015611d26576040519150601f19603f3d011682016040523d82523d6000602084013e611d2b565b6001600160e01b0319811663bc197c8160e01b1461170757604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611ec15750600091506003905082611f4b565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611f15573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f4157506000925060019150829050611f4b565b9250600091508190505b9450945094915050565b60606000611f62836120ee565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b611fa084848484612116565b6001600160a01b038416612053576000805b8351811015612039576000838281518110611fcf57611fcf612b4f565b602002602001015190508060066000878581518110611ff057611ff0612b4f565b6020026020010151815260200190815260200160002060008282546120159190612bca565b9091555061202590508184612bca565b9250508061203290612b7b565b9050611fb2565b50806007600082825461204c9190612bca565b9091555050505b6001600160a01b0383166108ac576000805b83518110156120dd57600083828151811061208257612082612b4f565b6020026020010151905080600660008785815181106120a3576120a3612b4f565b6020026020010151815260200190815260200160002060008282540392505081905550808301925050806120d690612b7b565b9050612065565b506007805491909103905550505050565b600060ff8216601f81111561070a57604051632cd44ac360e21b815260040160405180910390fd5b80518251146121455781518151604051635b05999160e01b815260048101929092526024820152604401610869565b3360005b8351811015612254576020818102858101820151908501909101516001600160a01b038816156121fc576000828152602081815260408083206001600160a01b038c168452909152902054818110156121d5576040516303dee4c560e01b81526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610869565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615612241576000828152602081815260408083206001600160a01b038b1684529091528120805483929061223b908490612bca565b90915550505b50508061224d90612b7b565b9050612149565b5082516001036122d55760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6285856040516122c6929190918252602082015260400190565b60405180910390a450506112b1565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612324929190612ee5565b60405180910390a45050505050565b80356001600160a01b038116811461234a57600080fd5b919050565b6000806040838503121561236257600080fd5b61236b83612333565b946020939093013593505050565b6001600160e01b0319811681146111f157600080fd5b6000602082840312156123a157600080fd5b81356111e081612379565b60005b838110156123c75781810151838201526020016123af565b50506000910152565b600081518084526123e88160208601602086016123ac565b601f01601f19169290920160200192915050565b6020815260006111e060208301846123d0565b60006020828403121561242157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561246657612466612428565b604052919050565b600082601f83011261247f57600080fd5b81356001600160401b0381111561249857612498612428565b6124ab601f8201601f191660200161243e565b8181528460208386010111156124c057600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156124f057600080fd5b8235915060208301356001600160401b0381111561250d57600080fd5b6125198582860161246e565b9150509250929050565b60006001600160401b0382111561253c5761253c612428565b5060051b60200190565b600082601f83011261255757600080fd5b8135602061256c61256783612523565b61243e565b82815260059290921b8401810191818101908684111561258b57600080fd5b8286015b848110156125a6578035835291830191830161258f565b509695505050505050565b600080600080600060a086880312156125c957600080fd5b6125d286612333565b94506125e060208701612333565b935060408601356001600160401b03808211156125fc57600080fd5b61260889838a01612546565b9450606088013591508082111561261e57600080fd5b61262a89838a01612546565b9350608088013591508082111561264057600080fd5b5061264d8882890161246e565b9150509295509295909350565b6000806040838503121561266d57600080fd5b8235915061267d60208401612333565b90509250929050565b6000806040838503121561269957600080fd5b82356001600160401b03808211156126b057600080fd5b818501915085601f8301126126c457600080fd5b813560206126d461256783612523565b82815260059290921b840181019181810190898411156126f357600080fd5b948201945b838610156127185761270986612333565b825294820194908201906126f8565b9650508601359250508082111561272e57600080fd5b5061251985828601612546565b600081518084526020808501945080840160005b8381101561276b5781518752958201959082019060010161274f565b509495945050505050565b6020815260006111e0602083018461273b565b60006020828403121561279b57600080fd5b81356001600160401b038111156127b157600080fd5b6127bd8482850161246e565b949350505050565b6000602082840312156127d757600080fd5b6111e082612333565b60008083601f8401126127f257600080fd5b5081356001600160401b0381111561280957600080fd5b60208301915083602082850101111561282157600080fd5b9250929050565b60008060006040848603121561283d57600080fd5b83356001600160401b038082111561285457600080fd5b908501906060828803121561286857600080fd5b60405160608101818110838211171561288357612883612428565b60405261288f83612333565b8152602083013560208201526040830135828111156128ad57600080fd5b6128b989828601612546565b604083015250945060208601359150808211156128d557600080fd5b506128e2868287016127e0565b9497909650939450505050565b60ff60f81b8816815260e06020820152600061290e60e08301896123d0565b828103604084015261292081896123d0565b606084018890526001600160a01b038716608085015260a0840186905283810360c08501529050612951818561273b565b9a9950505050505050505050565b8035801515811461234a57600080fd5b6000806040838503121561298257600080fd5b8235915061267d6020840161295f565b600080604083850312156129a557600080fd5b6129ae83612333565b915061267d6020840161295f565b60008083601f8401126129ce57600080fd5b5081356001600160401b038111156129e557600080fd5b6020830191508360208260051b850101111561282157600080fd5b60008060008060408587031215612a1657600080fd5b84356001600160401b0380821115612a2d57600080fd5b612a39888389016129bc565b90965094506020870135915080821115612a5257600080fd5b50612a5f878288016129bc565b95989497509550505050565b60008060408385031215612a7e57600080fd5b612a8783612333565b915061267d60208401612333565b600080600080600060a08688031215612aad57600080fd5b612ab686612333565b9450612ac460208701612333565b9350604086013592506060860135915060808601356001600160401b03811115612aed57600080fd5b61264d8882890161246e565b600181811c90821680612b0d57607f821691505b602082108103612b2d57634e487b7160e01b600052602260045260246000fd5b50919050565b60008251612b458184602087016123ac565b9190910192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612b8d57612b8d612b65565b5060010190565b815160009082906020808601845b83811015612bbe57815185529382019390820190600101612ba2565b50929695505050505050565b8082018082111561070a5761070a612b65565b6000808335601e19843603018112612bf457600080fd5b8301803591506001600160401b03821115612c0e57600080fd5b60200191503681900382131561282157600080fd5b6000808454612c3181612af9565b60018281168015612c495760018114612c5e57612c8d565b60ff1984168752821515830287019450612c8d565b8860005260208060002060005b85811015612c845781548a820152908401908201612c6b565b50505082870194505b505050508351612ca18183602088016123ac565b01949350505050565b601f8211156108e557600081815260208120601f850160051c81016020861015612cd15750805b601f850160051c820191505b8181101561087f57828155600101612cdd565b81516001600160401b03811115612d0957612d09612428565b612d1d81612d178454612af9565b84612caa565b602080601f831160018114612d525760008415612d3a5750858301515b600019600386901b1c1916600185901b17855561087f565b600085815260208120601f198616915b82811015612d8157888601518255948401946001909101908401612d62565b5085821015612d9f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526021908201527f596f7520616c72656164792068617665207468697320616368696576656d656e6040820152601d60fa1b606082015260800190565b600060ff821660ff8103612e0657612e06612b65565b60010192915050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612e5f908301846123d0565b979650505050505050565b600060208284031215612e7c57600080fd5b81516111e081612379565b6001600160a01b0386811682528516602082015260a060408201819052600090612eb39083018661273b565b8281036060840152612ec5818661273b565b90508281036080840152612ed981856123d0565b98975050505050505050565b604081526000612ef8604083018561273b565b8281036020840152612f0a818561273b565b9594505050505056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9299f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a2646970667358221220b8c1347f2a73d010c495e26bcdef1b8e5d9ec501e6a5157279e170821ba5ddbf64736f6c6343000815003397667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9290000000000000000000000000d0d5ff3cfef8b7b2b1cac6b6c27fd0846c09361000000000000000000000000381c031baa5995d0cc52386508050ac947780815000000000000000000000000381c031baa5995d0cc52386508050ac94778081500000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000007697066733a2f2f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5275627973636f72655f5461696b6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f5275627973636f72655f5461696b6f0000000000000000000000000000000000
Deployed ByteCode
0x6080604052600436106102035760003560e01c806391b7f5ed11610118578063ba772d8b116100a0578063d547741f1161006f578063d547741f14610635578063e985e9c514610655578063f242432a14610675578063f5b541a614610695578063ffa1ad74146106b757600080fd5b8063ba772d8b146105a6578063bd85b039146105c6578063c87b56dd146105f3578063d53913931461061357600080fd5b80639b3e5573116100e75780639b3e5573146104e0578063a217fddf14610500578063a22cb46514610515578063a3f4df7e14610535578063b93c37701461057657600080fd5b806391b7f5ed1461047657806391d148541461049657806395d89b41146104b657806398d5fdca146104cb57600080fd5b80632f2ff15d1161019b5780634f558e791161016a5780634f558e79146103b657806355f804b3146103e55780636834e3a8146104055780637c2ccc451461043b57806384b0196e1461044e57600080fd5b80632f2ff15d1461033457806336568abe146103545780633ccfd60b146103745780634e1273f41461038957600080fd5b8063162094c4116101d7578063162094c4146102ad57806318160ddd146102cf578063248a9ca3146102e45780632eb2c2d61461031457600080fd5b8062fdd58e1461020857806301ffc9a71461023b57806306fdde031461026b5780630e89341c1461028d575b600080fd5b34801561021457600080fd5b5061022861022336600461234f565b6106e8565b6040519081526020015b60405180910390f35b34801561024757600080fd5b5061025b61025636600461238f565b610710565b6040519015158152602001610232565b34801561027757600080fd5b5061028061071b565b60405161023291906123fc565b34801561029957600080fd5b506102806102a836600461240f565b6107a9565b3480156102b957600080fd5b506102cd6102c83660046124dd565b6107b4565b005b3480156102db57600080fd5b50600754610228565b3480156102f057600080fd5b506102286102ff36600461240f565b60009081526005602052604090206001015490565b34801561032057600080fd5b506102cd61032f3660046125b1565b61081b565b34801561034057600080fd5b506102cd61034f36600461265a565b610887565b34801561036057600080fd5b506102cd61036f36600461265a565b6108b2565b34801561038057600080fd5b506102cd6108ea565b34801561039557600080fd5b506103a96103a4366004612686565b610a0a565b6040516102329190612776565b3480156103c257600080fd5b5061025b6103d136600461240f565b600090815260066020526040902054151590565b3480156103f157600080fd5b506102cd610400366004612789565b610ade565b34801561041157600080fd5b506102286104203660046127c5565b6001600160a01b03166000908152600f602052604090205490565b6102cd610449366004612828565b610b41565b34801561045a57600080fd5b50610463610df0565b60405161023297969594939291906128ef565b34801561048257600080fd5b506102cd61049136600461240f565b610e36565b3480156104a257600080fd5b5061025b6104b136600461265a565b610e8a565b3480156104c257600080fd5b50610280610eb5565b3480156104d757600080fd5b50600b54610228565b3480156104ec57600080fd5b506102cd6104fb36600461296f565b610ec2565b34801561050c57600080fd5b50610228600081565b34801561052157600080fd5b506102cd610530366004612992565b610f27565b34801561054157600080fd5b5061028060405180604001604052806015815260200174149d589e5cd8dbdc9957d058da1a595d995b595b9d605a1b81525081565b34801561058257600080fd5b5061025b61059136600461240f565b6000908152600e602052604090205460ff1690565b3480156105b257600080fd5b506102cd6105c1366004612a00565b610f36565b3480156105d257600080fd5b506102286105e136600461240f565b60009081526006602052604090205490565b3480156105ff57600080fd5b5061028061060e36600461240f565b611025565b34801561061f57600080fd5b50610228600080516020612f3483398151915281565b34801561064157600080fd5b506102cd61065036600461265a565b611030565b34801561066157600080fd5b5061025b610670366004612a6b565b611055565b34801561068157600080fd5b506102cd610690366004612a95565b611083565b3480156106a157600080fd5b50610228600080516020612f1483398151915281565b3480156106c357600080fd5b5061028060405180604001604052806005815260200164302e302e3160d81b81525081565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b600061070a826110e2565b600c805461072890612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461075490612af9565b80156107a15780601f10610776576101008083540402835291602001916107a1565b820191906000526020600020905b81548152906001019060200180831161078457829003601f168201915b505050505081565b606061070a82611107565b600080516020612f348339815191526107cc816111e7565b6107d683836111f4565b816040516107e49190612b33565b6040519081900381209084907fda84ca2183491f179a603e877b2cb058e42195041c2b9c53d746427e519a34df90600090a3505050565b336001600160a01b038616811480159061083c575061083a8682611055565b155b156108725760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b61087f8686868686611251565b505050505050565b6000828152600560205260409020600101546108a2816111e7565b6108ac83836112b8565b50505050565b6001600160a01b03811633146108db5760405163334bd91960e11b815260040160405180910390fd5b6108e5828261134c565b505050565b60006108f5816111e7565b47806109435760405162461bcd60e51b815260206004820152601760248201527f5a65726f20616d6f756e7420746f2077697468647261770000000000000000006044820152606401610869565b604051600090339083908381818185875af1925050503d8060008114610985576040519150601f19603f3d011682016040523d82523d6000602084013e61098a565b606091505b50509050806109d25760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610869565b6040518281527f11e9d9f7a772129e26cb0560945658c96b41c42ac6712d233e20c894bfcd00fd9060200160405180910390a1505050565b60608151835114610a3b5781518351604051635b05999160e01b815260048101929092526024820152604401610869565b600083516001600160401b03811115610a5657610a56612428565b604051908082528060200260200182016040528015610a7f578160200160208202803683370190505b50905060005b8451811015610ad657602080820286010151610aa9906020808402870101516106e8565b828281518110610abb57610abb612b4f565b6020908102919091010152610acf81612b7b565b9050610a85565b509392505050565b600080516020612f14833981519152610af6816111e7565b610aff826113b9565b81604051610b0d9190612b33565b604051908190038120907ff9c7803e94e0d3c02900d8a90893a6d5e90dd04d32a4cfe825520f82bf9f32f690600090a25050565b610b496113c5565b60018360400151511015610b915760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964204e46542069647360881b6044820152606401610869565b600b543414610bd95760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81c185e5b595b9d08185b5bdd5b9d60621b6044820152606401610869565b6000610c9e7f66fe4d8b6c8e0542c70e2a244bf04681bb936b001f1be0f079a80e77158a847433600f6000336001600160a01b03166001600160a01b03168152602001908152602001600020548760400151604051602001610c3b9190612b94565b60405160208183030381529060405280519060200120604051602001610c8394939291909384526001600160a01b039290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001206113ef565b9050610cf7600080516020612f34833981519152610cf28386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061141c92505050565b611446565b83516001600160a01b03166000908152600f60205260408120805460019290610d21908490612bca565b909155505060408401515160011015610d5b57610d56846000015185604001516040518060200160405280600081525061147f565b610d97565b610d9784600001518560400151600081518110610d7a57610d7a612b4f565b602002602001015160405180602001604052806000815250611559565b836020015184600001516001600160a01b03167fff0a1dc048ef1a5e9e2845c6bb6cafd8b8531f3cb15368f4a708dec7d7bc789f8660400151604051610ddd9190612776565b60405180910390a3506108e56001600a55565b600060608060008060006060610e0461158d565b610e0c6115bf565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600080516020612f14833981519152610e4e816111e7565b600b8290556040518281527f66cbca4f3c64fecf1dcb9ce094abcf7f68c3450a1d4e3a8e917dd621edb4ebe09060200160405180910390a15050565b60009182526005602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600d805461072890612af9565b600080516020612f14833981519152610eda816111e7565b6000838152600e6020526040808220805460ff19168515159081179091559051909185917f784afb92b74f2c9ccd3cb1b9697580a90fadab59d6640bbb915d1637bfbbf0089190a3505050565b610f323383836115ec565b5050565b600080516020612f34833981519152610f4e816111e7565b838214610f8e5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c696420706172616d7360901b6044820152606401610869565b60005b8481101561087f57611013868683818110610fae57610fae612b4f565b90506020020135858584818110610fc757610fc7612b4f565b9050602002810190610fd99190612bdd565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506107b492505050565b8061101d81612b7b565b915050610f91565b606061070a826107a9565b60008281526005602052604090206001015461104b816111e7565b6108ac838361134c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b336001600160a01b03861681148015906110a457506110a28682611055565b155b156110d55760405163711bec9160e11b81526001600160a01b03808316600483015287166024820152604401610869565b61087f8686868686611682565b60006001600160e01b03198216637965db0b60e01b148061070a575061070a82611710565b60008181526009602052604081208054606092919061112590612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461115190612af9565b801561119e5780601f106111735761010080835404028352916020019161119e565b820191906000526020600020905b81548152906001019060200180831161118157829003601f168201915b5050505050905060008151116111bc576111b783611760565b6111e0565b6008816040516020016111d0929190612c23565b6040516020818303038152906040525b9392505050565b6111f18133611446565b50565b600082815260096020526040902061120c8282612cf0565b50817f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b611238846107a9565b60405161124591906123fc565b60405180910390a25050565b6001600160a01b03841661127b57604051632bfa23e760e11b815260006004820152602401610869565b6001600160a01b0385166112a457604051626a0d4560e21b815260006004820152602401610869565b6112b185858585856117f4565b5050505050565b60006112c48383610e8a565b6113445760008381526005602090815260408083206001600160a01b03861684529091529020805460ff191660011790556112fc3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161070a565b50600061070a565b60006113588383610e8a565b156113445760008381526005602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161070a565b6008610f328282612cf0565b6002600a54036113e857604051633ee5aeb560e01b815260040160405180910390fd5b6002600a55565b600061070a6113fc611847565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008061142c8686611972565b92509250925061143c82826119bf565b5090949350505050565b6114508282610e8a565b610f325760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610869565b600082516001600160401b0381111561149a5761149a612428565b6040519080825280602002602001820160405280156114c3578160200160208202803683370190505b50905060005b83518160ff16101561154c576114fb85858360ff16815181106114ee576114ee612b4f565b60200260200101516106e8565b156115185760405162461bcd60e51b815260040161086990612daf565b6001828260ff168151811061152f5761152f612b4f565b60209081029190910101528061154481612df0565b9150506114c9565b506108ac84848385611a78565b61156383836106e8565b156115805760405162461bcd60e51b815260040161086990612daf565b6108e58383600184611ab0565b60606115ba7f5275627973636f72655f416368696576656d656e7400000000000000000000156003611b0d565b905090565b60606115ba7f302e302e310000000000000000000000000000000000000000000000000000056004611b0d565b6001600160a01b0382166116155760405162ced3e160e81b815260006004820152602401610869565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0384166116ac57604051632bfa23e760e11b815260006004820152602401610869565b6001600160a01b0385166116d557604051626a0d4560e21b815260006004820152602401610869565b6040805160018082526020820186905281830190815260608201859052608082019092529061170787878484876117f4565b50505050505050565b60006001600160e01b03198216636cdb3d1360e11b148061174157506001600160e01b031982166303a24d0760e21b145b8061070a57506301ffc9a760e01b6001600160e01b031983161461070a565b60606002805461176f90612af9565b80601f016020809104026020016040519081016040528092919081815260200182805461179b90612af9565b80156117e85780601f106117bd576101008083540402835291602001916117e8565b820191906000526020600020905b8154815290600101906020018083116117cb57829003601f168201915b50505050509050919050565b61180085858585611bb8565b6001600160a01b038416156112b157825133906001036118395760208481015190840151611832838989858589611c79565b505061087f565b61087f818787878787611d9d565b6000306001600160a01b037f000000000000000000000000dc3d8318fbaec2de49281843f5bba22e78338146161480156118a057507f0000000000000000000000000000000000000000000000000000000000028c5846145b156118ca57507f006b7ced0ae69e3cafe8fae84830ffd53be5d26d90b9e4c0a5f3cc009f5eaefd90565b6115ba604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f2d2ade98d6bb8fe401ca155fda7789f3500abdfa8c04ae14de3ff34b1cd8bb25918101919091527fae209a0b48f21c054280f2455d32cf309387644879d9acbd8ffc19916381188560608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036119ac5760208401516040850151606086015160001a61199e88828585611e86565b9550955095505050506119b8565b50508151600091506002905b9250925092565b60008260038111156119d3576119d3612e0f565b036119dc575050565b60018260038111156119f0576119f0612e0f565b03611a0e5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115611a2257611a22612e0f565b03611a435760405163fce698f760e01b815260048101829052602401610869565b6003826003811115611a5757611a57612e0f565b03610f32576040516335e2f38360e21b815260048101829052602401610869565b6001600160a01b038416611aa257604051632bfa23e760e11b815260006004820152602401610869565b6108ac6000858585856117f4565b6001600160a01b038416611ada57604051632bfa23e760e11b815260006004820152602401610869565b6040805160018082526020820186905281830190815260608201859052608082019092529061087f6000878484876117f4565b606060ff8314611b2757611b2083611f55565b905061070a565b818054611b3390612af9565b80601f0160208091040260200160405190810160405280929190818152602001828054611b5f90612af9565b8015611bac5780601f10611b8157610100808354040283529160200191611bac565b820191906000526020600020905b815481529060010190602001808311611b8f57829003601f168201915b5050505050905061070a565b60005b8251811015611c6c57600e6000848381518110611bda57611bda612b4f565b60209081029190910181015182528101919091526040016000205460ff16158015611c0d57506001600160a01b03851615155b15611c5a5760405162461bcd60e51b815260206004820152601760248201527f5468697320746f6b656e206f6e6c7920666f7220796f750000000000000000006044820152606401610869565b80611c6481612b7b565b915050611bbb565b506108ac84848484611f94565b6001600160a01b0384163b1561087f5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611cbd9089908990889088908890600401612e25565b6020604051808303816000875af1925050508015611cf8575060408051601f3d908101601f19168201909252611cf591810190612e6a565b60015b611d61573d808015611d26576040519150601f19603f3d011682016040523d82523d6000602084013e611d2b565b606091505b508051600003611d5957604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b1461170757604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b6001600160a01b0384163b1561087f5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190611de19089908990889088908890600401612e87565b6020604051808303816000875af1925050508015611e1c575060408051601f3d908101601f19168201909252611e1991810190612e6a565b60015b611e4a573d808015611d26576040519150601f19603f3d011682016040523d82523d6000602084013e611d2b565b6001600160e01b0319811663bc197c8160e01b1461170757604051632bfa23e760e11b81526001600160a01b0386166004820152602401610869565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115611ec15750600091506003905082611f4b565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611f15573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f4157506000925060019150829050611f4b565b9250600091508190505b9450945094915050565b60606000611f62836120ee565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b611fa084848484612116565b6001600160a01b038416612053576000805b8351811015612039576000838281518110611fcf57611fcf612b4f565b602002602001015190508060066000878581518110611ff057611ff0612b4f565b6020026020010151815260200190815260200160002060008282546120159190612bca565b9091555061202590508184612bca565b9250508061203290612b7b565b9050611fb2565b50806007600082825461204c9190612bca565b9091555050505b6001600160a01b0383166108ac576000805b83518110156120dd57600083828151811061208257612082612b4f565b6020026020010151905080600660008785815181106120a3576120a3612b4f565b6020026020010151815260200190815260200160002060008282540392505081905550808301925050806120d690612b7b565b9050612065565b506007805491909103905550505050565b600060ff8216601f81111561070a57604051632cd44ac360e21b815260040160405180910390fd5b80518251146121455781518151604051635b05999160e01b815260048101929092526024820152604401610869565b3360005b8351811015612254576020818102858101820151908501909101516001600160a01b038816156121fc576000828152602081815260408083206001600160a01b038c168452909152902054818110156121d5576040516303dee4c560e01b81526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610869565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615612241576000828152602081815260408083206001600160a01b038b1684529091528120805483929061223b908490612bca565b90915550505b50508061224d90612b7b565b9050612149565b5082516001036122d55760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6285856040516122c6929190918252602082015260400190565b60405180910390a450506112b1565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612324929190612ee5565b60405180910390a45050505050565b80356001600160a01b038116811461234a57600080fd5b919050565b6000806040838503121561236257600080fd5b61236b83612333565b946020939093013593505050565b6001600160e01b0319811681146111f157600080fd5b6000602082840312156123a157600080fd5b81356111e081612379565b60005b838110156123c75781810151838201526020016123af565b50506000910152565b600081518084526123e88160208601602086016123ac565b601f01601f19169290920160200192915050565b6020815260006111e060208301846123d0565b60006020828403121561242157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561246657612466612428565b604052919050565b600082601f83011261247f57600080fd5b81356001600160401b0381111561249857612498612428565b6124ab601f8201601f191660200161243e565b8181528460208386010111156124c057600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156124f057600080fd5b8235915060208301356001600160401b0381111561250d57600080fd5b6125198582860161246e565b9150509250929050565b60006001600160401b0382111561253c5761253c612428565b5060051b60200190565b600082601f83011261255757600080fd5b8135602061256c61256783612523565b61243e565b82815260059290921b8401810191818101908684111561258b57600080fd5b8286015b848110156125a6578035835291830191830161258f565b509695505050505050565b600080600080600060a086880312156125c957600080fd5b6125d286612333565b94506125e060208701612333565b935060408601356001600160401b03808211156125fc57600080fd5b61260889838a01612546565b9450606088013591508082111561261e57600080fd5b61262a89838a01612546565b9350608088013591508082111561264057600080fd5b5061264d8882890161246e565b9150509295509295909350565b6000806040838503121561266d57600080fd5b8235915061267d60208401612333565b90509250929050565b6000806040838503121561269957600080fd5b82356001600160401b03808211156126b057600080fd5b818501915085601f8301126126c457600080fd5b813560206126d461256783612523565b82815260059290921b840181019181810190898411156126f357600080fd5b948201945b838610156127185761270986612333565b825294820194908201906126f8565b9650508601359250508082111561272e57600080fd5b5061251985828601612546565b600081518084526020808501945080840160005b8381101561276b5781518752958201959082019060010161274f565b509495945050505050565b6020815260006111e0602083018461273b565b60006020828403121561279b57600080fd5b81356001600160401b038111156127b157600080fd5b6127bd8482850161246e565b949350505050565b6000602082840312156127d757600080fd5b6111e082612333565b60008083601f8401126127f257600080fd5b5081356001600160401b0381111561280957600080fd5b60208301915083602082850101111561282157600080fd5b9250929050565b60008060006040848603121561283d57600080fd5b83356001600160401b038082111561285457600080fd5b908501906060828803121561286857600080fd5b60405160608101818110838211171561288357612883612428565b60405261288f83612333565b8152602083013560208201526040830135828111156128ad57600080fd5b6128b989828601612546565b604083015250945060208601359150808211156128d557600080fd5b506128e2868287016127e0565b9497909650939450505050565b60ff60f81b8816815260e06020820152600061290e60e08301896123d0565b828103604084015261292081896123d0565b606084018890526001600160a01b038716608085015260a0840186905283810360c08501529050612951818561273b565b9a9950505050505050505050565b8035801515811461234a57600080fd5b6000806040838503121561298257600080fd5b8235915061267d6020840161295f565b600080604083850312156129a557600080fd5b6129ae83612333565b915061267d6020840161295f565b60008083601f8401126129ce57600080fd5b5081356001600160401b038111156129e557600080fd5b6020830191508360208260051b850101111561282157600080fd5b60008060008060408587031215612a1657600080fd5b84356001600160401b0380821115612a2d57600080fd5b612a39888389016129bc565b90965094506020870135915080821115612a5257600080fd5b50612a5f878288016129bc565b95989497509550505050565b60008060408385031215612a7e57600080fd5b612a8783612333565b915061267d60208401612333565b600080600080600060a08688031215612aad57600080fd5b612ab686612333565b9450612ac460208701612333565b9350604086013592506060860135915060808601356001600160401b03811115612aed57600080fd5b61264d8882890161246e565b600181811c90821680612b0d57607f821691505b602082108103612b2d57634e487b7160e01b600052602260045260246000fd5b50919050565b60008251612b458184602087016123ac565b9190910192915050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612b8d57612b8d612b65565b5060010190565b815160009082906020808601845b83811015612bbe57815185529382019390820190600101612ba2565b50929695505050505050565b8082018082111561070a5761070a612b65565b6000808335601e19843603018112612bf457600080fd5b8301803591506001600160401b03821115612c0e57600080fd5b60200191503681900382131561282157600080fd5b6000808454612c3181612af9565b60018281168015612c495760018114612c5e57612c8d565b60ff1984168752821515830287019450612c8d565b8860005260208060002060005b85811015612c845781548a820152908401908201612c6b565b50505082870194505b505050508351612ca18183602088016123ac565b01949350505050565b601f8211156108e557600081815260208120601f850160051c81016020861015612cd15750805b601f850160051c820191505b8181101561087f57828155600101612cdd565b81516001600160401b03811115612d0957612d09612428565b612d1d81612d178454612af9565b84612caa565b602080601f831160018114612d525760008415612d3a5750858301515b600019600386901b1c1916600185901b17855561087f565b600085815260208120601f198616915b82811015612d8157888601518255948401946001909101908401612d62565b5085821015612d9f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526021908201527f596f7520616c72656164792068617665207468697320616368696576656d656e6040820152601d60fa1b606082015260800190565b600060ff821660ff8103612e0657612e06612b65565b60010192915050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612e5f908301846123d0565b979650505050505050565b600060208284031215612e7c57600080fd5b81516111e081612379565b6001600160a01b0386811682528516602082015260a060408201819052600090612eb39083018661273b565b8281036060840152612ec5818661273b565b90508281036080840152612ed981856123d0565b98975050505050505050565b604081526000612ef8604083018561273b565b8281036020840152612f0a818561273b565b9594505050505056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9299f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a2646970667358221220b8c1347f2a73d010c495e26bcdef1b8e5d9ec501e6a5157279e170821ba5ddbf64736f6c63430008150033