Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- PunkResolverV1
- Optimization enabled
- true
- Compiler version
- v0.8.4+commit.c7e474f2
- Optimization runs
- 200
- Verified at
- 2022-06-21T12:41:02.380605Z
contracts/resolver/PunkResolverV1.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interfaces/IBasePunkTLDFactory.sol";
import "../interfaces/IBasePunkTLD.sol";
import "../lib/strings.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
/// @title Punk Domains Resolver v1
/// @author Tempe Techie
/// @notice This contract resolves all punk domains and TLDs on the particular blockchain where it is deployed
contract PunkResolverV1 is Initializable, OwnableUpgradeable {
using strings for string;
mapping (address => bool) public isTldDeprecated; // deprecate an address, not TLD name
address[] public factories;
event FactoryAddressAdded(address user, address fAddr);
event DeprecatedTldAdded(address user, address tAddr);
event DeprecatedTldRemoved(address user, address tAddr);
// initializer (only for V1!)
function initialize() public initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
// READ
// reverse resolver: get user's default name for a given TLD
function getDefaultDomain(address _addr, string calldata _tld) public view returns(string memory) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tld);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
return string(IBasePunkTLD(tldAddr).defaultNames(_addr));
}
unchecked { ++i; }
}
return "";
}
// reverse resolver: get user's default names (all TLDs)
function getDefaultDomains(address _addr) public view returns(string memory) {
bytes memory result;
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
string[] memory tldNames = IBasePunkTLDFactory(factories[i]).getTldsArray();
for (uint256 j = 0; j < tldNames.length; ++j) {
string memory tldName = tldNames[j];
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(tldName);
string memory defaultName = IBasePunkTLD(tldAddr).defaultNames(_addr);
if (
strings.len(strings.toSlice(defaultName)) > 0 &&
!isTldDeprecated[tldAddr]
) {
if (j == (tldNames.length-1)) { // last TLD (do not include space at the end)
result = abi.encodePacked(result, defaultName, tldName);
} else {
result = abi.encodePacked(result, defaultName, tldName, " ");
}
}
}
unchecked { ++i; }
}
return string(result);
}
/// @notice domain resolver
function getDomainHolder(string calldata _domainName, string calldata _tld) public view returns(address) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tld);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
return address(IBasePunkTLD(tldAddr).getDomainHolder(_domainName));
}
unchecked { ++i; }
}
return address(0);
}
/// @notice fetch domain data for a given domain
function getDomainData(string calldata _domainName, string calldata _tld) public view returns(string memory) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tld);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
return string(IBasePunkTLD(tldAddr).getDomainData(_domainName));
}
unchecked { ++i; }
}
return "";
}
/// @notice fetch domain metadata for a given domain (tokenURI)
function getDomainTokenUri(string calldata _domainName, string calldata _tld) public view returns(string memory) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tld);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
(, uint256 _tokenId, , ) = IBasePunkTLD(tldAddr).domains(_domainName);
return IERC721Metadata(tldAddr).tokenURI(_tokenId);
}
unchecked { ++i; }
}
return "";
}
function getFactoriesArray() public view returns(address[] memory) {
return factories;
}
/// @notice reverse resolver: get single user's default name, the first that comes (all TLDs)
function getFirstDefaultDomain(address _addr) public view returns(string memory) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
string[] memory tldNames = IBasePunkTLDFactory(factories[i]).getTldsArray();
for (uint256 j = 0; j < tldNames.length; ++j) {
string memory tldName = tldNames[j];
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(tldName);
string memory defaultName = IBasePunkTLD(tldAddr).defaultNames(_addr);
if (
strings.len(strings.toSlice(defaultName)) > 0 &&
!isTldDeprecated[tldAddr]
) {
return string(abi.encodePacked(defaultName, tldName));
}
}
unchecked { ++i; }
}
return "";
}
/// @notice get the address of a given TLD name
function getTldAddress(string calldata _tldName) public view returns(address) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tldName);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
return tldAddr;
} else if (isTldDeprecated[tldAddr]) {
return address(0);
}
unchecked { ++i; }
}
return address(0);
}
/// @notice get the address of the factory contract through which a given TLD was created
function getTldFactoryAddress(string calldata _tldName) public view returns(address) {
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(_tldName);
if (tldAddr != address(0) && !isTldDeprecated[tldAddr]) {
return factories[i];
} else if (isTldDeprecated[tldAddr]) {
return address(0);
}
unchecked { ++i; }
}
return address(0);
}
/// @notice get a stringified CSV of all active TLDs (name,address) across all factories
function getTlds() public view returns(string memory) {
bytes memory result;
uint256 fLength = factories.length;
for (uint256 i = 0; i < fLength;) {
string[] memory tldNames = IBasePunkTLDFactory(factories[i]).getTldsArray();
for (uint256 j = 0; j < tldNames.length; ++j) {
string memory tldName = tldNames[j];
address tldAddr = IBasePunkTLDFactory(factories[i]).tldNamesAddresses(tldName);
if (!isTldDeprecated[tldAddr]) {
result = abi.encodePacked(
result,
abi.encodePacked(tldName, ',', Strings.toHexString(uint256(uint160(tldAddr)), 20), '\n')
);
}
}
unchecked { ++i; }
}
return string(result);
}
// OWNER
function addFactoryAddress(address _factoryAddress) external onlyOwner {
factories.push(_factoryAddress);
emit FactoryAddressAdded(_msgSender(), _factoryAddress);
}
function addDeprecatedTldAddress(address _deprecatedTldAddress) external onlyOwner {
isTldDeprecated[_deprecatedTldAddress] = true;
emit DeprecatedTldAdded(_msgSender(), _deprecatedTldAddress);
}
function removeFactoryAddress(uint _addrIndex) external onlyOwner {
factories[_addrIndex] = factories[factories.length - 1];
factories.pop();
}
function removeDeprecatedTldAddress(address _deprecatedTldAddress) external onlyOwner {
isTldDeprecated[_deprecatedTldAddress] = false;
emit DeprecatedTldRemoved(_msgSender(), _deprecatedTldAddress);
}
}
contracts/interfaces/IBasePunkTLDFactory.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;
interface IBasePunkTLDFactory {
function getTldsArray() external view returns(string[] memory);
function tldNamesAddresses(string memory) external view returns(address);
function createTld(
string memory _name,
string memory _symbol,
address _tldOwner,
uint256 _domainPrice,
bool _buyingEnabled
) external payable returns(address);
}
contracts/lib/strings.sol
// SPDX-License-Identifier: Apache-2.0
/*
* @title String & slice utility library for Solidity contracts.
* @author Nick Johnson <[email protected]>
*/
pragma solidity ^0.8.0;
library strings {
struct slice {
uint _len;
uint _ptr;
}
function memcpy(uint dest, uint src, uint _len) private pure {
// Copy word-length chunks while possible
for(; _len >= 32; _len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
// Copy remaining bytes
uint mask = type(uint).max;
if (_len > 0) {
mask = 256 ** (32 - _len) - 1;
}
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
}
/*
* @dev Returns a slice containing the entire string.
* @param self The string to make a slice from.
* @return A newly allocated slice containing the entire string.
*/
function toSlice(string memory self) internal pure returns (slice memory) {
uint ptr;
assembly {
ptr := add(self, 0x20)
}
return slice(bytes(self).length, ptr);
}
/*
* @dev Returns the length of a null-terminated bytes32 string.
* @param self The value to find the length of.
* @return The length of the string, from 0 to 32.
*/
function len(bytes32 self) internal pure returns (uint) {
uint ret;
if (self == 0)
return 0;
if (uint(self) & type(uint128).max == 0) {
ret += 16;
self = bytes32(uint(self) / 0x100000000000000000000000000000000);
}
if (uint(self) & type(uint64).max == 0) {
ret += 8;
self = bytes32(uint(self) / 0x10000000000000000);
}
if (uint(self) & type(uint32).max == 0) {
ret += 4;
self = bytes32(uint(self) / 0x100000000);
}
if (uint(self) & type(uint16).max == 0) {
ret += 2;
self = bytes32(uint(self) / 0x10000);
}
if (uint(self) & type(uint8).max == 0) {
ret += 1;
}
return 32 - ret;
}
/*
* @dev Returns a slice containing the entire bytes32, interpreted as a
* null-terminated utf-8 string.
* @param self The bytes32 value to convert to a slice.
* @return A new slice containing the value of the input argument up to the
* first null.
*/
function toSliceB32(bytes32 self) internal pure returns (slice memory ret) {
// Allocate space for `self` in memory, copy it there, and point ret at it
assembly {
let ptr := mload(0x40)
mstore(0x40, add(ptr, 0x20))
mstore(ptr, self)
mstore(add(ret, 0x20), ptr)
}
ret._len = len(self);
}
/*
* @dev Returns a new slice containing the same data as the current slice.
* @param self The slice to copy.
* @return A new slice containing the same data as `self`.
*/
function copy(slice memory self) internal pure returns (slice memory) {
return slice(self._len, self._ptr);
}
/*
* @dev Copies a slice to a new string.
* @param self The slice to copy.
* @return A newly allocated string containing the slice's text.
*/
function toString(slice memory self) internal pure returns (string memory) {
string memory ret = new string(self._len);
uint retptr;
assembly { retptr := add(ret, 32) }
memcpy(retptr, self._ptr, self._len);
return ret;
}
/*
* @dev Returns the length in runes of the slice. Note that this operation
* takes time proportional to the length of the slice; avoid using it
* in loops, and call `slice.empty()` if you only need to know whether
* the slice is empty or not.
* @param self The slice to operate on.
* @return The length of the slice in runes.
*/
function len(slice memory self) internal pure returns (uint l) {
// Starting at ptr-31 means the LSB will be the byte we care about
uint ptr = self._ptr - 31;
uint end = ptr + self._len;
for (l = 0; ptr < end; l++) {
uint8 b;
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
ptr += 1;
} else if(b < 0xE0) {
ptr += 2;
} else if(b < 0xF0) {
ptr += 3;
} else if(b < 0xF8) {
ptr += 4;
} else if(b < 0xFC) {
ptr += 5;
} else {
ptr += 6;
}
}
}
/*
* @dev Returns true if the slice is empty (has a length of 0).
* @param self The slice to operate on.
* @return True if the slice is empty, False otherwise.
*/
function empty(slice memory self) internal pure returns (bool) {
return self._len == 0;
}
/*
* @dev Returns a positive number if `other` comes lexicographically after
* `self`, a negative number if it comes before, or zero if the
* contents of the two slices are equal. Comparison is done per-rune,
* on unicode codepoints.
* @param self The first slice to compare.
* @param other The second slice to compare.
* @return The result of the comparison.
*/
function compare(slice memory self, slice memory other) internal pure returns (int) {
uint shortest = self._len;
if (other._len < self._len)
shortest = other._len;
uint selfptr = self._ptr;
uint otherptr = other._ptr;
for (uint idx = 0; idx < shortest; idx += 32) {
uint a;
uint b;
assembly {
a := mload(selfptr)
b := mload(otherptr)
}
if (a != b) {
// Mask out irrelevant bytes and check again
uint mask = type(uint).max; // 0xffff...
if(shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
unchecked {
uint diff = (a & mask) - (b & mask);
if (diff != 0)
return int(diff);
}
}
selfptr += 32;
otherptr += 32;
}
return int(self._len) - int(other._len);
}
/*
* @dev Returns true if the two slices contain the same text.
* @param self The first slice to compare.
* @param self The second slice to compare.
* @return True if the slices are equal, false otherwise.
*/
function equals(slice memory self, slice memory other) internal pure returns (bool) {
return compare(self, other) == 0;
}
/*
* @dev Extracts the first rune in the slice into `rune`, advancing the
* slice to point to the next rune and returning `self`.
* @param self The slice to operate on.
* @param rune The slice that will contain the first rune.
* @return `rune`.
*/
function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) {
rune._ptr = self._ptr;
if (self._len == 0) {
rune._len = 0;
return rune;
}
uint l;
uint b;
// Load the first byte of the rune into the LSBs of b
assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
if (b < 0x80) {
l = 1;
} else if(b < 0xE0) {
l = 2;
} else if(b < 0xF0) {
l = 3;
} else {
l = 4;
}
// Check for truncated codepoints
if (l > self._len) {
rune._len = self._len;
self._ptr += self._len;
self._len = 0;
return rune;
}
self._ptr += l;
self._len -= l;
rune._len = l;
return rune;
}
/*
* @dev Returns the first rune in the slice, advancing the slice to point
* to the next rune.
* @param self The slice to operate on.
* @return A slice containing only the first rune from `self`.
*/
function nextRune(slice memory self) internal pure returns (slice memory ret) {
nextRune(self, ret);
}
/*
* @dev Returns the number of the first codepoint in the slice.
* @param self The slice to operate on.
* @return The number of the first codepoint in the slice.
*/
function ord(slice memory self) internal pure returns (uint ret) {
if (self._len == 0) {
return 0;
}
uint word;
uint length;
uint divisor = 2 ** 248;
// Load the rune into the MSBs of b
assembly { word:= mload(mload(add(self, 32))) }
uint b = word / divisor;
if (b < 0x80) {
ret = b;
length = 1;
} else if(b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if(b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
ret = b & 0x07;
length = 4;
}
// Check for truncated codepoints
if (length > self._len) {
return 0;
}
for (uint i = 1; i < length; i++) {
divisor = divisor / 256;
b = (word / divisor) & 0xFF;
if (b & 0xC0 != 0x80) {
// Invalid UTF-8 sequence
return 0;
}
ret = (ret * 64) | (b & 0x3F);
}
return ret;
}
/*
* @dev Returns the keccak-256 hash of the slice.
* @param self The slice to hash.
* @return The hash of the slice.
*/
function keccak(slice memory self) internal pure returns (bytes32 ret) {
assembly {
ret := keccak256(mload(add(self, 32)), mload(self))
}
}
/*
* @dev Returns true if `self` starts with `needle`.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return True if the slice starts with the provided text, false otherwise.
*/
function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
if (self._len < needle._len) {
return false;
}
if (self._ptr == needle._ptr) {
return true;
}
bool equal;
assembly {
let length := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
return equal;
}
/*
* @dev If `self` starts with `needle`, `needle` is removed from the
* beginning of `self`. Otherwise, `self` is unmodified.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return `self`
*/
function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
bool equal = true;
if (self._ptr != needle._ptr) {
assembly {
let length := mload(needle)
let selfptr := mload(add(self, 0x20))
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
self._ptr += needle._len;
}
return self;
}
/*
* @dev Returns true if the slice ends with `needle`.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return True if the slice starts with the provided text, false otherwise.
*/
function endsWith(slice memory self, slice memory needle) internal pure returns (bool) {
if (self._len < needle._len) {
return false;
}
uint selfptr = self._ptr + self._len - needle._len;
if (selfptr == needle._ptr) {
return true;
}
bool equal;
assembly {
let length := mload(needle)
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
return equal;
}
/*
* @dev If `self` ends with `needle`, `needle` is removed from the
* end of `self`. Otherwise, `self` is unmodified.
* @param self The slice to operate on.
* @param needle The slice to search for.
* @return `self`
*/
function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
uint selfptr = self._ptr + self._len - needle._len;
bool equal = true;
if (selfptr != needle._ptr) {
assembly {
let length := mload(needle)
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
}
return self;
}
// Returns the memory address of the first byte of the first occurrence of
// `needle` in `self`, or the first byte after `self` if not found.
function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr = selfptr;
uint idx;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask;
if (needlelen > 0) {
mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
}
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
uint end = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr >= end)
return selfptr + selflen;
ptr++;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
for (idx = 0; idx <= selflen - needlelen; idx++) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr;
ptr += 1;
}
}
}
return selfptr + selflen;
}
// Returns the memory address of the first byte after the last occurrence of
// `needle` in `self`, or the address of `self` if not found.
function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {
uint ptr;
if (needlelen <= selflen) {
if (needlelen <= 32) {
bytes32 mask;
if (needlelen > 0) {
mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));
}
bytes32 needledata;
assembly { needledata := and(mload(needleptr), mask) }
ptr = selfptr + selflen - needlelen;
bytes32 ptrdata;
assembly { ptrdata := and(mload(ptr), mask) }
while (ptrdata != needledata) {
if (ptr <= selfptr)
return selfptr;
ptr--;
assembly { ptrdata := and(mload(ptr), mask) }
}
return ptr + needlelen;
} else {
// For long needles, use hashing
bytes32 hash;
assembly { hash := keccak256(needleptr, needlelen) }
ptr = selfptr + (selflen - needlelen);
while (ptr >= selfptr) {
bytes32 testHash;
assembly { testHash := keccak256(ptr, needlelen) }
if (hash == testHash)
return ptr + needlelen;
ptr -= 1;
}
}
}
return selfptr;
}
/*
* @dev Modifies `self` to contain everything from the first occurrence of
* `needle` to the end of the slice. `self` is set to the empty slice
* if `needle` is not found.
* @param self The slice to search and modify.
* @param needle The text to search for.
* @return `self`.
*/
function find(slice memory self, slice memory needle) internal pure returns (slice memory) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len -= ptr - self._ptr;
self._ptr = ptr;
return self;
}
/*
* @dev Modifies `self` to contain the part of the string from the start of
* `self` to the end of the first occurrence of `needle`. If `needle`
* is not found, `self` is set to the empty slice.
* @param self The slice to search and modify.
* @param needle The text to search for.
* @return `self`.
*/
function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
self._len = ptr - self._ptr;
return self;
}
/*
* @dev Splits the slice, setting `self` to everything after the first
* occurrence of `needle`, and `token` to everything before it. If
* `needle` does not occur in `self`, `self` is set to the empty slice,
* and `token` is set to the entirety of `self`.
* @param self The slice to split.
* @param needle The text to search for in `self`.
* @param token An output parameter to which the first token is written.
* @return `token`.
*/
function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = self._ptr;
token._len = ptr - self._ptr;
if (ptr == self._ptr + self._len) {
// Not found
self._len = 0;
} else {
self._len -= token._len + needle._len;
self._ptr = ptr + needle._len;
}
return token;
}
/*
* @dev Splits the slice, setting `self` to everything after the first
* occurrence of `needle`, and returning everything before it. If
* `needle` does not occur in `self`, `self` is set to the empty slice,
* and the entirety of `self` is returned.
* @param self The slice to split.
* @param needle The text to search for in `self`.
* @return The part of `self` up to the first occurrence of `delim`.
*/
function split(slice memory self, slice memory needle) internal pure returns (slice memory token) {
split(self, needle, token);
}
/*
* @dev Splits the slice, setting `self` to everything before the last
* occurrence of `needle`, and `token` to everything after it. If
* `needle` does not occur in `self`, `self` is set to the empty slice,
* and `token` is set to the entirety of `self`.
* @param self The slice to split.
* @param needle The text to search for in `self`.
* @param token An output parameter to which the first token is written.
* @return `token`.
*/
function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = ptr;
token._len = self._len - (ptr - self._ptr);
if (ptr == self._ptr) {
// Not found
self._len = 0;
} else {
self._len -= token._len + needle._len;
}
return token;
}
/*
* @dev Splits the slice, setting `self` to everything before the last
* occurrence of `needle`, and returning everything after it. If
* `needle` does not occur in `self`, `self` is set to the empty slice,
* and the entirety of `self` is returned.
* @param self The slice to split.
* @param needle The text to search for in `self`.
* @return The part of `self` after the last occurrence of `delim`.
*/
function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) {
rsplit(self, needle, token);
}
/*
* @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.
* @param self The slice to search.
* @param needle The text to search for in `self`.
* @return The number of occurrences of `needle` found in `self`.
*/
function count(slice memory self, slice memory needle) internal pure returns (uint cnt) {
uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
while (ptr <= self._ptr + self._len) {
cnt++;
ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len;
}
}
/*
* @dev Returns True if `self` contains `needle`.
* @param self The slice to search.
* @param needle The text to search for in `self`.
* @return True if `needle` is found in `self`, false otherwise.
*/
function contains(slice memory self, slice memory needle) internal pure returns (bool) {
return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
}
/*
* @dev Returns a newly allocated string containing the concatenation of
* `self` and `other`.
* @param self The first slice to concatenate.
* @param other The second slice to concatenate.
* @return The concatenation of the two strings.
*/
function concat(slice memory self, slice memory other) internal pure returns (string memory) {
string memory ret = new string(self._len + other._len);
uint retptr;
assembly { retptr := add(ret, 32) }
memcpy(retptr, self._ptr, self._len);
memcpy(retptr + self._len, other._ptr, other._len);
return ret;
}
/*
* @dev Joins an array of slices, using `self` as a delimiter, returning a
* newly allocated string.
* @param self The delimiter to use.
* @param parts A list of slices to join.
* @return A newly allocated string containing all the slices in `parts`,
* joined with `self`.
*/
function join(slice memory self, slice[] memory parts) internal pure returns (string memory) {
if (parts.length == 0)
return "";
uint length = self._len * (parts.length - 1);
for(uint i = 0; i < parts.length; i++)
length += parts[i]._len;
string memory ret = new string(length);
uint retptr;
assembly { retptr := add(ret, 32) }
for(uint i = 0; i < parts.length; i++) {
memcpy(retptr, parts[i]._ptr, parts[i]._len);
retptr += parts[i]._len;
if (i < parts.length - 1) {
memcpy(retptr, self._ptr, self._len);
retptr += self._len;
}
}
return ret;
}
/**
* Lower
*
* Converts all the values of a string to their corresponding lower case
* value.
*
* @param _base When being used for a data type this is the extended object
* otherwise this is the string base to convert to lower case
* @return string
*/
function lower(string memory _base)
internal
pure
returns (string memory) {
bytes memory _baseBytes = bytes(_base);
for (uint i = 0; i < _baseBytes.length; i++) {
_baseBytes[i] = _lower(_baseBytes[i]);
}
return string(_baseBytes);
}
/**
* Lower
*
* Convert an alphabetic character to lower case and return the original
* value when not alphabetic
*
* @param _b1 The byte to be converted to lower case
* @return bytes1 The converted value if the passed value was alphabetic
* and in a upper case otherwise returns the original value
*/
function _lower(bytes1 _b1)
private
pure
returns (bytes1) {
if (_b1 >= 0x41 && _b1 <= 0x5A) {
return bytes1(uint8(_b1) + 32);
}
return _b1;
}
}
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @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 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
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);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = _setInitializedVersion(1);
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
bool isTopLevelCall = _setInitializedVersion(version);
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(version);
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
_setInitializedVersion(type(uint8).max);
}
function _setInitializedVersion(uint8 version) private returns (bool) {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
// of initializers, because in other contexts the contract may have been reentered.
if (_initializing) {
require(
version == 1 && !AddressUpgradeable.isContract(address(this)),
"Initializable: contract is already initialized"
);
return false;
} else {
require(_initialized < version, "Initializable: contract is already initialized");
_initialized = version;
return true;
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
@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/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
@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/interfaces/IBasePunkTLD.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
interface IBasePunkTLD is IERC721 {
struct Domain {
string name; // domain name that goes before the TLD name; example: "tempetechie" in "tempetechie.web3"
uint256 tokenId;
address holder;
string data; // stringified JSON object, example: {"description": "Some text", "twitter": "@techie1239", "friends": ["0x123..."], "url": "https://punk.domains"}
}
event DomainCreated(address indexed user, address indexed owner, string fullDomainName);
event DomainBurned(address indexed user, string fullDomainName);
event DefaultDomainChanged(address indexed user, string defaultDomain);
event DataChanged(address indexed user);
event TldPriceChanged(address indexed user, uint256 tldPrice);
event ReferralFeeChanged(address indexed user, uint256 referralFee);
event TldRoyaltyChanged(address indexed user, uint256 tldRoyalty);
event DomainBuyingToggle(address indexed user, bool domainBuyingToggle);
function domains(string calldata _domainName) external view returns(string memory, uint256, address, string memory);
function defaultNames(address) external view returns(string memory);
function getDomainData(string calldata _domainName) external view returns(string memory);
function getDomainHolder(string calldata _domainName) external view returns(address);
function price() external view returns (uint256);
function referral() external view returns (uint256);
function changeNameMaxLength(uint256 _maxLength) external;
function changePrice(uint256 _price) external;
function changeReferralFee(uint256 _referral) external;
function mint(
string memory _domainName,
address _domainHolder,
address _referrer
) external payable returns(uint256);
}
Contract ABI
[{"type":"event","name":"DeprecatedTldAdded","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false},{"type":"address","name":"tAddr","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"DeprecatedTldRemoved","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false},{"type":"address","name":"tAddr","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"FactoryAddressAdded","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false},{"type":"address","name":"fAddr","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addDeprecatedTldAddress","inputs":[{"type":"address","name":"_deprecatedTldAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addFactoryAddress","inputs":[{"type":"address","name":"_factoryAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"factories","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getDefaultDomain","inputs":[{"type":"address","name":"_addr","internalType":"address"},{"type":"string","name":"_tld","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getDefaultDomains","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getDomainData","inputs":[{"type":"string","name":"_domainName","internalType":"string"},{"type":"string","name":"_tld","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getDomainHolder","inputs":[{"type":"string","name":"_domainName","internalType":"string"},{"type":"string","name":"_tld","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getDomainTokenUri","inputs":[{"type":"string","name":"_domainName","internalType":"string"},{"type":"string","name":"_tld","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getFactoriesArray","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getFirstDefaultDomain","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTldAddress","inputs":[{"type":"string","name":"_tldName","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTldFactoryAddress","inputs":[{"type":"string","name":"_tldName","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getTlds","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isTldDeprecated","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeDeprecatedTldAddress","inputs":[{"type":"address","name":"_deprecatedTldAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeFactoryAddress","inputs":[{"type":"uint256","name":"_addrIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5061246e806100206000396000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c806371c033fc116100ad578063b9f24d7b11610071578063b9f24d7b1461027b578063cc1b2d021461028e578063d1406151146102a1578063f267a10c146102b6578063f2fde38b146102c957600080fd5b806371c033fc146102295780638129fc1c1461023c5780638da5cb5b14610244578063924e8a6b14610255578063959923281461026857600080fd5b806363d5eee8116100f457806363d5eee8146101b5578063672383c4146101e85780636d3437fb146101fb5780636e94cac91461020e578063715018a61461022157600080fd5b8063124b356b1461013157806318c0c6951461014657806357951ea8146101595780635b20cf391461017757806362169a77146101a2575b600080fd5b61014461013f366004611dcf565b6102dc565b005b610144610154366004611dcf565b610380565b61016161041c565b60405161016e9190612215565b60405180910390f35b61018a610185366004611f1c565b61065a565b6040516001600160a01b03909116815260200161016e565b61018a6101b0366004611f1c565b6107d4565b6101d86101c3366004611dcf565b60656020526000908152604090205460ff1681565b604051901515815260200161016e565b61018a6101f6366004612076565b61090a565b610161610209366004611dcf565b610934565b61016161021c366004611f5c565b610c4c565b610144610e7b565b610161610237366004611dcf565b610eb1565b610144611199565b6033546001600160a01b031661018a565b610144610263366004612076565b611212565b610161610276366004611e07565b611316565b610161610289366004611f5c565b6114b9565b61018a61029c366004611f5c565b611645565b6102a96117cf565b60405161016e9190612199565b6101446102c4366004611dcf565b611831565b6101446102d7366004611dcf565b6118a2565b6033546001600160a01b0316331461030f5760405162461bcd60e51b815260040161030690612296565b60405180910390fd5b6001600160a01b0381166000908152606560205260409020805460ff191660011790557ff847dbe1168b3644f67f33bf127627062cb7a1777ac983fa83e44edb57989b2261035a3390565b604080516001600160a01b0392831681529184166020830152015b60405180910390a150565b6033546001600160a01b031633146103aa5760405162461bcd60e51b815260040161030690612296565b606680546001810182556000919091527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e943540180546001600160a01b0319166001600160a01b0383161790557f5928fa36137089d200461b1b8492840afb1c250ed4dc142dc2bc16f9ca4074893361035a565b606654606090819060005b818110156106525760006066828154811061045257634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b15801561049957600080fd5b505afa1580156104ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104d59190810190611e5a565b905060005b815181101561064857600082828151811061050557634e487b7160e01b600052603260045260246000fd5b6020026020010151905060006066858154811061053257634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061056b908590600401612215565b60206040518083038186803b15801561058357600080fd5b505afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190611deb565b6001600160a01b03811660009081526065602052604090205490915060ff166106355786826105f4836001600160a01b0316601461193a565b60405160200161060592919061214f565b60408051601f1981840301815290829052610623929160200161208e565b60405160208183030381529060405296505b505080610641906123dc565b90506104da565b5050600101610427565b509092915050565b606654600090815b818110156107c75760006066828154811061068d57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d5906106c890899089906004016121e6565b60206040518083038186803b1580156106e057600080fd5b505afa1580156106f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107189190611deb565b90506001600160a01b0381161580159061074b57506001600160a01b03811660009081526065602052604090205460ff16155b15610791576066828154811061077157634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031693506107ce92505050565b6001600160a01b03811660009081526065602052604090205460ff16156107be57600093505050506107ce565b50600101610662565b5060009150505b92915050565b606654600090815b818110156107c75760006066828154811061080757634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061084290899089906004016121e6565b60206040518083038186803b15801561085a57600080fd5b505afa15801561086e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108929190611deb565b90506001600160a01b038116158015906108c557506001600160a01b03811660009081526065602052604090205460ff16155b156108d45792506107ce915050565b6001600160a01b03811660009081526065602052604090205460ff161561090157600093505050506107ce565b506001016107dc565b6066818154811061091a57600080fd5b6000918252602090912001546001600160a01b0316905081565b606654606090819060005b81811015610c435760006066828154811061096a57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b1580156109b157600080fd5b505afa1580156109c5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109ed9190810190611e5a565b905060005b8151811015610c39576000828281518110610a1d57634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060668581548110610a4a57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610a83908590600401612215565b60206040518083038186803b158015610a9b57600080fd5b505afa158015610aaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad39190611deb565b6040516318ab1ea160e21b81526001600160a01b038b811660048301529192506000918316906362ac7a849060240160006040518083038186803b158015610b1a57600080fd5b505afa158015610b2e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b569190810190611fc5565b90506000610b93610b8e8360408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b611b1c565b118015610bb957506001600160a01b03821660009081526065602052604090205460ff16155b15610c255760018551610bcc919061237e565b841415610bfe57878184604051602001610be8939291906120bd565b6040516020818303038152906040529750610c25565b878184604051602001610c1393929190612100565b60405160208183030381529060405297505b50505080610c32906123dc565b90506109f2565b505060010161093f565b50909392505050565b60665460609060005b81811015610e5e57600060668281548110610c8057634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610cbb90899089906004016121e6565b60206040518083038186803b158015610cd357600080fd5b505afa158015610ce7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0b9190611deb565b90506001600160a01b03811615801590610d3e57506001600160a01b03811660009081526065602052604090205460ff16155b15610e5557604051632644923560e01b81526000906001600160a01b03831690632644923590610d74908c908c906004016121e6565b60006040518083038186803b158015610d8c57600080fd5b505afa158015610da0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dc89190810190611ff8565b505060405163c87b56dd60e01b8152600481018290529092506001600160a01b038416915063c87b56dd9060240160006040518083038186803b158015610e0e57600080fd5b505afa158015610e22573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e4a9190810190611fc5565b945050505050610e73565b50600101610c55565b50604051806020016040528060008152509150505b949350505050565b6033546001600160a01b03163314610ea55760405162461bcd60e51b815260040161030690612296565b610eaf6000611bf5565b565b60665460609060005b8181101561118257600060668281548110610ee557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b158015610f2c57600080fd5b505afa158015610f40573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f689190810190611e5a565b905060005b8151811015611178576000828281518110610f9857634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060668581548110610fc557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610ffe908590600401612215565b60206040518083038186803b15801561101657600080fd5b505afa15801561102a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104e9190611deb565b6040516318ab1ea160e21b81526001600160a01b038a811660048301529192506000918316906362ac7a849060240160006040518083038186803b15801561109557600080fd5b505afa1580156110a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110d19190810190611fc5565b90506000611109610b8e8360408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b11801561112f57506001600160a01b03821660009081526065602052604090205460ff16155b1561116457808360405160200161114792919061208e565b604051602081830303815290604052975050505050505050919050565b50505080611171906123dc565b9050610f6d565b5050600101610eba565b505060408051602081019091526000815292915050565b60006111a56001611c47565b905080156111bd576000805461ff0019166101001790555b6111c5611ccf565b6111cd611cf6565b801561120f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610375565b50565b6033546001600160a01b0316331461123c5760405162461bcd60e51b815260040161030690612296565b6066805461124c9060019061237e565b8154811061126a57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606680546001600160a01b0390921691839081106112a457634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060668054806112f157634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905550565b60665460609060005b8181101561149d5760006066828154811061134a57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061138590899089906004016121e6565b60206040518083038186803b15801561139d57600080fd5b505afa1580156113b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d59190611deb565b90506001600160a01b0381161580159061140857506001600160a01b03811660009081526065602052604090205460ff16155b15611494576040516318ab1ea160e21b81526001600160a01b0388811660048301528216906362ac7a849060240160006040518083038186803b15801561144e57600080fd5b505afa158015611462573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261148a9190810190611fc5565b93505050506114b2565b5060010161131f565b50604051806020016040528060008152509150505b9392505050565b60665460609060005b81811015610e5e576000606682815481106114ed57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061152890899089906004016121e6565b60206040518083038186803b15801561154057600080fd5b505afa158015611554573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115789190611deb565b90506001600160a01b038116158015906115ab57506001600160a01b03811660009081526065602052604090205460ff16155b1561163c57604051637afdfb4f60e01b81526001600160a01b03821690637afdfb4f906115de908b908b906004016121e6565b60006040518083038186803b1580156115f657600080fd5b505afa15801561160a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116329190810190611fc5565b9350505050610e73565b506001016114c2565b606654600090815b818110156117c25760006066828154811061167857634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d5906116b390899089906004016121e6565b60206040518083038186803b1580156116cb57600080fd5b505afa1580156116df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117039190611deb565b90506001600160a01b0381161580159061173657506001600160a01b03811660009081526065602052604090205460ff16155b156117b95760405163bfcdd7c360e01b81526001600160a01b0382169063bfcdd7c390611769908b908b906004016121e6565b60206040518083038186803b15801561178157600080fd5b505afa158015611795573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190611deb565b5060010161164d565b5060009695505050505050565b6060606680548060200260200160405190810160405280929190818152602001828054801561182757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611809575b5050505050905090565b6033546001600160a01b0316331461185b5760405162461bcd60e51b815260040161030690612296565b6001600160a01b0381166000908152606560205260409020805460ff191690557f9bb0227be14fac452f137fab7d0f8e1fb0441159a8b26f843c02355e4340eaa93361035a565b6033546001600160a01b031633146118cc5760405162461bcd60e51b815260040161030690612296565b6001600160a01b0381166119315760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610306565b61120f81611bf5565b6060600061194983600261235f565b611954906002612347565b67ffffffffffffffff81111561197a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156119a4576020820181803683370190505b509050600360fc1b816000815181106119cd57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a0a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611a2e84600261235f565b611a39906001612347565b90505b6001811115611acd576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7b57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611a9f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611ac6816123c5565b9050611a3c565b5083156114b25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610306565b600080601f8360200151611b30919061237e565b8351909150600090611b429083612347565b9050600092505b80821015611bee57815160ff166080811015611b7157611b6a600184612347565b9250611bdb565b60e08160ff161015611b8857611b6a600284612347565b60f08160ff161015611b9f57611b6a600384612347565b60f88160ff161015611bb657611b6a600484612347565b60fc8160ff161015611bcd57611b6a600584612347565b611bd8600684612347565b92505b5082611be6816123dc565b935050611b49565b5050919050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008054610100900460ff1615611c8e578160ff166001148015611c6a5750303b155b611c865760405162461bcd60e51b815260040161030690612248565b506000919050565b60005460ff808416911610611cb55760405162461bcd60e51b815260040161030690612248565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff16610eaf5760405162461bcd60e51b8152600401610306906122cb565b600054610100900460ff16611d1d5760405162461bcd60e51b8152600401610306906122cb565b610eaf33611bf5565b60008083601f840112611d37578182fd5b50813567ffffffffffffffff811115611d4e578182fd5b602083019150836020828501011115611d6657600080fd5b9250929050565b600082601f830112611d7d578081fd5b815167ffffffffffffffff811115611d9757611d9761240d565b611daa601f8201601f1916602001612316565b818152846020838601011115611dbe578283fd5b610e73826020830160208701612395565b600060208284031215611de0578081fd5b81356114b281612423565b600060208284031215611dfc578081fd5b81516114b281612423565b600080600060408486031215611e1b578182fd5b8335611e2681612423565b9250602084013567ffffffffffffffff811115611e41578283fd5b611e4d86828701611d26565b9497909650939450505050565b60006020808385031215611e6c578182fd5b825167ffffffffffffffff80821115611e83578384fd5b818501915085601f830112611e96578384fd5b815181811115611ea857611ea861240d565b8060051b611eb7858201612316565b8281528581019085870183870188018b1015611ed1578889fd5b8893505b84841015611f0e57805186811115611eeb57898afd5b611ef98c8a838b0101611d6d565b84525060019390930192918701918701611ed5565b509998505050505050505050565b60008060208385031215611f2e578182fd5b823567ffffffffffffffff811115611f44578283fd5b611f5085828601611d26565b90969095509350505050565b60008060008060408587031215611f71578081fd5b843567ffffffffffffffff80821115611f88578283fd5b611f9488838901611d26565b90965094506020870135915080821115611fac578283fd5b50611fb987828801611d26565b95989497509550505050565b600060208284031215611fd6578081fd5b815167ffffffffffffffff811115611fec578182fd5b610e7384828501611d6d565b6000806000806080858703121561200d578384fd5b845167ffffffffffffffff80821115612024578586fd5b61203088838901611d6d565b9550602087015194506040870151915061204982612423565b60608701519193508082111561205d578283fd5b5061206a87828801611d6d565b91505092959194509250565b600060208284031215612087578081fd5b5035919050565b600083516120a0818460208801612395565b8351908301906120b4818360208801612395565b01949350505050565b600084516120cf818460208901612395565b8451908301906120e3818360208901612395565b84519101906120f6818360208801612395565b0195945050505050565b60008451612112818460208901612395565b845190830190612126818360208901612395565b8451910190612139818360208801612395565b600160fd1b910190815260010195945050505050565b60008351612161818460208801612395565b600b60fa1b908301908152835161217f816001840160208801612395565b600560f91b60019290910191820152600201949350505050565b6020808252825182820181905260009190848201906040850190845b818110156121da5783516001600160a01b0316835292840192918401916001016121b5565b50909695505050505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020815260008251806020840152612234816040850160208701612395565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561233f5761233f61240d565b604052919050565b6000821982111561235a5761235a6123f7565b500190565b6000816000190483118215151615612379576123796123f7565b500290565b600082821015612390576123906123f7565b500390565b60005b838110156123b0578181015183820152602001612398565b838111156123bf576000848401525b50505050565b6000816123d4576123d46123f7565b506000190190565b60006000198214156123f0576123f06123f7565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461120f57600080fdfea2646970667358221220a7908b802a9b2de4eeafab596a4b82e9b6257c3c92bd1cb7f351b1a8364cfd9364736f6c63430008040033
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806371c033fc116100ad578063b9f24d7b11610071578063b9f24d7b1461027b578063cc1b2d021461028e578063d1406151146102a1578063f267a10c146102b6578063f2fde38b146102c957600080fd5b806371c033fc146102295780638129fc1c1461023c5780638da5cb5b14610244578063924e8a6b14610255578063959923281461026857600080fd5b806363d5eee8116100f457806363d5eee8146101b5578063672383c4146101e85780636d3437fb146101fb5780636e94cac91461020e578063715018a61461022157600080fd5b8063124b356b1461013157806318c0c6951461014657806357951ea8146101595780635b20cf391461017757806362169a77146101a2575b600080fd5b61014461013f366004611dcf565b6102dc565b005b610144610154366004611dcf565b610380565b61016161041c565b60405161016e9190612215565b60405180910390f35b61018a610185366004611f1c565b61065a565b6040516001600160a01b03909116815260200161016e565b61018a6101b0366004611f1c565b6107d4565b6101d86101c3366004611dcf565b60656020526000908152604090205460ff1681565b604051901515815260200161016e565b61018a6101f6366004612076565b61090a565b610161610209366004611dcf565b610934565b61016161021c366004611f5c565b610c4c565b610144610e7b565b610161610237366004611dcf565b610eb1565b610144611199565b6033546001600160a01b031661018a565b610144610263366004612076565b611212565b610161610276366004611e07565b611316565b610161610289366004611f5c565b6114b9565b61018a61029c366004611f5c565b611645565b6102a96117cf565b60405161016e9190612199565b6101446102c4366004611dcf565b611831565b6101446102d7366004611dcf565b6118a2565b6033546001600160a01b0316331461030f5760405162461bcd60e51b815260040161030690612296565b60405180910390fd5b6001600160a01b0381166000908152606560205260409020805460ff191660011790557ff847dbe1168b3644f67f33bf127627062cb7a1777ac983fa83e44edb57989b2261035a3390565b604080516001600160a01b0392831681529184166020830152015b60405180910390a150565b6033546001600160a01b031633146103aa5760405162461bcd60e51b815260040161030690612296565b606680546001810182556000919091527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e943540180546001600160a01b0319166001600160a01b0383161790557f5928fa36137089d200461b1b8492840afb1c250ed4dc142dc2bc16f9ca4074893361035a565b606654606090819060005b818110156106525760006066828154811061045257634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b15801561049957600080fd5b505afa1580156104ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526104d59190810190611e5a565b905060005b815181101561064857600082828151811061050557634e487b7160e01b600052603260045260246000fd5b6020026020010151905060006066858154811061053257634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061056b908590600401612215565b60206040518083038186803b15801561058357600080fd5b505afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190611deb565b6001600160a01b03811660009081526065602052604090205490915060ff166106355786826105f4836001600160a01b0316601461193a565b60405160200161060592919061214f565b60408051601f1981840301815290829052610623929160200161208e565b60405160208183030381529060405296505b505080610641906123dc565b90506104da565b5050600101610427565b509092915050565b606654600090815b818110156107c75760006066828154811061068d57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d5906106c890899089906004016121e6565b60206040518083038186803b1580156106e057600080fd5b505afa1580156106f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107189190611deb565b90506001600160a01b0381161580159061074b57506001600160a01b03811660009081526065602052604090205460ff16155b15610791576066828154811061077157634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031693506107ce92505050565b6001600160a01b03811660009081526065602052604090205460ff16156107be57600093505050506107ce565b50600101610662565b5060009150505b92915050565b606654600090815b818110156107c75760006066828154811061080757634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061084290899089906004016121e6565b60206040518083038186803b15801561085a57600080fd5b505afa15801561086e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108929190611deb565b90506001600160a01b038116158015906108c557506001600160a01b03811660009081526065602052604090205460ff16155b156108d45792506107ce915050565b6001600160a01b03811660009081526065602052604090205460ff161561090157600093505050506107ce565b506001016107dc565b6066818154811061091a57600080fd5b6000918252602090912001546001600160a01b0316905081565b606654606090819060005b81811015610c435760006066828154811061096a57634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b1580156109b157600080fd5b505afa1580156109c5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109ed9190810190611e5a565b905060005b8151811015610c39576000828281518110610a1d57634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060668581548110610a4a57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610a83908590600401612215565b60206040518083038186803b158015610a9b57600080fd5b505afa158015610aaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad39190611deb565b6040516318ab1ea160e21b81526001600160a01b038b811660048301529192506000918316906362ac7a849060240160006040518083038186803b158015610b1a57600080fd5b505afa158015610b2e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b569190810190611fc5565b90506000610b93610b8e8360408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b611b1c565b118015610bb957506001600160a01b03821660009081526065602052604090205460ff16155b15610c255760018551610bcc919061237e565b841415610bfe57878184604051602001610be8939291906120bd565b6040516020818303038152906040529750610c25565b878184604051602001610c1393929190612100565b60405160208183030381529060405297505b50505080610c32906123dc565b90506109f2565b505060010161093f565b50909392505050565b60665460609060005b81811015610e5e57600060668281548110610c8057634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610cbb90899089906004016121e6565b60206040518083038186803b158015610cd357600080fd5b505afa158015610ce7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0b9190611deb565b90506001600160a01b03811615801590610d3e57506001600160a01b03811660009081526065602052604090205460ff16155b15610e5557604051632644923560e01b81526000906001600160a01b03831690632644923590610d74908c908c906004016121e6565b60006040518083038186803b158015610d8c57600080fd5b505afa158015610da0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dc89190810190611ff8565b505060405163c87b56dd60e01b8152600481018290529092506001600160a01b038416915063c87b56dd9060240160006040518083038186803b158015610e0e57600080fd5b505afa158015610e22573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e4a9190810190611fc5565b945050505050610e73565b50600101610c55565b50604051806020016040528060008152509150505b949350505050565b6033546001600160a01b03163314610ea55760405162461bcd60e51b815260040161030690612296565b610eaf6000611bf5565b565b60665460609060005b8181101561118257600060668281548110610ee557634e487b7160e01b600052603260045260246000fd5b60009182526020822001546040805163ebe7321760e01b815290516001600160a01b039092169263ebe7321792600480840193829003018186803b158015610f2c57600080fd5b505afa158015610f40573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f689190810190611e5a565b905060005b8151811015611178576000828281518110610f9857634e487b7160e01b600052603260045260246000fd5b60200260200101519050600060668581548110610fc557634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d590610ffe908590600401612215565b60206040518083038186803b15801561101657600080fd5b505afa15801561102a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104e9190611deb565b6040516318ab1ea160e21b81526001600160a01b038a811660048301529192506000918316906362ac7a849060240160006040518083038186803b15801561109557600080fd5b505afa1580156110a9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110d19190810190611fc5565b90506000611109610b8e8360408051808201825260008082526020918201528151808301909252825182529182019181019190915290565b11801561112f57506001600160a01b03821660009081526065602052604090205460ff16155b1561116457808360405160200161114792919061208e565b604051602081830303815290604052975050505050505050919050565b50505080611171906123dc565b9050610f6d565b5050600101610eba565b505060408051602081019091526000815292915050565b60006111a56001611c47565b905080156111bd576000805461ff0019166101001790555b6111c5611ccf565b6111cd611cf6565b801561120f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610375565b50565b6033546001600160a01b0316331461123c5760405162461bcd60e51b815260040161030690612296565b6066805461124c9060019061237e565b8154811061126a57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154606680546001600160a01b0390921691839081106112a457634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060668054806112f157634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b031916905501905550565b60665460609060005b8181101561149d5760006066828154811061134a57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061138590899089906004016121e6565b60206040518083038186803b15801561139d57600080fd5b505afa1580156113b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d59190611deb565b90506001600160a01b0381161580159061140857506001600160a01b03811660009081526065602052604090205460ff16155b15611494576040516318ab1ea160e21b81526001600160a01b0388811660048301528216906362ac7a849060240160006040518083038186803b15801561144e57600080fd5b505afa158015611462573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261148a9190810190611fc5565b93505050506114b2565b5060010161131f565b50604051806020016040528060008152509150505b9392505050565b60665460609060005b81811015610e5e576000606682815481106114ed57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d59061152890899089906004016121e6565b60206040518083038186803b15801561154057600080fd5b505afa158015611554573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115789190611deb565b90506001600160a01b038116158015906115ab57506001600160a01b03811660009081526065602052604090205460ff16155b1561163c57604051637afdfb4f60e01b81526001600160a01b03821690637afdfb4f906115de908b908b906004016121e6565b60006040518083038186803b1580156115f657600080fd5b505afa15801561160a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116329190810190611fc5565b9350505050610e73565b506001016114c2565b606654600090815b818110156117c25760006066828154811061167857634e487b7160e01b600052603260045260246000fd5b60009182526020909120015460405163399122d560e01b81526001600160a01b039091169063399122d5906116b390899089906004016121e6565b60206040518083038186803b1580156116cb57600080fd5b505afa1580156116df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117039190611deb565b90506001600160a01b0381161580159061173657506001600160a01b03811660009081526065602052604090205460ff16155b156117b95760405163bfcdd7c360e01b81526001600160a01b0382169063bfcdd7c390611769908b908b906004016121e6565b60206040518083038186803b15801561178157600080fd5b505afa158015611795573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116329190611deb565b5060010161164d565b5060009695505050505050565b6060606680548060200260200160405190810160405280929190818152602001828054801561182757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611809575b5050505050905090565b6033546001600160a01b0316331461185b5760405162461bcd60e51b815260040161030690612296565b6001600160a01b0381166000908152606560205260409020805460ff191690557f9bb0227be14fac452f137fab7d0f8e1fb0441159a8b26f843c02355e4340eaa93361035a565b6033546001600160a01b031633146118cc5760405162461bcd60e51b815260040161030690612296565b6001600160a01b0381166119315760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610306565b61120f81611bf5565b6060600061194983600261235f565b611954906002612347565b67ffffffffffffffff81111561197a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156119a4576020820181803683370190505b509050600360fc1b816000815181106119cd57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a0a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611a2e84600261235f565b611a39906001612347565b90505b6001811115611acd576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7b57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611a9f57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611ac6816123c5565b9050611a3c565b5083156114b25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610306565b600080601f8360200151611b30919061237e565b8351909150600090611b429083612347565b9050600092505b80821015611bee57815160ff166080811015611b7157611b6a600184612347565b9250611bdb565b60e08160ff161015611b8857611b6a600284612347565b60f08160ff161015611b9f57611b6a600384612347565b60f88160ff161015611bb657611b6a600484612347565b60fc8160ff161015611bcd57611b6a600584612347565b611bd8600684612347565b92505b5082611be6816123dc565b935050611b49565b5050919050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008054610100900460ff1615611c8e578160ff166001148015611c6a5750303b155b611c865760405162461bcd60e51b815260040161030690612248565b506000919050565b60005460ff808416911610611cb55760405162461bcd60e51b815260040161030690612248565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff16610eaf5760405162461bcd60e51b8152600401610306906122cb565b600054610100900460ff16611d1d5760405162461bcd60e51b8152600401610306906122cb565b610eaf33611bf5565b60008083601f840112611d37578182fd5b50813567ffffffffffffffff811115611d4e578182fd5b602083019150836020828501011115611d6657600080fd5b9250929050565b600082601f830112611d7d578081fd5b815167ffffffffffffffff811115611d9757611d9761240d565b611daa601f8201601f1916602001612316565b818152846020838601011115611dbe578283fd5b610e73826020830160208701612395565b600060208284031215611de0578081fd5b81356114b281612423565b600060208284031215611dfc578081fd5b81516114b281612423565b600080600060408486031215611e1b578182fd5b8335611e2681612423565b9250602084013567ffffffffffffffff811115611e41578283fd5b611e4d86828701611d26565b9497909650939450505050565b60006020808385031215611e6c578182fd5b825167ffffffffffffffff80821115611e83578384fd5b818501915085601f830112611e96578384fd5b815181811115611ea857611ea861240d565b8060051b611eb7858201612316565b8281528581019085870183870188018b1015611ed1578889fd5b8893505b84841015611f0e57805186811115611eeb57898afd5b611ef98c8a838b0101611d6d565b84525060019390930192918701918701611ed5565b509998505050505050505050565b60008060208385031215611f2e578182fd5b823567ffffffffffffffff811115611f44578283fd5b611f5085828601611d26565b90969095509350505050565b60008060008060408587031215611f71578081fd5b843567ffffffffffffffff80821115611f88578283fd5b611f9488838901611d26565b90965094506020870135915080821115611fac578283fd5b50611fb987828801611d26565b95989497509550505050565b600060208284031215611fd6578081fd5b815167ffffffffffffffff811115611fec578182fd5b610e7384828501611d6d565b6000806000806080858703121561200d578384fd5b845167ffffffffffffffff80821115612024578586fd5b61203088838901611d6d565b9550602087015194506040870151915061204982612423565b60608701519193508082111561205d578283fd5b5061206a87828801611d6d565b91505092959194509250565b600060208284031215612087578081fd5b5035919050565b600083516120a0818460208801612395565b8351908301906120b4818360208801612395565b01949350505050565b600084516120cf818460208901612395565b8451908301906120e3818360208901612395565b84519101906120f6818360208801612395565b0195945050505050565b60008451612112818460208901612395565b845190830190612126818360208901612395565b8451910190612139818360208801612395565b600160fd1b910190815260010195945050505050565b60008351612161818460208801612395565b600b60fa1b908301908152835161217f816001840160208801612395565b600560f91b60019290910191820152600201949350505050565b6020808252825182820181905260009190848201906040850190845b818110156121da5783516001600160a01b0316835292840192918401916001016121b5565b50909695505050505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020815260008251806020840152612234816040850160208701612395565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561233f5761233f61240d565b604052919050565b6000821982111561235a5761235a6123f7565b500190565b6000816000190483118215151615612379576123796123f7565b500290565b600082821015612390576123906123f7565b500390565b60005b838110156123b0578181015183820152602001612398565b838111156123bf576000848401525b50505050565b6000816123d4576123d46123f7565b506000190190565b60006000198214156123f0576123f06123f7565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461120f57600080fdfea2646970667358221220a7908b802a9b2de4eeafab596a4b82e9b6257c3c92bd1cb7f351b1a8364cfd9364736f6c63430008040033