Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- NanakusaNFTFactory
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-05-14T02:03:31.354833Z
Constructor Arguments
0x0000000000000000000000002564c8ac021fa8cddf83c5e9e63a8edaf37c907d
Arg [0] (address) : 0x2564c8ac021fa8cddf83c5e9e63a8edaf37c907d
contracts/sbinft/token/erc721/nanakusa/factory/NanakusaNFTFactory.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import "./NanakusaNFT.sol";
/**
* @title SBINFT Nanakusa NFT Contract Factory
* @author SBINFT Co., Ltd.
*/
contract NanakusaNFTFactory is ERC2771Context {
address private immutable _trustedForwarderThis;
// コントラクト情報格納配列
mapping(address => address[]) private _nanakusaNFTContracts;
event NanakusaNFTContractCreated(
address contractAddress,
string name,
string symbol,
address owner,
address trustedForwarder
);
/**
* @dev Constructor
*
* @param trustedForwarder address
*/
constructor(address trustedForwarder) ERC2771Context(trustedForwarder) {
_trustedForwarderThis = trustedForwarder;
}
/**
* @dev 新規NanakusaNFTコントラクトを作成する
*
* @param name string calldata
* @param symbol string calldata
* @param owner address
*/
function createContract(
string memory name,
string memory symbol,
address[] memory operatorList,
address owner
) external {
NanakusaNFT nanakusaNFT = new NanakusaNFT(
name,
symbol,
operatorList,
_trustedForwarderThis
);
nanakusaNFT.transferOwnership(owner);
address[] storage ownerContracts = _nanakusaNFTContracts[owner];
ownerContracts.push(address(nanakusaNFT));
emit NanakusaNFTContractCreated(
address(nanakusaNFT),
name,
symbol,
owner,
_trustedForwarderThis
);
}
/**
* @dev Retures the list of deployed contracts by owner
*
* @param owner_ address
*/
function getContractByOwner(
address owner_
) public view returns (address[] memory) {
return _nanakusaNFTContracts[owner_];
}
}
@openzeppelin/contracts/security/Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
@openzeppelin/contracts/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
contracts/sbinft/market/v1/library/OrderDomain.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/**
* @dev Model data related with Order
*/
library OrderDomain {
// ORIGIN_KIND
bytes4 private constant NANAKUSA_ORIGIN_KIND = bytes4(keccak256("NANAKUSA"));
bytes4 private constant PARTNER_ORIGIN_KIND = bytes4(keccak256("PARTNER"));
// PAYMENT_MODE
bytes4 public constant NATIVE_PAYMENT_MODE = bytes4(keccak256("NATIVE"));
bytes4 public constant ERC20_PAYMENT_MODE = bytes4(keccak256("ERC20"));
bytes4 private constant CREDIT_CARD_PAYMENT_MODE =
bytes4(keccak256("CREDIT_CARD"));
bytes4 private constant OTHER_BLOCKCHAIN_PAYMENT_MODE =
bytes4(keccak256("OTHER_BLOCKCHAIN"));
struct Asset {
bytes4 originKind;
address token;
uint256 tokenId;
uint16 partnerFeeRate; // only set when originKind = PARTNER_ORIGIN_KIND
uint8 isSecondarySale;
}
struct Payment {
bytes4 paymentMode; // Like NATIVE_PAYMENT_MODE || ERC20_PAYMENT_MODE || ...
address paymentToken; // Token contract address
uint256 price;
}
struct SaleOrder {
Asset[] assetList; // Array will represent bundle
address currentOwner;
address paymentReceiver; // Onchain payment receiver, can be same as currentOwner
Payment[] acceptedPaymentMode;
uint16 pfSaleFeeRate;
uint256 start; // Always non zero
uint256 end; // Can be zero when there is no end time
uint256 nonce;
}
struct BuyOrder {
uint256 saleNonce;
address payable buyer;
address payable payer; // If no payer means buyer is the payer
Payment paymentDetails;
uint256 validUntil; // UNIX timestamp to determine the of validity of buyOrder
}
// ---- EIP712 ----
bytes32 private constant ASSET_TYPEHASH =
keccak256(
"Asset(bytes4 originKind,address token,uint256 tokenId,uint16 partnerFeeRate,uint8 isSecondarySale)"
);
bytes32 private constant PAYMENT_TYPEHASH =
keccak256("Payment(bytes4 paymentMode,address paymentToken,uint256 price)");
bytes32 private constant SALE_ORDER_TYPEHASH =
keccak256(
"SaleOrder(Asset[] assetList,address currentOwner,address paymentReceiver,Payment[] acceptedPaymentMode,uint16 pfSaleFeeRate,uint256 start,uint256 end,uint256 nonce)Asset(bytes4 originKind,address token,uint256 tokenId,uint16 partnerFeeRate,uint8 isSecondarySale)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
);
bytes32 private constant BUY_ORDER_TYPEHASH =
keccak256(
"BuyOrder(uint256 saleNonce,address buyer,address payer,Payment paymentDetails,uint256 validUntil)Payment(bytes4 paymentMode,address paymentToken,uint256 price)"
);
/**
* @dev Prepares keccak256 hash for Asset
*
* @param _asset OrderDomain.Asset
*/
function _hashAsset(Asset calldata _asset) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
ASSET_TYPEHASH,
_asset.originKind,
_asset.token,
_asset.tokenId,
_asset.partnerFeeRate,
_asset.isSecondarySale
)
);
}
/**
* @dev Prepares keccak256 hash for Asset list
*
* @param _assetList OrderDomain.Asset[]
*/
function _hashAsset(
Asset[] calldata _assetList
) internal pure returns (bytes32) {
bytes32[] memory keccakData = new bytes32[](_assetList.length);
for (uint256 idx = 0; idx < _assetList.length; idx++) {
keccakData[idx] = _hashAsset(_assetList[idx]);
}
return keccak256(abi.encodePacked(keccakData));
}
/**
* @dev Prepares keccak256 hash for Payment
*
* @param _payment OrderDomain.Payment
*/
function _hashPayment(
Payment calldata _payment
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
PAYMENT_TYPEHASH,
_payment.paymentMode,
_payment.paymentToken,
_payment.price
)
);
}
/**
* @dev Prepares keccak256 hash for Payment list
*
* @param _paymentList OrderDomain.Payment[]
*/
function _hashPayment(
Payment[] calldata _paymentList
) internal pure returns (bytes32) {
bytes32[] memory keccakData = new bytes32[](_paymentList.length);
for (uint256 idx = 0; idx < _paymentList.length; idx++) {
keccakData[idx] = _hashPayment(_paymentList[idx]);
}
return keccak256(abi.encodePacked(keccakData));
}
/**
* @dev Prepares keccak256 hash for SaleOrder
*
* @param _saleOrder OrderDomain.SaleOrder
*/
function _hashSaleOrder(
SaleOrder calldata _saleOrder
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
SALE_ORDER_TYPEHASH,
_hashAsset(_saleOrder.assetList),
_saleOrder.currentOwner,
_saleOrder.paymentReceiver,
_hashPayment(_saleOrder.acceptedPaymentMode),
_saleOrder.pfSaleFeeRate,
_saleOrder.start,
_saleOrder.end,
_saleOrder.nonce
)
);
}
/**
* @dev Prepares keccak256 hash for BuyOrder
*
* @param _buyOrder OrderDomain.BuyOrder
*/
function _hashBuyOrder(
BuyOrder calldata _buyOrder
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
BUY_ORDER_TYPEHASH,
_buyOrder.saleNonce,
_buyOrder.buyer,
_buyOrder.payer,
_hashPayment(_buyOrder.paymentDetails),
_buyOrder.validUntil
)
);
}
// ---- EIP712 ----
/**
* @dev Checks if it's a Secondary Sale
*
* @param _secondarySale uint8
*/
function _isSecondarySale(uint8 _secondarySale) internal pure returns (bool) {
return (_secondarySale == 1);
}
/**
* @dev Checks if it's a valid origin kind
*
* @param _originKind bytes4
*/
function _isValidOriginKind(bytes4 _originKind) internal pure returns (bool) {
return (_originKind == NANAKUSA_ORIGIN_KIND ||
_originKind == PARTNER_ORIGIN_KIND);
}
/**
* @dev Checks if it's a valid payment mode
*
* @param _paymentMode bytes4
*/
function _isValidPaymentMode(
bytes4 _paymentMode
) internal pure returns (bool) {
return (_paymentMode == NATIVE_PAYMENT_MODE ||
_paymentMode == ERC20_PAYMENT_MODE ||
_paymentMode == CREDIT_CARD_PAYMENT_MODE ||
_paymentMode == OTHER_BLOCKCHAIN_PAYMENT_MODE);
}
/**
* @dev Checks if payment mode is onchain
*
* @param _paymentMode bytes4
*/
function _isOnchainPaymentMode(
bytes4 _paymentMode
) internal pure returns (bool) {
return (_paymentMode == NATIVE_PAYMENT_MODE ||
_paymentMode == ERC20_PAYMENT_MODE);
}
/**
* @dev Checks if origin kind is partner
*
* @param _originKind bytes4
*/
function _isPartnerOrigin(bytes4 _originKind) internal pure returns (bool) {
return (_originKind == PARTNER_ORIGIN_KIND);
}
/**
* @dev Find the total sale price by matching payment mode of SaleOrder and BuyOrder
*
* @param _saleOrder SaleOrder
* @param _buyOrder BuyOrder
*/
function _findTotalSalePrice(
SaleOrder calldata _saleOrder,
BuyOrder calldata _buyOrder
) internal pure returns (uint256) {
uint256 totalSalePrice = 0;
// Find total sale price
for (uint256 idx = 0; idx < _saleOrder.acceptedPaymentMode.length; idx++) {
if (
_saleOrder.acceptedPaymentMode[idx].paymentMode ==
_buyOrder.paymentDetails.paymentMode
) {
totalSalePrice = _saleOrder.acceptedPaymentMode[idx].price;
break;
}
}
return totalSalePrice;
}
}
contracts/sbinft/token/erc721/nanakusa/factory/NanakusaNFT.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import "@openzeppelin/contracts/metatx/ERC2771Context.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../interface/INanakusa.sol";
/**
* @title SBINFT Nanakusa Factory NFT Contract
* @author SBINFT Co., Ltd.
*/
contract NanakusaNFT is
INanakusa,
ERC2771Context,
EIP712,
ERC721URIStorage,
ERC721Pausable,
ERC721Burnable,
ERC721Royalty,
Ownable
{
using ECDSA for bytes32;
bytes32 private constant MINT_DATA_TYPEHASH =
keccak256("MintData(address creator,uint256 nftId,string tokenURI)");
// Map of pre-approved operators
mapping(address => bool) private _preApprovedOperator;
uint256 private _lastMintedTokenId;
/**
* @dev Constructor
*
* @param name_ string memory
* @param symbol_ string memory
* @param trustedForwarder address
*/
constructor(
string memory name_,
string memory symbol_,
address[] memory operatorList,
address trustedForwarder
)
ERC2771Context(trustedForwarder)
ERC721(name_, symbol_)
EIP712("SBINFT Nanakusa Factoy NFT", "1.0")
{
addPreApprovedOperator(operatorList);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721Royalty, ERC721) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* See {ERC2771Context._msgSender()}
*/
function _msgSender()
internal
view
virtual
override(Context, ERC2771Context)
returns (address sender)
{
return ERC2771Context._msgSender();
}
/**
* See {ERC2771Context._msgData()}
*/
function _msgData()
internal
view
virtual
override(Context, ERC2771Context)
returns (bytes calldata)
{
return ERC2771Context._msgData();
}
/**
* @dev Prepares keccak256 hash for MintData
*
* @param mintData MintData calldata
*/
function _hashMintData(
MintData calldata mintData
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
MINT_DATA_TYPEHASH,
mintData.creator,
mintData.nftId,
keccak256(bytes(mintData.tokenURI))
)
);
}
/**
* @dev Verify arguments before minting
*
* @param mintData MintData calldata
* @param mintSign bytes calldata
*/
function _verifyMintArguments(
MintData calldata mintData,
bytes calldata mintSign
) internal view {
require(
mintData.nftId > 0,
"NanakusaNFT:mint mintData.nftId must be greater than zero"
);
require(
bytes(mintData.tokenURI).length > 0,
"NanakusaNFT:mint mintData.tokenURI is invalid"
);
address owner_ = owner();
// Must be called by [owner] or must be called with [signature from owner]
if (_msgSender() != owner_) {
// Recoverd address of ERC712 signed data
address recoverdAddress = _domainSeparatorV4()
.toTypedDataHash(_hashMintData(mintData))
.recover(mintSign);
// Make sure its signed by owner
require(
recoverdAddress == owner_,
"NanakusaNFT:mint not signed by Owner"
);
}
}
/**
* @dev Mint token
*
* @param mintData MintData calldata
* @param mintSign bytes calldata
*/
function mintToken(
MintData calldata mintData,
bytes calldata mintSign
) external virtual override whenNotPaused {
_verifyMintArguments(mintData, mintSign);
uint256 tokenId = mintData.nftId;
_safeMint(mintData.creator, tokenId);
_setTokenURI(tokenId, mintData.tokenURI);
_lastMintedTokenId = tokenId;
}
/**
* @dev Lazy mint and transfer
*
* @param transferTo address
* @param mintData MintData calldata
* @param mintSign bytes calldata
*/
function lazyMintAndTransfer(
MintData calldata mintData,
address transferTo,
bytes calldata mintSign
) external virtual override whenNotPaused {
require(
transferTo != address(0),
"NanakusaNFT:lazyMintAndTransfer transferTo is invalid"
);
_verifyMintArguments(mintData, mintSign);
uint256 tokenId = mintData.nftId;
_safeMint(mintData.creator, tokenId);
_setTokenURI(tokenId, mintData.tokenURI);
_safeTransfer(mintData.creator, transferTo, mintData.nftId, "");
_lastMintedTokenId = tokenId;
}
/**
* @dev Returns last minted token Id/ NFT Id
*/
function getLastMintedTokenId()
external
view
virtual
override
returns (uint256)
{
return _lastMintedTokenId;
}
/**
* @dev See {ERC2981._setDefaultRoyalty}
*/
function setDefaultRoyalty(
address receiver,
uint96 feeNumerator
) external onlyOwner {
ERC2981._setDefaultRoyalty(receiver, feeNumerator);
}
/**
* @dev See {ERC2981._deleteDefaultRoyalty}
*/
function deleteDefaultRoyalty() external onlyOwner {
ERC2981._deleteDefaultRoyalty();
}
/**
* @dev See {ERC2981._setTokenRoyalty}
*/
function setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) external {
require(
ownerOf(tokenId) == _msgSender(),
"NanakusaNFT: only owner can set Token Royalty"
);
ERC2981._setTokenRoyalty(tokenId, receiver, feeNumerator);
}
/**
* @dev See {ERC2981._resetTokenRoyalty}
*/
function resetTokenRoyalty(uint256 tokenId) external {
require(
ownerOf(tokenId) == _msgSender(),
"NanakusaNFT:resetTokenRoyalty only owner can reset Token Royalty"
);
ERC2981._resetTokenRoyalty(tokenId);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(
uint256 tokenId
)
public
view
virtual
override(ERC721URIStorage, ERC721)
returns (string memory)
{
return ERC721URIStorage.tokenURI(tokenId);
}
/**
* @dev See {INanakusa.addPreApprovedOperator()}
*/
function addPreApprovedOperator(
address[] memory operatorList
) public virtual override onlyOwner {
for (uint256 idx = 0; idx < operatorList.length; idx++) {
address operator = operatorList[idx];
if (
operator != address(0) &&
operator.code.length > 0 &&
isPreApprovedOperator(operator) == false
) {
// Make sure its a valid contract address and not a already per approved operator
_preApprovedOperator[operator] = true;
emit PreApprovedOperatorAdded(operator);
}
}
}
/**
* @dev See {INanakusa.removePreApprovedOperator()}
*/
function removePreApprovedOperator(
address[] memory operatorList
) external virtual override onlyOwner {
for (uint256 idx = 0; idx < operatorList.length; idx++) {
address operator = operatorList[idx];
if (isPreApprovedOperator(operator)) {
// Make sure its a valid per approved operator
delete _preApprovedOperator[operator];
emit PreApprovedOperatorRemoved(operator);
}
}
}
/**
* @dev See {INanakusa.isPreApprovedOperator()}
*/
function isPreApprovedOperator(
address operator
) public view virtual override returns (bool) {
return _preApprovedOperator[operator];
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(
address owner_,
address operator
) public view virtual override returns (bool) {
return
isPreApprovedOperator(operator) ||
super.isApprovedForAll(owner_, operator);
}
/**
* @dev See {ERC721-_burn}. This override additionally checks to see if a
* token-specific URI was set for the token, and if so, it deletes the token URI from
* the storage mapping.
*/
function _burn(
uint256 tokenId
)
internal
virtual
override(ERC721Royalty, ERC721URIStorage, ERC721)
whenNotPaused
{
super._burn(tokenId);
}
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721Pausable, ERC721) {
super._beforeTokenTransfer(from, to, tokenId);
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function pause() external onlyOwner {
_pause();
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function unpause() external onlyOwner {
_unpause();
}
}
@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165Upgradeable.sol";
@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @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 IERC165Upgradeable {
/**
* @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/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts/interfaces/IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
@openzeppelin/contracts/metatx/ERC2771Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)
pragma solidity ^0.8.9;
import "../utils/Context.sol";
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771Context is Context {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable _trustedForwarder;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address trustedForwarder) {
_trustedForwarder = trustedForwarder;
}
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return forwarder == _trustedForwarder;
}
function _msgSender() internal view virtual override returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
/// @solidity memory-safe-assembly
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return super._msgSender();
}
}
function _msgData() internal view virtual override returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return super._msgData();
}
}
}
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../../utils/Context.sol";
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be burned (destroyed).
*/
abstract contract ERC721Burnable is Context, ERC721 {
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_burn(tokenId);
}
}
@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../../security/Pausable.sol";
/**
* @dev ERC721 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*/
abstract contract ERC721Pausable is ERC721, Pausable {
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
require(!paused(), "ERC721Pausable: token transfer while paused");
}
}
@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/ERC721Royalty.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../common/ERC2981.sol";
import "../../../utils/introspection/ERC165.sol";
/**
* @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
* information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC721Royalty is ERC2981, ERC721 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
/**
* @dev See {ERC721-_burn}. This override additionally clears the royalty information for the token.
*/
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
_resetTokenRoyalty(tokenId);
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./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);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
/**
* @dev ERC721 token with storage based token URI management.
*/
abstract contract ERC721URIStorage is ERC721 {
using Strings for uint256;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = _baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
return super.tokenURI(tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev See {ERC721-_burn}. This override additionally checks to see if a
* token-specific URI was set for the token, and if so, it deletes the token URI from
* the storage mapping.
*/
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
}
}
@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
@openzeppelin/contracts/token/common/ERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @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);
}
}
@openzeppelin/contracts/utils/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @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,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode 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 {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]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
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);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode 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 {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
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]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
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.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// 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);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// 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);
}
return (signer, RecoverError.NoError);
}
/**
* @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) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)
pragma solidity ^0.8.0;
import "./ECDSA.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic 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 their contracts 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].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// 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 _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
address private immutable _CACHED_THIS;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @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) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_CACHED_THIS = address(this);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, 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 ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
contracts/sbinft/token/erc721/nanakusa/interface/INanakusa.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol";
import "contracts/sbinft/market/v1/library/OrderDomain.sol";
/**
* @title SBINFT Nanakusa protocol
* @author SBINFT Co., Ltd.
*/
interface INanakusa {
// Emits whenever Pre Approved Operator is Added
event PreApprovedOperatorAdded(address operator);
// Emits whenever Pre Approved Operator is Removed
event PreApprovedOperatorRemoved(address operator);
struct MintData {
address creator;
uint256 nftId;
string tokenURI;
}
/**
* @dev Mint token
*
* @param mintData MintData calldata
* @param mintSign bytes calldata
*/
function mintToken(
MintData calldata mintData,
bytes calldata mintSign
) external;
/**
* @dev Lazy mint and transfer
*
* @param mintData MintData calldata
* @param transferTo address
* @param mintSign bytes calldata
*/
function lazyMintAndTransfer(
MintData calldata mintData,
address transferTo,
bytes calldata mintSign
) external;
/**
* @dev Returns last minted token Id/ NFT Id
*/
function getLastMintedTokenId() external view returns (uint256);
/**
* @dev Add list of Pre Approved Operator
* if zero address or already exist then it wont be added and
* Event PreApprovedOperatorAdded wont be fired for the respective operator
*
* @param operatorList address[] memory
*/
function addPreApprovedOperator(address[] memory operatorList) external;
/**
* @dev Remove list of Pre Approved Operator
* if zero address then
* Event PreApprovedOperatorRemoved wont be fired for the respective operator
*
* @param operatorList address[] memory
*/
function removePreApprovedOperator(address[] memory operatorList) external;
/**
* @dev Check the operator is a Pre Approved Operator
*
* @param operator address
*/
function isPreApprovedOperator(address operator) external returns (bool);
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"trustedForwarder","internalType":"address"}]},{"type":"event","name":"NanakusaNFTContractCreated","inputs":[{"type":"address","name":"contractAddress","internalType":"address","indexed":false},{"type":"string","name":"name","internalType":"string","indexed":false},{"type":"string","name":"symbol","internalType":"string","indexed":false},{"type":"address","name":"owner","internalType":"address","indexed":false},{"type":"address","name":"trustedForwarder","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createContract","inputs":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"},{"type":"address[]","name":"operatorList","internalType":"address[]"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getContractByOwner","inputs":[{"type":"address","name":"owner_","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTrustedForwarder","inputs":[{"type":"address","name":"forwarder","internalType":"address"}]}]
Contract Creation Code
0x60c060405234801561001057600080fd5b50604051613d54380380613d5483398101604081905261002f91610045565b6001600160a01b0316608081905260a052610075565b60006020828403121561005757600080fd5b81516001600160a01b038116811461006e57600080fd5b9392505050565b60805160a051613cb561009f6000396000818160e901526102190152600060770152613cb56000f3fe60806040523480156200001157600080fd5b5060043610620000465760003560e01c80633a300e08146200004b578063572b6c0514620000645780637edebec214620000bc575b600080fd5b620000626200005c366004620003b1565b620000e2565b005b620000a762000075366004620004cb565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b60405190151581526020015b60405180910390f35b620000d3620000cd366004620004cb565b6200024f565b604051620000b3919062000536565b60008484847f00000000000000000000000000000000000000000000000000000000000000006040516200011690620002c5565b62000125949392919062000593565b604051809103906000f08015801562000142573d6000803e3d6000fd5b5060405163f2fde38b60e01b81526001600160a01b0384811660048301529192509082169063f2fde38b90602401600060405180830381600087803b1580156200018b57600080fd5b505af1158015620001a0573d6000803e3d6000fd5b505050506001600160a01b0382811660009081526020818152604080832080546001810182558185529290932090910180546001600160a01b0319169385169390931790925590517fb8cad47d27c460e6d14c1f2ef0bb20f617ad2db6069c980933c03629d6eb063f906200023f9084908990899088907f000000000000000000000000000000000000000000000000000000000000000090620005ec565b60405180910390a1505050505050565b6001600160a01b03811660009081526020818152604091829020805483518184028101840190945280845260609392830182828015620002b957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116200029a575b50505050509050919050565b613640806200064083390190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715620003155762000315620002d3565b604052919050565b600082601f8301126200032f57600080fd5b813567ffffffffffffffff8111156200034c576200034c620002d3565b62000361601f8201601f1916602001620002e9565b8181528460208386010111156200037757600080fd5b816020850160208301376000918101602001919091529392505050565b80356001600160a01b0381168114620003ac57600080fd5b919050565b60008060008060808587031215620003c857600080fd5b843567ffffffffffffffff80821115620003e157600080fd5b620003ef888389016200031d565b95506020915081870135818111156200040757600080fd5b6200041589828a016200031d565b9550506040870135818111156200042b57600080fd5b8701601f810189136200043d57600080fd5b803582811115620004525762000452620002d3565b8060051b925062000465848401620002e9565b818152928201840192848101908b8511156200048057600080fd5b928501925b84841015620004a957620004998462000394565b8252928501929085019062000485565b809750505050505050620004c06060860162000394565b905092959194509250565b600060208284031215620004de57600080fd5b620004e98262000394565b9392505050565b600081518084526020808501945080840160005b838110156200052b5781516001600160a01b03168752958201959082019060010162000504565b509495945050505050565b602081526000620004e96020830184620004f0565b6000815180845260005b81811015620005735760208185018101518683018201520162000555565b506000602082860101526020601f19601f83011685010191505092915050565b608081526000620005a860808301876200054b565b8281036020840152620005bc81876200054b565b90508281036040840152620005d28186620004f0565b91505060018060a01b038316606083015295945050505050565b600060018060a01b03808816835260a060208401526200061060a08401886200054b565b83810360408501526200062481886200054b565b9582166060850152509290921660809091015250939250505056fe6101606040523480156200001257600080fd5b50604051620036403803806200364083398101604081905262000035916200049a565b604080518082018252601a81527f5342494e4654204e616e616b75736120466163746f79204e46540000000000006020808301918252835180850190945260038452620312e360ec1b9084019081526001600160a01b038516608052825190912083519091206101008290526101208190524660c052879387939290917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620001238184846040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b60a0523060e0526101405250600292506200014391508490508262000642565b50600362000152828262000642565b50506009805460ff1916905550620001736200016d62000188565b62000199565b6200017e82620001f3565b505050506200074c565b600062000194620002f7565b905090565b600980546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b620001fd6200031f565b60005b8151811015620002f35760008282815181106200022157620002216200070e565b6020026020010151905060006001600160a01b0316816001600160a01b0316141580156200025957506000816001600160a01b03163b115b80156200027f57506001600160a01b0381166000908152600a602052604090205460ff16155b15620002dd576001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fc8dfb5ab9ab6cf753862beaaf785f23636e0eab79a3542f13d4073588583f73d910160405180910390a15b5080620002ea8162000724565b91505062000200565b5050565b6080516000906001600160a01b031633036200031a575060131936013560601c90565b503390565b6200032962000188565b6001600160a01b03166200034a60095461010090046001600160a01b031690565b6001600160a01b031614620003a55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640160405180910390fd5b565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620003e857620003e8620003a7565b604052919050565b600082601f8301126200040257600080fd5b81516001600160401b038111156200041e576200041e620003a7565b602062000434601f8301601f19168201620003bd565b82815285828487010111156200044957600080fd5b60005b83811015620004695785810183015182820184015282016200044c565b506000928101909101919091529392505050565b80516001600160a01b03811681146200049557600080fd5b919050565b60008060008060808587031215620004b157600080fd5b84516001600160401b0380821115620004c957600080fd5b620004d788838901620003f0565b9550602091508187015181811115620004ef57600080fd5b620004fd89828a01620003f0565b9550506040870151818111156200051357600080fd5b8701601f810189136200052557600080fd5b8051828111156200053a576200053a620003a7565b8060051b92506200054d848401620003bd565b818152928201840192848101908b8511156200056857600080fd5b928501925b84841015620005915762000581846200047d565b825292850192908501906200056d565b809750505050505050620005a8606086016200047d565b905092959194509250565b600181811c90821680620005c857607f821691505b602082108103620005e957634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200063d57600081815260208120601f850160051c81016020861015620006185750805b601f850160051c820191505b81811015620006395782815560010162000624565b5050505b505050565b81516001600160401b038111156200065e576200065e620003a7565b62000676816200066f8454620005b3565b84620005ef565b602080601f831160018114620006ae5760008415620006955750858301515b600019600386901b1c1916600185901b17855562000639565b600085815260208120601f198616915b82811015620006df57888601518255948401946001909101908401620006be565b5085821015620006fe5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b6000600182016200074557634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c05160e051610100516101205161014051612e92620007ae6000396000611b6c01526000611bbb01526000611b9601526000611aef01526000611b1901526000611b4301526000818161031b01526119f30152612e926000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c806367db2d921161010f578063a22cb465116100a2578063cad8359111610071578063cad8359114610466578063e79c245514610479578063e985e9c51461048c578063f2fde38b1461049f57600080fd5b8063a22cb46514610425578063aa1b103f14610438578063b88d4fde14610440578063c87b56dd1461045357600080fd5b80638456cb59116100de5780638456cb59146103ec5780638a616bc0146103f45780638da5cb5b1461040757806395d89b411461041d57600080fd5b806367db2d921461038f57806370a08231146103bb578063715018a6146103dc5780637974e46a146103e457600080fd5b80633f4ba83a116101875780635944c753116101565780635944c7531461034b5780635c975abb1461035e5780635e73ea34146103695780636352211e1461037c57600080fd5b80633f4ba83a146102dd57806342842e0e146102e557806342966c68146102f8578063572b6c051461030b57600080fd5b8063095ea7b3116101c3578063095ea7b31461027257806323b872dd146102855780632a55205a146102985780632bb65084146102ca57600080fd5b806301ffc9a7146101f557806304634d8d1461021d57806306fdde0314610232578063081812fc14610247575b600080fd5b610208610203366004612548565b6104b2565b60405190151581526020015b60405180910390f35b61023061022b366004612598565b6104c3565b005b61023a6104d9565b604051610214919061261b565b61025a61025536600461262e565b61056b565b6040516001600160a01b039091168152602001610214565b610230610280366004612647565b610592565b610230610293366004612671565b6106be565b6102ab6102a63660046126ad565b6106f6565b604080516001600160a01b039093168352602083019190915201610214565b6102306102d8366004612729565b6107a4565b6102306108c5565b6102306102f3366004612671565b6108d7565b61023061030636600461262e565b6108f2565b6102086103193660046127a0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6102306103593660046127bb565b610925565b60095460ff16610208565b6102306103773660046127f7565b6109b6565b61025a61038a36600461262e565b6109f7565b61020861039d3660046127a0565b6001600160a01b03166000908152600a602052604090205460ff1690565b6103ce6103c93660046127a0565b610a57565b604051908152602001610214565b610230610add565b600b546103ce565b610230610aef565b61023061040236600461262e565b610aff565b60095461010090046001600160a01b031661025a565b61023a610ba8565b610230610433366004612860565b610bb7565b610230610bc9565b61023061044e3660046128e3565b610bda565b61023a61046136600461262e565b610c19565b6102306104743660046129a3565b610c24565b6102306104873660046129a3565b610ce5565b61020861049a366004612a50565b610dd9565b6102306104ad3660046127a0565b610e2c565b60006104bd82610ea2565b92915050565b6104cb610ead565b6104d58282610f2c565b5050565b6060600280546104e890612a7a565b80601f016020809104026020016040519081016040528092919081815260200182805461051490612a7a565b80156105615780601f1061053657610100808354040283529160200191610561565b820191906000526020600020905b81548152906001019060200180831161054457829003601f168201915b5050505050905090565b600061057682610fe6565b506000908152600660205260409020546001600160a01b031690565b600061059d826109f7565b9050806001600160a01b0316836001600160a01b03160361060f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b806001600160a01b0316610621611045565b6001600160a01b0316148061063d575061063d8161049a611045565b6106af5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610606565b6106b98383611054565b505050565b6106cf6106c9611045565b826110c2565b6106eb5760405162461bcd60e51b815260040161060690612aae565b6106b9838383611121565b60008281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b031692820192909252829161076b5750604080518082019091526000546001600160a01b0381168252600160a01b90046001600160601b031660208201525b60208101516000906127109061078a906001600160601b031687612b12565b6107949190612b3f565b91519350909150505b9250929050565b6107ac6112c8565b6001600160a01b0383166108205760405162461bcd60e51b815260206004820152603560248201527f4e616e616b7573614e46543a6c617a794d696e74416e645472616e73666572206044820152741d1c985b9cd9995c951bc81a5cc81a5b9d985b1a59605a1b6064820152608401610606565b61082b84838361130e565b602084018035906108469061084090876127a0565b8261152d565b610891816108576040880188612b53565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061154792505050565b6108bc6108a160208701876127a0565b858760200135604051806020016040528060008152506115da565b600b5550505050565b6108cd610ead565b6108d561160d565b565b6106b983838360405180602001604052806000815250610bda565b6108fd6106c9611045565b6109195760405162461bcd60e51b815260040161060690612aae565b61092281611665565b50565b61092d611045565b6001600160a01b031661093f846109f7565b6001600160a01b0316146109ab5760405162461bcd60e51b815260206004820152602d60248201527f4e616e616b7573614e46543a206f6e6c79206f776e65722063616e207365742060448201526c546f6b656e20526f79616c747960981b6064820152608401610606565b6106b9838383611676565b6109be6112c8565b6109c983838361130e565b602083018035906109de9061084090866127a0565b6109ef816108576040870187612b53565b600b55505050565b6000818152600460205260408120546001600160a01b0316806104bd5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610606565b60006001600160a01b038216610ac15760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610606565b506001600160a01b031660009081526005602052604090205490565b610ae5610ead565b6108d56000611741565b610af7610ead565b6108d561179b565b610b07611045565b6001600160a01b0316610b19826109f7565b6001600160a01b031614610b97576040805162461bcd60e51b81526020600482015260248101919091527f4e616e616b7573614e46543a7265736574546f6b656e526f79616c7479206f6e60448201527f6c79206f776e65722063616e20726573657420546f6b656e20526f79616c74796064820152608401610606565b600090815260016020526040812055565b6060600380546104e890612a7a565b6104d5610bc2611045565b83836117d9565b610bd1610ead565b6108d560008055565b610beb610be5611045565b836110c2565b610c075760405162461bcd60e51b815260040161060690612aae565b610c13848484846115da565b50505050565b60606104bd826118a7565b610c2c610ead565b60005b81518110156104d5576000828281518110610c4c57610c4c612b9a565b60200260200101519050610c78816001600160a01b03166000908152600a602052604090205460ff1690565b15610cd2576001600160a01b0381166000818152600a6020908152604091829020805460ff1916905590519182527ff8f9e1bebee7b0c58697594ecda657e7f23175d236f37eb4407d7a9eaa13bdaa910160405180910390a15b5080610cdd81612bb0565b915050610c2f565b610ced610ead565b60005b81518110156104d5576000828281518110610d0d57610d0d612b9a565b6020026020010151905060006001600160a01b0316816001600160a01b031614158015610d4457506000816001600160a01b03163b115b8015610d6957506001600160a01b0381166000908152600a602052604090205460ff16155b15610dc6576001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fc8dfb5ab9ab6cf753862beaaf785f23636e0eab79a3542f13d4073588583f73d910160405180910390a15b5080610dd181612bb0565b915050610cf0565b6001600160a01b0381166000908152600a602052604081205460ff1680610e2557506001600160a01b0380841660009081526007602090815260408083209386168352929052205460ff165b9392505050565b610e34610ead565b6001600160a01b038116610e995760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610606565b61092281611741565b60006104bd826119af565b610eb5611045565b6001600160a01b0316610ed66009546001600160a01b036101009091041690565b6001600160a01b0316146108d55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610606565b6127106001600160601b0382161115610f575760405162461bcd60e51b815260040161060690612bc9565b6001600160a01b038216610fad5760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610606565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600055565b6000818152600460205260409020546001600160a01b03166109225760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610606565b600061104f6119ef565b905090565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611089826109f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806110ce836109f7565b9050806001600160a01b0316846001600160a01b031614806110f557506110f58185610dd9565b806111195750836001600160a01b031661110e8461056b565b6001600160a01b0316145b949350505050565b826001600160a01b0316611134826109f7565b6001600160a01b0316146111985760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610606565b6001600160a01b0382166111fa5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610606565b611205838383611a33565b611210600082611054565b6001600160a01b0383166000908152600560205260408120805460019290611239908490612c13565b90915550506001600160a01b0382166000908152600560205260408120805460019290611267908490612c26565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60095460ff16156108d55760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610606565b60008360200135116113885760405162461bcd60e51b815260206004820152603960248201527f4e616e616b7573614e46543a6d696e74206d696e74446174612e6e667449642060448201527f6d7573742062652067726561746572207468616e207a65726f000000000000006064820152608401610606565b60006113976040850185612b53565b9050116113fc5760405162461bcd60e51b815260206004820152602d60248201527f4e616e616b7573614e46543a6d696e74206d696e74446174612e746f6b656e5560448201526c1492481a5cc81a5b9d985b1a59609a1b6064820152608401610606565b60095461010090046001600160a01b031680611416611045565b6001600160a01b031614610c135760006114b784848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506114b1925061146e9150899050611a3e565b611476611ae2565b6040805161190160f01b6020808301919091526022820193909352604280820194909452815180820390940184526062019052815191012090565b90611c09565b9050816001600160a01b0316816001600160a01b0316146115265760405162461bcd60e51b8152602060048201526024808201527f4e616e616b7573614e46543a6d696e74206e6f74207369676e6564206279204f6044820152633bb732b960e11b6064820152608401610606565b5050505050565b6104d5828260405180602001604052806000815250611c2d565b6000828152600460205260409020546001600160a01b03166115c25760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610606565b60008281526008602052604090206106b98282612c87565b6115e5848484611121565b6115f184848484611c60565b610c135760405162461bcd60e51b815260040161060690612d47565b611615611d68565b6009805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611648611045565b6040516001600160a01b03909116815260200160405180910390a1565b61166d6112c8565b61092281611db1565b6127106001600160601b03821611156116a15760405162461bcd60e51b815260040161060690612bc9565b6001600160a01b0382166116f75760405162461bcd60e51b815260206004820152601b60248201527f455243323938313a20496e76616c696420706172616d657465727300000000006044820152606401610606565b6040805180820182526001600160a01b0393841681526001600160601b0392831660208083019182526000968752600190529190942093519051909116600160a01b029116179055565b600980546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6117a36112c8565b6009805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611648611045565b816001600160a01b0316836001600160a01b03160361183a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610606565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60606118b282610fe6565b600082815260086020526040812080546118cb90612a7a565b80601f01602080910402602001604051908101604052809291908181526020018280546118f790612a7a565b80156119445780601f1061191957610100808354040283529160200191611944565b820191906000526020600020905b81548152906001019060200180831161192757829003601f168201915b50505050509050600061196260408051602081019091526000815290565b90508051600003611974575092915050565b8151156119a657808260405160200161198e929190612d99565b60405160208183030381529060405292505050919050565b61111984611dba565b60006001600160e01b031982166380ac58cd60e01b14806119e057506001600160e01b03198216635b5e139f60e01b145b806104bd57506104bd82611e2d565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303611a2e575060131936013560601c90565b503390565b6106b9838383611e62565b60007fef794e6d6869d49dbff445812bf818a6333bfc231f266b4c115072185760f4fe611a6e60208401846127a0565b6020840135611a806040860186612b53565b604051611a8e929190612dc8565b604051908190038120611ac5949392916020019384526001600160a01b039290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015611b3b57507f000000000000000000000000000000000000000000000000000000000000000046145b15611b6557507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6000806000611c188585611ec9565b91509150611c2581611f0b565b509392505050565b611c3783836120c1565b611c446000848484611c60565b6106b95760405162461bcd60e51b815260040161060690612d47565b60006001600160a01b0384163b15611d5d57836001600160a01b031663150b7a02611c89611045565b8786866040518563ffffffff1660e01b8152600401611cab9493929190612dd8565b6020604051808303816000875af1925050508015611ce6575060408051601f3d908101601f19168201909252611ce391810190612e15565b60015b611d43573d808015611d14576040519150601f19603f3d011682016040523d82523d6000602084013e611d19565b606091505b508051600003611d3b5760405162461bcd60e51b815260040161060690612d47565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611119565b506001949350505050565b60095460ff166108d55760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610606565b610b978161220f565b6060611dc582610fe6565b6000611ddc60408051602081019091526000815290565b90506000815111611dfc5760405180602001604052806000815250610e25565b80611e068461224f565b604051602001611e17929190612d99565b6040516020818303038152906040529392505050565b60006001600160e01b0319821663152a902d60e11b14806104bd57506301ffc9a760e01b6001600160e01b03198316146104bd565b60095460ff16156106b95760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610606565b6000808251604103611eff5760208301516040840151606085015160001a611ef387828585612350565b9450945050505061079d565b5060009050600261079d565b6000816004811115611f1f57611f1f612e32565b03611f275750565b6001816004811115611f3b57611f3b612e32565b03611f885760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610606565b6002816004811115611f9c57611f9c612e32565b03611fe95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610606565b6003816004811115611ffd57611ffd612e32565b036120555760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610606565b600481600481111561206957612069612e32565b036109225760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610606565b6001600160a01b0382166121175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610606565b6000818152600460205260409020546001600160a01b03161561217c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610606565b61218860008383611a33565b6001600160a01b03821660009081526005602052604081208054600192906121b1908490612c26565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6122188161243d565b6000818152600860205260409020805461223190612a7a565b159050610922576000818152600860205260408120610922916124e4565b6060816000036122765750506040805180820190915260018152600360fc1b602082015290565b8160005b81156122a0578061228a81612bb0565b91506122999050600a83612b3f565b915061227a565b60008167ffffffffffffffff8111156122bb576122bb61289c565b6040519080825280601f01601f1916602001820160405280156122e5576020820181803683370190505b5090505b8415611119576122fa600183612c13565b9150612307600a86612e48565b612312906030612c26565b60f81b81838151811061232757612327612b9a565b60200101906001600160f81b031916908160001a905350612349600a86612b3f565b94506122e9565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156123875750600090506003612434565b8460ff16601b1415801561239f57508460ff16601c14155b156123b05750600090506004612434565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612404573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661242d57600060019250925050612434565b9150600090505b94509492505050565b6000612448826109f7565b905061245681600084611a33565b612461600083611054565b6001600160a01b038116600090815260056020526040812080546001929061248a908490612c13565b909155505060008281526004602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b5080546124f090612a7a565b6000825580601f10612500575050565b601f01602090049060005260206000209081019061092291905b8082111561252e576000815560010161251a565b5090565b6001600160e01b03198116811461092257600080fd5b60006020828403121561255a57600080fd5b8135610e2581612532565b80356001600160a01b038116811461257c57600080fd5b919050565b80356001600160601b038116811461257c57600080fd5b600080604083850312156125ab57600080fd5b6125b483612565565b91506125c260208401612581565b90509250929050565b60005b838110156125e65781810151838201526020016125ce565b50506000910152565b600081518084526126078160208601602086016125cb565b601f01601f19169290920160200192915050565b602081526000610e2560208301846125ef565b60006020828403121561264057600080fd5b5035919050565b6000806040838503121561265a57600080fd5b61266383612565565b946020939093013593505050565b60008060006060848603121561268657600080fd5b61268f84612565565b925061269d60208501612565565b9150604084013590509250925092565b600080604083850312156126c057600080fd5b50508035926020909101359150565b6000606082840312156126e157600080fd5b50919050565b60008083601f8401126126f957600080fd5b50813567ffffffffffffffff81111561271157600080fd5b60208301915083602082850101111561079d57600080fd5b6000806000806060858703121561273f57600080fd5b843567ffffffffffffffff8082111561275757600080fd5b612763888389016126cf565b955061277160208801612565565b9450604087013591508082111561278757600080fd5b50612794878288016126e7565b95989497509550505050565b6000602082840312156127b257600080fd5b610e2582612565565b6000806000606084860312156127d057600080fd5b833592506127e060208501612565565b91506127ee60408501612581565b90509250925092565b60008060006040848603121561280c57600080fd5b833567ffffffffffffffff8082111561282457600080fd5b612830878388016126cf565b9450602086013591508082111561284657600080fd5b50612853868287016126e7565b9497909650939450505050565b6000806040838503121561287357600080fd5b61287c83612565565b91506020830135801515811461289157600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156128db576128db61289c565b604052919050565b600080600080608085870312156128f957600080fd5b61290285612565565b93506020612911818701612565565b935060408601359250606086013567ffffffffffffffff8082111561293557600080fd5b818801915088601f83011261294957600080fd5b81358181111561295b5761295b61289c565b61296d601f8201601f191685016128b2565b9150808252898482850101111561298357600080fd5b808484018584013760008482840101525080935050505092959194509250565b600060208083850312156129b657600080fd5b823567ffffffffffffffff808211156129ce57600080fd5b818501915085601f8301126129e257600080fd5b8135818111156129f4576129f461289c565b8060051b9150612a058483016128b2565b8181529183018401918481019088841115612a1f57600080fd5b938501935b83851015612a4457612a3585612565565b82529385019390850190612a24565b98975050505050505050565b60008060408385031215612a6357600080fd5b612a6c83612565565b91506125c260208401612565565b600181811c90821680612a8e57607f821691505b6020821081036126e157634e487b7160e01b600052602260045260246000fd5b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104bd576104bd612afc565b634e487b7160e01b600052601260045260246000fd5b600082612b4e57612b4e612b29565b500490565b6000808335601e19843603018112612b6a57600080fd5b83018035915067ffffffffffffffff821115612b8557600080fd5b60200191503681900382131561079d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060018201612bc257612bc2612afc565b5060010190565b6020808252602a908201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646040820152692073616c65507269636560b01b606082015260800190565b818103818111156104bd576104bd612afc565b808201808211156104bd576104bd612afc565b601f8211156106b957600081815260208120601f850160051c81016020861015612c605750805b601f850160051c820191505b81811015612c7f57828155600101612c6c565b505050505050565b815167ffffffffffffffff811115612ca157612ca161289c565b612cb581612caf8454612a7a565b84612c39565b602080601f831160018114612cea5760008415612cd25750858301515b600019600386901b1c1916600185901b178555612c7f565b600085815260208120601f198616915b82811015612d1957888601518255948401946001909101908401612cfa565b5085821015612d375787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612dab8184602088016125cb565b835190830190612dbf8183602088016125cb565b01949350505050565b8183823760009101908152919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612e0b908301846125ef565b9695505050505050565b600060208284031215612e2757600080fd5b8151610e2581612532565b634e487b7160e01b600052602160045260246000fd5b600082612e5757612e57612b29565b50069056fea2646970667358221220361296f61acd6e9fae7ac9cfc9b9064637e46721be4a3b1a25835af7612c459664736f6c63430008130033a2646970667358221220c7a27d0831b0e29cf8e8bf337561ad2fa689a38ad634a75214cbaf4fc544d08164736f6c634300081300330000000000000000000000002564c8ac021fa8cddf83c5e9e63a8edaf37c907d
Deployed ByteCode
0x60806040523480156200001157600080fd5b5060043610620000465760003560e01c80633a300e08146200004b578063572b6c0514620000645780637edebec214620000bc575b600080fd5b620000626200005c366004620003b1565b620000e2565b005b620000a762000075366004620004cb565b7f0000000000000000000000002564c8ac021fa8cddf83c5e9e63a8edaf37c907d6001600160a01b0390811691161490565b60405190151581526020015b60405180910390f35b620000d3620000cd366004620004cb565b6200024f565b604051620000b3919062000536565b60008484847f0000000000000000000000002564c8ac021fa8cddf83c5e9e63a8edaf37c907d6040516200011690620002c5565b62000125949392919062000593565b604051809103906000f08015801562000142573d6000803e3d6000fd5b5060405163f2fde38b60e01b81526001600160a01b0384811660048301529192509082169063f2fde38b90602401600060405180830381600087803b1580156200018b57600080fd5b505af1158015620001a0573d6000803e3d6000fd5b505050506001600160a01b0382811660009081526020818152604080832080546001810182558185529290932090910180546001600160a01b0319169385169390931790925590517fb8cad47d27c460e6d14c1f2ef0bb20f617ad2db6069c980933c03629d6eb063f906200023f9084908990899088907f0000000000000000000000002564c8ac021fa8cddf83c5e9e63a8edaf37c907d90620005ec565b60405180910390a1505050505050565b6001600160a01b03811660009081526020818152604091829020805483518184028101840190945280845260609392830182828015620002b957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116200029a575b50505050509050919050565b613640806200064083390190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715620003155762000315620002d3565b604052919050565b600082601f8301126200032f57600080fd5b813567ffffffffffffffff8111156200034c576200034c620002d3565b62000361601f8201601f1916602001620002e9565b8181528460208386010111156200037757600080fd5b816020850160208301376000918101602001919091529392505050565b80356001600160a01b0381168114620003ac57600080fd5b919050565b60008060008060808587031215620003c857600080fd5b843567ffffffffffffffff80821115620003e157600080fd5b620003ef888389016200031d565b95506020915081870135818111156200040757600080fd5b6200041589828a016200031d565b9550506040870135818111156200042b57600080fd5b8701601f810189136200043d57600080fd5b803582811115620004525762000452620002d3565b8060051b925062000465848401620002e9565b818152928201840192848101908b8511156200048057600080fd5b928501925b84841015620004a957620004998462000394565b8252928501929085019062000485565b809750505050505050620004c06060860162000394565b905092959194509250565b600060208284031215620004de57600080fd5b620004e98262000394565b9392505050565b600081518084526020808501945080840160005b838110156200052b5781516001600160a01b03168752958201959082019060010162000504565b509495945050505050565b602081526000620004e96020830184620004f0565b6000815180845260005b81811015620005735760208185018101518683018201520162000555565b506000602082860101526020601f19601f83011685010191505092915050565b608081526000620005a860808301876200054b565b8281036020840152620005bc81876200054b565b90508281036040840152620005d28186620004f0565b91505060018060a01b038316606083015295945050505050565b600060018060a01b03808816835260a060208401526200061060a08401886200054b565b83810360408501526200062481886200054b565b9582166060850152509290921660809091015250939250505056fe6101606040523480156200001257600080fd5b50604051620036403803806200364083398101604081905262000035916200049a565b604080518082018252601a81527f5342494e4654204e616e616b75736120466163746f79204e46540000000000006020808301918252835180850190945260038452620312e360ec1b9084019081526001600160a01b038516608052825190912083519091206101008290526101208190524660c052879387939290917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620001238184846040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b60a0523060e0526101405250600292506200014391508490508262000642565b50600362000152828262000642565b50506009805460ff1916905550620001736200016d62000188565b62000199565b6200017e82620001f3565b505050506200074c565b600062000194620002f7565b905090565b600980546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b620001fd6200031f565b60005b8151811015620002f35760008282815181106200022157620002216200070e565b6020026020010151905060006001600160a01b0316816001600160a01b0316141580156200025957506000816001600160a01b03163b115b80156200027f57506001600160a01b0381166000908152600a602052604090205460ff16155b15620002dd576001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fc8dfb5ab9ab6cf753862beaaf785f23636e0eab79a3542f13d4073588583f73d910160405180910390a15b5080620002ea8162000724565b91505062000200565b5050565b6080516000906001600160a01b031633036200031a575060131936013560601c90565b503390565b6200032962000188565b6001600160a01b03166200034a60095461010090046001600160a01b031690565b6001600160a01b031614620003a55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640160405180910390fd5b565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620003e857620003e8620003a7565b604052919050565b600082601f8301126200040257600080fd5b81516001600160401b038111156200041e576200041e620003a7565b602062000434601f8301601f19168201620003bd565b82815285828487010111156200044957600080fd5b60005b83811015620004695785810183015182820184015282016200044c565b506000928101909101919091529392505050565b80516001600160a01b03811681146200049557600080fd5b919050565b60008060008060808587031215620004b157600080fd5b84516001600160401b0380821115620004c957600080fd5b620004d788838901620003f0565b9550602091508187015181811115620004ef57600080fd5b620004fd89828a01620003f0565b9550506040870151818111156200051357600080fd5b8701601f810189136200052557600080fd5b8051828111156200053a576200053a620003a7565b8060051b92506200054d848401620003bd565b818152928201840192848101908b8511156200056857600080fd5b928501925b84841015620005915762000581846200047d565b825292850192908501906200056d565b809750505050505050620005a8606086016200047d565b905092959194509250565b600181811c90821680620005c857607f821691505b602082108103620005e957634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200063d57600081815260208120601f850160051c81016020861015620006185750805b601f850160051c820191505b81811015620006395782815560010162000624565b5050505b505050565b81516001600160401b038111156200065e576200065e620003a7565b62000676816200066f8454620005b3565b84620005ef565b602080601f831160018114620006ae5760008415620006955750858301515b600019600386901b1c1916600185901b17855562000639565b600085815260208120601f198616915b82811015620006df57888601518255948401946001909101908401620006be565b5085821015620006fe5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b6000600182016200074557634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c05160e051610100516101205161014051612e92620007ae6000396000611b6c01526000611bbb01526000611b9601526000611aef01526000611b1901526000611b4301526000818161031b01526119f30152612e926000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c806367db2d921161010f578063a22cb465116100a2578063cad8359111610071578063cad8359114610466578063e79c245514610479578063e985e9c51461048c578063f2fde38b1461049f57600080fd5b8063a22cb46514610425578063aa1b103f14610438578063b88d4fde14610440578063c87b56dd1461045357600080fd5b80638456cb59116100de5780638456cb59146103ec5780638a616bc0146103f45780638da5cb5b1461040757806395d89b411461041d57600080fd5b806367db2d921461038f57806370a08231146103bb578063715018a6146103dc5780637974e46a146103e457600080fd5b80633f4ba83a116101875780635944c753116101565780635944c7531461034b5780635c975abb1461035e5780635e73ea34146103695780636352211e1461037c57600080fd5b80633f4ba83a146102dd57806342842e0e146102e557806342966c68146102f8578063572b6c051461030b57600080fd5b8063095ea7b3116101c3578063095ea7b31461027257806323b872dd146102855780632a55205a146102985780632bb65084146102ca57600080fd5b806301ffc9a7146101f557806304634d8d1461021d57806306fdde0314610232578063081812fc14610247575b600080fd5b610208610203366004612548565b6104b2565b60405190151581526020015b60405180910390f35b61023061022b366004612598565b6104c3565b005b61023a6104d9565b604051610214919061261b565b61025a61025536600461262e565b61056b565b6040516001600160a01b039091168152602001610214565b610230610280366004612647565b610592565b610230610293366004612671565b6106be565b6102ab6102a63660046126ad565b6106f6565b604080516001600160a01b039093168352602083019190915201610214565b6102306102d8366004612729565b6107a4565b6102306108c5565b6102306102f3366004612671565b6108d7565b61023061030636600461262e565b6108f2565b6102086103193660046127a0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6102306103593660046127bb565b610925565b60095460ff16610208565b6102306103773660046127f7565b6109b6565b61025a61038a36600461262e565b6109f7565b61020861039d3660046127a0565b6001600160a01b03166000908152600a602052604090205460ff1690565b6103ce6103c93660046127a0565b610a57565b604051908152602001610214565b610230610add565b600b546103ce565b610230610aef565b61023061040236600461262e565b610aff565b60095461010090046001600160a01b031661025a565b61023a610ba8565b610230610433366004612860565b610bb7565b610230610bc9565b61023061044e3660046128e3565b610bda565b61023a61046136600461262e565b610c19565b6102306104743660046129a3565b610c24565b6102306104873660046129a3565b610ce5565b61020861049a366004612a50565b610dd9565b6102306104ad3660046127a0565b610e2c565b60006104bd82610ea2565b92915050565b6104cb610ead565b6104d58282610f2c565b5050565b6060600280546104e890612a7a565b80601f016020809104026020016040519081016040528092919081815260200182805461051490612a7a565b80156105615780601f1061053657610100808354040283529160200191610561565b820191906000526020600020905b81548152906001019060200180831161054457829003601f168201915b5050505050905090565b600061057682610fe6565b506000908152600660205260409020546001600160a01b031690565b600061059d826109f7565b9050806001600160a01b0316836001600160a01b03160361060f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b806001600160a01b0316610621611045565b6001600160a01b0316148061063d575061063d8161049a611045565b6106af5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610606565b6106b98383611054565b505050565b6106cf6106c9611045565b826110c2565b6106eb5760405162461bcd60e51b815260040161060690612aae565b6106b9838383611121565b60008281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b031692820192909252829161076b5750604080518082019091526000546001600160a01b0381168252600160a01b90046001600160601b031660208201525b60208101516000906127109061078a906001600160601b031687612b12565b6107949190612b3f565b91519350909150505b9250929050565b6107ac6112c8565b6001600160a01b0383166108205760405162461bcd60e51b815260206004820152603560248201527f4e616e616b7573614e46543a6c617a794d696e74416e645472616e73666572206044820152741d1c985b9cd9995c951bc81a5cc81a5b9d985b1a59605a1b6064820152608401610606565b61082b84838361130e565b602084018035906108469061084090876127a0565b8261152d565b610891816108576040880188612b53565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061154792505050565b6108bc6108a160208701876127a0565b858760200135604051806020016040528060008152506115da565b600b5550505050565b6108cd610ead565b6108d561160d565b565b6106b983838360405180602001604052806000815250610bda565b6108fd6106c9611045565b6109195760405162461bcd60e51b815260040161060690612aae565b61092281611665565b50565b61092d611045565b6001600160a01b031661093f846109f7565b6001600160a01b0316146109ab5760405162461bcd60e51b815260206004820152602d60248201527f4e616e616b7573614e46543a206f6e6c79206f776e65722063616e207365742060448201526c546f6b656e20526f79616c747960981b6064820152608401610606565b6106b9838383611676565b6109be6112c8565b6109c983838361130e565b602083018035906109de9061084090866127a0565b6109ef816108576040870187612b53565b600b55505050565b6000818152600460205260408120546001600160a01b0316806104bd5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610606565b60006001600160a01b038216610ac15760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610606565b506001600160a01b031660009081526005602052604090205490565b610ae5610ead565b6108d56000611741565b610af7610ead565b6108d561179b565b610b07611045565b6001600160a01b0316610b19826109f7565b6001600160a01b031614610b97576040805162461bcd60e51b81526020600482015260248101919091527f4e616e616b7573614e46543a7265736574546f6b656e526f79616c7479206f6e60448201527f6c79206f776e65722063616e20726573657420546f6b656e20526f79616c74796064820152608401610606565b600090815260016020526040812055565b6060600380546104e890612a7a565b6104d5610bc2611045565b83836117d9565b610bd1610ead565b6108d560008055565b610beb610be5611045565b836110c2565b610c075760405162461bcd60e51b815260040161060690612aae565b610c13848484846115da565b50505050565b60606104bd826118a7565b610c2c610ead565b60005b81518110156104d5576000828281518110610c4c57610c4c612b9a565b60200260200101519050610c78816001600160a01b03166000908152600a602052604090205460ff1690565b15610cd2576001600160a01b0381166000818152600a6020908152604091829020805460ff1916905590519182527ff8f9e1bebee7b0c58697594ecda657e7f23175d236f37eb4407d7a9eaa13bdaa910160405180910390a15b5080610cdd81612bb0565b915050610c2f565b610ced610ead565b60005b81518110156104d5576000828281518110610d0d57610d0d612b9a565b6020026020010151905060006001600160a01b0316816001600160a01b031614158015610d4457506000816001600160a01b03163b115b8015610d6957506001600160a01b0381166000908152600a602052604090205460ff16155b15610dc6576001600160a01b0381166000818152600a6020908152604091829020805460ff1916600117905590519182527fc8dfb5ab9ab6cf753862beaaf785f23636e0eab79a3542f13d4073588583f73d910160405180910390a15b5080610dd181612bb0565b915050610cf0565b6001600160a01b0381166000908152600a602052604081205460ff1680610e2557506001600160a01b0380841660009081526007602090815260408083209386168352929052205460ff165b9392505050565b610e34610ead565b6001600160a01b038116610e995760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610606565b61092281611741565b60006104bd826119af565b610eb5611045565b6001600160a01b0316610ed66009546001600160a01b036101009091041690565b6001600160a01b0316146108d55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610606565b6127106001600160601b0382161115610f575760405162461bcd60e51b815260040161060690612bc9565b6001600160a01b038216610fad5760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610606565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600055565b6000818152600460205260409020546001600160a01b03166109225760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610606565b600061104f6119ef565b905090565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611089826109f7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806110ce836109f7565b9050806001600160a01b0316846001600160a01b031614806110f557506110f58185610dd9565b806111195750836001600160a01b031661110e8461056b565b6001600160a01b0316145b949350505050565b826001600160a01b0316611134826109f7565b6001600160a01b0316146111985760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610606565b6001600160a01b0382166111fa5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610606565b611205838383611a33565b611210600082611054565b6001600160a01b0383166000908152600560205260408120805460019290611239908490612c13565b90915550506001600160a01b0382166000908152600560205260408120805460019290611267908490612c26565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60095460ff16156108d55760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610606565b60008360200135116113885760405162461bcd60e51b815260206004820152603960248201527f4e616e616b7573614e46543a6d696e74206d696e74446174612e6e667449642060448201527f6d7573742062652067726561746572207468616e207a65726f000000000000006064820152608401610606565b60006113976040850185612b53565b9050116113fc5760405162461bcd60e51b815260206004820152602d60248201527f4e616e616b7573614e46543a6d696e74206d696e74446174612e746f6b656e5560448201526c1492481a5cc81a5b9d985b1a59609a1b6064820152608401610606565b60095461010090046001600160a01b031680611416611045565b6001600160a01b031614610c135760006114b784848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506114b1925061146e9150899050611a3e565b611476611ae2565b6040805161190160f01b6020808301919091526022820193909352604280820194909452815180820390940184526062019052815191012090565b90611c09565b9050816001600160a01b0316816001600160a01b0316146115265760405162461bcd60e51b8152602060048201526024808201527f4e616e616b7573614e46543a6d696e74206e6f74207369676e6564206279204f6044820152633bb732b960e11b6064820152608401610606565b5050505050565b6104d5828260405180602001604052806000815250611c2d565b6000828152600460205260409020546001600160a01b03166115c25760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610606565b60008281526008602052604090206106b98282612c87565b6115e5848484611121565b6115f184848484611c60565b610c135760405162461bcd60e51b815260040161060690612d47565b611615611d68565b6009805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611648611045565b6040516001600160a01b03909116815260200160405180910390a1565b61166d6112c8565b61092281611db1565b6127106001600160601b03821611156116a15760405162461bcd60e51b815260040161060690612bc9565b6001600160a01b0382166116f75760405162461bcd60e51b815260206004820152601b60248201527f455243323938313a20496e76616c696420706172616d657465727300000000006044820152606401610606565b6040805180820182526001600160a01b0393841681526001600160601b0392831660208083019182526000968752600190529190942093519051909116600160a01b029116179055565b600980546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6117a36112c8565b6009805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611648611045565b816001600160a01b0316836001600160a01b03160361183a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610606565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60606118b282610fe6565b600082815260086020526040812080546118cb90612a7a565b80601f01602080910402602001604051908101604052809291908181526020018280546118f790612a7a565b80156119445780601f1061191957610100808354040283529160200191611944565b820191906000526020600020905b81548152906001019060200180831161192757829003601f168201915b50505050509050600061196260408051602081019091526000815290565b90508051600003611974575092915050565b8151156119a657808260405160200161198e929190612d99565b60405160208183030381529060405292505050919050565b61111984611dba565b60006001600160e01b031982166380ac58cd60e01b14806119e057506001600160e01b03198216635b5e139f60e01b145b806104bd57506104bd82611e2d565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303611a2e575060131936013560601c90565b503390565b6106b9838383611e62565b60007fef794e6d6869d49dbff445812bf818a6333bfc231f266b4c115072185760f4fe611a6e60208401846127a0565b6020840135611a806040860186612b53565b604051611a8e929190612dc8565b604051908190038120611ac5949392916020019384526001600160a01b039290921660208401526040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015611b3b57507f000000000000000000000000000000000000000000000000000000000000000046145b15611b6557507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6000806000611c188585611ec9565b91509150611c2581611f0b565b509392505050565b611c3783836120c1565b611c446000848484611c60565b6106b95760405162461bcd60e51b815260040161060690612d47565b60006001600160a01b0384163b15611d5d57836001600160a01b031663150b7a02611c89611045565b8786866040518563ffffffff1660e01b8152600401611cab9493929190612dd8565b6020604051808303816000875af1925050508015611ce6575060408051601f3d908101601f19168201909252611ce391810190612e15565b60015b611d43573d808015611d14576040519150601f19603f3d011682016040523d82523d6000602084013e611d19565b606091505b508051600003611d3b5760405162461bcd60e51b815260040161060690612d47565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611119565b506001949350505050565b60095460ff166108d55760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610606565b610b978161220f565b6060611dc582610fe6565b6000611ddc60408051602081019091526000815290565b90506000815111611dfc5760405180602001604052806000815250610e25565b80611e068461224f565b604051602001611e17929190612d99565b6040516020818303038152906040529392505050565b60006001600160e01b0319821663152a902d60e11b14806104bd57506301ffc9a760e01b6001600160e01b03198316146104bd565b60095460ff16156106b95760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610606565b6000808251604103611eff5760208301516040840151606085015160001a611ef387828585612350565b9450945050505061079d565b5060009050600261079d565b6000816004811115611f1f57611f1f612e32565b03611f275750565b6001816004811115611f3b57611f3b612e32565b03611f885760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610606565b6002816004811115611f9c57611f9c612e32565b03611fe95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610606565b6003816004811115611ffd57611ffd612e32565b036120555760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610606565b600481600481111561206957612069612e32565b036109225760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610606565b6001600160a01b0382166121175760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610606565b6000818152600460205260409020546001600160a01b03161561217c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610606565b61218860008383611a33565b6001600160a01b03821660009081526005602052604081208054600192906121b1908490612c26565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6122188161243d565b6000818152600860205260409020805461223190612a7a565b159050610922576000818152600860205260408120610922916124e4565b6060816000036122765750506040805180820190915260018152600360fc1b602082015290565b8160005b81156122a0578061228a81612bb0565b91506122999050600a83612b3f565b915061227a565b60008167ffffffffffffffff8111156122bb576122bb61289c565b6040519080825280601f01601f1916602001820160405280156122e5576020820181803683370190505b5090505b8415611119576122fa600183612c13565b9150612307600a86612e48565b612312906030612c26565b60f81b81838151811061232757612327612b9a565b60200101906001600160f81b031916908160001a905350612349600a86612b3f565b94506122e9565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156123875750600090506003612434565b8460ff16601b1415801561239f57508460ff16601c14155b156123b05750600090506004612434565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612404573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661242d57600060019250925050612434565b9150600090505b94509492505050565b6000612448826109f7565b905061245681600084611a33565b612461600083611054565b6001600160a01b038116600090815260056020526040812080546001929061248a908490612c13565b909155505060008281526004602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b5080546124f090612a7a565b6000825580601f10612500575050565b601f01602090049060005260206000209081019061092291905b8082111561252e576000815560010161251a565b5090565b6001600160e01b03198116811461092257600080fd5b60006020828403121561255a57600080fd5b8135610e2581612532565b80356001600160a01b038116811461257c57600080fd5b919050565b80356001600160601b038116811461257c57600080fd5b600080604083850312156125ab57600080fd5b6125b483612565565b91506125c260208401612581565b90509250929050565b60005b838110156125e65781810151838201526020016125ce565b50506000910152565b600081518084526126078160208601602086016125cb565b601f01601f19169290920160200192915050565b602081526000610e2560208301846125ef565b60006020828403121561264057600080fd5b5035919050565b6000806040838503121561265a57600080fd5b61266383612565565b946020939093013593505050565b60008060006060848603121561268657600080fd5b61268f84612565565b925061269d60208501612565565b9150604084013590509250925092565b600080604083850312156126c057600080fd5b50508035926020909101359150565b6000606082840312156126e157600080fd5b50919050565b60008083601f8401126126f957600080fd5b50813567ffffffffffffffff81111561271157600080fd5b60208301915083602082850101111561079d57600080fd5b6000806000806060858703121561273f57600080fd5b843567ffffffffffffffff8082111561275757600080fd5b612763888389016126cf565b955061277160208801612565565b9450604087013591508082111561278757600080fd5b50612794878288016126e7565b95989497509550505050565b6000602082840312156127b257600080fd5b610e2582612565565b6000806000606084860312156127d057600080fd5b833592506127e060208501612565565b91506127ee60408501612581565b90509250925092565b60008060006040848603121561280c57600080fd5b833567ffffffffffffffff8082111561282457600080fd5b612830878388016126cf565b9450602086013591508082111561284657600080fd5b50612853868287016126e7565b9497909650939450505050565b6000806040838503121561287357600080fd5b61287c83612565565b91506020830135801515811461289157600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156128db576128db61289c565b604052919050565b600080600080608085870312156128f957600080fd5b61290285612565565b93506020612911818701612565565b935060408601359250606086013567ffffffffffffffff8082111561293557600080fd5b818801915088601f83011261294957600080fd5b81358181111561295b5761295b61289c565b61296d601f8201601f191685016128b2565b9150808252898482850101111561298357600080fd5b808484018584013760008482840101525080935050505092959194509250565b600060208083850312156129b657600080fd5b823567ffffffffffffffff808211156129ce57600080fd5b818501915085601f8301126129e257600080fd5b8135818111156129f4576129f461289c565b8060051b9150612a058483016128b2565b8181529183018401918481019088841115612a1f57600080fd5b938501935b83851015612a4457612a3585612565565b82529385019390850190612a24565b98975050505050505050565b60008060408385031215612a6357600080fd5b612a6c83612565565b91506125c260208401612565565b600181811c90821680612a8e57607f821691505b6020821081036126e157634e487b7160e01b600052602260045260246000fd5b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104bd576104bd612afc565b634e487b7160e01b600052601260045260246000fd5b600082612b4e57612b4e612b29565b500490565b6000808335601e19843603018112612b6a57600080fd5b83018035915067ffffffffffffffff821115612b8557600080fd5b60200191503681900382131561079d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060018201612bc257612bc2612afc565b5060010190565b6020808252602a908201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646040820152692073616c65507269636560b01b606082015260800190565b818103818111156104bd576104bd612afc565b808201808211156104bd576104bd612afc565b601f8211156106b957600081815260208120601f850160051c81016020861015612c605750805b601f850160051c820191505b81811015612c7f57828155600101612c6c565b505050505050565b815167ffffffffffffffff811115612ca157612ca161289c565b612cb581612caf8454612a7a565b84612c39565b602080601f831160018114612cea5760008415612cd25750858301515b600019600386901b1c1916600185901b178555612c7f565b600085815260208120601f198616915b82811015612d1957888601518255948401946001909101908401612cfa565b5085821015612d375787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612dab8184602088016125cb565b835190830190612dbf8183602088016125cb565b01949350505050565b8183823760009101908152919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612e0b908301846125ef565b9695505050505050565b600060208284031215612e2757600080fd5b8151610e2581612532565b634e487b7160e01b600052602160045260246000fd5b600082612e5757612e57612b29565b50069056fea2646970667358221220361296f61acd6e9fae7ac9cfc9b9064637e46721be4a3b1a25835af7612c459664736f6c63430008130033a2646970667358221220c7a27d0831b0e29cf8e8bf337561ad2fa689a38ad634a75214cbaf4fc544d08164736f6c63430008130033