More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 2,056 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Set Approval For... | 13409967 | 66 days ago | IN | 0 GLMR | 0.00656326 | ||||
| Set Approval For... | 13349956 | 71 days ago | IN | 0 GLMR | 0.00101177 | ||||
| Set Approval For... | 13349956 | 71 days ago | IN | 0 GLMR | 0.00778063 | ||||
| Set Approval For... | 13349953 | 71 days ago | IN | 0 GLMR | 0.00101177 | ||||
| Set Approval For... | 13349953 | 71 days ago | IN | 0 GLMR | 0.00101177 | ||||
| Set Approval For... | 13349953 | 71 days ago | IN | 0 GLMR | 0.00778063 | ||||
| Set Approval For... | 9493570 | 353 days ago | IN | 0 GLMR | 0.01336315 | ||||
| Set Approval For... | 6870402 | 539 days ago | IN | 0 GLMR | 0.0151854 | ||||
| Set Approval For... | 6870391 | 539 days ago | IN | 0 GLMR | 0.0129582 | ||||
| Set Approval For... | 6636013 | 556 days ago | IN | 0 GLMR | 0.01285697 | ||||
| Set Approval For... | 6636010 | 556 days ago | IN | 0 GLMR | 0.01285697 | ||||
| Set Approval For... | 6336743 | 595 days ago | IN | 0 GLMR | 0.0126705 | ||||
| Set Approval For... | 6327560 | 596 days ago | IN | 0 GLMR | 0.0126705 | ||||
| Equip | 6154669 | 621 days ago | IN | 0 GLMR | 0.02897 | ||||
| Equip | 6141155 | 623 days ago | IN | 0 GLMR | 0.0302245 | ||||
| Equip | 6141125 | 623 days ago | IN | 0 GLMR | 0.0300505 | ||||
| Transfer Child | 6141115 | 623 days ago | IN | 0 GLMR | 0.02576 | ||||
| Equip | 6132287 | 624 days ago | IN | 0 GLMR | 0.03025776 | ||||
| Transfer Child | 6132277 | 624 days ago | IN | 0 GLMR | 0.02577678 | ||||
| Equip | 6132275 | 624 days ago | IN | 0 GLMR | 0.035052 | ||||
| Transfer Child | 6132271 | 624 days ago | IN | 0 GLMR | 0.02565706 | ||||
| Transfer Child | 6132250 | 624 days ago | IN | 0 GLMR | 0.029973 | ||||
| Equip | 6132249 | 624 days ago | IN | 0 GLMR | 0.035052 | ||||
| Transfer Child | 6132236 | 624 days ago | IN | 0 GLMR | 0.02609724 | ||||
| Equip | 6132234 | 624 days ago | IN | 0 GLMR | 0.0382411 |
View more zero value Internal Transactions in Advanced View mode
Cross-Chain Transactions
Loading...
Loading
Contract Name:
SnakeSoldier
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 80 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@rmrk-team/evm-contracts/contracts/RMRK/access/Ownable.sol";
import "@rmrk-team/evm-contracts/contracts/RMRK/equippable/RMRKMinifiedEquippable.sol";
import "@rmrk-team/evm-contracts/contracts/RMRK/extension/RMRKRoyalties.sol";
import "@rmrk-team/evm-contracts/contracts/RMRK/utils/RMRKCollectionMetadata.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./IERC20Min.sol";
error BadMigration();
error CannotUnequipElementGem();
error ElementAlreadyRevealed();
error MaxGiftsPerPhaseReached();
error MaxPhaseReached();
error MintOverMax();
error MintUnderpriced();
error MintZero();
error NextPhasePriceMustBeEqualOrHigher();
error SaleNotOpen();
error SalePaused();
contract SnakeSoldier is
Ownable,
RMRKCollectionMetadata,
RMRKRoyalties,
RMRKMinifiedEquippable
{
using Strings for uint256;
event Minted(
Rank rank,
address indexed buyer,
uint256 indexed from,
uint256 indexed to
);
enum Rank {
Soldier,
Commander,
General
}
uint256 private constant _MAX_SUPPLY_PER_PHASE_SOLDIERS = 240; // A maximum possible of 240*20=4800
uint256 private constant _MAX_SUPPLY_PER_PHASE_COMMANDERS = 9; // A maximum possible of 9*20=180
uint256 private constant _MAX_SUPPLY_PER_PHASE_GENERALS = 1; // A maximum possible of 1*20=20
uint256 private constant _MAX_PHASES = 20;
uint64 private constant _LOWEST_POSSIBLE_PRIORITY = (2 ^ 64) - 1;
uint64 private constant _ASSET_ID_SOLDIER_EGG_FIRE = 1;
// uint64 private constant _ASSET_ID_SOLDIER_EGG_EARTH = 2;
// uint64 private constant _ASSET_ID_SOLDIER_EGG_WATER = 3;
// uint64 private constant _ASSET_ID_SOLDIER_EGG_AIR = 4;
uint64 private constant _ASSET_ID_COMMANDER_EGG_FIRE = 5;
// uint64 private constant _ASSET_ID_COMMANDER_EGG_EARTH = 6;
// uint64 private constant _ASSET_ID_COMMANDER_EGG_WATER = 7;
// uint64 private constant _ASSET_ID_COMMANDER_EGG_AIR = 8;
uint64 private constant _ASSET_ID_GENERAL_EGG_FIRE = 9;
// uint64 private constant _ASSET_ID_GENERAL_EGG_EARTH = 10;
// uint64 private constant _ASSET_ID_GENERAL_EGG_WATER = 11;
// uint64 private constant _ASSET_ID_GENERAL_EGG_AIR = 12;
uint256 private constant _GENERALS_OFFSET = 0; // No offset.
uint256 private constant _COMMANDERS_OFFSET =
_MAX_SUPPLY_PER_PHASE_GENERALS * _MAX_PHASES; // Starts after generals.
uint256 private constant _SOLDIERS_OFFSET =
(_MAX_SUPPLY_PER_PHASE_COMMANDERS + _MAX_SUPPLY_PER_PHASE_GENERALS) *
_MAX_PHASES; // After generals and Commanders.
uint256 private _pricePerSoldier;
uint256 private _pricePerCommander;
uint256 private _pricePerGeneral;
mapping(uint256 => uint256) private _elementRevealed;
mapping(Rank => uint256) private _totalMinted;
mapping(Rank => uint256) private _totalBurned;
uint256 private _phase;
uint256 private _phasesLocked;
uint256 private _paused;
uint256 private _totalAssets;
mapping(uint64 => uint256) private _isTokenAssetEnumerated;
mapping(address => bool) private _autoAcceptCollection;
uint256 private _totalGifts;
uint256 private immutable _maxGiftsPerPhase;
uint256 private constant _MAX_MIGRATIONS = 500;
uint256 private _total_migrations;
uint64 private _slotForElementGem;
constructor(
string memory collectionMetadata_,
uint256 maxGiftsPerPhase_
)
RMRKCollectionMetadata(collectionMetadata_)
RMRKRoyalties(_msgSender(), 500) // 500 -> 5%
RMRKMinifiedEquippable("Snake Soldiers", "SS")
{
_maxGiftsPerPhase = maxGiftsPerPhase_;
}
function updateRoyaltyRecipient(
address newRoyaltyRecipient
) external override onlyOwner {
_setRoyaltyRecipient(newRoyaltyRecipient);
}
function tokenURI(
uint256 tokenId
) public view virtual returns (string memory) {
_requireMinted(tokenId);
// We assume this alway has at least 1 element, since we add it on mint and it can only be replaced, not removed
uint64[] memory priorities = getActiveAssetPriorities(tokenId);
uint256 len = priorities.length;
uint64 maxPriority = _LOWEST_POSSIBLE_PRIORITY;
uint64 maxPriorityIndex;
for (uint64 i; i < len; ) {
uint64 currentPrio = priorities[i];
if (currentPrio < maxPriority) {
maxPriority = currentPrio;
maxPriorityIndex = i;
}
unchecked {
++i;
}
}
uint64 maxPriorityAssetId = getActiveAssets(tokenId)[maxPriorityIndex];
return getAssetMetadata(tokenId, maxPriorityAssetId);
}
function addEquippableAssetEntries(
uint64 equippableGroupId,
address catalogAddress,
string[] memory metadataURI,
uint64[] memory partIds
) public virtual onlyOwnerOrContributor {
uint256 len = metadataURI.length;
for (uint256 i; i < len; ) {
unchecked {
++_totalAssets;
}
_addAssetEntry(
uint64(_totalAssets),
equippableGroupId,
catalogAddress,
metadataURI[i],
partIds
);
unchecked {
++i;
}
}
}
function addAssetsToTokens(
uint256[] memory tokenIds,
uint64[] memory assetIds,
uint64 replacesAssetWithId
) public virtual onlyOwnerOrContributor {
uint256 len = tokenIds.length;
for (uint256 i; i < len; ) {
_addAssetToToken(tokenIds[i], assetIds[i], replacesAssetWithId);
unchecked {
++i;
}
}
}
function setValidParentForEquippableGroup(
uint64 equippableGroupId,
address parentAddress,
uint64 partId
) public virtual onlyOwnerOrContributor {
_setValidParentForEquippableGroup(
equippableGroupId,
parentAddress,
partId
);
}
function getAssetMetadata(
uint256 tokenId,
uint64 assetId
)
public
view
override
returns (string memory)
{
string memory metaUri = super.getAssetMetadata(tokenId, assetId);
if (_isTokenAssetEnumerated[assetId] != 0)
metaUri = string(abi.encodePacked(metaUri, tokenId.toString()));
return metaUri;
}
function setAssetEnumerated(
uint64 assetId,
bool enumerated
) external onlyOwner {
if (enumerated) _isTokenAssetEnumerated[assetId] = 1;
else delete _isTokenAssetEnumerated[assetId];
}
function totalAssets() public view returns (uint256) {
return _totalAssets;
}
function totalSupply(Rank rank) public view returns (uint256) {
return _totalMinted[rank] - _totalBurned[rank];
}
function totalSupply() public view returns (uint256) {
return
totalSupply(Rank.Soldier) +
totalSupply(Rank.Commander) +
totalSupply(Rank.General);
}
function maxSupply(Rank rank) public view returns (uint256) {
if (rank == Rank.Soldier)
return _MAX_SUPPLY_PER_PHASE_SOLDIERS * _phase;
else if (rank == Rank.Commander)
return _MAX_SUPPLY_PER_PHASE_COMMANDERS * _phase;
else return _MAX_SUPPLY_PER_PHASE_GENERALS * _phase;
}
function maxSupply() public view returns (uint256) {
return
(_MAX_SUPPLY_PER_PHASE_SOLDIERS +
_MAX_SUPPLY_PER_PHASE_COMMANDERS +
_MAX_SUPPLY_PER_PHASE_GENERALS) * _phase;
}
function setPaused(bool paused) external onlyOwner {
_paused = paused ? 1 : 0;
}
function enableNextPhase(
uint256 pricePerSoldier,
uint256 pricePerCommander,
uint256 pricePerGeneral
) external onlyOwner {
if (_phase == _MAX_PHASES || _phasesLocked == 1)
revert MaxPhaseReached();
if (
_pricePerSoldier > pricePerSoldier ||
_pricePerCommander > pricePerCommander ||
_pricePerGeneral > pricePerGeneral
) revert NextPhasePriceMustBeEqualOrHigher();
_phase += 1;
_pricePerSoldier = pricePerSoldier;
_pricePerCommander = pricePerCommander;
_pricePerGeneral = pricePerGeneral;
}
function lockPhases() external onlyOwner {
_phasesLocked = 1;
}
function _rankOffset(Rank rank) private pure returns (uint256) {
if (rank == Rank.Soldier) return _SOLDIERS_OFFSET;
else if (rank == Rank.Commander) return _COMMANDERS_OFFSET;
else return _GENERALS_OFFSET;
}
function pricePerMint(Rank rank) public view returns (uint256) {
if (rank == Rank.Soldier) return _pricePerSoldier;
else if (rank == Rank.Commander) return _pricePerCommander;
else return _pricePerGeneral;
}
function mint(address to, uint256 numToMint, Rank rank) external payable {
_mintChecks(numToMint, rank);
uint256 mintPriceRequired = numToMint * pricePerMint(rank);
if (mintPriceRequired != msg.value) revert MintUnderpriced();
_innerMint(to, numToMint, rank);
}
function giftMint(address to, Rank rank) external onlyOwner {
_mintChecks(1, rank);
if (_totalGifts == _maxGiftsPerPhase * _phase)
revert MaxGiftsPerPhaseReached();
unchecked {
++_totalGifts;
}
_innerMint(to, 1, rank);
}
function _mintChecks(uint256 numToMint, Rank rank) private view {
if (_phase == 0) revert SaleNotOpen();
if (_paused == 1) revert SalePaused();
if (numToMint == uint256(0)) revert MintZero();
if (numToMint + _totalMinted[rank] > maxSupply(rank))
revert MintOverMax();
}
function migrate(address[] memory owners, Rank rank) public onlyOwner {
uint256 len = owners.length;
if(_total_migrations + len > _MAX_MIGRATIONS) revert BadMigration();
_total_migrations += len;
for (uint256 i; i < len; ) {
_innerMint(owners[i], 1, rank);
unchecked {
++i;
}
}
}
function _innerMint(address to, uint256 numToMint, Rank rank) private {
uint256 nextToken = _totalMinted[rank] + 1 + _rankOffset(rank);
unchecked {
_totalMinted[rank] += numToMint;
}
uint256 totalSupplyOffset = nextToken + numToMint;
uint64 assetId;
for (uint256 i = nextToken; i < totalSupplyOffset; ) {
_safeMint(to, i, "");
// The "+ tokenId % 4" part, sets the asset for the right element
if (i > _SOLDIERS_OFFSET) {
assetId = _ASSET_ID_SOLDIER_EGG_FIRE;
} else if (i > _COMMANDERS_OFFSET) {
assetId = _ASSET_ID_COMMANDER_EGG_FIRE;
} else {
assetId = _ASSET_ID_GENERAL_EGG_FIRE;
}
assetId += uint64(i % 4);
_addAssetToToken(i, assetId, 0);
_acceptAsset(i, 0, assetId);
unchecked {
++i;
}
}
emit Minted(rank, to, nextToken, totalSupplyOffset - 1);
}
function withdrawRaised(address to, uint256 amount) external onlyOwner {
(bool success, ) = to.call{value: amount}("");
require(success, "Transfer failed.");
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override {
super._beforeTokenTransfer(from, to, tokenId);
if (to == address(0)) {
Rank rank;
if (tokenId > _SOLDIERS_OFFSET)
rank = Rank.Soldier;
else if (tokenId > _COMMANDERS_OFFSET)
rank = Rank.Commander;
else rank = Rank.General;
unchecked { ++_totalBurned[rank]; }
}
}
function setAutoAcceptCollection(
address collection
) public virtual onlyOwner {
_autoAcceptCollection[collection] = true;
}
function setSlotForElementGem(uint64 slotPartId) public onlyOwner {
_slotForElementGem = slotPartId;
}
function _afterAddChild(
uint256 tokenId,
address childAddress,
uint256 childId,
bytes memory
) internal override {
// Auto accept children if they are from known collections
if (_autoAcceptCollection[childAddress]) {
_acceptChild(
tokenId,
_pendingChildren[tokenId].length - 1,
childAddress,
childId
);
}
}
function _beforeUnequip(
uint256,
uint64,
uint64 slotPartId
) internal virtual override {
if (slotPartId == _slotForElementGem)
revert CannotUnequipElementGem();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/utils/Context.sol";
import "../library/RMRKErrors.sol";
/**
* @title Ownable
* @author RMRK team
* @notice A minimal ownable smart contractf or owner and contributors.
* @dev This smart contract is based on "openzeppelin's access/Ownable.sol".
*/
contract Ownable is Context {
address private _owner;
mapping(address => uint256) private _contributors;
/**
* @notice Used to anounce the transfer of ownership.
* @param previousOwner Address of the account that transferred their ownership role
* @param newOwner Address of the account receiving the ownership role
*/
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @notice Event that signifies that an address was granted contributor role or that the permission has been
* revoked.
* @dev This can only be triggered by a current owner, so there is no need to include that information in the event.
* @param contributor Address of the account that had contributor role status updated
* @param isContributor A boolean value signifying whether the role has been granted (`true`) or revoked (`false`)
*/
event ContributorUpdate(address indexed contributor, bool isContributor);
/**
* @dev Reverts if called by any account other than the owner or an approved contributor.
*/
modifier onlyOwnerOrContributor() {
_onlyOwnerOrContributor();
_;
}
/**
* @dev Reverts if called by any account other than the owner.
*/
modifier onlyOwner() {
_onlyOwner();
_;
}
/**
* @dev Initializes the contract by setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @notice Returns the address of the current owner.
* @return Address of the current owner
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @notice Leaves the contract without owner. Functions using the `onlyOwner` modifier will be disabled.
* @dev Can only be called by the current owner.
* @dev 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));
}
/**
* @notice Transfers ownership of the contract to a new owner.
* @dev Can only be called by the current owner.
* @param newOwner Address of the new owner's account
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) revert RMRKNewOwnerIsZeroAddress();
_transferOwnership(newOwner);
}
/**
* @notice Transfers ownership of the contract to a new owner.
* @dev Internal function without access restriction.
* @dev Emits ***OwnershipTransferred*** event.
* @param newOwner Address of the new owner's account
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @notice Adds or removes a contributor to the smart contract.
* @dev Can only be called by the owner.
* @dev Emits ***ContributorUpdate*** event.
* @param contributor Address of the contributor's account
* @param grantRole A boolean value signifying whether the contributor role is being granted (`true`) or revoked
* (`false`)
*/
function manageContributor(
address contributor,
bool grantRole
) external onlyOwner {
if (contributor == address(0)) revert RMRKNewContributorIsZeroAddress();
grantRole
? _contributors[contributor] = 1
: _contributors[contributor] = 0;
emit ContributorUpdate(contributor, grantRole);
}
/**
* @notice Used to check if the address is one of the contributors.
* @param contributor Address of the contributor whose status we are checking
* @return Boolean value indicating whether the address is a contributor or not
*/
function isContributor(address contributor) public view returns (bool) {
return _contributors[contributor] == 1;
}
/**
* @notice Used to verify that the caller is either the owner or a contributor.
* @dev If the caller is not the owner or a contributor, the execution will be reverted.
*/
function _onlyOwnerOrContributor() private view {
if (owner() != _msgSender() && !isContributor(_msgSender()))
revert RMRKNotOwnerOrContributor();
}
/**
* @notice Used to verify that the caller is the owner.
* @dev If the caller is not the owner, the execution will be reverted.
*/
function _onlyOwner() private view {
if (owner() != _msgSender()) revert RMRKNotOwner();
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IRMRKCatalog
* @author RMRK team
* @notice An interface Catalog for RMRK equippable module.
*/
interface IRMRKCatalog is IERC165 {
/**
* @notice Event to announce addition of a new part.
* @dev It is emitted when a new part is added.
* @param partId ID of the part that was added
* @param itemType Enum value specifying whether the part is `None`, `Slot` and `Fixed`
* @param zIndex An uint specifying the z value of the part. It is used to specify the depth which the part should
* be rendered at
* @param equippableAddresses An array of addresses that can equip this part
* @param metadataURI The metadata URI of the part
*/
event AddedPart(
uint64 indexed partId,
ItemType indexed itemType,
uint8 zIndex,
address[] equippableAddresses,
string metadataURI
);
/**
* @notice Event to announce new equippables to the part.
* @dev It is emitted when new addresses are marked as equippable for `partId`.
* @param partId ID of the part that had new equippable addresses added
* @param equippableAddresses An array of the new addresses that can equip this part
*/
event AddedEquippables(
uint64 indexed partId,
address[] equippableAddresses
);
/**
* @notice Event to announce the overriding of equippable addresses of the part.
* @dev It is emitted when the existing list of addresses marked as equippable for `partId` is overwritten by a new one.
* @param partId ID of the part whose list of equippable addresses was overwritten
* @param equippableAddresses The new, full, list of addresses that can equip this part
*/
event SetEquippables(uint64 indexed partId, address[] equippableAddresses);
/**
* @notice Event to announce that a given part can be equipped by any address.
* @dev It is emitted when a given part is marked as equippable by any.
* @param partId ID of the part marked as equippable by any address
*/
event SetEquippableToAll(uint64 indexed partId);
/**
* @notice Used to define a type of the item. Possible values are `None`, `Slot` or `Fixed`.
* @dev Used for fixed and slot parts.
*/
enum ItemType {
None,
Slot,
Fixed
}
/**
* @notice The integral structure of a standard RMRK catalog item defining it.
* @dev Requires a minimum of 3 storage slots per catalog item, equivalent to roughly 60,000 gas as of Berlin hard
* fork (April 14, 2021), though 5-7 storage slots is more realistic, given the standard length of an IPFS URI.
* This will result in between 25,000,000 and 35,000,000 gas per 250 assets--the maximum block size of Ethereum
* mainnet is 30M at peak usage.
* @return itemType The item type of the part
* @return z The z value of the part defining how it should be rendered when presenting the full NFT
* @return equippable The array of addresses allowed to be equipped in this part
* @return metadataURI The metadata URI of the part
*/
struct Part {
ItemType itemType; //1 byte
uint8 z; //1 byte
address[] equippable; //n Collections that can be equipped into this slot
string metadataURI; //n bytes 32+
}
/**
* @notice The structure used to add a new `Part`.
* @dev The part is added with specified ID, so you have to make sure that you are using an unused `partId`,
* otherwise the addition of the part vill be reverted.
* @dev The full `IntakeStruct` looks like this:
* [
* partID,
* [
* itemType,
* z,
* [
* permittedCollectionAddress0,
* permittedCollectionAddress1,
* permittedCollectionAddress2
* ],
* metadataURI
* ]
* ]
* @return partId ID to be assigned to the `Part`
* @return part A `Part` to be added
*/
struct IntakeStruct {
uint64 partId;
Part part;
}
/**
* @notice Used to return the metadata URI of the associated Catalog.
* @return Catalog metadata URI
*/
function getMetadataURI() external view returns (string memory);
/**
* @notice Used to return the `itemType` of the associated Catalog
* @return `itemType` of the associated Catalog
*/
function getType() external view returns (string memory);
/**
* @notice Used to check whether the given address is allowed to equip the desired `Part`.
* @dev Returns true if a collection may equip asset with `partId`.
* @param partId The ID of the part that we are checking
* @param targetAddress The address that we are checking for whether the part can be equipped into it or not
* @return The status indicating whether the `targetAddress` can be equipped into `Part` with `partId` or not
*/
function checkIsEquippable(
uint64 partId,
address targetAddress
) external view returns (bool);
/**
* @notice Used to check if the part is equippable by all addresses.
* @dev Returns true if part is equippable to all.
* @param partId ID of the part that we are checking
* @return The status indicating whether the part with `partId` can be equipped by any address or not
*/
function checkIsEquippableToAll(uint64 partId) external view returns (bool);
/**
* @notice Used to retrieve a `Part` with id `partId`
* @param partId ID of the part that we are retrieving
* @return The `Part` struct associated with given `partId`
*/
function getPart(uint64 partId) external view returns (Part memory);
/**
* @notice Used to retrieve multiple parts at the same time.
* @param partIds An array of part IDs that we want to retrieve
* @return An array of `Part` structs associated with given `partIds`
*/
function getParts(
uint64[] memory partIds
) external view returns (Part[] memory);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
/**
* @title IRMRKCore
* @author RMRK team
* @notice Interface smart contract for RMRK core module.
*/
interface IRMRKCore {
/**
* @notice Used to retrieve the collection name.
* @return Name of the collection
*/
function name() external view returns (string memory);
/**
* @notice Used to retrieve the collection symbol.
* @return Symbol of the collection
*/
function symbol() external view returns (string memory);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "./IRMRKCore.sol";
/**
* @title RMRKCore
* @author RMRK team
* @notice Smart contract of the RMRK core module.
* @dev This is currently just a passthrough contract which allows for granular editing of base-level ERC721 functions.
*/
contract RMRKCore is IRMRKCore {
/**
* @notice Version of the @rmrk-team/evm-contracts package
* @return Version identifier of the smart contract
*/
string public constant VERSION = "1.2.1";
bytes4 public constant RMRK_INTERFACE = 0x524D524B; // "RMRK" in ASCII hex
/**
* @notice Used to initialize the smart contract.
* @param name_ Name of the token collection
* @param symbol_ Symbol of the token collection
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/// Token name
string private _name;
/// Token symbol
string private _symbol;
/**
* @notice Used to retrieve the collection name.
* @return Name of the collection
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @notice Used to retrieve the collection symbol.
* @return Symbol of the collection
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @notice Hook that is called before any token transfer. This includes minting and burning.
* @dev Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be transferred to `to`.
* - When `from` is zero, `tokenId` will be minted to `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never zero at the same time.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param from Address from which the token is being transferred
* @param to Address to which the token is being transferred
* @param tokenId ID of the token being transferred
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @notice Hook that is called after any transfer of tokens. This includes minting and burning.
* @dev Calling conditions:
*
* - When `from` and `to` are both non-zero.
* - `from` and `to` are never zero at the same time.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param from Address from which the token has been transferred
* @param to Address to which the token has been transferred
* @param tokenId ID of the token that has been transferred
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "../multiasset/IERC5773.sol";
/**
* @title IERC6220
* @author RMRK team
* @notice Interface smart contract of the RMRK equippable module.
*/
interface IERC6220 is IERC5773 {
/**
* @notice Used to store the core structure of the `Equippable` RMRK lego.
* @return assetId The ID of the asset equipping a child
* @return childAssetId The ID of the asset used as equipment
* @return childId The ID of token that is equipped
* @return childEquippableAddress Address of the collection to which the child asset belongs to
*/
struct Equipment {
uint64 assetId;
uint64 childAssetId;
uint256 childId;
address childEquippableAddress;
}
/**
* @notice Used to provide a struct for inputing equip data.
* @dev Only used for input and not storage of data.
* @return tokenId ID of the token we are managing
* @return childIndex Index of a child in the list of token's active children
* @return assetId ID of the asset that we are equipping into
* @return slotPartId ID of the slot part that we are using to equip
* @return childAssetId ID of the asset that we are equipping
*/
struct IntakeEquip {
uint256 tokenId;
uint256 childIndex;
uint64 assetId;
uint64 slotPartId;
uint64 childAssetId;
}
/**
* @notice Used to notify listeners that a child's asset has been equipped into one of its parent assets.
* @param tokenId ID of the token that had an asset equipped
* @param assetId ID of the asset associated with the token we are equipping into
* @param slotPartId ID of the slot we are using to equip
* @param childId ID of the child token we are equipping into the slot
* @param childAddress Address of the child token's collection
* @param childAssetId ID of the asset associated with the token we are equipping
*/
event ChildAssetEquipped(
uint256 indexed tokenId,
uint64 indexed assetId,
uint64 indexed slotPartId,
uint256 childId,
address childAddress,
uint64 childAssetId
);
/**
* @notice Used to notify listeners that a child's asset has been unequipped from one of its parent assets.
* @param tokenId ID of the token that had an asset unequipped
* @param assetId ID of the asset associated with the token we are unequipping out of
* @param slotPartId ID of the slot we are unequipping from
* @param childId ID of the token being unequipped
* @param childAddress Address of the collection that a token that is being unequipped belongs to
* @param childAssetId ID of the asset associated with the token we are unequipping
*/
event ChildAssetUnequipped(
uint256 indexed tokenId,
uint64 indexed assetId,
uint64 indexed slotPartId,
uint256 childId,
address childAddress,
uint64 childAssetId
);
/**
* @notice Used to notify listeners that the assets belonging to a `equippableGroupId` have been marked as
* equippable into a given slot and parent
* @param equippableGroupId ID of the equippable group being marked as equippable into the slot associated with
* `slotPartId` of the `parentAddress` collection
* @param slotPartId ID of the slot part of the catalog into which the parts belonging to the equippable group
* associated with `equippableGroupId` can be equipped
* @param parentAddress Address of the collection into which the parts belonging to `equippableGroupId` can be
* equipped
*/
event ValidParentEquippableGroupIdSet(
uint64 indexed equippableGroupId,
uint64 indexed slotPartId,
address parentAddress
);
/**
* @notice Used to equip a child into a token.
* @dev The `IntakeEquip` stuct contains the following data:
* [
* tokenId,
* childIndex,
* assetId,
* slotPartId,
* childAssetId
* ]
* @param data An `IntakeEquip` struct specifying the equip data
*/
function equip(IntakeEquip memory data) external;
/**
* @notice Used to unequip child from parent token.
* @dev This can only be called by the owner of the token or by an account that has been granted permission to
* manage the given token by the current owner.
* @param tokenId ID of the parent from which the child is being unequipped
* @param assetId ID of the parent's asset that contains the `Slot` into which the child is equipped
* @param slotPartId ID of the `Slot` from which to unequip the child
*/
function unequip(
uint256 tokenId,
uint64 assetId,
uint64 slotPartId
) external;
/**
* @notice Used to check whether the token has a given child equipped.
* @dev This is used to prevent from transferring a child that is equipped.
* @param tokenId ID of the parent token for which we are querying for
* @param childAddress Address of the child token's smart contract
* @param childId ID of the child token
* @return A boolean value indicating whether the child token is equipped into the given token or not
*/
function isChildEquipped(
uint256 tokenId,
address childAddress,
uint256 childId
) external view returns (bool);
/**
* @notice Used to verify whether a token can be equipped into a given parent's slot.
* @param parent Address of the parent token's smart contract
* @param tokenId ID of the token we want to equip
* @param assetId ID of the asset associated with the token we want to equip
* @param slotId ID of the slot that we want to equip the token into
* @return A boolean indicating whether the token with the given asset can be equipped into the desired slot
*/
function canTokenBeEquippedWithAssetIntoSlot(
address parent,
uint256 tokenId,
uint64 assetId,
uint64 slotId
) external view returns (bool);
/**
* @notice Used to get the Equipment object equipped into the specified slot of the desired token.
* @dev The `Equipment` struct consists of the following data:
* [
* assetId,
* childAssetId,
* childId,
* childEquippableAddress
* ]
* @param tokenId ID of the token for which we are retrieving the equipped object
* @param targetCatalogAddress Address of the `Catalog` associated with the `Slot` part of the token
* @param slotPartId ID of the `Slot` part that we are checking for equipped objects
* @return The `Equipment` struct containing data about the equipped object
*/
function getEquipment(
uint256 tokenId,
address targetCatalogAddress,
uint64 slotPartId
) external view returns (Equipment memory);
/**
* @notice Used to get the asset and equippable data associated with given `assetId`.
* @param tokenId ID of the token for which to retrieve the asset
* @param assetId ID of the asset of which we are retrieving
* @return metadataURI The metadata URI of the asset
* @return equippableGroupId ID of the equippable group this asset belongs to
* @return catalogAddress The address of the catalog the part belongs to
* @return partIds An array of IDs of parts included in the asset
*/
function getAssetAndEquippableData(
uint256 tokenId,
uint64 assetId
)
external
view
returns (
string memory metadataURI,
uint64 equippableGroupId,
address catalogAddress,
uint64[] memory partIds
);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "../catalog/IRMRKCatalog.sol";
import "../core/RMRKCore.sol";
import "../equippable/IERC6220.sol";
import "../library/RMRKErrors.sol";
import "../library/RMRKLib.sol";
import "../nestable/IERC6059.sol";
import "../security/ReentrancyGuard.sol";
/**
* @title RMRKMinifiedEquippable
* @author RMRK team
* @notice Smart contract of the RMRK Equippable module, without utility internal functions.
* @dev This includes all the code for MultiAsset, Nestable and Equippable.
* @dev Most of the code is duplicated from the other legos, this version is created to save size.
*/
contract RMRKMinifiedEquippable is
ReentrancyGuard,
Context,
IERC165,
IERC721,
IERC6059,
IERC6220,
RMRKCore
{
using RMRKLib for uint64[];
using Address for address;
uint256 private constant _MAX_LEVELS_TO_CHECK_FOR_INHERITANCE_LOOP = 100;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approver address to approved address
// The approver is necessary so approvals are invalidated for nested children on transfer
// WARNING: If a child NFT returns to a previous root owner, old permissions would be active again
mapping(uint256 => mapping(address => address)) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// ------------------- NESTABLE --------------
// Mapping from token ID to DirectOwner struct
mapping(uint256 => DirectOwner) private _RMRKOwners;
// Mapping of tokenId to array of active children structs
mapping(uint256 => Child[]) internal _activeChildren;
// Mapping of tokenId to array of pending children structs
mapping(uint256 => Child[]) internal _pendingChildren;
// Mapping of child token address to child token ID to whether they are pending or active on any token
// We might have a first extra mapping from token ID, but since the same child cannot be nested into multiple tokens
// we can strip it for size/gas savings.
mapping(address => mapping(uint256 => uint256)) internal _childIsInActive;
// -------------------------- MODIFIERS ----------------------------
/**
* @notice Used to verify that the caller is either the owner of the token or approved to manage it by its owner.
* @dev If the caller is not the owner of the token or approved to manage it by its owner, the execution will be
* reverted.
* @param tokenId ID of the token to check
*/
function _onlyApprovedOrOwner(uint256 tokenId) private view {
address owner = ownerOf(tokenId);
if (
!(_msgSender() == owner ||
isApprovedForAll(owner, _msgSender()) ||
getApproved(tokenId) == _msgSender())
) revert ERC721NotApprovedOrOwner();
}
/**
* @notice Used to verify that the caller is either the owner of the token or approved to manage it by its owner.
* @param tokenId ID of the token to check
*/
modifier onlyApprovedOrOwner(uint256 tokenId) {
_onlyApprovedOrOwner(tokenId);
_;
}
/**
* @notice Used to verify that the caller is approved to manage the given token or it its direct owner.
* @dev This does not delegate to ownerOf, which returns the root owner, but rater uses an owner from DirectOwner
* struct.
* @dev The execution is reverted if the caller is not immediate owner or approved to manage the given token.
* @dev Used for parent-scoped transfers.
* @param tokenId ID of the token to check.
*/
function _onlyApprovedOrDirectOwner(uint256 tokenId) private view {
(address owner, uint256 parentId, ) = directOwnerOf(tokenId);
// When the parent is an NFT, only it can do operations. Otherwise, the owner or approved address can
if (
(parentId != 0 && _msgSender() != owner) ||
!(_msgSender() == owner ||
isApprovedForAll(owner, _msgSender()) ||
getApproved(tokenId) == _msgSender())
) {
revert RMRKNotApprovedOrDirectOwner();
}
}
/**
* @notice Used to verify that the caller is approved to manage the given token or is its direct owner.
* @param tokenId ID of the token to check
*/
modifier onlyApprovedOrDirectOwner(uint256 tokenId) {
_onlyApprovedOrDirectOwner(tokenId);
_;
}
// ------------------------------- ERC721 ---------------------------------
/**
* @notice Used to retrieve the number of tokens in `owner`'s account.
* @param owner Address of the account being checked
* @return The balance of the given account
*/
function balanceOf(address owner) public view virtual returns (uint256) {
if (owner == address(0)) revert ERC721AddressZeroIsNotaValidOwner();
return _balances[owner];
}
////////////////////////////////////////
// TRANSFERS
////////////////////////////////////////
/**
* @notice Transfers a given token from `from` to `to`.
* @dev 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}.
* @dev Emits a {Transfer} event.
* @param from Address from which to transfer the token from
* @param to Address to which to transfer the token to
* @param tokenId ID of the token to transfer
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual onlyApprovedOrDirectOwner(tokenId) {
_transfer(from, to, tokenId, "");
}
/**
* @notice Used to safely transfer a given token token from `from` to `to`.
* @dev 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.
* @dev Emits a {Transfer} event.
* @param from Address to transfer the tokens from
* @param to Address to transfer the tokens to
* @param tokenId ID of the token to transfer
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @notice Used to safely transfer a given token token from `from` to `to`.
* @dev 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.
* @dev Emits a {Transfer} event.
* @param from Address to transfer the tokens from
* @param to Address to transfer the tokens to
* @param tokenId ID of the token to transfer
* @param data Additional data without a specified format to be sent along with the token transaction
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual onlyApprovedOrDirectOwner(tokenId) {
_transfer(from, to, tokenId, data);
if (!_checkOnERC721Received(from, to, tokenId, data))
revert ERC721TransferToNonReceiverImplementer();
}
/**
* @inheritdoc IERC6059
*/
function nestTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 destinationId,
bytes memory data
) public virtual onlyApprovedOrDirectOwner(tokenId) {
(address immediateOwner, uint256 parentId, ) = directOwnerOf(tokenId);
if (immediateOwner != from) revert ERC721TransferFromIncorrectOwner();
if (to == address(0)) revert ERC721TransferToTheZeroAddress();
if (to == address(this) && tokenId == destinationId)
revert RMRKNestableTransferToSelf();
// Destination contract checks:
// It seems redundant, but otherwise it would revert with no error
if (!to.isContract()) revert RMRKIsNotContract();
if (!IERC165(to).supportsInterface(type(IERC6059).interfaceId))
revert RMRKNestableTransferToNonRMRKNestableImplementer();
_checkForInheritanceLoop(tokenId, to, destinationId);
_beforeTokenTransfer(from, to, tokenId);
_beforeNestedTokenTransfer(
immediateOwner,
to,
parentId,
destinationId,
tokenId,
data
);
_balances[from] -= 1;
_updateOwnerAndClearApprovals(tokenId, destinationId, to);
_balances[to] += 1;
// Sending to NFT:
_sendToNFT(immediateOwner, to, parentId, destinationId, tokenId, data);
}
/**
* @notice Used to transfer the token from `from` to `to`.
* @dev As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
* @dev Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* @dev Emits a {Transfer} event.
* @param from Address of the account currently owning the given token
* @param to Address to transfer the token to
* @param tokenId ID of the token to transfer
* @param data Additional data with no specified format, sent in call to `to`
*/
function _transfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
(address immediateOwner, uint256 parentId, ) = directOwnerOf(tokenId);
if (immediateOwner != from) revert ERC721TransferFromIncorrectOwner();
if (to == address(0)) revert ERC721TransferToTheZeroAddress();
_beforeTokenTransfer(from, to, tokenId);
_beforeNestedTokenTransfer(
immediateOwner,
to,
parentId,
0,
tokenId,
data
);
_balances[from] -= 1;
_updateOwnerAndClearApprovals(tokenId, 0, to);
_balances[to] += 1;
emit Transfer(from, to, tokenId);
emit NestTransfer(immediateOwner, to, parentId, 0, tokenId);
_afterTokenTransfer(from, to, tokenId);
_afterNestedTokenTransfer(
immediateOwner,
to,
parentId,
0,
tokenId,
data
);
}
/**
* @notice Used to send a token to another token.
* @dev If the token being sent is currently owned by an externally owned account, the `parentId` should equal `0`.
* @dev Emits {Transfer} event.
* @dev Emits {NestTransfer} event.
* @param from Address from which the token is being sent
* @param to Address of the collection smart contract of the token to receive the given token
* @param parentId ID of the current parent token of the token being sent
* @param destinationId ID of the tokento receive the token being sent
* @param tokenId ID of the token being sent
* @param data Additional data with no specified format, sent in the addChild call
*/
function _sendToNFT(
address from,
address to,
uint256 parentId,
uint256 destinationId,
uint256 tokenId,
bytes memory data
) private {
IERC6059 destContract = IERC6059(to);
destContract.addChild(destinationId, tokenId, data);
emit Transfer(from, to, tokenId);
emit NestTransfer(from, to, parentId, destinationId, tokenId);
_afterTokenTransfer(from, to, tokenId);
_afterNestedTokenTransfer(
from,
to,
parentId,
destinationId,
tokenId,
data
);
}
/**
* @notice Used to check if nesting a given token into a specified token would create an inheritance loop.
* @dev If a loop would occur, the tokens would be unmanageable, so the execution is reverted if one is detected.
* @dev The check for inheritance loop is bounded to guard against too much gas being consumed.
* @param currentId ID of the token that would be nested
* @param targetContract Address of the collection smart contract of the token into which the given token would be
* nested
* @param targetId ID of the token into which the given token would be nested
*/
function _checkForInheritanceLoop(
uint256 currentId,
address targetContract,
uint256 targetId
) private view {
for (uint256 i; i < _MAX_LEVELS_TO_CHECK_FOR_INHERITANCE_LOOP; ) {
(
address nextOwner,
uint256 nextOwnerTokenId,
bool isNft
) = IERC6059(targetContract).directOwnerOf(targetId);
// If there's a final address, we're good. There's no loop.
if (!isNft) {
return;
}
// Ff the current nft is an ancestor at some point, there is an inheritance loop
if (nextOwner == address(this) && nextOwnerTokenId == currentId) {
revert RMRKNestableTransferToDescendant();
}
// We reuse the parameters to save some contract size
targetContract = nextOwner;
targetId = nextOwnerTokenId;
unchecked {
++i;
}
}
revert RMRKNestableTooDeep();
}
////////////////////////////////////////
// MINTING
////////////////////////////////////////
/**
* @notice Used to safely mint the token to the specified address while passing the additional data to contract
* recipients.
* @param to Address to which to mint the token
* @param tokenId ID of the token to mint
* @param data Additional data to send with the tokens
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_innerMint(to, tokenId, 0, data);
emit Transfer(address(0), to, tokenId);
emit NestTransfer(address(0), to, 0, 0, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
_afterNestedTokenTransfer(address(0), to, 0, 0, tokenId, data);
if (!_checkOnERC721Received(address(0), to, tokenId, data))
revert ERC721TransferToNonReceiverImplementer();
}
/**
* @notice Used to mint a child token to a given parent token.
* @param to Address of the collection smart contract of the token into which to mint the child token
* @param tokenId ID of the token to mint
* @param destinationId ID of the token into which to mint the new child token
* @param data Additional data with no specified format, sent in the addChild call
*/
function _nestMint(
address to,
uint256 tokenId,
uint256 destinationId,
bytes memory data
) internal virtual {
// It seems redundant, but otherwise it would revert with no error
if (!to.isContract()) revert RMRKIsNotContract();
if (!IERC165(to).supportsInterface(type(IERC6059).interfaceId))
revert RMRKMintToNonRMRKNestableImplementer();
_innerMint(to, tokenId, destinationId, data);
_sendToNFT(address(0), to, 0, destinationId, tokenId, data);
}
/**
* @notice Used to mint a child token into a given parent token.
* @dev Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` must not exist.
* - `tokenId` must not be `0`.
* @param to Address of the collection smart contract of the token into which to mint the child token
* @param tokenId ID of the token to mint
* @param destinationId ID of the token into which to mint the new token
* @param data Additional data with no specified format, sent in call to `to`
*/
function _innerMint(
address to,
uint256 tokenId,
uint256 destinationId,
bytes memory data
) private {
if (to == address(0)) revert ERC721MintToTheZeroAddress();
if (_exists(tokenId)) revert ERC721TokenAlreadyMinted();
if (tokenId == uint256(0)) revert RMRKIdZeroForbidden();
_beforeTokenTransfer(address(0), to, tokenId);
_beforeNestedTokenTransfer(
address(0),
to,
0,
destinationId,
tokenId,
data
);
_balances[to] += 1;
_RMRKOwners[tokenId] = DirectOwner({
ownerAddress: to,
tokenId: destinationId
});
}
////////////////////////////////////////
// Ownership
////////////////////////////////////////
/**
* @inheritdoc IERC6059
*/
function ownerOf(
uint256 tokenId
) public view virtual override(IERC6059, IERC721) returns (address) {
(address owner, uint256 ownerTokenId, bool isNft) = directOwnerOf(
tokenId
);
if (isNft) {
owner = IERC6059(owner).ownerOf(ownerTokenId);
}
return owner;
}
/**
* @inheritdoc IERC6059
*/
function directOwnerOf(
uint256 tokenId
) public view virtual returns (address, uint256, bool) {
DirectOwner memory owner = _RMRKOwners[tokenId];
if (owner.ownerAddress == address(0)) revert ERC721InvalidTokenId();
return (owner.ownerAddress, owner.tokenId, owner.tokenId != 0);
}
////////////////////////////////////////
// BURNING
////////////////////////////////////////
/**
* @notice Used to burn a given token.
* @dev In case the token has any child tokens, the execution will be reverted.
* @param tokenId ID of the token to burn
*/
function burn(uint256 tokenId) public virtual {
burn(tokenId, 0);
}
/**
* @inheritdoc IERC6059
*/
function burn(
uint256 tokenId,
uint256 maxChildrenBurns
) public virtual onlyApprovedOrDirectOwner(tokenId) returns (uint256) {
(address immediateOwner, uint256 parentId, ) = directOwnerOf(tokenId);
address owner = ownerOf(tokenId);
_balances[immediateOwner] -= 1;
_beforeTokenTransfer(owner, address(0), tokenId);
_beforeNestedTokenTransfer(
immediateOwner,
address(0),
parentId,
0,
tokenId,
""
);
_approve(address(0), tokenId);
_approveForAssets(address(0), tokenId);
Child[] memory children = childrenOf(tokenId);
delete _activeChildren[tokenId];
delete _pendingChildren[tokenId];
delete _tokenApprovals[tokenId][owner];
uint256 pendingRecursiveBurns;
uint256 totalChildBurns;
uint256 length = children.length; //gas savings
for (uint256 i; i < length; ) {
if (totalChildBurns >= maxChildrenBurns)
revert RMRKMaxRecursiveBurnsReached(
children[i].contractAddress,
children[i].tokenId
);
delete _childIsInActive[children[i].contractAddress][
children[i].tokenId
];
unchecked {
// At this point we know pendingRecursiveBurns must be at least 1
pendingRecursiveBurns = maxChildrenBurns - totalChildBurns;
}
// We substract one to the next level to count for the token being burned, then add it again on returns
// This is to allow the behavior of 0 recursive burns meaning only the current token is deleted.
totalChildBurns +=
IERC6059(children[i].contractAddress).burn(
children[i].tokenId,
pendingRecursiveBurns - 1
) +
1;
unchecked {
++i;
}
}
// Can't remove before burning child since child will call back to get root owner
delete _RMRKOwners[tokenId];
emit Transfer(owner, address(0), tokenId);
emit NestTransfer(immediateOwner, address(0), parentId, 0, tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
_afterNestedTokenTransfer(
immediateOwner,
address(0),
parentId,
0,
tokenId,
""
);
return totalChildBurns;
}
////////////////////////////////////////
// APPROVALS
////////////////////////////////////////
/**
* @notice Used to grant a one-time approval to manage one's token.
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* @dev The approval is cleared when the token is transferred.
* @dev Only a single account can be approved at a time, so approving the zero address clears previous approvals.
* @dev Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
* @dev Emits an {Approval} event.
* @param to Address receiving the approval
* @param tokenId ID of the token for which the approval is being granted
*/
function approve(address to, uint256 tokenId) public virtual {
address owner = ownerOf(tokenId);
if (to == owner) revert ERC721ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender()))
revert ERC721ApproveCallerIsNotOwnerNorApprovedForAll();
_approve(to, tokenId);
}
/**
* @notice Used to retrieve the account approved to manage given token.
* @dev Requirements:
*
* - `tokenId` must exist.
* @param tokenId ID of the token to check for approval
* @return Address of the account approved to manage the token
*/
function getApproved(
uint256 tokenId
) public view virtual returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId][ownerOf(tokenId)];
}
/**
* @notice Used to approve or remove `operator` as an operator for the caller.
* @dev Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
* @dev Requirements:
*
* - The `operator` cannot be the caller.
* @dev Emits an {ApprovalForAll} event.
* @param operator Address of the operator being managed
* @param approved A boolean value signifying whether the approval is being granted (`true`) or (`revoked`)
*/
function setApprovalForAll(address operator, bool approved) public virtual {
if (_msgSender() == operator) revert ERC721ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @notice Used to check if the given address is allowed to manage the tokens of the specified address.
* @param owner Address of the owner of the tokens
* @param operator Address being checked for approval
* @return A boolean value signifying whether the *operator* is allowed to manage the tokens of the *owner* (`true`)
* or not (`false`)
*/
function isApprovedForAll(
address owner,
address operator
) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @notice Used to grant an approval to manage a given token.
* @dev Emits an {Approval} event.
* @param to Address to which the approval is being granted
* @param tokenId ID of the token for which the approval is being granted
*/
function _approve(address to, uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_tokenApprovals[tokenId][owner] = to;
emit Approval(owner, to, tokenId);
}
/**
* @notice Used to update the owner of the token and clear the approvals associated with the previous owner.
* @dev The `destinationId` should equal `0` if the new owner is an externally owned account.
* @param tokenId ID of the token being updated
* @param destinationId ID of the token to receive the given token
* @param to Address of account to receive the token
*/
function _updateOwnerAndClearApprovals(
uint256 tokenId,
uint256 destinationId,
address to
) internal {
_RMRKOwners[tokenId] = DirectOwner({
ownerAddress: to,
tokenId: destinationId
});
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_approveForAssets(address(0), tokenId);
}
/**
* @notice Used to remove approvals for the current owner of the given token.
* @param tokenId ID of the token to clear the approvals for
*/
////////////////////////////////////////
// UTILS
////////////////////////////////////////
/**
* @notice Used to enforce that the given token has been minted.
* @dev Reverts if the `tokenId` has not been minted yet.
* @dev The validation checks whether the owner of a given token is a `0x0` address and considers it not minted if
* it is. This means that both tokens that haven't been minted yet as well as the ones that have already been
* burned will cause the transaction to be reverted.
* @param tokenId ID of the token to check
*/
function _requireMinted(uint256 tokenId) internal view virtual {
if (!_exists(tokenId)) revert ERC721InvalidTokenId();
}
/**
* @notice Used to check whether the given token exists.
* @dev Tokens start existing when they are minted (`_mint`) and stop existing when they are burned (`_burn`).
* @param tokenId ID of the token being checked
* @return A boolean value signifying whether the token exists
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _RMRKOwners[tokenId].ownerAddress != address(0);
}
/**
* @notice Used to invoke {IERC721Receiver-onERC721Received} on a target address.
* @dev The call is not executed if the target address is not a contract.
* @param from Address representing the previous owner of the given token
* @param to Yarget address that will receive the tokens
* @param tokenId ID of the token to be transferred
* @param data Optional data to send along with the call
* @return Boolean value signifying whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(
_msgSender(),
from,
tokenId,
data
)
returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == uint256(0)) {
revert ERC721TransferToNonReceiverImplementer();
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
////////////////////////////////////////
// CHILD MANAGEMENT PUBLIC
////////////////////////////////////////
/**
* @inheritdoc IERC6059
*/
function addChild(
uint256 parentId,
uint256 childId,
bytes memory data
) public virtual {
_requireMinted(parentId);
address childAddress = _msgSender();
if (!childAddress.isContract()) revert RMRKIsNotContract();
Child memory child = Child({
contractAddress: childAddress,
tokenId: childId
});
_beforeAddChild(parentId, childAddress, childId, data);
uint256 length = pendingChildrenOf(parentId).length;
if (length < 128) {
_pendingChildren[parentId].push(child);
} else {
revert RMRKMaxPendingChildrenReached();
}
// Previous length matches the index for the new child
emit ChildProposed(parentId, length, childAddress, childId);
_afterAddChild(parentId, childAddress, childId, data);
}
/**
* @inheritdoc IERC6059
*/
function acceptChild(
uint256 parentId,
uint256 childIndex,
address childAddress,
uint256 childId
) public virtual onlyApprovedOrOwner(parentId) {
_acceptChild(parentId, childIndex, childAddress, childId);
}
/**
* @notice Used to accept a pending child token for a given parent token.
* @dev This moves the child token from parent token's pending child tokens array into the active child tokens
* array.
* @dev Requirements:
*
* - `tokenId` must exist
* - `index` must be in range of the pending children array
* @dev Emits ***ChildAccepted*** event.
* @param parentId ID of the parent token for which the child token is being accepted
* @param childIndex Index of a child tokem in the given parent's pending children array
* @param childAddress Address of the collection smart contract of the child token expected to be located at the
* specified index of the given parent token's pending children array
* @param childId ID of the child token expected to be located at the specified index of the given parent token's
* pending children array
*/
function _acceptChild(
uint256 parentId,
uint256 childIndex,
address childAddress,
uint256 childId
) internal virtual {
Child memory child = pendingChildOf(parentId, childIndex);
_checkExpectedChild(child, childAddress, childId);
if (_childIsInActive[childAddress][childId] != 0)
revert RMRKChildAlreadyExists();
_beforeAcceptChild(parentId, childIndex, childAddress, childId);
// Remove from pending:
_removeChildByIndex(_pendingChildren[parentId], childIndex);
// Add to active:
_activeChildren[parentId].push(child);
_childIsInActive[childAddress][childId] = 1; // We use 1 as true
emit ChildAccepted(parentId, childIndex, childAddress, childId);
_afterAcceptChild(parentId, childIndex, childAddress, childId);
}
/**
* @inheritdoc IERC6059
*/
function rejectAllChildren(
uint256 tokenId,
uint256 maxRejections
) public virtual onlyApprovedOrOwner(tokenId) {
if (_pendingChildren[tokenId].length > maxRejections)
revert RMRKUnexpectedNumberOfChildren();
_beforeRejectAllChildren(tokenId);
delete _pendingChildren[tokenId];
emit AllChildrenRejected(tokenId);
_afterRejectAllChildren(tokenId);
}
/**
* @inheritdoc IERC6059
*/
function transferChild(
uint256 tokenId,
address to,
uint256 destinationId,
uint256 childIndex,
address childAddress,
uint256 childId,
bool isPending,
bytes memory data
) public virtual onlyApprovedOrOwner(tokenId) {
Child memory child;
if (isPending) {
child = pendingChildOf(tokenId, childIndex);
} else {
if (isChildEquipped(tokenId, childAddress, childId))
revert RMRKMustUnequipFirst();
child = childOf(tokenId, childIndex);
}
_checkExpectedChild(child, childAddress, childId);
_beforeTransferChild(
tokenId,
childIndex,
childAddress,
childId,
isPending,
data
);
if (isPending) {
_removeChildByIndex(_pendingChildren[tokenId], childIndex);
} else {
delete _childIsInActive[childAddress][childId];
_removeChildByIndex(_activeChildren[tokenId], childIndex);
}
if (to != address(0)) {
if (destinationId == uint256(0)) {
IERC721(childAddress).safeTransferFrom(
address(this),
to,
childId,
data
);
} else {
// Destination is an NFT
IERC6059(child.contractAddress).nestTransferFrom(
address(this),
to,
child.tokenId,
destinationId,
data
);
}
}
emit ChildTransferred(
tokenId,
childIndex,
childAddress,
childId,
isPending,
to == address(0)
);
_afterTransferChild(
tokenId,
childIndex,
childAddress,
childId,
isPending,
data
);
}
/**
* @notice Used to verify that the child being accessed is the intended child.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param child A Child struct of a child being accessed
* @param expectedAddress The address expected to be the one of the child
* @param expectedId The token ID expected to be the one of the child
*/
function _checkExpectedChild(
Child memory child,
address expectedAddress,
uint256 expectedId
) private pure {
if (
expectedAddress != child.contractAddress ||
expectedId != child.tokenId
) revert RMRKUnexpectedChildId();
}
////////////////////////////////////////
// CHILD MANAGEMENT GETTERS
////////////////////////////////////////
/**
* @inheritdoc IERC6059
*/
function childrenOf(
uint256 parentId
) public view virtual returns (Child[] memory) {
Child[] memory children = _activeChildren[parentId];
return children;
}
/**
* @inheritdoc IERC6059
*/
function pendingChildrenOf(
uint256 parentId
) public view virtual returns (Child[] memory) {
Child[] memory pendingChildren = _pendingChildren[parentId];
return pendingChildren;
}
/**
* @inheritdoc IERC6059
*/
function childOf(
uint256 parentId,
uint256 index
) public view virtual returns (Child memory) {
if (childrenOf(parentId).length <= index)
revert RMRKChildIndexOutOfRange();
Child memory child = _activeChildren[parentId][index];
return child;
}
/**
* @inheritdoc IERC6059
*/
function pendingChildOf(
uint256 parentId,
uint256 index
) public view virtual returns (Child memory) {
if (pendingChildrenOf(parentId).length <= index)
revert RMRKPendingChildIndexOutOfRange();
Child memory child = _pendingChildren[parentId][index];
return child;
}
// HOOKS
/**
* @notice Hook that is called before nested token transfer.
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param from Address from which the token is being transferred
* @param to Address to which the token is being transferred
* @param fromTokenId ID of the token from which the given token is being transferred
* @param toTokenId ID of the token to which the given token is being transferred
* @param tokenId ID of the token being transferred
* @param data Additional data with no specified format, sent in the addChild call
*/
function _beforeNestedTokenTransfer(
address from,
address to,
uint256 fromTokenId,
uint256 toTokenId,
uint256 tokenId,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called after nested token transfer.
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param from Address from which the token was transferred
* @param to Address to which the token was transferred
* @param fromTokenId ID of the token from which the given token was transferred
* @param toTokenId ID of the token to which the given token was transferred
* @param tokenId ID of the token that was transferred
* @param data Additional data with no specified format, sent in the addChild call
*/
function _afterNestedTokenTransfer(
address from,
address to,
uint256 fromTokenId,
uint256 toTokenId,
uint256 tokenId,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called before a child is added to the pending tokens array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that will receive a new pending child token
* @param childAddress Address of the collection smart contract of the child token expected to be located at the
* specified index of the given parent token's pending children array
* @param childId ID of the child token expected to be located at the specified index of the given parent token's
* pending children array
* @param data Additional data with no specified format
*/
function _beforeAddChild(
uint256 tokenId,
address childAddress,
uint256 childId,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called after a child is added to the pending tokens array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that has received a new pending child token
* @param childAddress Address of the collection smart contract of the child token expected to be located at the
* specified index of the given parent token's pending children array
* @param childId ID of the child token expected to be located at the specified index of the given parent token's
* pending children array
* @param data Additional data with no specified format
*/
function _afterAddChild(
uint256 tokenId,
address childAddress,
uint256 childId,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called before a child is accepted to the active tokens array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param parentId ID of the token that will accept a pending child token
* @param childIndex Index of the child token to accept in the given parent token's pending children array
* @param childAddress Address of the collection smart contract of the child token expected to be located at the
* specified index of the given parent token's pending children array
* @param childId ID of the child token expected to be located at the specified index of the given parent token's
* pending children array
*/
function _beforeAcceptChild(
uint256 parentId,
uint256 childIndex,
address childAddress,
uint256 childId
) internal virtual {}
/**
* @notice Hook that is called after a child is accepted to the active tokens array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param parentId ID of the token that has accepted a pending child token
* @param childIndex Index of the child token that was accpeted in the given parent token's pending children array
* @param childAddress Address of the collection smart contract of the child token that was expected to be located
* at the specified index of the given parent token's pending children array
* @param childId ID of the child token that was expected to be located at the specified index of the given parent
* token's pending children array
*/
function _afterAcceptChild(
uint256 parentId,
uint256 childIndex,
address childAddress,
uint256 childId
) internal virtual {}
/**
* @notice Hook that is called before a child is transferred from a given child token array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that will transfer a child token
* @param childIndex Index of the child token that will be transferred from the given parent token's children array
* @param childAddress Address of the collection smart contract of the child token that is expected to be located
* at the specified index of the given parent token's children array
* @param childId ID of the child token that is expected to be located at the specified index of the given parent
* token's children array
* @param isPending A boolean value signifying whether the child token is being transferred from the pending child
* tokens array (`true`) or from the active child tokens array (`false`)
* @param data Additional data with no specified format, sent in the addChild call
*/
function _beforeTransferChild(
uint256 tokenId,
uint256 childIndex,
address childAddress,
uint256 childId,
bool isPending,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called after a child is transferred from a given child token array of a given token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that has transferred a child token
* @param childIndex Index of the child token that was transferred from the given parent token's children array
* @param childAddress Address of the collection smart contract of the child token that was expected to be located
* at the specified index of the given parent token's children array
* @param childId ID of the child token that was expected to be located at the specified index of the given parent
* token's children array
* @param isPending A boolean value signifying whether the child token was transferred from the pending child tokens
* array (`true`) or from the active child tokens array (`false`)
* @param data Additional data with no specified format, sent in the addChild call
*/
function _afterTransferChild(
uint256 tokenId,
uint256 childIndex,
address childAddress,
uint256 childId,
bool isPending,
bytes memory data
) internal virtual {}
/**
* @notice Hook that is called before a pending child tokens array of a given token is cleared.
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that will reject all of the pending child tokens
*/
function _beforeRejectAllChildren(uint256 tokenId) internal virtual {}
/**
* @notice Hook that is called after a pending child tokens array of a given token is cleared.
* @dev To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
* @param tokenId ID of the token that has rejected all of the pending child tokens
*/
function _afterRejectAllChildren(uint256 tokenId) internal virtual {}
// HELPERS
/**
* @notice Used to remove a specified child token form an array using its index within said array.
* @dev The caller must ensure that the length of the array is valid compared to the index passed.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param array An array od Child struct containing info about the child tokens in a given child tokens array
* @param index An index of the child token to remove in the accompanying array
*/
function _removeChildByIndex(Child[] storage array, uint256 index) private {
array[index] = array[array.length - 1];
array.pop();
}
/// Mapping of uint64 Ids to asset metadata
mapping(uint64 => string) private _assets;
/// Mapping of tokenId to new asset, to asset to be replaced
mapping(uint256 => mapping(uint64 => uint64)) private _assetReplacements;
/// Mapping of tokenId to an array of active assets
/// @dev Active recurses is unbounded, getting all would reach gas limit at around 30k items
/// so we leave this as internal in case a custom implementation needs to implement pagination
mapping(uint256 => uint64[]) internal _activeAssets;
/// Mapping of tokenId to an array of pending assets
mapping(uint256 => uint64[]) internal _pendingAssets;
/// Mapping of tokenId to an array of priorities for active assets
mapping(uint256 => uint64[]) internal _activeAssetPriorities;
/// Mapping of tokenId to assetId to whether the token has this asset assigned
mapping(uint256 => mapping(uint64 => bool)) private _tokenAssets;
/// Mapping from owner to operator approvals for assets
mapping(address => mapping(address => bool))
private _operatorApprovalsForAssets;
/**
* @inheritdoc IERC5773
*/
function getAssetMetadata(
uint256 tokenId,
uint64 assetId
) public view virtual returns (string memory) {
if (!_tokenAssets[tokenId][assetId]) revert RMRKTokenDoesNotHaveAsset();
return _assets[assetId];
}
/**
* @inheritdoc IERC5773
*/
function getActiveAssets(
uint256 tokenId
) public view virtual returns (uint64[] memory) {
return _activeAssets[tokenId];
}
/**
* @inheritdoc IERC5773
*/
function getPendingAssets(
uint256 tokenId
) public view virtual returns (uint64[] memory) {
return _pendingAssets[tokenId];
}
/**
* @inheritdoc IERC5773
*/
function getActiveAssetPriorities(
uint256 tokenId
) public view virtual returns (uint64[] memory) {
return _activeAssetPriorities[tokenId];
}
/**
* @inheritdoc IERC5773
*/
function getAssetReplacements(
uint256 tokenId,
uint64 newAssetId
) public view virtual returns (uint64) {
return _assetReplacements[tokenId][newAssetId];
}
/**
* @inheritdoc IERC5773
*/
function isApprovedForAllForAssets(
address owner,
address operator
) public view virtual returns (bool) {
return _operatorApprovalsForAssets[owner][operator];
}
/**
* @inheritdoc IERC5773
*/
function setApprovalForAllForAssets(
address operator,
bool approved
) public virtual {
if (_msgSender() == operator)
revert RMRKApprovalForAssetsToCurrentOwner();
_operatorApprovalsForAssets[_msgSender()][operator] = approved;
emit ApprovalForAllForAssets(_msgSender(), operator, approved);
}
/**
* @notice Used to validate the index on the pending assets array
* @dev The call is reverted if the index is out of range or the asset Id is not present at the index.
* @param tokenId ID of the token that the asset is validated from
* @param index Index of the asset in the pending array
* @param assetId Id of the asset expected to be in the index
*/
function _validatePendingAssetAtIndex(
uint256 tokenId,
uint256 index,
uint64 assetId
) private view {
if (index >= _pendingAssets[tokenId].length)
revert RMRKIndexOutOfRange();
if (assetId != _pendingAssets[tokenId][index])
revert RMRKUnexpectedAssetId();
}
/**
* @notice Used to remove the asset at the index on the pending assets array
* @param tokenId ID of the token that the asset is being removed from
* @param index Index of the asset in the pending array
* @param assetId Id of the asset expected to be in the index
*/
function _removePendingAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) private {
_pendingAssets[tokenId].removeItemByIndex(index);
delete _assetReplacements[tokenId][assetId];
}
/**
* @notice Used to add an asset entry.
* @dev If the specified ID is already used by another asset, the execution will be reverted.
* @dev This internal function warrants custom access control to be implemented when used.
* @dev Emits ***AssetSet*** event.
* @param id ID of the asset to assign to the new asset
* @param metadataURI Metadata URI of the asset
*/
function _addAssetEntry(
uint64 id,
string memory metadataURI
) internal virtual {
if (id == uint64(0)) revert RMRKIdZeroForbidden();
if (bytes(_assets[id]).length > 0) revert RMRKAssetAlreadyExists();
_beforeAddAsset(id, metadataURI);
_assets[id] = metadataURI;
emit AssetSet(id);
_afterAddAsset(id, metadataURI);
}
/**
* @notice Used to add an asset to a token.
* @dev If the given asset is already added to the token, the execution will be reverted.
* @dev If the asset ID is invalid, the execution will be reverted.
* @dev If the token already has the maximum amount of pending assets (128), the execution will be
* reverted.
* @dev Emits ***AssetAddedToTokens*** event.
* @param tokenId ID of the token to add the asset to
* @param assetId ID of the asset to add to the token
* @param replacesAssetWithId ID of the asset to replace from the token's list of active assets
*/
function _addAssetToToken(
uint256 tokenId,
uint64 assetId,
uint64 replacesAssetWithId
) internal virtual {
if (_tokenAssets[tokenId][assetId]) revert RMRKAssetAlreadyExists();
if (bytes(_assets[assetId]).length == uint256(0))
revert RMRKNoAssetMatchingId();
if (_pendingAssets[tokenId].length >= 128)
revert RMRKMaxPendingAssetsReached();
_beforeAddAssetToToken(tokenId, assetId, replacesAssetWithId);
_tokenAssets[tokenId][assetId] = true;
_pendingAssets[tokenId].push(assetId);
if (replacesAssetWithId != uint64(0)) {
_assetReplacements[tokenId][assetId] = replacesAssetWithId;
}
uint256[] memory tokenIds = new uint256[](1);
tokenIds[0] = tokenId;
emit AssetAddedToTokens(tokenIds, assetId, replacesAssetWithId);
_afterAddAssetToToken(tokenId, assetId, replacesAssetWithId);
}
/**
* @notice Hook that is called before an asset is added.
* @param id ID of the asset
* @param metadataURI Metadata URI of the asset
*/
function _beforeAddAsset(
uint64 id,
string memory metadataURI
) internal virtual {}
/**
* @notice Hook that is called after an asset is added.
* @param id ID of the asset
* @param metadataURI Metadata URI of the asset
*/
function _afterAddAsset(
uint64 id,
string memory metadataURI
) internal virtual {}
/**
* @notice Hook that is called before adding an asset to a token's pending assets array.
* @dev If the asset doesn't intend to replace another asset, the `replacesAssetWithId` value should be `0`.
* @param tokenId ID of the token to which the asset is being added
* @param assetId ID of the asset that is being added
* @param replacesAssetWithId ID of the asset that this asset is attempting to replace
*/
function _beforeAddAssetToToken(
uint256 tokenId,
uint64 assetId,
uint64 replacesAssetWithId
) internal virtual {}
/**
* @notice Hook that is called after an asset has been added to a token's pending assets array.
* @dev If the asset doesn't intend to replace another asset, the `replacesAssetWithId` value should be `0`.
* @param tokenId ID of the token to which the asset is has been added
* @param assetId ID of the asset that is has been added
* @param replacesAssetWithId ID of the asset that this asset is attempting to replace
*/
function _afterAddAssetToToken(
uint256 tokenId,
uint64 assetId,
uint64 replacesAssetWithId
) internal virtual {}
/**
* @notice Hook that is called before an asset is accepted to a token's active assets array.
* @param tokenId ID of the token for which the asset is being accepted
* @param index Index of the asset in the token's pending assets array
* @param assetId ID of the asset expected to be located at the specified `index`
*/
function _beforeAcceptAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) internal virtual {}
/**
* @notice Hook that is called after an asset is accepted to a token's active assets array.
* @param tokenId ID of the token for which the asset has been accepted
* @param index Index of the asset in the token's pending assets array
* @param assetId ID of the asset expected to have been located at the specified `index`
*/
function _afterAcceptAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) internal virtual {}
/**
* @notice Hook that is called before rejecting an asset.
* @param tokenId ID of the token from which the asset is being rejected
* @param index Index of the asset in the token's pending assets array
* @param assetId ID of the asset expected to be located at the specified `index`
*/
function _beforeRejectAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) internal virtual {}
/**
* @notice Hook that is called after rejecting an asset.
* @param tokenId ID of the token from which the asset has been rejected
* @param index Index of the asset in the token's pending assets array
* @param assetId ID of the asset expected to have been located at the specified `index`
*/
function _afterRejectAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) internal virtual {}
/**
* @notice Hook that is called before rejecting all assets of a token.
* @param tokenId ID of the token from which all of the assets are being rejected
*/
function _beforeRejectAllAssets(uint256 tokenId) internal virtual {}
/**
* @notice Hook that is called after rejecting all assets of a token.
* @param tokenId ID of the token from which all of the assets have been rejected
*/
function _afterRejectAllAssets(uint256 tokenId) internal virtual {}
/**
* @notice Hook that is called before the priorities for token's assets is set.
* @param tokenId ID of the token for which the asset priorities are being set
* @param priorities[] An array of priorities for token's active resources
*/
function _beforeSetPriority(
uint256 tokenId,
uint64[] calldata priorities
) internal virtual {}
/**
* @notice Hook that is called after the priorities for token's assets is set.
* @param tokenId ID of the token for which the asset priorities have been set
* @param priorities[] An array of priorities for token's active resources
*/
function _afterSetPriority(
uint256 tokenId,
uint64[] calldata priorities
) internal virtual {}
// ------------------- ASSETS --------------
// ------------------- ASSET APPROVALS --------------
/**
* @notice Mapping from token ID to approver address to approved address for assets.
* @dev The approver is necessary so approvals are invalidated for nested children on transfer.
* @dev WARNING: If a child NFT returns the original root owner, old permissions would be active again.
*/
mapping(uint256 => mapping(address => address))
private _tokenApprovalsForAssets;
// ------------------- EQUIPPABLE --------------
/// Mapping of uint64 asset ID to corresponding catalog address.
mapping(uint64 => address) private _catalogAddresses;
/// Mapping of uint64 ID to asset object.
mapping(uint64 => uint64) private _equippableGroupIds;
/// Mapping of assetId to catalog parts applicable to this asset, both fixed and slot
mapping(uint64 => uint64[]) private _partIds;
/// Mapping of token ID to catalog address to slot part ID to equipment information. Used to compose an NFT.
mapping(uint256 => mapping(address => mapping(uint64 => Equipment)))
private _equipments;
/// Mapping of token ID to child (nestable) address to child ID to count of equipped items. Used to check if equipped.
mapping(uint256 => mapping(address => mapping(uint256 => uint256)))
private _equipCountPerChild;
/// Mapping of `equippableGroupId` to parent contract address and valid `slotId`.
mapping(uint64 => mapping(address => uint64)) private _validParentSlots;
/**
* @notice Used to verify that the caller is either the owner of the given token or approved to manage the token's assets
* of the owner.
* @param tokenId ID of the token that we are checking
*/
function _onlyApprovedForAssetsOrOwner(uint256 tokenId) internal view {
address owner = ownerOf(tokenId);
if (
!(_msgSender() == owner ||
isApprovedForAllForAssets(owner, _msgSender()) ||
getApprovedForAssets(tokenId) == _msgSender())
) revert RMRKNotApprovedForAssetsOrOwner();
}
/**
* @notice Used to ensure that the caller is either the owner of the given token or approved to manage the token's assets
* of the owner.
* @dev If that is not the case, the execution of the function will be reverted.
* @param tokenId ID of the token that we are checking
*/
modifier onlyApprovedForAssetsOrOwner(uint256 tokenId) {
_onlyApprovedForAssetsOrOwner(tokenId);
_;
}
// ----------------------------- CONSTRUCTOR ------------------------------
/**
* @notice Initializes the contract by setting a `name` and a `symbol` of the token collection.
* @param name_ Name of the token collection
* @param symbol_ Symbol of the token collection
*/
constructor(
string memory name_,
string memory symbol_
) RMRKCore(name_, symbol_) {}
/**
* @inheritdoc IERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override returns (bool) {
return
interfaceId == type(IERC165).interfaceId ||
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC6059).interfaceId ||
interfaceId == type(IERC5773).interfaceId ||
interfaceId == type(IERC6220).interfaceId;
}
// ------------------------------- ASSETS ------------------------------
// --------------------------- ASSET HANDLERS -------------------------
/**
* @notice Accepts a asset at from the pending array of given token.
* @dev Migrates the asset from the token's pending asset array to the token's active asset array.
* @dev Active assets cannot be removed by anyone, but can be replaced by a new asset.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - `index` must be in range of the length of the pending asset array.
* @dev Emits an {AssetAccepted} event.
* @param tokenId ID of the token for which to accept the pending asset
* @param index Index of the asset in the pending array to accept
* @param assetId ID of the asset that is being accepted
*/
function acceptAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) public virtual onlyApprovedForAssetsOrOwner(tokenId) {
_acceptAsset(tokenId, index, assetId);
}
/**
* @notice Used to accept a pending asset.
* @dev The call is reverted if there is no pending asset at a given index.
* @dev Emits ***AssetAccepted*** event.
* @param tokenId ID of the token for which to accept the pending asset
* @param index Index of the asset in the pending array to accept
* @param assetId ID of the asset to accept in token's pending array
*/
function _acceptAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) internal virtual {
_validatePendingAssetAtIndex(tokenId, index, assetId);
_beforeAcceptAsset(tokenId, index, assetId);
uint64 replacesId = _assetReplacements[tokenId][assetId];
uint256 replaceIndex;
bool replacefound;
if (replacesId != uint64(0))
(replaceIndex, replacefound) = _activeAssets[tokenId].indexOf(
replacesId
);
if (replacefound) {
// We don't want to remove and then push a new asset.
// This way we also keep the priority of the original asset
_activeAssets[tokenId][replaceIndex] = assetId;
delete _tokenAssets[tokenId][replacesId];
} else {
// We use the current size as next priority, by default priorities would be [0,1,2...]
_activeAssetPriorities[tokenId].push(
uint64(_activeAssets[tokenId].length)
);
_activeAssets[tokenId].push(assetId);
replacesId = uint64(0);
}
_removePendingAsset(tokenId, index, assetId);
emit AssetAccepted(tokenId, assetId, replacesId);
_afterAcceptAsset(tokenId, index, assetId);
}
/**
* @notice Rejects a asset from the pending array of given token.
* @dev Removes the asset from the token's pending asset array.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - `index` must be in range of the length of the pending asset array.
* @dev Emits a {AssetRejected} event.
* @param tokenId ID of the token that the asset is being rejected from
* @param index Index of the asset in the pending array to be rejected
* @param assetId ID of the asset that is being rejected
*/
function rejectAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) public virtual onlyApprovedForAssetsOrOwner(tokenId) {
_validatePendingAssetAtIndex(tokenId, index, assetId);
_beforeRejectAsset(tokenId, index, assetId);
_removePendingAsset(tokenId, index, assetId);
delete _tokenAssets[tokenId][assetId];
emit AssetRejected(tokenId, assetId);
_afterRejectAsset(tokenId, index, assetId);
}
/**
* @notice Rejects all assets from the pending array of a given token.
* @dev Effecitvely deletes the pending array.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* @dev Emits a {AssetRejected} event with assetId = 0.
* @param tokenId ID of the token of which to clear the pending array.
* @param maxRejections Maximum number of expected assets to reject, used to prevent from rejecting assets which
* arrive just before this operation.
*/
function rejectAllAssets(
uint256 tokenId,
uint256 maxRejections
) public virtual onlyApprovedForAssetsOrOwner(tokenId) {
uint256 len = _pendingAssets[tokenId].length;
if (len > maxRejections) revert RMRKUnexpectedNumberOfAssets();
_beforeRejectAllAssets(tokenId);
for (uint256 i; i < len; ) {
uint64 assetId = _pendingAssets[tokenId][i];
delete _assetReplacements[tokenId][assetId];
unchecked {
++i;
}
}
delete (_pendingAssets[tokenId]);
emit AssetRejected(tokenId, uint64(0));
_afterRejectAllAssets(tokenId);
}
/**
* @notice Sets a new priority array for a given token.
* @dev The priority array is a non-sequential list of `uint64`s, where the lowest value is considered highest
* priority.
* @dev Value `0` of a priority is a special case equivalent to unitialized.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - The length of `priorities` must be equal the length of the active assets array.
* @dev Emits a {AssetPrioritySet} event.
* @param tokenId ID of the token to set the priorities for
* @param priorities An array of priority values
*/
function setPriority(
uint256 tokenId,
uint64[] calldata priorities
) public virtual onlyApprovedForAssetsOrOwner(tokenId) {
uint256 length = priorities.length;
if (length != _activeAssets[tokenId].length)
revert RMRKBadPriorityListLength();
_beforeSetPriority(tokenId, priorities);
_activeAssetPriorities[tokenId] = priorities;
emit AssetPrioritySet(tokenId);
_afterSetPriority(tokenId, priorities);
}
// --------------------------- ASSET INTERNALS -------------------------
/**
* @notice Used to add a asset entry.
* @dev This internal function warrants custom access control to be implemented when used.
* @param id ID of the asset being added
* @param equippableGroupId ID of the equippable group being marked as equippable into the slot associated with
* `Parts` of the `Slot` type
* @param catalogAddress Address of the `Catalog` associated with the asset
* @param metadataURI The metadata URI of the asset
* @param partIds An array of IDs of fixed and slot parts to be included in the asset
*/
function _addAssetEntry(
uint64 id,
uint64 equippableGroupId,
address catalogAddress,
string memory metadataURI,
uint64[] memory partIds
) internal virtual {
_addAssetEntry(id, metadataURI);
if (catalogAddress == address(0) && partIds.length != 0)
revert RMRKCatalogRequiredForParts();
_catalogAddresses[id] = catalogAddress;
_equippableGroupIds[id] = equippableGroupId;
_partIds[id] = partIds;
}
// ----------------------- ASSET APPROVALS ------------------------
/**
* @notice Used to grant approvals for specific tokens to a specified address.
* @dev This can only be called by the owner of the token or by an account that has been granted permission to
* manage all of the owner's assets.
* @param to Address of the account to receive the approval to the specified token
* @param tokenId ID of the token for which we are granting the permission
*/
function approveForAssets(address to, uint256 tokenId) public virtual {
address owner = ownerOf(tokenId);
if (to == owner) revert RMRKApprovalForAssetsToCurrentOwner();
if (
_msgSender() != owner &&
!isApprovedForAllForAssets(owner, _msgSender())
) revert RMRKApproveForAssetsCallerIsNotOwnerNorApprovedForAll();
_approveForAssets(to, tokenId);
}
/**
* @notice Used to get the address of the user that is approved to manage the specified token from the current
* owner.
* @param tokenId ID of the token we are checking
* @return Address of the account that is approved to manage the token
*/
function getApprovedForAssets(
uint256 tokenId
) public view virtual returns (address) {
_requireMinted(tokenId);
return _tokenApprovalsForAssets[tokenId][ownerOf(tokenId)];
}
/**
* @notice Internal function for granting approvals for a specific token.
* @param to Address of the account we are granting an approval to
* @param tokenId ID of the token we are granting the approval for
*/
function _approveForAssets(address to, uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_tokenApprovalsForAssets[tokenId][owner] = to;
emit ApprovalForAssets(owner, to, tokenId);
}
// ------------------------------- EQUIPPING ------------------------------
/**
* @inheritdoc IERC6220
*/
function equip(
IntakeEquip memory data
) public virtual onlyApprovedOrOwner(data.tokenId) nonReentrant {
address catalogAddress = _catalogAddresses[data.assetId];
uint64 slotPartId = data.slotPartId;
if (
_equipments[data.tokenId][catalogAddress][slotPartId]
.childEquippableAddress != address(0)
) revert RMRKSlotAlreadyUsed();
// Check from parent's asset perspective:
_checkAssetAcceptsSlot(data.assetId, slotPartId);
IERC6059.Child memory child = childOf(data.tokenId, data.childIndex);
// Check from child perspective intention to be used in part
// We add reentrancy guard because of this call, it happens before updating state
if (
!IERC6220(child.contractAddress)
.canTokenBeEquippedWithAssetIntoSlot(
address(this),
child.tokenId,
data.childAssetId,
slotPartId
)
) revert RMRKTokenCannotBeEquippedWithAssetIntoSlot();
// Check from catalog perspective
if (
!IRMRKCatalog(catalogAddress).checkIsEquippable(
slotPartId,
child.contractAddress
)
) revert RMRKEquippableEquipNotAllowedByCatalog();
_beforeEquip(data);
Equipment memory newEquip = Equipment({
assetId: data.assetId,
childAssetId: data.childAssetId,
childId: child.tokenId,
childEquippableAddress: child.contractAddress
});
_equipments[data.tokenId][catalogAddress][slotPartId] = newEquip;
_equipCountPerChild[data.tokenId][child.contractAddress][
child.tokenId
] += 1;
emit ChildAssetEquipped(
data.tokenId,
data.assetId,
slotPartId,
child.tokenId,
child.contractAddress,
data.childAssetId
);
_afterEquip(data);
}
/**
* @notice Private function to check if a given asset accepts a given slot or not.
* @dev Execution will be reverted if the `Slot` does not apply for the asset.
* @param assetId ID of the asset
* @param slotPartId ID of the `Slot`
*/
function _checkAssetAcceptsSlot(
uint64 assetId,
uint64 slotPartId
) private view {
(, bool found) = _partIds[assetId].indexOf(slotPartId);
if (!found) revert RMRKTargetAssetCannotReceiveSlot();
}
/**
* @inheritdoc IERC6220
*/
function unequip(
uint256 tokenId,
uint64 assetId,
uint64 slotPartId
) public virtual onlyApprovedOrOwner(tokenId) {
address targetCatalogAddress = _catalogAddresses[assetId];
Equipment memory equipment = _equipments[tokenId][targetCatalogAddress][
slotPartId
];
if (equipment.childEquippableAddress == address(0))
revert RMRKNotEquipped();
_beforeUnequip(tokenId, assetId, slotPartId);
delete _equipments[tokenId][targetCatalogAddress][slotPartId];
_equipCountPerChild[tokenId][equipment.childEquippableAddress][
equipment.childId
] -= 1;
emit ChildAssetUnequipped(
tokenId,
assetId,
slotPartId,
equipment.childId,
equipment.childEquippableAddress,
equipment.childAssetId
);
_afterUnequip(tokenId, assetId, slotPartId);
}
/**
* @inheritdoc IERC6220
*/
function isChildEquipped(
uint256 tokenId,
address childAddress,
uint256 childId
) public view virtual returns (bool) {
return _equipCountPerChild[tokenId][childAddress][childId] != 0;
}
// --------------------- ADMIN VALIDATION ---------------------
/**
* @notice Internal function used to declare that the assets belonging to a given `equippableGroupId` are
* equippable into the `Slot` associated with the `partId` of the collection at the specified `parentAddress`.
* @dev Emits ***ValidParentEquippableGroupIdSet*** event.
* @param equippableGroupId ID of the equippable group
* @param parentAddress Address of the parent into which the equippable group can be equipped into
* @param slotPartId ID of the `Slot` that the items belonging to the equippable group can be equipped into
*/
function _setValidParentForEquippableGroup(
uint64 equippableGroupId,
address parentAddress,
uint64 slotPartId
) internal virtual {
if (equippableGroupId == uint64(0) || slotPartId == uint64(0))
revert RMRKIdZeroForbidden();
_validParentSlots[equippableGroupId][parentAddress] = slotPartId;
emit ValidParentEquippableGroupIdSet(
equippableGroupId,
slotPartId,
parentAddress
);
}
/**
* @inheritdoc IERC6220
*/
function canTokenBeEquippedWithAssetIntoSlot(
address parent,
uint256 tokenId,
uint64 assetId,
uint64 slotId
) public view virtual returns (bool) {
uint64 equippableGroupId = _equippableGroupIds[assetId];
uint64 equippableSlot = _validParentSlots[equippableGroupId][parent];
if (equippableSlot == slotId) {
(, bool found) = getActiveAssets(tokenId).indexOf(assetId);
return found;
}
return false;
}
// --------------------- Getting Extended Assets ---------------------
/**
* @inheritdoc IERC6220
*/
function getAssetAndEquippableData(
uint256 tokenId,
uint64 assetId
)
public
view
virtual
returns (string memory, uint64, address, uint64[] memory)
{
return (
getAssetMetadata(tokenId, assetId),
_equippableGroupIds[assetId],
_catalogAddresses[assetId],
_partIds[assetId]
);
}
////////////////////////////////////////
// UTILS
////////////////////////////////////////
/**
* @inheritdoc IERC6220
*/
function getEquipment(
uint256 tokenId,
address targetCatalogAddress,
uint64 slotPartId
) public view virtual returns (Equipment memory) {
return _equipments[tokenId][targetCatalogAddress][slotPartId];
}
// HOOKS
/**
* @notice A hook to be called before a equipping a asset to the token.
* @dev The `IntakeEquip` struct consist of the following data:
* [
* tokenId,
* childIndex,
* assetId,
* slotPartId,
* childAssetId
* ]
* @param data The `IntakeEquip` struct containing data of the asset that is being equipped
*/
function _beforeEquip(IntakeEquip memory data) internal virtual {}
/**
* @notice A hook to be called after equipping a asset to the token.
* @dev The `IntakeEquip` struct consist of the following data:
* [
* tokenId,
* childIndex,
* assetId,
* slotPartId,
* childAssetId
* ]
* @param data The `IntakeEquip` struct containing data of the asset that was equipped
*/
function _afterEquip(IntakeEquip memory data) internal virtual {}
/**
* @notice A hook to be called before unequipping a asset from the token.
* @param tokenId ID of the token from which the asset is being unequipped
* @param assetId ID of the asset being unequipped
* @param slotPartId ID of the slot from which the asset is being unequipped
*/
function _beforeUnequip(
uint256 tokenId,
uint64 assetId,
uint64 slotPartId
) internal virtual {}
/**
* @notice A hook to be called after unequipping a asset from the token.
* @param tokenId ID of the token from which the asset was unequipped
* @param assetId ID of the asset that was unequipped
* @param slotPartId ID of the slot from which the asset was unequipped
*/
function _afterUnequip(
uint256 tokenId,
uint64 assetId,
uint64 slotPartId
) internal virtual {}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "../library/RMRKErrors.sol";
/**
* @title RMRKRoyalties
* @author RMRK team
* @notice Smart contract of the RMRK Royalties module.
*/
abstract contract RMRKRoyalties is IERC2981 {
address private _royaltyRecipient;
uint256 private _royaltyPercentageBps;
/**
* @notice Used to initiate the smart contract.
* @dev `royaltyPercentageBps` is expressed in basis points, so 1 basis point equals 0.01% and 500 basis points
* equal 5%.
* @param royaltyRecipient Address to which royalties should be sent
* @param royaltyPercentageBps The royalty percentage expressed in basis points
*/
constructor(
address royaltyRecipient,
uint256 royaltyPercentageBps //in basis points
) {
_setRoyaltyRecipient(royaltyRecipient);
if (royaltyPercentageBps >= 10000) revert RMRKRoyaltiesTooHigh();
_royaltyPercentageBps = royaltyPercentageBps;
}
/**
* @notice Used to update recipient of royalties.
* @dev Custom access control has to be implemented to ensure that only the intended actors can update the
* beneficiary.
* @param newRoyaltyRecipient Address of the new recipient of royalties
*/
function updateRoyaltyRecipient(
address newRoyaltyRecipient
) external virtual;
/**
* @notice Used to update the royalty recipient.
* @param newRoyaltyRecipient Address of the new recipient of royalties
*/
function _setRoyaltyRecipient(address newRoyaltyRecipient) internal {
_royaltyRecipient = newRoyaltyRecipient;
}
/**
* @notice Used to retrieve the recipient of royalties.
* @return Address of the recipient of royalties
*/
function getRoyaltyRecipient() public view virtual returns (address) {
return _royaltyRecipient;
}
/**
* @notice Used to retrieve the specified royalty percentage.
* @return The royalty percentage expressed in the basis points
*/
function getRoyaltyPercentage() public view virtual returns (uint256) {
return _royaltyPercentageBps;
}
/**
* @notice Used to retrieve the information about who shall receive royalties of a sale of the specified token and
* how much they will be.
* @param tokenId ID of the token for which the royalty info is being retrieved
* @param salePrice Price of the token sale
* @return receiver The beneficiary receiving royalties of the sale
* @return royaltyAmount The value of the royalties recieved by the `receiver` from the sale
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
)
external
view
virtual
override
returns (address receiver, uint256 royaltyAmount)
{
receiver = _royaltyRecipient;
royaltyAmount = (salePrice * _royaltyPercentageBps) / 10000;
}
}// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.18; /// @title RMRKErrors /// @author RMRK team /// @notice A collection of errors used in the RMRK suite /// @dev Errors are kept in a centralised file in order to provide a central point of reference and to avoid error /// naming collisions due to inheritance /// Attempting to grant the token to 0x0 address error ERC721AddressZeroIsNotaValidOwner(); /// Attempting to grant approval to the current owner of the token error ERC721ApprovalToCurrentOwner(); /// Attempting to grant approval when not being owner or approved for all should not be permitted error ERC721ApproveCallerIsNotOwnerNorApprovedForAll(); /// Attempting to get approvals for a token owned by 0x0 (considered non-existent) error ERC721ApprovedQueryForNonexistentToken(); /// Attempting to grant approval to self error ERC721ApproveToCaller(); /// Attempting to use an invalid token ID error ERC721InvalidTokenId(); /// Attempting to mint to 0x0 address error ERC721MintToTheZeroAddress(); /// Attempting to manage a token without being its owner or approved by the owner error ERC721NotApprovedOrOwner(); /// Attempting to mint an already minted token error ERC721TokenAlreadyMinted(); /// Attempting to transfer the token from an address that is not the owner error ERC721TransferFromIncorrectOwner(); /// Attempting to safe transfer to an address that is unable to receive the token error ERC721TransferToNonReceiverImplementer(); /// Attempting to transfer the token to a 0x0 address error ERC721TransferToTheZeroAddress(); /// Attempting to grant approval of assets to their current owner error RMRKApprovalForAssetsToCurrentOwner(); /// Attempting to grant approval of assets without being the caller or approved for all error RMRKApproveForAssetsCallerIsNotOwnerNorApprovedForAll(); /// Attempting to incorrectly configue a Catalog item error RMRKBadConfig(); /// Attempting to set the priorities with an array of length that doesn't match the length of active assets array error RMRKBadPriorityListLength(); /// Attempting to add an asset entry with `Part`s, without setting the `Catalog` address error RMRKCatalogRequiredForParts(); /// Attempting to transfer a soulbound (non-transferrable) token error RMRKCannotTransferSoulbound(); /// Attempting to accept a child that has already been accepted error RMRKChildAlreadyExists(); /// Attempting to interact with a child, using index that is higher than the number of children error RMRKChildIndexOutOfRange(); /// Attempting to find the index of a child token on a parent which does not own it. error RMRKChildNotFoundInParent(); /// Attempting to pass collaborator address array and collaborator permission array of different lengths error RMRKCollaboratorArraysNotEqualLength(); /// Attempting to register a collection that is already registered error RMRKCollectionAlreadyRegistered(); /// Attempting to manage or interact with colleciton that is not registered error RMRKCollectionNotRegistered(); /// Attempting to equip a `Part` with a child not approved by the Catalog error RMRKEquippableEquipNotAllowedByCatalog(); /// Attempting to use ID 0, which is not supported /// @dev The ID 0 in RMRK suite is reserved for empty values. Guarding against its use ensures the expected operation error RMRKIdZeroForbidden(); /// Attempting to interact with an asset, using index greater than number of assets error RMRKIndexOutOfRange(); /// Attempting to reclaim a child that can't be reclaimed error RMRKInvalidChildReclaim(); /// Attempting to interact with an end-user account when the contract account is expected error RMRKIsNotContract(); /// Attempting to interact with a contract that had its operation locked error RMRKLocked(); /// Attempting to add a pending child after the number of pending children has reached the limit (default limit is 128) error RMRKMaxPendingChildrenReached(); /// Attempting to add a pending asset after the number of pending assets has reached the limit (default limit is /// 128) error RMRKMaxPendingAssetsReached(); /// Attempting to burn a total number of recursive children higher than maximum set /// @param childContract Address of the collection smart contract in which the maximum number of recursive burns was reached /// @param childId ID of the child token at which the maximum number of recursive burns was reached error RMRKMaxRecursiveBurnsReached(address childContract, uint256 childId); /// Attempting to mint a number of tokens that would cause the total supply to be greater than maximum supply error RMRKMintOverMax(); /// Attempting to mint a nested token to a smart contract that doesn't support nesting error RMRKMintToNonRMRKNestableImplementer(); /// Attempting to pass complementary arrays of different lengths error RMRKMismachedArrayLength(); /// Attempting to transfer a child before it is unequipped error RMRKMustUnequipFirst(); /// Attempting to nest a child over the nestable limit (current limit is 100 levels of nesting) error RMRKNestableTooDeep(); /// Attempting to nest the token to own descendant, which would create a loop and leave the looped tokens in limbo error RMRKNestableTransferToDescendant(); /// Attempting to nest the token to a smart contract that doesn't support nesting error RMRKNestableTransferToNonRMRKNestableImplementer(); /// Attempting to nest the token into itself error RMRKNestableTransferToSelf(); /// Attempting to interact with an asset that can not be found error RMRKNoAssetMatchingId(); /// Attempting to manage an asset without owning it or having been granted permission by the owner to do so error RMRKNotApprovedForAssetsOrOwner(); /// Attempting to interact with a token without being its owner or having been granted permission by the /// owner to do so /// @dev When a token is nested, only the direct owner (NFT parent) can mange it. In that case, approved addresses are /// not allowed to manage it, in order to ensure the expected behaviour error RMRKNotApprovedOrDirectOwner(); /// Attempting to manage a collection without being the collection's collaborator error RMRKNotCollectionCollaborator(); /// Attemting to manage a collection without being the collection's issuer error RMRKNotCollectionIssuer(); /// Attempting to manage a collection without being the collection's issuer or collaborator error RMRKNotCollectionIssuerOrCollaborator(); /// Attempting to compose an asset wihtout having an associated Catalog error RMRKNotComposableAsset(); /// Attempting to unequip an item that isn't equipped error RMRKNotEquipped(); /// Attempting to interact with a management function without being the smart contract's owner error RMRKNotOwner(); /// Attempting to interact with a function without being the owner or contributor of the collection error RMRKNotOwnerOrContributor(); /// Attempting to manage a collection without being the specific address error RMRKNotSpecificAddress(); /// Attempting to manage a token without being its owner error RMRKNotTokenOwner(); /// Attempting to transfer the ownership to the 0x0 address error RMRKNewOwnerIsZeroAddress(); /// Attempting to assign a 0x0 address as a contributor error RMRKNewContributorIsZeroAddress(); /// Attemtping to use `Ownable` interface without implementing it error RMRKOwnableNotImplemented(); /// Attempting an operation requiring the token being nested, while it is not error RMRKParentIsNotNFT(); /// Attempting to add a `Part` with an ID that is already used error RMRKPartAlreadyExists(); /// Attempting to use a `Part` that doesn't exist error RMRKPartDoesNotExist(); /// Attempting to use a `Part` that is `Fixed` when `Slot` kind of `Part` should be used error RMRKPartIsNotSlot(); /// Attempting to interact with a pending child using an index greater than the size of pending array error RMRKPendingChildIndexOutOfRange(); /// Attempting to add an asset using an ID that has already been used error RMRKAssetAlreadyExists(); /// Attempting to equip an item into a slot that already has an item equipped error RMRKSlotAlreadyUsed(); /// Attempting to equip an item into a `Slot` that the target asset does not implement error RMRKTargetAssetCannotReceiveSlot(); /// Attempting to equip a child into a `Slot` and parent that the child's collection doesn't support error RMRKTokenCannotBeEquippedWithAssetIntoSlot(); /// Attempting to compose a NFT of a token without active assets error RMRKTokenDoesNotHaveAsset(); /// Attempting to determine the asset with the top priority on a token without assets error RMRKTokenHasNoAssets(); /// Attempting to accept or transfer a child which does not match the one at the specified index error RMRKUnexpectedChildId(); /// Attempting to reject all pending assets but more assets than expected are pending error RMRKUnexpectedNumberOfAssets(); /// Attempting to reject all pending children but children assets than expected are pending error RMRKUnexpectedNumberOfChildren(); /// Attempting to accept or reject an asset which does not match the one at the specified index error RMRKUnexpectedAssetId(); /// Attempting an operation expecting a parent to the token which is not the actual one error RMRKUnexpectedParent(); /// Attempting not to pass an empty array of equippable addresses when adding or setting the equippable addresses error RMRKZeroLengthIdsPassed(); /// Attempting to set the royalties to a value higher than 100% (10000 in base points) error RMRKRoyaltiesTooHigh(); /// Attempting to do a bulk operation on a token that is not owned by the caller error RMRKCanOnlyDoBulkOperationsOnOwnedTokens(); /// Attempting to do a bulk operation with multiple tokens at a time error RMRKCanOnlyDoBulkOperationsWithOneTokenAtATime();
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
/**
* @title RMRKLib
* @author RMRK team
* @notice RMRK library smart contract.
*/
library RMRKLib {
/**
* @notice Used to remove an item from the array using the specified index.
* @dev The item is removed by replacing it with the last item and removing the last element.
* @param array An array of items containing the item to be removed
* @param index Index of the item to remove
*/
function removeItemByIndex(uint64[] storage array, uint256 index) internal {
//Check to see if this is already gated by require in all calls
require(index < array.length);
array[index] = array[array.length - 1];
array.pop();
}
/**
* @notice Used to determine the index of the item in the array by spedifying its value.
* @dev This was adapted from Cryptofin-Solidity `arrayUtils`.
* @dev If the item is not found the index returned will equal `0`.
* @param A The array containing the item to be found
* @param a The value of the item to find the index of
* @return The index of the item in the array
* @return A boolean value specifying whether the item was found
*/
function indexOf(
uint64[] memory A,
uint64 a
) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i; i < length; ) {
if (A[i] == a) {
return (i, true);
}
unchecked {
++i;
}
}
return (0, false);
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IERC5773
* @author RMRK team
* @notice Interface smart contract of the RMRK multi asset module.
*/
interface IERC5773 is IERC165 {
/**
* @notice Used to notify listeners that an asset object is initialized at `assetId`.
* @param assetId ID of the asset that was initialized
*/
event AssetSet(uint64 indexed assetId);
/**
* @notice Used to notify listeners that an asset object at `assetId` is added to token's pending asset
* array.
* @param tokenIds An array of token IDs that received a new pending asset
* @param assetId ID of the asset that has been added to the token's pending assets array
* @param replacesId ID of the asset that would be replaced
*/
event AssetAddedToTokens(
uint256[] tokenIds,
uint64 indexed assetId,
uint64 indexed replacesId
);
/**
* @notice Used to notify listeners that an asset object at `assetId` is accepted by the token and migrated
* from token's pending assets array to active assets array of the token.
* @param tokenId ID of the token that had a new asset accepted
* @param assetId ID of the asset that was accepted
* @param replacesId ID of the asset that was replaced
*/
event AssetAccepted(
uint256 indexed tokenId,
uint64 indexed assetId,
uint64 indexed replacesId
);
/**
* @notice Used to notify listeners that an asset object at `assetId` is rejected from token and is dropped
* from the pending assets array of the token.
* @param tokenId ID of the token that had an asset rejected
* @param assetId ID of the asset that was rejected
*/
event AssetRejected(uint256 indexed tokenId, uint64 indexed assetId);
/**
* @notice Used to notify listeners that token's prioritiy array is reordered.
* @param tokenId ID of the token that had the asset priority array updated
*/
event AssetPrioritySet(uint256 indexed tokenId);
/**
* @notice Used to notify listeners that owner has granted an approval to the user to manage the assets of a
* given token.
* @dev Approvals must be cleared on transfer
* @param owner Address of the account that has granted the approval for all token's assets
* @param approved Address of the account that has been granted approval to manage the token's assets
* @param tokenId ID of the token on which the approval was granted
*/
event ApprovalForAssets(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
/**
* @notice Used to notify listeners that owner has granted approval to the user to manage assets of all of their
* tokens.
* @param owner Address of the account that has granted the approval for all assets on all of their tokens
* @param operator Address of the account that has been granted the approval to manage the token's assets on all of
* the tokens
* @param approved Boolean value signifying whether the permission has been granted (`true`) or revoked (`false`)
*/
event ApprovalForAllForAssets(
address indexed owner,
address indexed operator,
bool approved
);
/**
* @notice Accepts an asset at from the pending array of given token.
* @dev Migrates the asset from the token's pending asset array to the token's active asset array.
* @dev Active assets cannot be removed by anyone, but can be replaced by a new asset.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - `index` must be in range of the length of the pending asset array.
* @dev Emits an {AssetAccepted} event.
* @param tokenId ID of the token for which to accept the pending asset
* @param index Index of the asset in the pending array to accept
* @param assetId ID of the asset expected to be in the index
*/
function acceptAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) external;
/**
* @notice Rejects an asset from the pending array of given token.
* @dev Removes the asset from the token's pending asset array.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - `index` must be in range of the length of the pending asset array.
* @dev Emits a {AssetRejected} event.
* @param tokenId ID of the token that the asset is being rejected from
* @param index Index of the asset in the pending array to be rejected
* @param assetId ID of the asset expected to be in the index
*/
function rejectAsset(
uint256 tokenId,
uint256 index,
uint64 assetId
) external;
/**
* @notice Rejects all assets from the pending array of a given token.
* @dev Effecitvely deletes the pending array.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* @dev Emits a {AssetRejected} event with assetId = 0.
* @param tokenId ID of the token of which to clear the pending array.
* @param maxRejections Maximum number of expected assets to reject, used to prevent from rejecting assets which
* arrive just before this operation.
*/
function rejectAllAssets(uint256 tokenId, uint256 maxRejections) external;
/**
* @notice Sets a new priority array for a given token.
* @dev The priority array is a non-sequential list of `uint64`s, where the lowest value is considered highest
* priority.
* @dev Value `0` of a priority is a special case equivalent to unitialized.
* @dev Requirements:
*
* - The caller must own the token or be approved to manage the token's assets
* - `tokenId` must exist.
* - The length of `priorities` must be equal the length of the active assets array.
* @dev Emits a {AssetPrioritySet} event.
* @param tokenId ID of the token to set the priorities for
* @param priorities An array of priorities of active assets. The succesion of items in the priorities array
* matches that of the succesion of items in the active array
*/
function setPriority(
uint256 tokenId,
uint64[] calldata priorities
) external;
/**
* @notice Used to retrieve IDs of the active assets of given token.
* @dev Asset data is stored by reference, in order to access the data corresponding to the ID, call
* `getAssetMetadata(tokenId, assetId)`.
* @dev You can safely get 10k
* @param tokenId ID of the token to retrieve the IDs of the active assets
* @return An array of active asset IDs of the given token
*/
function getActiveAssets(
uint256 tokenId
) external view returns (uint64[] memory);
/**
* @notice Used to retrieve IDs of the pending assets of given token.
* @dev Asset data is stored by reference, in order to access the data corresponding to the ID, call
* `getAssetMetadata(tokenId, assetId)`.
* @param tokenId ID of the token to retrieve the IDs of the pending assets
* @return An array of pending asset IDs of the given token
*/
function getPendingAssets(
uint256 tokenId
) external view returns (uint64[] memory);
/**
* @notice Used to retrieve the priorities of the active resoources of a given token.
* @dev Asset priorities are a non-sequential array of uint64 values with an array size equal to active asset
* priorites.
* @param tokenId ID of the token for which to retrieve the priorities of the active assets
* @return An array of priorities of the active assets of the given token
*/
function getActiveAssetPriorities(
uint256 tokenId
) external view returns (uint64[] memory);
/**
* @notice Used to retrieve the asset that will be replaced if a given asset from the token's pending array
* is accepted.
* @dev Asset data is stored by reference, in order to access the data corresponding to the ID, call
* `getAssetMetadata(tokenId, assetId)`.
* @param tokenId ID of the token to check
* @param newAssetId ID of the pending asset which will be accepted
* @return ID of the asset which will be replaced
*/
function getAssetReplacements(
uint256 tokenId,
uint64 newAssetId
) external view returns (uint64);
/**
* @notice Used to fetch the asset metadata of the specified token's active asset with the given index.
* @dev Assets are stored by reference mapping `_assets[assetId]`.
* @dev Can be overriden to implement enumerate, fallback or other custom logic.
* @param tokenId ID of the token from which to retrieve the asset metadata
* @param assetId Asset Id, must be in the active assets array
* @return The metadata of the asset belonging to the specified index in the token's active assets
* array
*/
function getAssetMetadata(
uint256 tokenId,
uint64 assetId
) external view returns (string memory);
// Approvals
/**
* @notice Used to grant permission to the user to manage token's assets.
* @dev This differs from transfer approvals, as approvals are not cleared when the approved party accepts or
* rejects an asset, or sets asset priorities. This approval is cleared on token transfer.
* @dev Only a single account can be approved at a time, so approving the `0x0` address clears previous approvals.
* @dev Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
* @dev Emits an {ApprovalForAssets} event.
* @param to Address of the account to grant the approval to
* @param tokenId ID of the token for which the approval to manage the assets is granted
*/
function approveForAssets(address to, uint256 tokenId) external;
/**
* @notice Used to retrieve the address of the account approved to manage assets of a given token.
* @dev Requirements:
*
* - `tokenId` must exist.
* @param tokenId ID of the token for which to retrieve the approved address
* @return Address of the account that is approved to manage the specified token's assets
*/
function getApprovedForAssets(
uint256 tokenId
) external view returns (address);
/**
* @notice Used to add or remove an operator of assets for the caller.
* @dev Operators can call {acceptAsset}, {rejectAsset}, {rejectAllAssets} or {setPriority} for any token
* owned by the caller.
* @dev Requirements:
*
* - The `operator` cannot be the caller.
* @dev Emits an {ApprovalForAllForAssets} event.
* @param operator Address of the account to which the operator role is granted or revoked from
* @param approved The boolean value indicating whether the operator role is being granted (`true`) or revoked
* (`false`)
*/
function setApprovalForAllForAssets(
address operator,
bool approved
) external;
/**
* @notice Used to check whether the address has been granted the operator role by a given address or not.
* @dev See {setApprovalForAllForAssets}.
* @param owner Address of the account that we are checking for whether it has granted the operator role
* @param operator Address of the account that we are checking whether it has the operator role or not
* @return A boolean value indicating wehter the account we are checking has been granted the operator role
*/
function isApprovedForAllForAssets(
address owner,
address operator
) external view returns (bool);
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @title IERC6059
* @author RMRK team
* @notice Interface smart contract of the RMRK nestable module.
*/
interface IERC6059 is IERC165 {
/**
* @notice The core struct of RMRK ownership.
* @dev The `DirectOwner` struct is used to store information of the next immediate owner, be it the parent token or
* the externally owned account.
* @dev If the token is owned by the externally owned account, the `tokenId` should equal `0`.
* @param tokenId ID of the parent token
* @param ownerAddress Address of the owner of the token. If the owner is another token, then the address should be
* the one of the parent token's collection smart contract. If the owner is externally owned account, the address
* should be the address of this account
* @param isNft A boolean value signifying whether the token is owned by another token (`true`) or by an externally
* owned account (`false`)
*/
struct DirectOwner {
uint256 tokenId;
address ownerAddress;
}
/**
* @notice Used to notify listeners that the token is being transferred.
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
* @param from Address of the previous immediate owner, which is a smart contract if the token was nested.
* @param to Address of the new immediate owner, which is a smart contract if the token is being nested.
* @param fromTokenId ID of the previous parent token. If the token was not nested before, the value should be `0`
* @param toTokenId ID of the new parent token. If the token is not being nested, the value should be `0`
* @param tokenId ID of the token being transferred
*/
event NestTransfer(
address indexed from,
address indexed to,
uint256 fromTokenId,
uint256 toTokenId,
uint256 indexed tokenId
);
/**
* @notice Used to notify listeners that a new token has been added to a given token's pending children array.
* @dev Emitted when a child NFT is added to a token's pending array.
* @param tokenId ID of the token that received a new pending child token
* @param childIndex Index of the proposed child token in the parent token's pending children array
* @param childAddress Address of the proposed child token's collection smart contract
* @param childId ID of the child token in the child token's collection smart contract
*/
event ChildProposed(
uint256 indexed tokenId,
uint256 childIndex,
address indexed childAddress,
uint256 indexed childId
);
/**
* @notice Used to notify listeners that a new child token was accepted by the parent token.
* @dev Emitted when a parent token accepts a token from its pending array, migrating it to the active array.
* @param tokenId ID of the token that accepted a new child token
* @param childIndex Index of the newly accepted child token in the parent token's active children array
* @param childAddress Address of the child token's collection smart contract
* @param childId ID of the child token in the child token's collection smart contract
*/
event ChildAccepted(
uint256 indexed tokenId,
uint256 childIndex,
address indexed childAddress,
uint256 indexed childId
);
/**
* @notice Used to notify listeners that all pending child tokens of a given token have been rejected.
* @dev Emitted when a token removes all a child tokens from its pending array.
* @param tokenId ID of the token that rejected all of the pending children
*/
event AllChildrenRejected(uint256 indexed tokenId);
/**
* @notice Used to notify listeners a child token has been transferred from parent token.
* @dev Emitted when a token transfers a child from itself, transferring ownership to the root owner.
* @param tokenId ID of the token that transferred a child token
* @param childIndex Index of a child in the array from which it is being transferred
* @param childAddress Address of the child token's collection smart contract
* @param childId ID of the child token in the child token's collection smart contract
* @param fromPending A boolean value signifying whether the token was in the pending child tokens array (`true`) or
* in the active child tokens array (`false`)
* @param toZero A boolean value signifying whether the token is being transferred to the `0x0` address (`true`) or
* not (`false`)
*/
event ChildTransferred(
uint256 indexed tokenId,
uint256 childIndex,
address indexed childAddress,
uint256 indexed childId,
bool fromPending,
bool toZero
);
/**
* @notice The core child token struct, holding the information about the child tokens.
* @return tokenId ID of the child token in the child token's collection smart contract
* @return contractAddress Address of the child token's smart contract
*/
struct Child {
uint256 tokenId;
address contractAddress;
}
/**
* @notice Used to retrieve the *root* owner of a given token.
* @dev The *root* owner of the token is an externally owned account (EOA). If the given token is child of another
* NFT, this will return an EOA address. Otherwise, if the token is owned by an EOA, this EOA wil be returned.
* @param tokenId ID of the token for which the *root* owner has been retrieved
* @return owner The *root* owner of the token
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @notice Used to retrieve the immediate owner of the given token.
* @dev If the immediate owner is another token, the address returned, should be the one of the parent token's
* collection smart contract.
* @param tokenId ID of the token for which the RMRK owner is being retrieved
* @return Address of the given token's owner
* @return The ID of the parent token. Should be `0` if the owner is an externally owned account
* @return The boolean value signifying whether the owner is an NFT or not
*/
function directOwnerOf(
uint256 tokenId
) external view returns (address, uint256, bool);
/**
* @notice Used to burn a given token.
* @dev When a token is burned, all of its child tokens are recursively burned as well.
* @dev When specifying the maximum recursive burns, the execution will be reverted if there are more children to be
* burned.
* @dev Setting the `maxRecursiveBurn` value to 0 will only attempt to burn the specified token and revert if there
* are any child tokens present.
* @dev The approvals are cleared when the token is burned.
* @dev Requirements:
*
* - `tokenId` must exist.
* @dev Emits a {Transfer} event.
* @param tokenId ID of the token to burn
* @param maxRecursiveBurns Maximum number of tokens to recursively burn
* @return Number of recursively burned children
*/
function burn(
uint256 tokenId,
uint256 maxRecursiveBurns
) external returns (uint256);
/**
* @notice Used to add a child token to a given parent token.
* @dev This adds the child token into the given parent token's pending child tokens array.
* @dev Requirements:
*
* - `directOwnerOf` on the child contract must resolve to the called contract.
* - the pending array of the parent contract must not be full.
* @param parentId ID of the parent token to receive the new child token
* @param childId ID of the new proposed child token
* @param data Additional data with no specified format
*/
function addChild(
uint256 parentId,
uint256 childId,
bytes memory data
) external;
/**
* @notice Used to accept a pending child token for a given parent token.
* @dev This moves the child token from parent token's pending child tokens array into the active child tokens
* array.
* @param parentId ID of the parent token for which the child token is being accepted
* @param childIndex Index of a child tokem in the given parent's pending children array
* @param childAddress Address of the collection smart contract of the child token expected to be located at the
* specified index of the given parent token's pending children array
* @param childId ID of the child token expected to be located at the specified index of the given parent token's
* pending children array
*/
function acceptChild(
uint256 parentId,
uint256 childIndex,
address childAddress,
uint256 childId
) external;
/**
* @notice Used to reject all pending children of a given parent token.
* @dev Removes the children from the pending array mapping.
* @dev This does not update the ownership storage data on children. If necessary, ownership can be reclaimed by the
* rootOwner of the previous parent.
* @dev Requirements:
*
* Requirements:
*
* - `parentId` must exist
* @param parentId ID of the parent token for which to reject all of the pending tokens.
* @param maxRejections Maximum number of expected children to reject, used to prevent from rejecting children which
* arrive just before this operation.
*/
function rejectAllChildren(
uint256 parentId,
uint256 maxRejections
) external;
/**
* @notice Used to transfer a child token from a given parent token.
* @dev When transferring a child token, the owner of the token is set to `to`, or is not updated in the event of
* `to` being the `0x0` address.
* @param tokenId ID of the parent token from which the child token is being transferred
* @param to Address to which to transfer the token to
* @param destinationId ID of the token to receive this child token (MUST be 0 if the destination is not a token)
* @param childIndex Index of a token we are transferring, in the array it belongs to (can be either active array or
* pending array)
* @param childAddress Address of the child token's collection smart contract.
* @param childId ID of the child token in its own collection smart contract.
* @param isPending A boolean value indicating whether the child token being transferred is in the pending array of
* the parent token (`true`) or in the active array (`false`)
* @param data Additional data with no specified format, sent in call to `_to`
*/
function transferChild(
uint256 tokenId,
address to,
uint256 destinationId,
uint256 childIndex,
address childAddress,
uint256 childId,
bool isPending,
bytes memory data
) external;
/**
* @notice Used to retrieve the active child tokens of a given parent token.
* @dev Returns array of Child structs existing for parent token.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param parentId ID of the parent token for which to retrieve the active child tokens
* @return An array of Child structs containing the parent token's active child tokens
*/
function childrenOf(
uint256 parentId
) external view returns (Child[] memory);
/**
* @notice Used to retrieve the pending child tokens of a given parent token.
* @dev Returns array of pending Child structs existing for given parent.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param parentId ID of the parent token for which to retrieve the pending child tokens
* @return An array of Child structs containing the parent token's pending child tokens
*/
function pendingChildrenOf(
uint256 parentId
) external view returns (Child[] memory);
/**
* @notice Used to retrieve a specific active child token for a given parent token.
* @dev Returns a single Child struct locating at `index` of parent token's active child tokens array.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param parentId ID of the parent token for which the child is being retrieved
* @param index Index of the child token in the parent token's active child tokens array
* @return A Child struct containing data about the specified child
*/
function childOf(
uint256 parentId,
uint256 index
) external view returns (Child memory);
/**
* @notice Used to retrieve a specific pending child token from a given parent token.
* @dev Returns a single Child struct locating at `index` of parent token's active child tokens array.
* @dev The Child struct consists of the following values:
* [
* tokenId,
* contractAddress
* ]
* @param parentId ID of the parent token for which the pending child token is being retrieved
* @param index Index of the child token in the parent token's pending child tokens array
* @return A Child struct containting data about the specified child
*/
function pendingChildOf(
uint256 parentId,
uint256 index
) external view returns (Child memory);
/**
* @notice Used to transfer the token into another token.
* @param from Address of the direct owner of the token to be transferred
* @param to Address of the receiving token's collection smart contract
* @param tokenId ID of the token being transferred
* @param destinationId ID of the token to receive the token being transferred
* @param data Additional data with no specified format, sent in the addChild call
*/
function nestTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 destinationId,
bytes memory data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.18;
error RentrantCall();
/**
* @title ReentrancyGuard
* @notice Smart contract used to guard against potential reentrancy exploits.
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
/**
* @notice Initializes the ReentrancyGuard with the `_status` of `_NOT_ENTERED`.
*/
constructor() {
_status = _NOT_ENTERED;
}
/**
* @notice Used to ensure that the function it is applied to cannot be reentered.
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantIn();
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @notice Used to ensure that the current call is not a reentrant call.
* @dev If reentrant call is detected, the execution will be reverted.
*/
function _nonReentrantIn() private {
// On the first call to nonReentrant, _notEntered will be true
if (_status == _ENTERED) revert RentrantCall();
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
/**
* @title RMRKCollectionMetadata
* @author RMRK team
* @notice Smart contract of the RMRK Collection metadata module.
*/
contract RMRKCollectionMetadata {
string private _collectionMetadata;
/**
* @notice Used to initialize the contract with the given metadata.
* @param collectionMetadata_ The collection metadata with which to initialize the smart contract
*/
constructor(string memory collectionMetadata_) {
_setCollectionMetadata(collectionMetadata_);
}
/**
* @notice Used to set the metadata of the collection.
* @param newMetadata The new metadata of the collection
*/
function _setCollectionMetadata(string memory newMetadata) internal {
_collectionMetadata = newMetadata;
}
/**
* @notice Used to retrieve the metadata of the collection.
* @return string The metadata URI of the collection
*/
function collectionMetadata() public view returns (string memory) {
return _collectionMetadata;
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.18;
interface IERC20Min {
function balanceOf(address account) external view returns (uint256);
}{
"optimizer": {
"enabled": true,
"runs": 80
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"string","name":"collectionMetadata_","type":"string"},{"internalType":"uint256","name":"maxGiftsPerPhase_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BadMigration","type":"error"},{"inputs":[],"name":"CannotUnequipElementGem","type":"error"},{"inputs":[],"name":"ERC721AddressZeroIsNotaValidOwner","type":"error"},{"inputs":[],"name":"ERC721ApprovalToCurrentOwner","type":"error"},{"inputs":[],"name":"ERC721ApproveCallerIsNotOwnerNorApprovedForAll","type":"error"},{"inputs":[],"name":"ERC721ApproveToCaller","type":"error"},{"inputs":[],"name":"ERC721InvalidTokenId","type":"error"},{"inputs":[],"name":"ERC721MintToTheZeroAddress","type":"error"},{"inputs":[],"name":"ERC721NotApprovedOrOwner","type":"error"},{"inputs":[],"name":"ERC721TokenAlreadyMinted","type":"error"},{"inputs":[],"name":"ERC721TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"ERC721TransferToNonReceiverImplementer","type":"error"},{"inputs":[],"name":"ERC721TransferToTheZeroAddress","type":"error"},{"inputs":[],"name":"MaxGiftsPerPhaseReached","type":"error"},{"inputs":[],"name":"MaxPhaseReached","type":"error"},{"inputs":[],"name":"MintOverMax","type":"error"},{"inputs":[],"name":"MintUnderpriced","type":"error"},{"inputs":[],"name":"MintZero","type":"error"},{"inputs":[],"name":"NextPhasePriceMustBeEqualOrHigher","type":"error"},{"inputs":[],"name":"RMRKApprovalForAssetsToCurrentOwner","type":"error"},{"inputs":[],"name":"RMRKApproveForAssetsCallerIsNotOwnerNorApprovedForAll","type":"error"},{"inputs":[],"name":"RMRKAssetAlreadyExists","type":"error"},{"inputs":[],"name":"RMRKBadPriorityListLength","type":"error"},{"inputs":[],"name":"RMRKCatalogRequiredForParts","type":"error"},{"inputs":[],"name":"RMRKChildAlreadyExists","type":"error"},{"inputs":[],"name":"RMRKChildIndexOutOfRange","type":"error"},{"inputs":[],"name":"RMRKEquippableEquipNotAllowedByCatalog","type":"error"},{"inputs":[],"name":"RMRKIdZeroForbidden","type":"error"},{"inputs":[],"name":"RMRKIndexOutOfRange","type":"error"},{"inputs":[],"name":"RMRKIsNotContract","type":"error"},{"inputs":[],"name":"RMRKMaxPendingAssetsReached","type":"error"},{"inputs":[],"name":"RMRKMaxPendingChildrenReached","type":"error"},{"inputs":[{"internalType":"address","name":"childContract","type":"address"},{"internalType":"uint256","name":"childId","type":"uint256"}],"name":"RMRKMaxRecursiveBurnsReached","type":"error"},{"inputs":[],"name":"RMRKMustUnequipFirst","type":"error"},{"inputs":[],"name":"RMRKNestableTooDeep","type":"error"},{"inputs":[],"name":"RMRKNestableTransferToDescendant","type":"error"},{"inputs":[],"name":"RMRKNestableTransferToNonRMRKNestableImplementer","type":"error"},{"inputs":[],"name":"RMRKNestableTransferToSelf","type":"error"},{"inputs":[],"name":"RMRKNewContributorIsZeroAddress","type":"error"},{"inputs":[],"name":"RMRKNewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"RMRKNoAssetMatchingId","type":"error"},{"inputs":[],"name":"RMRKNotApprovedForAssetsOrOwner","type":"error"},{"inputs":[],"name":"RMRKNotApprovedOrDirectOwner","type":"error"},{"inputs":[],"name":"RMRKNotEquipped","type":"error"},{"inputs":[],"name":"RMRKNotOwner","type":"error"},{"inputs":[],"name":"RMRKNotOwnerOrContributor","type":"error"},{"inputs":[],"name":"RMRKPendingChildIndexOutOfRange","type":"error"},{"inputs":[],"name":"RMRKRoyaltiesTooHigh","type":"error"},{"inputs":[],"name":"RMRKSlotAlreadyUsed","type":"error"},{"inputs":[],"name":"RMRKTargetAssetCannotReceiveSlot","type":"error"},{"inputs":[],"name":"RMRKTokenCannotBeEquippedWithAssetIntoSlot","type":"error"},{"inputs":[],"name":"RMRKTokenDoesNotHaveAsset","type":"error"},{"inputs":[],"name":"RMRKUnexpectedAssetId","type":"error"},{"inputs":[],"name":"RMRKUnexpectedChildId","type":"error"},{"inputs":[],"name":"RMRKUnexpectedNumberOfAssets","type":"error"},{"inputs":[],"name":"RMRKUnexpectedNumberOfChildren","type":"error"},{"inputs":[],"name":"RentrantCall","type":"error"},{"inputs":[],"name":"SaleNotOpen","type":"error"},{"inputs":[],"name":"SalePaused","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"AllChildrenRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAllForAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ApprovalForAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"replacesId","type":"uint64"}],"name":"AssetAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"replacesId","type":"uint64"}],"name":"AssetAddedToTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"AssetPrioritySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"AssetRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"AssetSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"childIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"childAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"childId","type":"uint256"}],"name":"ChildAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"slotPartId","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"childId","type":"uint256"},{"indexed":false,"internalType":"address","name":"childAddress","type":"address"},{"indexed":false,"internalType":"uint64","name":"childAssetId","type":"uint64"}],"name":"ChildAssetEquipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"assetId","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"slotPartId","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"childId","type":"uint256"},{"indexed":false,"internalType":"address","name":"childAddress","type":"address"},{"indexed":false,"internalType":"uint64","name":"childAssetId","type":"uint64"}],"name":"ChildAssetUnequipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"childIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"childAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"childId","type":"uint256"}],"name":"ChildProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"childIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"childAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"childId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"fromPending","type":"bool"},{"indexed":false,"internalType":"bool","name":"toZero","type":"bool"}],"name":"ChildTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"contributor","type":"address"},{"indexed":false,"internalType":"bool","name":"isContributor","type":"bool"}],"name":"ContributorUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"to","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"NestTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"equippableGroupId","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"slotPartId","type":"uint64"},{"indexed":false,"internalType":"address","name":"parentAddress","type":"address"}],"name":"ValidParentEquippableGroupIdSet","type":"event"},{"inputs":[],"name":"RMRK_INTERFACE","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"acceptAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"},{"internalType":"uint256","name":"childIndex","type":"uint256"},{"internalType":"address","name":"childAddress","type":"address"},{"internalType":"uint256","name":"childId","type":"uint256"}],"name":"acceptChild","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint64[]","name":"assetIds","type":"uint64[]"},{"internalType":"uint64","name":"replacesAssetWithId","type":"uint64"}],"name":"addAssetsToTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"},{"internalType":"uint256","name":"childId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"addChild","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"equippableGroupId","type":"uint64"},{"internalType":"address","name":"catalogAddress","type":"address"},{"internalType":"string[]","name":"metadataURI","type":"string[]"},{"internalType":"uint64[]","name":"partIds","type":"uint64[]"}],"name":"addEquippableAssetEntries","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approveForAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"maxChildrenBurns","type":"uint256"}],"name":"burn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"parent","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"},{"internalType":"uint64","name":"slotId","type":"uint64"}],"name":"canTokenBeEquippedWithAssetIntoSlot","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"childOf","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct IERC6059.Child","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"}],"name":"childrenOf","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct IERC6059.Child[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectionMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"directOwnerOf","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pricePerSoldier","type":"uint256"},{"internalType":"uint256","name":"pricePerCommander","type":"uint256"},{"internalType":"uint256","name":"pricePerGeneral","type":"uint256"}],"name":"enableNextPhase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"childIndex","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"},{"internalType":"uint64","name":"slotPartId","type":"uint64"},{"internalType":"uint64","name":"childAssetId","type":"uint64"}],"internalType":"struct IERC6220.IntakeEquip","name":"data","type":"tuple"}],"name":"equip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getActiveAssetPriorities","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getActiveAssets","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApprovedForAssets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"getAssetAndEquippableData","outputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"getAssetMetadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"newAssetId","type":"uint64"}],"name":"getAssetReplacements","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"targetCatalogAddress","type":"address"},{"internalType":"uint64","name":"slotPartId","type":"uint64"}],"name":"getEquipment","outputs":[{"components":[{"internalType":"uint64","name":"assetId","type":"uint64"},{"internalType":"uint64","name":"childAssetId","type":"uint64"},{"internalType":"uint256","name":"childId","type":"uint256"},{"internalType":"address","name":"childEquippableAddress","type":"address"}],"internalType":"struct IERC6220.Equipment","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPendingAssets","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRoyaltyPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRoyaltyRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"giftMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAllForAssets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"childAddress","type":"address"},{"internalType":"uint256","name":"childId","type":"uint256"}],"name":"isChildEquipped","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contributor","type":"address"}],"name":"isContributor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockPhases","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contributor","type":"address"},{"internalType":"bool","name":"grantRole","type":"bool"}],"name":"manageContributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"numToMint","type":"uint256"},{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"destinationId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"nestTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"pendingChildOf","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct IERC6059.Child","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentId","type":"uint256"}],"name":"pendingChildrenOf","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct IERC6059.Child[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"pricePerMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"maxRejections","type":"uint256"}],"name":"rejectAllAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"maxRejections","type":"uint256"}],"name":"rejectAllChildren","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"}],"name":"rejectAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAllForAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"assetId","type":"uint64"},{"internalType":"bool","name":"enumerated","type":"bool"}],"name":"setAssetEnumerated","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"}],"name":"setAutoAcceptCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64[]","name":"priorities","type":"uint64[]"}],"name":"setPriority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"slotPartId","type":"uint64"}],"name":"setSlotForElementGem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"equippableGroupId","type":"uint64"},{"internalType":"address","name":"parentAddress","type":"address"},{"internalType":"uint64","name":"partId","type":"uint64"}],"name":"setValidParentForEquippableGroup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum SnakeSoldier.Rank","name":"rank","type":"uint8"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"destinationId","type":"uint256"},{"internalType":"uint256","name":"childIndex","type":"uint256"},{"internalType":"address","name":"childAddress","type":"address"},{"internalType":"uint256","name":"childId","type":"uint256"},{"internalType":"bool","name":"isPending","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"transferChild","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"assetId","type":"uint64"},{"internalType":"uint64","name":"slotPartId","type":"uint64"}],"name":"unequip","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newRoyaltyRecipient","type":"address"}],"name":"updateRoyaltyRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawRaised","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a06040523480156200001157600080fd5b50604051620063bf380380620063bf833981016040819052620000349162000198565b6040518060400160405280600e81526020016d536e616b6520536f6c646965727360901b81525060405180604001604052806002815260200161535360f01b8152508181620000886200011a60201b60201c565b60016000556101f4876200009c336200011e565b620000a78162000170565b50600480546001600160a01b0319166001600160a01b0384161790556127108110620000e657604051634006185d60e11b815260040160405180910390fd5b600555506006620000f8838262000302565b50600762000107828262000302565b50505060809290925250620003ce915050565b3390565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60036200017e828262000302565b5050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215620001ac57600080fd5b82516001600160401b0380821115620001c457600080fd5b818501915085601f830112620001d957600080fd5b815181811115620001ee57620001ee62000182565b604051601f8201601f19908116603f0116810190838211818310171562000219576200021962000182565b816040528281526020935088848487010111156200023657600080fd5b600091505b828210156200025a57848201840151818301850152908301906200023b565b6000928101840192909252509401519395939450505050565b600181811c908216806200028857607f821691505b602082108103620002a957634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002fd57600081815260208120601f850160051c81016020861015620002d85750805b601f850160051c820191505b81811015620002f957828155600101620002e4565b5050505b505050565b81516001600160401b038111156200031e576200031e62000182565b62000336816200032f845462000273565b84620002af565b602080601f8311600181146200036e5760008415620003555750858301515b600019600386901b1c1916600185901b178555620002f9565b600085815260208120601f198616915b828110156200039f578886015182559484019460019091019084016200037e565b5085821015620003be5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051615fd5620003ea60003960006124a40152615fd56000f3fe6080604052600436106103bc5760003560e01c8063635490cc116101f4578063b88d4fde1161010e578063e467a48f116100a6578063e467a48f14610d3a578063e7de4de414610d5a578063e97ceaa814610d7a578063e985e9c514610d9a578063ee1dffcf14610de3578063f2fde38b14610e03578063f74b83c614610e23578063fb25fb7a14610e43578063fc3517c814610e8a578063ffa1ad7414610eaa57600080fd5b8063b88d4fde14610bf4578063c259a98814610c14578063c6824bae14610c34578063c87b56dd14610c54578063d5abeb0114610c74578063de8e602c14610c89578063defa80c314610ca9578063df6f556b14610cc9578063e425e25814610d2557600080fd5b806389bf627b1161018c57806389bf627b14610ac657806389ed2edf14610ae65780638d4f3bf514610afb5780638da5cb5b14610b2357806395d89b4114610b4157806395edc18c14610b565780639796133614610b74578063a22cb46514610b94578063a898e36414610bb4578063b390c0ab14610bd457600080fd5b8063635490cc146108dd57806365b67eb9146108fd5780636f19951c1461091d57806370a082311461093d578063715018a61461095d5780637280281e146109725780637507e2ae1461099257806379e8ca9e14610a865780638507dc2814610aa657600080fd5b806331a58a30116102e55780634876053d1161027d5780634876053d14610798578063496d9f44146107b85780634e60edba146107d857806351532e5a1461080857806359c8b7dd146108355780635e2e32921461084a5780635e94354a1461086a5780635ea72f361461088a5780636112e8ac146108aa5780636352211e146108bd57600080fd5b806331a58a301461066b578063326d526d1461068b57806333ed2845146106ab578063362b67f4146106cb57806338dcf74c146106eb57806342842e0e1461070b57806342966c681461072b57806344ec93441461074b57806346e948281461077857600080fd5b806316c38b3c1161035857806316c38b3c1461051157806318160ddd146105315780631d0d35f51461054657806322e6d1601461057f57806322f6da9c1461059f57806323b872dd146105bf5780632a55205a146105df5780632d8120b51461061e5780632f32f9371461063e57600080fd5b806301e1d114146103c157806301ffc9a7146103e55780630254976014610415578063064c0a3a1461043757806306fdde0314610457578063074334fb14610479578063081812fc14610499578063095ea7b3146104d15780630fc499f5146104f1575b600080fd5b3480156103cd57600080fd5b506026545b6040519081526020015b60405180910390f35b3480156103f157600080fd5b50610405610400366004614edc565b610edb565b60405190151581526020016103dc565b34801561042157600080fd5b50610435610430366004615057565b610f7e565b005b34801561044357600080fd5b50610435610452366004615185565b610fdb565b34801561046357600080fd5b5061046c6111d4565b6040516103dc919061524a565b34801561048557600080fd5b5061040561049436600461525d565b611266565b3480156104a557600080fd5b506104b96104b43660046152ac565b6112e0565b6040516001600160a01b0390911681526020016103dc565b3480156104dd57600080fd5b506104356104ec3660046152c5565b611326565b3480156104fd57600080fd5b5061043561050c3660046152f1565b6113b2565b34801561051d57600080fd5b5061043561052c36600461531c565b6113db565b34801561053d57600080fd5b506103d26113fb565b34801561055257600080fd5b506104056105613660046152f1565b6001600160a01b031660009081526002602052604090205460011490565b34801561058b57600080fd5b5061040561059a366004615339565b611434565b3480156105ab57600080fd5b506104356105ba366004615372565b611462565b3480156105cb57600080fd5b506104356105da3660046153a7565b6114dd565b3480156105eb57600080fd5b506105ff6105fa3660046153e8565b611502565b604080516001600160a01b0390931683526020830191909152016103dc565b34801561062a57600080fd5b506103d2610639366004615419565b611538565b34801561064a57600080fd5b5061065e6106593660046153e8565b61159a565b6040516103dc9190615434565b34801561067757600080fd5b50610435610686366004615454565b611633565b34801561069757600080fd5b506104356106a63660046152f1565b6116cd565b3480156106b757600080fd5b506104356106c63660046152c5565b6116f9565b3480156106d757600080fd5b506104356106e6366004615480565b61179c565b3480156106f757600080fd5b5061043561070636600461553f565b6117fd565b34801561071757600080fd5b506104356107263660046153a7565b611b61565b34801561073757600080fd5b506104356107463660046152ac565b611b7c565b34801561075757600080fd5b5061076b6107663660046152ac565b611b8b565b6040516103dc91906155c0565b34801561078457600080fd5b50610435610793366004615620565b611c0a565b3480156107a457600080fd5b506104356107b33660046156cb565b611c95565b3480156107c457600080fd5b506103d26107d3366004615419565b611cbf565b3480156107e457600080fd5b506107f86107f33660046156e6565b611d37565b6040516103dc949392919061574d565b34801561081457600080fd5b506108286108233660046152ac565b611e14565b6040516103dc9190615790565b34801561084157600080fd5b506005546103d2565b34801561085657600080fd5b5061046c6108653660046156e6565b611ea8565b34801561087657600080fd5b506108286108853660046152ac565b611f0b565b34801561089657600080fd5b506104356108a53660046152c5565b611f74565b6104356108b83660046157a3565b611ffb565b3480156108c957600080fd5b506104b96108d83660046152ac565b612047565b3480156108e957600080fd5b506104356108f83660046157d8565b6120d7565b34801561090957600080fd5b50610435610918366004615827565b6121f0565b34801561092957600080fd5b5061076b6109383660046152ac565b612203565b34801561094957600080fd5b506103d26109583660046152f1565b612273565b34801561096957600080fd5b506104356122b8565b34801561097e57600080fd5b5061082861098d3660046152ac565b6122cc565b34801561099e57600080fd5b50610a3c6109ad366004615863565b6040805160808082018352600080835260208084018290528385018290526060938401829052968152601a87528381206001600160a01b03968716825287528381206001600160401b03958616825287528390208351918201845280548086168352600160401b9004909416958101959095526001830154918501919091526002909101549091169082015290565b6040516103dc919081516001600160401b03908116825260208084015190911690820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b348015610a9257600080fd5b50610435610aa136600461588a565b612335565b348015610ab257600080fd5b50610435610ac136600461588a565b6123f2565b348015610ad257600080fd5b50610435610ae13660046158b8565b612488565b348015610af257600080fd5b5061046c612501565b348015610b0757600080fd5b50610b1663524d524b60e01b81565b6040516103dc91906158e4565b348015610b2f57600080fd5b506001546001600160a01b03166104b9565b348015610b4d57600080fd5b5061046c612510565b348015610b6257600080fd5b506004546001600160a01b03166104b9565b348015610b8057600080fd5b50610435610b8f3660046153e8565b61251f565b348015610ba057600080fd5b50610435610baf36600461588a565b61259f565b348015610bc057600080fd5b5061065e610bcf3660046153e8565b61262d565b348015610be057600080fd5b506103d2610bef3660046153e8565b61268a565b348015610c0057600080fd5b50610435610c0f3660046158f9565b6129f2565b348015610c2057600080fd5b50610435610c2f366004615958565b612a31565b348015610c4057600080fd5b506103d2610c4f366004615419565b612be2565b348015610c6057600080fd5b5061046c610c6f3660046152ac565b612c2d565b348015610c8057600080fd5b506103d2612cf5565b348015610c9557600080fd5b50610435610ca436600461597d565b612d1d565b348015610cb557600080fd5b50610435610cc43660046159fb565b612da1565b348015610cd557600080fd5b50610d0d610ce43660046156e6565b60009182526010602090815260408084206001600160401b039384168552909152909120541690565b6040516001600160401b0390911681526020016103dc565b348015610d3157600080fd5b50610435612fbc565b348015610d4657600080fd5b506104b9610d553660046152ac565b612fcb565b348015610d6657600080fd5b50610435610d753660046153e8565b612fee565b348015610d8657600080fd5b50610435610d95366004615a96565b6130ef565b348015610da657600080fd5b50610405610db5366004615339565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205460ff1690565b348015610def57600080fd5b50610405610dfe366004615ad5565b613105565b348015610e0f57600080fd5b50610435610e1e3660046152f1565b613136565b348015610e2f57600080fd5b50610435610e3e366004615afc565b61316e565b348015610e4f57600080fd5b50610e63610e5e3660046152ac565b6131b5565b604080516001600160a01b03909416845260208401929092521515908201526060016103dc565b348015610e9657600080fd5b50610435610ea5366004615372565b61321d565b348015610eb657600080fd5b5061046c60405180604001604052806005815260200164312e322e3160d81b81525081565b60006001600160e01b031982166301ffc9a760e01b1480610f0c57506001600160e01b031982166380ac58cd60e01b145b80610f2757506001600160e01b03198216635b5e139f60e01b145b80610f4257506001600160e01b031982166342b0e56f60e01b145b80610f5d57506001600160e01b0319821663035a194d60e11b145b80610f7857506001600160e01b03198216630a2f26b960e21b145b92915050565b610f86613232565b815160005b81811015610fd35760266000815460010191905081905550610fcb6026548787878581518110610fbd57610fbd615b18565b602002602001015187613271565b600101610f8b565b505050505050565b82610fe581613317565b600080610ff1866131b5565b5091509150876001600160a01b0316826001600160a01b0316146110285760405163e146af6f60e01b815260040160405180910390fd5b6001600160a01b03871661104f576040516338f646ff60e21b815260040160405180910390fd5b6001600160a01b0387163014801561106657508486145b1561108457604051633d76b10760e01b815260040160405180910390fd5b6001600160a01b0387163b6110ac5760405163b9d3114760e01b815260040160405180910390fd5b6040516301ffc9a760e01b81526001600160a01b038816906301ffc9a7906110df906342b0e56f60e01b906004016158e4565b602060405180830381865afa1580156110fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111209190615b2e565b61113d57604051631784ec7360e21b815260040160405180910390fd5b61114886888761339f565b611153888888613490565b6001600160a01b038816600090815260086020526040812080546001929061117c908490615b61565b9091555061118d905086868961352a565b6001600160a01b03871660009081526008602052604081208054600192906111b6908490615b74565b909155506111ca9050828883888a8961358b565b5050505050505050565b6060600680546111e390615b87565b80601f016020809104026020016040519081016040528092919081815260200182805461120f90615b87565b801561125c5780601f106112315761010080835404028352916020019161125c565b820191906000526020600020905b81548152906001019060200180831161123f57829003601f168201915b5050505050905090565b6001600160401b038083166000908152601860209081526040808320548416808452601c83528184206001600160a01b038a16855290925282205491929091811690841681036112d15760006112c5866112bf896122cc565b9061366c565b94506112d89350505050565b6000925050505b949350505050565b60006112eb826136d5565b60008281526009602052604081209061130384612047565b6001600160a01b0390811682526020820192909252604001600020541692915050565b600061133182612047565b9050806001600160a01b0316836001600160a01b03160361136557604051630591db6d60e01b815260040160405180910390fd5b336001600160a01b0382161480159061138557506113838133610db5565b155b156113a357604051634c12315960e11b815260040160405180910390fd5b6113ad83836136fb565b505050565b6113ba613774565b600480546001600160a01b0319166001600160a01b03831617905550565b50565b6113e3613774565b806113ef5760006113f2565b60015b60ff1660255550565b60006114076002611cbf565b6114116001611cbf565b61141b6000611cbf565b6114259190615b74565b61142f9190615b74565b905090565b6001600160a01b03918216600090815260156020908152604080832093909416825291909152205460ff1690565b8261146c8161379f565b611477848484613800565b6114828484846138a8565b60008481526014602090815260408083206001600160401b0386168085529252808320805460ff1916905551909186917f1010837a46db9510cad56c9b63e97183557a136e9d4ddbec309ce52c99afb1249190a35b50505050565b806114e781613317565b6114d7848484604051806020016040528060008152506138f5565b6004546005546001600160a01b0390911690600090612710906115259085615bc1565b61152f9190615bee565b90509250929050565b60008082600281111561154d5761154d615c02565b0361156057602354610f789060f0615bc1565b600182600281111561157457611574615c02565b0361158757602354610f78906009615bc1565b602354610f78906001615bc1565b919050565b6040805180820190915260008082526020820152816115b884612203565b51116115d75760405163653e642560e11b815260040160405180910390fd5b6000838152600c602052604081208054849081106115f7576115f7615b18565b60009182526020918290206040805180820190915260029092020180548252600101546001600160a01b03169181019190915291505092915050565b61163b613774565b6014602354148061164e57506024546001145b1561166c576040516307b486d360e41b815260040160405180910390fd5b82601d54118061167d575081601e54115b80611689575080601f54115b156116a757604051633ca0721160e21b815260040160405180910390fd5b6001602360008282546116ba9190615b74565b9091555050601d92909255601e55601f55565b6116d5613774565b6001600160a01b03166000908152602860205260409020805460ff19166001179055565b611701613774565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461174e576040519150601f19603f3d011682016040523d82523d6000602084013e611753565b606091505b50509050806113ad5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b60448201526064015b60405180910390fd5b6117a4613232565b825160005b818110156117f6576117ee8582815181106117c6576117c6615b18565b60200260200101518583815181106117e0576117e0615b18565b602002602001015185613a3a565b6001016117a9565b5050505050565b805161180881613c2f565b611810613c90565b6040808301516001600160401b0390811660009081526017602090815283822054606087015187518452601a83528584206001600160a01b0392831680865290845286852095821685529490925293909120600201549192909116156118895760405163bd0650ab60e01b815260040160405180910390fd5b611897846040015182613cba565b60006118ab8560000151866020015161159a565b60208101518151608088015160405163074334fb60e01b815230600482015260248101929092526001600160401b039081166044830152851660648201529192506001600160a01b03169063074334fb90608401602060405180830381865afa15801561191c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119409190615b2e565b61195d57604051632c36cd3360e01b815260040160405180910390fd5b6020810151604051636e5bceab60e11b81526001600160401b03841660048201526001600160a01b0391821660248201529084169063dcb79d5690604401602060405180830381865afa1580156119b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119dc9190615b2e565b6119f957604051637228eff560e11b815260040160405180910390fd5b6040805160808082018352878301516001600160401b0390811683529088015181166020808401918252855184860190815286820180516001600160a01b03908116606088019081528d516000908152601a86528981208d8416825286528981208c8916825286528981208951815498518a16600160401b026001600160801b031990991699169890981796909617875592516001808801919091559251600290960180549682166001600160a01b0319909716969096179095558b518452601b835286842090519094168352928152848220865183529052928320805492939192909190611ae9908490615b74565b92505081905550826001600160401b031686604001516001600160401b031687600001517f1f5de02b1d9c93ca468f54630e1daf13f6dc458a63f8061ff73e85bf9bc38884856000015186602001518b60800151604051611b4c93929190615c18565b60405180910390a45050600160005550505050565b6113ad838383604051806020016040528060008152506129f2565b611b8781600061268a565b5050565b6000818152600d60209081526040808320805482518185028101850190935280835260609493849084015b82821015611bfe5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611bb6565b50929695505050505050565b611c12613774565b8151602a546101f490611c26908390615b74565b1115611c4557604051630ddc056b60e21b815260040160405180910390fd5b80602a6000828254611c579190615b74565b90915550600090505b818110156114d757611c8d848281518110611c7d57611c7d615b18565b6020026020010151600185613d84565b600101611c60565b611c9d613774565b602b80546001600160401b0319166001600160401b0392909216919091179055565b600060226000836002811115611cd757611cd7615c02565b6002811115611ce857611ce8615c02565b81526020019081526020016000205460216000846002811115611d0d57611d0d615c02565b6002811115611d1e57611d1e615c02565b815260200190815260200160002054610f789190615b61565b60606000806060611d488686611ea8565b6001600160401b0380871660009081526018602090815260408083205460178352818420546019845293829020805483518186028101860190945280845291909516946001600160a01b039094169392839190830182828015611dfc57602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411611db95790505b50505050509050935093509350935092959194509250565b600081815260126020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411611e595790505b50505050509050919050565b60606000611eb68484613f27565b6001600160401b03841660009081526027602052604090205490915015611f045780611ee185614016565b604051602001611ef2929190615c40565b60405160208183030381529060405290505b9392505050565b600081815260136020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57600091825260209182902080546001600160401b03168452908202830192909160089101808411611e59575094979650505050505050565b6000611f7f82612047565b9050806001600160a01b0316836001600160a01b031603611fb3576040516375f45abd60e01b815260040160405180910390fd5b336001600160a01b03821614801590611fd35750611fd18133611434565b155b15611ff1576040516357a2e94960e11b815260040160405180910390fd5b6113ad83836140a8565b6120058282614121565b600061201082612be2565b61201a9084615bc1565b905034811461203c57604051632ec1a93b60e21b815260040160405180910390fd5b6114d7848484613d84565b600080600080612056856131b5565b92509250925080156120ce576040516331a9108f60e11b8152600481018390526001600160a01b03841690636352211e90602401602060405180830381865afa1580156120a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cb9190615c6f565b92505b50909392505050565b6120e0836136d5565b33803b6121005760405163b9d3114760e01b815260040160405180910390fd5b604080518082019091528381526001600160a01b0382166020820152600061212786611b8b565b5190506080811015612186576000868152600d60209081526040822080546001808201835591845292829020855160029094020192835590840151910180546001600160a01b0319166001600160a01b0390921691909117905561219f565b60405163a53c8c0560e01b815260040160405180910390fd5b84836001600160a01b0316877fe65085e689b77b126ba0bac3b079aa8288f19f4d5445af11c76003f8ab3075dd846040516121dc91815260200190565b60405180910390a4610fd3868487876141ee565b6121f8613232565b6113ad838383614237565b6000818152600c60209081526040808320805482518185028101850190935280835260609493849084018215611bfe5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611bb6565b60006001600160a01b03821661229c57604051633bb9143360e11b815260040160405180910390fd5b506001600160a01b031660009081526008602052604090205490565b6122c0613774565b6122ca60006142ea565b565b600081815260116020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57600091825260209182902080546001600160401b03168452908202830192909160089101808411611e59575094979650505050505050565b61233d613774565b6001600160a01b0382166123645760405163016b812760e71b815260040160405180910390fd5b80612389576001600160a01b03821660009081526002602052604081208190556123a8565b6001600160a01b03821660009081526002602052604090206001908190555b50816001600160a01b03167f4b5657e84cf8a17ac5587bbeb3cc2bab9826c4c67b8bad81b4849de49d37aac2826040516123e6911515815260200190565b60405180910390a25050565b6001600160a01b038216330361241b576040516375f45abd60e01b815260040160405180910390fd5b3360008181526015602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f0cff4fcf777050010027190b8061fd8bfd1de16d81b1f94e9752df1427a2623591015b60405180910390a35050565b612490613774565b61249b600182614121565b6023546124c8907f0000000000000000000000000000000000000000000000000000000000000000615bc1565b602954036124e957604051636e8bc3c360e01b815260040160405180910390fd5b602980546001908101909155611b8790839083613d84565b6060600380546111e390615b87565b6060600780546111e390615b87565b8161252981613c2f565b6000838152600d602052604090205482101561255857604051631e73178b60e11b815260040160405180910390fd5b6000838152600d6020526040812061256f91614d10565b60405183907f8ac4a0d65950c3e40448afb2260e2e0ec36ea15644d9b39e37e85472e5f9445190600090a2505050565b6001600160a01b03821633036125c857604051630b7b99b960e21b815260040160405180910390fd5b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910161247c565b60408051808201909152600080825260208201528161264b84611b8b565b511161266a5760405163da22687f60e01b815260040160405180910390fd5b6000838152600d602052604081208054849081106115f7576115f7615b18565b60008261269681613317565b6000806126a2866131b5565b509150915060006126b287612047565b6001600160a01b038416600090815260086020526040812080549293506001929091906126e0908490615b61565b909155506126f2905081600089613490565b60408051602081019091526000905261270c6000886136fb565b6127176000886140a8565b600061272288612203565b6000898152600c6020526040812091925061273d9190614d10565b6000888152600d6020526040812061275491614d10565b60008881526009602090815260408083206001600160a01b0386168452909152812080546001600160a01b031916905581518190815b81811015612955578a83106127ff578481815181106127ab576127ab615b18565b6020026020010151602001518582815181106127c9576127c9615b18565b6020908102919091010151516040516306177b2560e41b81526001600160a01b0390921660048301526024820152604401611793565b600e600086838151811061281557612815615b18565b6020026020010151602001516001600160a01b03166001600160a01b03168152602001908152602001600020600086838151811061285557612855615b18565b602002602001015160000151815260200190815260200160002060009055828b03935084818151811061288a5761288a615b18565b6020026020010151602001516001600160a01b031663b390c0ab8683815181106128b6576128b6615b18565b6020026020010151600001516001876128cf9190615b61565b6040516001600160e01b031960e085901b168152600481019290925260248201526044016020604051808303816000875af1158015612912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129369190615c8c565b612941906001615b74565b61294b9084615b74565b925060010161278a565b5060008b8152600b602052604080822082815560010180546001600160a01b0319169055518c91906001600160a01b03881690600080516020615f80833981519152908390a4604080518781526000602082018190528d9290916001600160a01b038b1691600080516020615f60833981519152910160405180910390a460408051602081019091526000905250965050505050505b5092915050565b816129fc81613317565b612a08858585856138f5565b612a148585858561433c565b6117f65760405163bcb5663760e01b815260040160405180910390fd5b82612a3b81613c2f565b6001600160401b03808416600090815260176020908152604080832054888452601a83528184206001600160a01b039182168086529084528285208887168652845293829020825160808101845281548088168252600160401b9004909616938601939093526001830154918501919091526002909101541660608301819052909190612adb576040516317de7dd760e21b815260040160405180910390fd5b612ae6868686614438565b6000868152601a602090815260408083206001600160a01b0380871685529083528184206001600160401b0389168552835281842080546001600160801b03191681556001808201869055600290910180546001600160a01b03191690558a8552601b8452828520606087015190921685529083528184208583015185529092528220805491929091612b7a908490615b61565b92505081905550836001600160401b0316856001600160401b0316877f438e039ebbba8f290f3b5d41aaf3295eccc9b5e6b0e1d52ace700772afb7da13846040015185606001518660200151604051612bd593929190615c18565b60405180910390a4610fd3565b600080826002811115612bf757612bf7615c02565b03612c04575050601d5490565b6001826002811115612c1857612c18615c02565b03612c25575050601e5490565b5050601f5490565b6060612c38826136d5565b6000612c4383611f0b565b805190915060416000805b83816001600160401b03161015612cb057600085826001600160401b031681518110612c7c57612c7c615b18565b60200260200101519050836001600160401b0316816001600160401b03161015612ca7578093508192505b50600101612c4e565b506000612cbc876122cc565b826001600160401b031681518110612cd657612cd6615b18565b60200260200101519050612cea8782611ea8565b979650505050505050565b6023546000906001612d09600960f0615b74565b612d139190615b74565b61142f9190615bc1565b82612d278161379f565b60008481526011602052604090205482908114612d5757604051633581be1d60e11b815260040160405180910390fd5b6000858152601360205260409020612d70908585614d31565b5060405185907ff0bfd70b0068f973d58178846ca67112671ec45e060838f7de5662036bcf801790600090a26117f6565b87612dab81613c2f565b60408051808201909152600080825260208201528315612dd657612dcf8a8861262d565b9050612e0c565b612de18a8787613105565b15612dff57604051630619dc9d60e21b815260040160405180910390fd5b612e098a8861159a565b90505b612e17818787614467565b8315612e3a5760008a8152600d60205260409020612e3590886144ab565b612e74565b6001600160a01b0386166000908152600e6020908152604080832088845282528083208390558c8352600c9091529020612e7490886144ab565b6001600160a01b03891615612f5e5787612ef157604051635c46a7ef60e11b81526001600160a01b0387169063b88d4fde90612eba9030908d908a908990600401615ca5565b600060405180830381600087803b158015612ed457600080fd5b505af1158015612ee8573d6000803e3d6000fd5b50505050612f5e565b60208101518151604051630326051d60e11b81526001600160a01b039092169163064c0a3a91612f2b9130918e918e908a90600401615ce2565b600060405180830381600087803b158015612f4557600080fd5b505af1158015612f59573d6000803e3d6000fd5b505050505b6040805188815285151560208201526001600160a01b038b81161582840152915187928916918d917f02d6d6dbcb604d5e1e8c7886456e82a9cdce88b0a580071358f206b5a4d58f709181900360600190a450505050505050505050565b612fc4613774565b6001602455565b6000612fd6826136d5565b60008281526016602052604081209061130384612047565b81612ff88161379f565b6000838152601260205260409020548281111561302857604051635134ce8960e01b815260040160405180910390fd5b60005b818110156130a557600085815260126020526040812080548390811061305357613053615b18565b6000918252602080832060048304015489845260108252604080852060039094166008026101000a9091046001600160401b03168452919052902080546001600160401b03191690555060010161302b565b5060008481526012602052604081206130bd91614df2565b60405160009085907f1010837a46db9510cad56c9b63e97183557a136e9d4ddbec309ce52c99afb124908390a36114d7565b836130f981613c2f565b6117f685858585614565565b6000928352601b602090815260408085206001600160a01b0394909416855292815282842091845252902054151590565b61313e613774565b6001600160a01b03811661316557604051634ece6ecf60e01b815260040160405180910390fd5b6113d8816142ea565b613176613774565b801561319a57506001600160401b0316600090815260276020526040902060019055565b506001600160401b0316600090815260276020526040812055565b6000818152600b60209081526040808320815180830190925280548252600101546001600160a01b031691810182905282918291906132075760405163089ba7e160e41b815260040160405180910390fd5b6020810151905190959094508415159350915050565b826132278161379f565b6114d7848484614673565b6001546001600160a01b03163314801590613253575061325133610561565b155b156122ca576040516301eca16760e41b815260040160405180910390fd5b61327b8583614889565b6001600160a01b0383161580156132925750805115155b156132b057604051631035ad0760e11b815260040160405180910390fd5b6001600160401b03858116600090815260176020908152604080832080546001600160a01b0319166001600160a01b0389161790556018825280832080546001600160401b03191694891694909417909355601981529190208251610fd392840190614e17565b600080613323836131b5565b5091509150806000141580156133425750336001600160a01b03831614155b806133815750336001600160a01b038316148061336457506133648233610db5565b8061337f575033613374846112e0565b6001600160a01b0316145b155b156113ad576040516345f3c98360e11b815260040160405180910390fd5b60005b6064811015613476576000806000856001600160a01b031663fb25fb7a866040518263ffffffff1660e01b81526004016133de91815260200190565b606060405180830381865afa1580156133fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341f9190615d1c565b925092509250806134335750505050505050565b6001600160a01b0383163014801561344a57508682145b15613468576040516324543e6d60e11b815260040160405180910390fd5b5090935091506001016133a2565b50604051630349a6bd60e51b815260040160405180910390fd5b6001600160a01b0382166113ad57600060146134ae60016009615b74565b6134b89190615bc1565b8211156134c7575060006134e6565b6134d360146001615bc1565b8211156134e2575060016134e6565b5060025b602260008260028111156134fc576134fc615c02565b600281111561350d5761350d615c02565b815260208101919091526040016000208054600101905550505050565b6040805180820182528381526001600160a01b0383811660208084019182526000888152600b9091529384209251835551600190920180546001600160a01b0319169290911691909117905561358090846136fb565b6113ad6000846140a8565b6040516318d5243360e21b815285906001600160a01b0382169063635490cc906135bd90879087908790600401615d5f565b600060405180830381600087803b1580156135d757600080fd5b505af11580156135eb573d6000803e3d6000fd5b5050505082866001600160a01b0316886001600160a01b0316600080516020615f8083398151915260405160405180910390a482866001600160a01b0316886001600160a01b0316600080516020615f60833981519152888860405161365b929190918252602082015260400190565b60405180910390a450505050505050565b81516000908190815b818110156136c457846001600160401b031686828151811061369957613699615b18565b60200260200101516001600160401b0316036136bc579250600191506136ce9050565b600101613675565b5060008092509250505b9250929050565b6136de8161494f565b6113d85760405163089ba7e160e41b815260040160405180910390fd5b600061370682612047565b60008381526009602090815260408083206001600160a01b038581168086529190935281842080546001600160a01b031916938916938417905590519394508593919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a4505050565b6001546001600160a01b031633146122ca57604051631c62d58f60e11b815260040160405180910390fd5b60006137aa82612047565b9050336001600160a01b03821614806137c857506137c88133611434565b806137e35750336137d883612fcb565b6001600160a01b0316145b611b8757604051635d64832960e01b815260040160405180910390fd5b600083815260126020526040902054821061382e57604051630757d52160e01b815260040160405180910390fd5b600083815260126020526040902080548390811061384e5761384e615b18565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03166001600160401b0316816001600160401b0316146113ad576040516378eeeecf60e01b815260040160405180910390fd5b60008381526012602052604090206138c0908361496f565b60009283526010602090815260408085206001600160401b03909316855291905290912080546001600160401b031916905550565b600080613901846131b5565b5091509150856001600160a01b0316826001600160a01b0316146139385760405163e146af6f60e01b815260040160405180910390fd5b6001600160a01b03851661395f576040516338f646ff60e21b815260040160405180910390fd5b61396a868686613490565b6001600160a01b0386166000908152600860205260408120805460019290613993908490615b61565b909155506139a590508460008761352a565b6001600160a01b03851660009081526008602052604081208054600192906139ce908490615b74565b909155505060405184906001600160a01b038088169190891690600080516020615f8083398151915290600090a483856001600160a01b0316836001600160a01b0316600080516020615f60833981519152846000604051612bd5929190918252602082015260400190565b60008381526014602090815260408083206001600160401b038616845290915290205460ff1615613a7e576040516308fe3c3160e41b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604081208054613aa190615b87565b905003613ac157604051632aa5eff960e11b815260040160405180910390fd5b600083815260126020526040902054608011613af05760405163bade3a7b60e01b815260040160405180910390fd5b60008381526014602090815260408083206001600160401b038681168086529184528285208054600160ff19909116811790915588865260128552928520805493840181558552929093206004820401805460039092166008026101000a808402199092169190930217909155811615613b9d5760008381526010602090815260408083206001600160401b038681168552925290912080546001600160401b0319169183169190911790555b604080516001808252818301909252600091602080830190803683370190505090508381600081518110613bd357613bd3615b18565b602002602001018181525050816001600160401b0316836001600160401b03167f4a85a0221f784dbe75db7c29c422f474c15bde9211a98e50a30018fa8dfa937b83604051613c229190615d87565b60405180910390a36114d7565b6000613c3a82612047565b9050336001600160a01b0382161480613c585750613c588133610db5565b80613c73575033613c68836112e0565b6001600160a01b0316145b611b87576040516302728a9d60e41b815260040160405180910390fd5b600260005403613cb3576040516362bfeae960e11b815260040160405180910390fd5b6002600055565b6001600160401b03821660009081526019602090815260408083208054825181850281018501909352808352613d63938693929190830182828015613d5057602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411613d0d5790505b505050505061366c90919063ffffffff16565b915050806113ad57604051634ef44ed560e01b815260040160405180910390fd5b6000613d8f82614a55565b60216000846002811115613da557613da5615c02565b6002811115613db657613db6615c02565b8152602001908152602001600020546001613dd19190615b74565b613ddb9190615b74565b90508260216000846002811115613df457613df4615c02565b6002811115613e0557613e05615c02565b8152602081019190915260400160009081208054909201909155613e298483615b74565b90506000825b82811015613ed157613e51878260405180602001604052806000815250614ab4565b6014613e5f60016009615b74565b613e699190615bc1565b811115613e795760019150613e9a565b613e8560146001615bc1565b811115613e955760059150613e9a565b600991505b613ea5600482615dcb565b613eaf9083615ddf565b9150613ebd81836000613a3a565b613ec981600084614673565b600101613e2f565b50613edd600183615b61565b83876001600160a01b03167f7ac572687bf4e66a8514fc2ec464fc2644c78bcb1d80a225fc51a33e0ee38bfa87604051613f179190615dff565b60405180910390a4505050505050565b60008281526014602090815260408083206001600160401b038516845290915290205460609060ff16613f6d57604051631b9928fd60e31b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604090208054613f9090615b87565b80601f0160208091040260200160405190810160405280929190818152602001828054613fbc90615b87565b80156140095780601f10613fde57610100808354040283529160200191614009565b820191906000526020600020905b815481529060010190602001808311613fec57829003601f168201915b5050505050905092915050565b6060600061402383614b47565b60010190506000816001600160401b0381111561404257614042614f25565b6040519080825280601f01601f19166020018201604052801561406c576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461407657509392505050565b60006140b382612047565b60008381526016602090815260408083206001600160a01b038581168086529190935281842080546001600160a01b031916938916938417905590519394508593919290917fb90cc0d925ac3511ab6af2d7ca73ffcf7ec4bd871fff36b958ecf440079c463e9190a4505050565b60235460000361414457604051631117739360e21b815260040160405180910390fd5b602554600103614167576040516308a98cbd60e41b815260040160405180910390fd5b816141855760405163220328c760e11b815260040160405180910390fd5b61418e81611538565b602160008360028111156141a4576141a4615c02565b60028111156141b5576141b5615c02565b815260200190815260200160002054836141cf9190615b74565b1115611b87576040516379027f2f60e01b815260040160405180910390fd5b6001600160a01b03831660009081526028602052604090205460ff16156114d7576000848152600d60205260409020546114d790859061423090600190615b61565b8585614565565b6001600160401b038316158061425457506001600160401b038116155b15614272576040516312c33ce360e01b815260040160405180910390fd5b6001600160401b038381166000818152601c602090815260408083206001600160a01b0388168085529083529281902080546001600160401b0319169587169586179055519182527f5b5af0622001a9b735a56357ddc1abd65e6a640126498674daf9d2fb05160725910160405180910390a3505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b1561443057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290614380903390899088908890600401615ca5565b6020604051808303816000875af19250505080156143bb575060408051601f3d908101601f191682019092526143b891810190615e27565b60015b614416573d8080156143e9576040519150601f19603f3d011682016040523d82523d6000602084013e6143ee565b606091505b50805161440e5760405163bcb5663760e01b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112d8565b5060016112d8565b602b546001600160401b03908116908216036113ad5760405163030bef8760e31b815260040160405180910390fd5b82602001516001600160a01b0316826001600160a01b031614158061448d575082518114155b156113ad57604051637383f2c160e11b815260040160405180910390fd5b815482906144bb90600190615b61565b815481106144cb576144cb615b18565b90600052602060002090600202018282815481106144eb576144eb615b18565b600091825260209091208254600290920201908155600191820154910180546001600160a01b0319166001600160a01b03909216919091179055815482908061453657614536615e44565b60008281526020812060026000199093019283020190815560010180546001600160a01b031916905590555050565b6000614571858561262d565b905061457e818484614467565b6001600160a01b0383166000908152600e60209081526040808320858452909152902054156145c05760405163188a497360e01b815260040160405180910390fd5b6000858152600d602052604090206145d890856144ab565b6000858152600c6020908152604080832080546001808201835591855283852086516002909202019081558584015190820180546001600160a01b0319166001600160a01b039283161790558716808552600e8452828520878652845293829020555186815284929188917f29486b9e2ae569b440933a9b1b421467306fa21f3dcad439c262910a634963a9910160405180910390a46117f6565b61467e838383613800565b60008381526010602090815260408083206001600160401b0380861685529252822054169080821561472c576147268360116000898152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015613d5057600091825260209182902080546001600160401b03168452908202830192909160089101808411613d0d579050505050505061366c90919063ffffffff16565b90925090505b80156147ad57600086815260116020526040902080548591908490811061475557614755615b18565b600091825260208083206004830401805460039093166008026101000a6001600160401b038181021990941695841602949094179093558882526014835260408083209187168352925220805460ff19169055614838565b6000868152601360209081526040808320601183529083208054825460018181018555938652848620600480830490910180546001600160401b0394851660086003958616810261010090810a9283029288021990931691909117909255855496870186559488529587209085040180548b84169590921690950290920a9283029202191617905592505b6148438686866138a8565b826001600160401b0316846001600160401b0316877f3f2709a99f6c06b4e57bbb38eb0134332f96f51a3da314f41a515adbb28b17cc60405160405180910390a4610fd3565b6001600160401b0382166148b0576040516312c33ce360e01b815260040160405180910390fd5b6001600160401b0382166000908152600f6020526040812080546148d390615b87565b905011156148f4576040516308fe3c3160e41b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604090206149168282615ea0565b506040516001600160401b038316907f3cd061096eaf881067d936308fbd8b81d060c45ab2ec910c02b953162befc10990600090a25050565b6000908152600b60205260409020600101546001600160a01b0316151590565b8154811061497c57600080fd5b8154829061498c90600190615b61565b8154811061499c5761499c615b18565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03168282815481106149d7576149d7615b18565b90600052602060002090600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b0316021790555081805480614a2057614a20615e44565b60008281526020902060046000199092019182040180546001600160401b03600860038516026101000a021916905590555050565b600080826002811115614a6a57614a6a615c02565b03614a87576014614a7d60016009615b74565b610f789190615bc1565b6001826002811115614a9b57614a9b615c02565b03614aac57610f7860146001615bc1565b506000919050565b614ac18383600084614c1f565b60405182906001600160a01b03851690600090600080516020615f80833981519152908290a46040805160008082526020820181905284926001600160a01b03871692600080516020615f60833981519152910160405180910390a4614b2a600084848461433c565b6113ad5760405163bcb5663760e01b815260040160405180910390fd5b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310614b865772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310614bb2576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310614bd057662386f26fc10000830492506010015b6305f5e1008310614be8576305f5e100830492506008015b6127108310614bfc57612710830492506004015b60648310614c0e576064830492506002015b600a8310610f785760010192915050565b6001600160a01b038416614c46576040516325bd6bd360e01b815260040160405180910390fd5b614c4f8361494f565b15614c6d5760405163c5a8d37160e01b815260040160405180910390fd5b82614c8b576040516312c33ce360e01b815260040160405180910390fd5b614c9760008585613490565b6001600160a01b0384166000908152600860205260408120805460019290614cc0908490615b74565b90915550506040805180820182529283526001600160a01b0394851660208085019182526000958652600b9052932091518255509051600190910180546001600160a01b03191691909216179055565b50805460008255600202906000526020600020908101906113d89190614e8a565b82805482825590600052602060002090600301600490048101928215614de25791602002820160005b83821115614dad5783356001600160401b031683826101000a8154816001600160401b0302191690836001600160401b031602179055509260200192600801602081600701049283019260010302614d5a565b8015614de05782816101000a8154906001600160401b030219169055600801602081600701049283019260010302614dad565b505b50614dee929150614eb1565b5090565b5080546000825560030160049004906000526020600020908101906113d89190614eb1565b82805482825590600052602060002090600301600490048101928215614de25791602002820160005b83821115614dad57835183826101000a8154816001600160401b0302191690836001600160401b031602179055509260200192600801602081600701049283019260010302614e40565b5b80821115614dee57600081556001810180546001600160a01b0319169055600201614e8b565b5b80821115614dee5760008155600101614eb2565b6001600160e01b0319811681146113d857600080fd5b600060208284031215614eee57600080fd5b8135611f0481614ec6565b80356001600160401b038116811461159557600080fd5b6001600160a01b03811681146113d857600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614f6357614f63614f25565b604052919050565b60006001600160401b03821115614f8457614f84614f25565b5060051b60200190565b60006001600160401b03831115614fa757614fa7614f25565b614fba601f8401601f1916602001614f3b565b9050828152838383011115614fce57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614ff657600080fd5b8135602061500b61500683614f6b565b614f3b565b82815260059290921b8401810191818101908684111561502a57600080fd5b8286015b8481101561504c5761503f81614ef9565b835291830191830161502e565b509695505050505050565b6000806000806080858703121561506d57600080fd5b61507685614ef9565b935060208086013561508781614f10565b93506040868101356001600160401b03808211156150a457600080fd5b818901915089601f8301126150b857600080fd5b81356150c661500682614f6b565b81815260059190911b8301850190858101908c8311156150e557600080fd5b8685015b83811015615131578035858111156151015760008081fd5b8601603f81018f136151135760008081fd5b6151238f8a8301358a8401614f8e565b8452509187019187016150e9565b5097505050606089013593508084111561514a57600080fd5b50505061515987828801614fe5565b91505092959194509250565b600082601f83011261517657600080fd5b611f0483833560208501614f8e565b600080600080600060a0868803121561519d57600080fd5b85356151a881614f10565b945060208601356151b881614f10565b9350604086013592506060860135915060808601356001600160401b038111156151e157600080fd5b6151ed88828901615165565b9150509295509295909350565b60005b838110156152155781810151838201526020016151fd565b50506000910152565b600081518084526152368160208601602086016151fa565b601f01601f19169290920160200192915050565b602081526000611f04602083018461521e565b6000806000806080858703121561527357600080fd5b843561527e81614f10565b93506020850135925061529360408601614ef9565b91506152a160608601614ef9565b905092959194509250565b6000602082840312156152be57600080fd5b5035919050565b600080604083850312156152d857600080fd5b82356152e381614f10565b946020939093013593505050565b60006020828403121561530357600080fd5b8135611f0481614f10565b80151581146113d857600080fd5b60006020828403121561532e57600080fd5b8135611f048161530e565b6000806040838503121561534c57600080fd5b823561535781614f10565b9150602083013561536781614f10565b809150509250929050565b60008060006060848603121561538757600080fd5b833592506020840135915061539e60408501614ef9565b90509250925092565b6000806000606084860312156153bc57600080fd5b83356153c781614f10565b925060208401356153d781614f10565b929592945050506040919091013590565b600080604083850312156153fb57600080fd5b50508035926020909101359150565b80356003811061159557600080fd5b60006020828403121561542b57600080fd5b611f048261540a565b815181526020808301516001600160a01b03169082015260408101610f78565b60008060006060848603121561546957600080fd5b505081359360208301359350604090920135919050565b60008060006060848603121561549557600080fd5b83356001600160401b03808211156154ac57600080fd5b818601915086601f8301126154c057600080fd5b813560206154d061500683614f6b565b82815260059290921b8401810191818101908a8411156154ef57600080fd5b948201945b8386101561550d578535825294820194908201906154f4565b9750508701359250508082111561552357600080fd5b5061553086828701614fe5565b92505061539e60408501614ef9565b600060a0828403121561555157600080fd5b60405160a081018181106001600160401b038211171561557357615573614f25565b8060405250823581526020830135602082015261559260408401614ef9565b60408201526155a360608401614ef9565b60608201526155b460808401614ef9565b60808201529392505050565b602080825282518282018190526000919060409081850190868401855b8281101561561357615603848351805182526020908101516001600160a01b0316910152565b92840192908501906001016155dd565b5091979650505050505050565b6000806040838503121561563357600080fd5b82356001600160401b0381111561564957600080fd5b8301601f8101851361565a57600080fd5b8035602061566a61500683614f6b565b82815260059290921b8301810191818101908884111561568957600080fd5b938201935b838510156156b05784356156a181614f10565b8252938201939082019061568e565b95506156bf905086820161540a565b93505050509250929050565b6000602082840312156156dd57600080fd5b611f0482614ef9565b600080604083850312156156f957600080fd5b8235915061152f60208401614ef9565b600081518084526020808501945080840160005b838110156157425781516001600160401b03168752958201959082019060010161571d565b509495945050505050565b608081526000615760608083018761521e565b6001600160401b03861660208401526001600160a01b03851660408401528281036060840152612cea8185615709565b602081526000611f046020830184615709565b6000806000606084860312156157b857600080fd5b83356157c381614f10565b92506020840135915061539e6040850161540a565b6000806000606084860312156157ed57600080fd5b833592506020840135915060408401356001600160401b0381111561581157600080fd5b61581d86828701615165565b9150509250925092565b60008060006060848603121561583c57600080fd5b61584584614ef9565b9250602084013561585581614f10565b915061539e60408501614ef9565b60008060006060848603121561587857600080fd5b83359250602084013561585581614f10565b6000806040838503121561589d57600080fd5b82356158a881614f10565b915060208301356153678161530e565b600080604083850312156158cb57600080fd5b82356158d681614f10565b915061152f6020840161540a565b6001600160e01b031991909116815260200190565b6000806000806080858703121561590f57600080fd5b843561591a81614f10565b9350602085013561592a81614f10565b92506040850135915060608501356001600160401b0381111561594c57600080fd5b61515987828801615165565b60008060006060848603121561596d57600080fd5b8335925061585560208501614ef9565b60008060006040848603121561599257600080fd5b8335925060208401356001600160401b03808211156159b057600080fd5b818601915086601f8301126159c457600080fd5b8135818111156159d357600080fd5b8760208260051b85010111156159e857600080fd5b6020830194508093505050509250925092565b600080600080600080600080610100898b031215615a1857600080fd5b883597506020890135615a2a81614f10565b965060408901359550606089013594506080890135615a4881614f10565b935060a0890135925060c0890135615a5f8161530e565b915060e08901356001600160401b03811115615a7a57600080fd5b615a868b828c01615165565b9150509295985092959890939650565b60008060008060808587031215615aac57600080fd5b84359350602085013592506040850135615ac581614f10565b9396929550929360600135925050565b600080600060608486031215615aea57600080fd5b8335925060208401356153d781614f10565b60008060408385031215615b0f57600080fd5b6158a883614ef9565b634e487b7160e01b600052603260045260246000fd5b600060208284031215615b4057600080fd5b8151611f048161530e565b634e487b7160e01b600052601160045260246000fd5b81810381811115610f7857610f78615b4b565b80820180821115610f7857610f78615b4b565b600181811c90821680615b9b57607f821691505b602082108103615bbb57634e487b7160e01b600052602260045260246000fd5b50919050565b8082028115828204841417610f7857610f78615b4b565b634e487b7160e01b600052601260045260246000fd5b600082615bfd57615bfd615bd8565b500490565b634e487b7160e01b600052602160045260246000fd5b9283526001600160a01b039190911660208301526001600160401b0316604082015260600190565b60008351615c528184602088016151fa565b835190830190615c668183602088016151fa565b01949350505050565b600060208284031215615c8157600080fd5b8151611f0481614f10565b600060208284031215615c9e57600080fd5b5051919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615cd89083018461521e565b9695505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612cea9083018461521e565b600080600060608486031215615d3157600080fd5b8351615d3c81614f10565b602085015160408601519194509250615d548161530e565b809150509250925092565b838152826020820152606060408201526000615d7e606083018461521e565b95945050505050565b6020808252825182820181905260009190848201906040850190845b81811015615dbf57835183529284019291840191600101615da3565b50909695505050505050565b600082615dda57615dda615bd8565b500690565b6001600160401b038181168382160190808211156129eb576129eb615b4b565b6020810160038310615e2157634e487b7160e01b600052602160045260246000fd5b91905290565b600060208284031215615e3957600080fd5b8151611f0481614ec6565b634e487b7160e01b600052603160045260246000fd5b601f8211156113ad57600081815260208120601f850160051c81016020861015615e815750805b601f850160051c820191505b81811015610fd357828155600101615e8d565b81516001600160401b03811115615eb957615eb9614f25565b615ecd81615ec78454615b87565b84615e5a565b602080601f831160018114615f025760008415615eea5750858301515b600019600386901b1c1916600185901b178555610fd3565b600085815260208120601f198616915b82811015615f3157888601518255948401946001909101908401615f12565b5085821015615f4f5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe04444026cefd1b05506559cab59d1b865ae3ba4ed2fe5c894f04e522776c552dddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220a45cd6b3f3c131e44491ce2389ee99ab02549ade9212d098b95458e0e0b9b5e964736f6c634300081200330000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5a4a685338646e686e526279626b66357377616f6270315936346f46644d35327548786357787558673159540000000000000000000000
Deployed Bytecode
0x6080604052600436106103bc5760003560e01c8063635490cc116101f4578063b88d4fde1161010e578063e467a48f116100a6578063e467a48f14610d3a578063e7de4de414610d5a578063e97ceaa814610d7a578063e985e9c514610d9a578063ee1dffcf14610de3578063f2fde38b14610e03578063f74b83c614610e23578063fb25fb7a14610e43578063fc3517c814610e8a578063ffa1ad7414610eaa57600080fd5b8063b88d4fde14610bf4578063c259a98814610c14578063c6824bae14610c34578063c87b56dd14610c54578063d5abeb0114610c74578063de8e602c14610c89578063defa80c314610ca9578063df6f556b14610cc9578063e425e25814610d2557600080fd5b806389bf627b1161018c57806389bf627b14610ac657806389ed2edf14610ae65780638d4f3bf514610afb5780638da5cb5b14610b2357806395d89b4114610b4157806395edc18c14610b565780639796133614610b74578063a22cb46514610b94578063a898e36414610bb4578063b390c0ab14610bd457600080fd5b8063635490cc146108dd57806365b67eb9146108fd5780636f19951c1461091d57806370a082311461093d578063715018a61461095d5780637280281e146109725780637507e2ae1461099257806379e8ca9e14610a865780638507dc2814610aa657600080fd5b806331a58a30116102e55780634876053d1161027d5780634876053d14610798578063496d9f44146107b85780634e60edba146107d857806351532e5a1461080857806359c8b7dd146108355780635e2e32921461084a5780635e94354a1461086a5780635ea72f361461088a5780636112e8ac146108aa5780636352211e146108bd57600080fd5b806331a58a301461066b578063326d526d1461068b57806333ed2845146106ab578063362b67f4146106cb57806338dcf74c146106eb57806342842e0e1461070b57806342966c681461072b57806344ec93441461074b57806346e948281461077857600080fd5b806316c38b3c1161035857806316c38b3c1461051157806318160ddd146105315780631d0d35f51461054657806322e6d1601461057f57806322f6da9c1461059f57806323b872dd146105bf5780632a55205a146105df5780632d8120b51461061e5780632f32f9371461063e57600080fd5b806301e1d114146103c157806301ffc9a7146103e55780630254976014610415578063064c0a3a1461043757806306fdde0314610457578063074334fb14610479578063081812fc14610499578063095ea7b3146104d15780630fc499f5146104f1575b600080fd5b3480156103cd57600080fd5b506026545b6040519081526020015b60405180910390f35b3480156103f157600080fd5b50610405610400366004614edc565b610edb565b60405190151581526020016103dc565b34801561042157600080fd5b50610435610430366004615057565b610f7e565b005b34801561044357600080fd5b50610435610452366004615185565b610fdb565b34801561046357600080fd5b5061046c6111d4565b6040516103dc919061524a565b34801561048557600080fd5b5061040561049436600461525d565b611266565b3480156104a557600080fd5b506104b96104b43660046152ac565b6112e0565b6040516001600160a01b0390911681526020016103dc565b3480156104dd57600080fd5b506104356104ec3660046152c5565b611326565b3480156104fd57600080fd5b5061043561050c3660046152f1565b6113b2565b34801561051d57600080fd5b5061043561052c36600461531c565b6113db565b34801561053d57600080fd5b506103d26113fb565b34801561055257600080fd5b506104056105613660046152f1565b6001600160a01b031660009081526002602052604090205460011490565b34801561058b57600080fd5b5061040561059a366004615339565b611434565b3480156105ab57600080fd5b506104356105ba366004615372565b611462565b3480156105cb57600080fd5b506104356105da3660046153a7565b6114dd565b3480156105eb57600080fd5b506105ff6105fa3660046153e8565b611502565b604080516001600160a01b0390931683526020830191909152016103dc565b34801561062a57600080fd5b506103d2610639366004615419565b611538565b34801561064a57600080fd5b5061065e6106593660046153e8565b61159a565b6040516103dc9190615434565b34801561067757600080fd5b50610435610686366004615454565b611633565b34801561069757600080fd5b506104356106a63660046152f1565b6116cd565b3480156106b757600080fd5b506104356106c63660046152c5565b6116f9565b3480156106d757600080fd5b506104356106e6366004615480565b61179c565b3480156106f757600080fd5b5061043561070636600461553f565b6117fd565b34801561071757600080fd5b506104356107263660046153a7565b611b61565b34801561073757600080fd5b506104356107463660046152ac565b611b7c565b34801561075757600080fd5b5061076b6107663660046152ac565b611b8b565b6040516103dc91906155c0565b34801561078457600080fd5b50610435610793366004615620565b611c0a565b3480156107a457600080fd5b506104356107b33660046156cb565b611c95565b3480156107c457600080fd5b506103d26107d3366004615419565b611cbf565b3480156107e457600080fd5b506107f86107f33660046156e6565b611d37565b6040516103dc949392919061574d565b34801561081457600080fd5b506108286108233660046152ac565b611e14565b6040516103dc9190615790565b34801561084157600080fd5b506005546103d2565b34801561085657600080fd5b5061046c6108653660046156e6565b611ea8565b34801561087657600080fd5b506108286108853660046152ac565b611f0b565b34801561089657600080fd5b506104356108a53660046152c5565b611f74565b6104356108b83660046157a3565b611ffb565b3480156108c957600080fd5b506104b96108d83660046152ac565b612047565b3480156108e957600080fd5b506104356108f83660046157d8565b6120d7565b34801561090957600080fd5b50610435610918366004615827565b6121f0565b34801561092957600080fd5b5061076b6109383660046152ac565b612203565b34801561094957600080fd5b506103d26109583660046152f1565b612273565b34801561096957600080fd5b506104356122b8565b34801561097e57600080fd5b5061082861098d3660046152ac565b6122cc565b34801561099e57600080fd5b50610a3c6109ad366004615863565b6040805160808082018352600080835260208084018290528385018290526060938401829052968152601a87528381206001600160a01b03968716825287528381206001600160401b03958616825287528390208351918201845280548086168352600160401b9004909416958101959095526001830154918501919091526002909101549091169082015290565b6040516103dc919081516001600160401b03908116825260208084015190911690820152604080830151908201526060918201516001600160a01b03169181019190915260800190565b348015610a9257600080fd5b50610435610aa136600461588a565b612335565b348015610ab257600080fd5b50610435610ac136600461588a565b6123f2565b348015610ad257600080fd5b50610435610ae13660046158b8565b612488565b348015610af257600080fd5b5061046c612501565b348015610b0757600080fd5b50610b1663524d524b60e01b81565b6040516103dc91906158e4565b348015610b2f57600080fd5b506001546001600160a01b03166104b9565b348015610b4d57600080fd5b5061046c612510565b348015610b6257600080fd5b506004546001600160a01b03166104b9565b348015610b8057600080fd5b50610435610b8f3660046153e8565b61251f565b348015610ba057600080fd5b50610435610baf36600461588a565b61259f565b348015610bc057600080fd5b5061065e610bcf3660046153e8565b61262d565b348015610be057600080fd5b506103d2610bef3660046153e8565b61268a565b348015610c0057600080fd5b50610435610c0f3660046158f9565b6129f2565b348015610c2057600080fd5b50610435610c2f366004615958565b612a31565b348015610c4057600080fd5b506103d2610c4f366004615419565b612be2565b348015610c6057600080fd5b5061046c610c6f3660046152ac565b612c2d565b348015610c8057600080fd5b506103d2612cf5565b348015610c9557600080fd5b50610435610ca436600461597d565b612d1d565b348015610cb557600080fd5b50610435610cc43660046159fb565b612da1565b348015610cd557600080fd5b50610d0d610ce43660046156e6565b60009182526010602090815260408084206001600160401b039384168552909152909120541690565b6040516001600160401b0390911681526020016103dc565b348015610d3157600080fd5b50610435612fbc565b348015610d4657600080fd5b506104b9610d553660046152ac565b612fcb565b348015610d6657600080fd5b50610435610d753660046153e8565b612fee565b348015610d8657600080fd5b50610435610d95366004615a96565b6130ef565b348015610da657600080fd5b50610405610db5366004615339565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205460ff1690565b348015610def57600080fd5b50610405610dfe366004615ad5565b613105565b348015610e0f57600080fd5b50610435610e1e3660046152f1565b613136565b348015610e2f57600080fd5b50610435610e3e366004615afc565b61316e565b348015610e4f57600080fd5b50610e63610e5e3660046152ac565b6131b5565b604080516001600160a01b03909416845260208401929092521515908201526060016103dc565b348015610e9657600080fd5b50610435610ea5366004615372565b61321d565b348015610eb657600080fd5b5061046c60405180604001604052806005815260200164312e322e3160d81b81525081565b60006001600160e01b031982166301ffc9a760e01b1480610f0c57506001600160e01b031982166380ac58cd60e01b145b80610f2757506001600160e01b03198216635b5e139f60e01b145b80610f4257506001600160e01b031982166342b0e56f60e01b145b80610f5d57506001600160e01b0319821663035a194d60e11b145b80610f7857506001600160e01b03198216630a2f26b960e21b145b92915050565b610f86613232565b815160005b81811015610fd35760266000815460010191905081905550610fcb6026548787878581518110610fbd57610fbd615b18565b602002602001015187613271565b600101610f8b565b505050505050565b82610fe581613317565b600080610ff1866131b5565b5091509150876001600160a01b0316826001600160a01b0316146110285760405163e146af6f60e01b815260040160405180910390fd5b6001600160a01b03871661104f576040516338f646ff60e21b815260040160405180910390fd5b6001600160a01b0387163014801561106657508486145b1561108457604051633d76b10760e01b815260040160405180910390fd5b6001600160a01b0387163b6110ac5760405163b9d3114760e01b815260040160405180910390fd5b6040516301ffc9a760e01b81526001600160a01b038816906301ffc9a7906110df906342b0e56f60e01b906004016158e4565b602060405180830381865afa1580156110fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111209190615b2e565b61113d57604051631784ec7360e21b815260040160405180910390fd5b61114886888761339f565b611153888888613490565b6001600160a01b038816600090815260086020526040812080546001929061117c908490615b61565b9091555061118d905086868961352a565b6001600160a01b03871660009081526008602052604081208054600192906111b6908490615b74565b909155506111ca9050828883888a8961358b565b5050505050505050565b6060600680546111e390615b87565b80601f016020809104026020016040519081016040528092919081815260200182805461120f90615b87565b801561125c5780601f106112315761010080835404028352916020019161125c565b820191906000526020600020905b81548152906001019060200180831161123f57829003601f168201915b5050505050905090565b6001600160401b038083166000908152601860209081526040808320548416808452601c83528184206001600160a01b038a16855290925282205491929091811690841681036112d15760006112c5866112bf896122cc565b9061366c565b94506112d89350505050565b6000925050505b949350505050565b60006112eb826136d5565b60008281526009602052604081209061130384612047565b6001600160a01b0390811682526020820192909252604001600020541692915050565b600061133182612047565b9050806001600160a01b0316836001600160a01b03160361136557604051630591db6d60e01b815260040160405180910390fd5b336001600160a01b0382161480159061138557506113838133610db5565b155b156113a357604051634c12315960e11b815260040160405180910390fd5b6113ad83836136fb565b505050565b6113ba613774565b600480546001600160a01b0319166001600160a01b03831617905550565b50565b6113e3613774565b806113ef5760006113f2565b60015b60ff1660255550565b60006114076002611cbf565b6114116001611cbf565b61141b6000611cbf565b6114259190615b74565b61142f9190615b74565b905090565b6001600160a01b03918216600090815260156020908152604080832093909416825291909152205460ff1690565b8261146c8161379f565b611477848484613800565b6114828484846138a8565b60008481526014602090815260408083206001600160401b0386168085529252808320805460ff1916905551909186917f1010837a46db9510cad56c9b63e97183557a136e9d4ddbec309ce52c99afb1249190a35b50505050565b806114e781613317565b6114d7848484604051806020016040528060008152506138f5565b6004546005546001600160a01b0390911690600090612710906115259085615bc1565b61152f9190615bee565b90509250929050565b60008082600281111561154d5761154d615c02565b0361156057602354610f789060f0615bc1565b600182600281111561157457611574615c02565b0361158757602354610f78906009615bc1565b602354610f78906001615bc1565b919050565b6040805180820190915260008082526020820152816115b884612203565b51116115d75760405163653e642560e11b815260040160405180910390fd5b6000838152600c602052604081208054849081106115f7576115f7615b18565b60009182526020918290206040805180820190915260029092020180548252600101546001600160a01b03169181019190915291505092915050565b61163b613774565b6014602354148061164e57506024546001145b1561166c576040516307b486d360e41b815260040160405180910390fd5b82601d54118061167d575081601e54115b80611689575080601f54115b156116a757604051633ca0721160e21b815260040160405180910390fd5b6001602360008282546116ba9190615b74565b9091555050601d92909255601e55601f55565b6116d5613774565b6001600160a01b03166000908152602860205260409020805460ff19166001179055565b611701613774565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461174e576040519150601f19603f3d011682016040523d82523d6000602084013e611753565b606091505b50509050806113ad5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b60448201526064015b60405180910390fd5b6117a4613232565b825160005b818110156117f6576117ee8582815181106117c6576117c6615b18565b60200260200101518583815181106117e0576117e0615b18565b602002602001015185613a3a565b6001016117a9565b5050505050565b805161180881613c2f565b611810613c90565b6040808301516001600160401b0390811660009081526017602090815283822054606087015187518452601a83528584206001600160a01b0392831680865290845286852095821685529490925293909120600201549192909116156118895760405163bd0650ab60e01b815260040160405180910390fd5b611897846040015182613cba565b60006118ab8560000151866020015161159a565b60208101518151608088015160405163074334fb60e01b815230600482015260248101929092526001600160401b039081166044830152851660648201529192506001600160a01b03169063074334fb90608401602060405180830381865afa15801561191c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119409190615b2e565b61195d57604051632c36cd3360e01b815260040160405180910390fd5b6020810151604051636e5bceab60e11b81526001600160401b03841660048201526001600160a01b0391821660248201529084169063dcb79d5690604401602060405180830381865afa1580156119b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119dc9190615b2e565b6119f957604051637228eff560e11b815260040160405180910390fd5b6040805160808082018352878301516001600160401b0390811683529088015181166020808401918252855184860190815286820180516001600160a01b03908116606088019081528d516000908152601a86528981208d8416825286528981208c8916825286528981208951815498518a16600160401b026001600160801b031990991699169890981796909617875592516001808801919091559251600290960180549682166001600160a01b0319909716969096179095558b518452601b835286842090519094168352928152848220865183529052928320805492939192909190611ae9908490615b74565b92505081905550826001600160401b031686604001516001600160401b031687600001517f1f5de02b1d9c93ca468f54630e1daf13f6dc458a63f8061ff73e85bf9bc38884856000015186602001518b60800151604051611b4c93929190615c18565b60405180910390a45050600160005550505050565b6113ad838383604051806020016040528060008152506129f2565b611b8781600061268a565b5050565b6000818152600d60209081526040808320805482518185028101850190935280835260609493849084015b82821015611bfe5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611bb6565b50929695505050505050565b611c12613774565b8151602a546101f490611c26908390615b74565b1115611c4557604051630ddc056b60e21b815260040160405180910390fd5b80602a6000828254611c579190615b74565b90915550600090505b818110156114d757611c8d848281518110611c7d57611c7d615b18565b6020026020010151600185613d84565b600101611c60565b611c9d613774565b602b80546001600160401b0319166001600160401b0392909216919091179055565b600060226000836002811115611cd757611cd7615c02565b6002811115611ce857611ce8615c02565b81526020019081526020016000205460216000846002811115611d0d57611d0d615c02565b6002811115611d1e57611d1e615c02565b815260200190815260200160002054610f789190615b61565b60606000806060611d488686611ea8565b6001600160401b0380871660009081526018602090815260408083205460178352818420546019845293829020805483518186028101860190945280845291909516946001600160a01b039094169392839190830182828015611dfc57602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411611db95790505b50505050509050935093509350935092959194509250565b600081815260126020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411611e595790505b50505050509050919050565b60606000611eb68484613f27565b6001600160401b03841660009081526027602052604090205490915015611f045780611ee185614016565b604051602001611ef2929190615c40565b60405160208183030381529060405290505b9392505050565b600081815260136020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57600091825260209182902080546001600160401b03168452908202830192909160089101808411611e59575094979650505050505050565b6000611f7f82612047565b9050806001600160a01b0316836001600160a01b031603611fb3576040516375f45abd60e01b815260040160405180910390fd5b336001600160a01b03821614801590611fd35750611fd18133611434565b155b15611ff1576040516357a2e94960e11b815260040160405180910390fd5b6113ad83836140a8565b6120058282614121565b600061201082612be2565b61201a9084615bc1565b905034811461203c57604051632ec1a93b60e21b815260040160405180910390fd5b6114d7848484613d84565b600080600080612056856131b5565b92509250925080156120ce576040516331a9108f60e11b8152600481018390526001600160a01b03841690636352211e90602401602060405180830381865afa1580156120a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cb9190615c6f565b92505b50909392505050565b6120e0836136d5565b33803b6121005760405163b9d3114760e01b815260040160405180910390fd5b604080518082019091528381526001600160a01b0382166020820152600061212786611b8b565b5190506080811015612186576000868152600d60209081526040822080546001808201835591845292829020855160029094020192835590840151910180546001600160a01b0319166001600160a01b0390921691909117905561219f565b60405163a53c8c0560e01b815260040160405180910390fd5b84836001600160a01b0316877fe65085e689b77b126ba0bac3b079aa8288f19f4d5445af11c76003f8ab3075dd846040516121dc91815260200190565b60405180910390a4610fd3868487876141ee565b6121f8613232565b6113ad838383614237565b6000818152600c60209081526040808320805482518185028101850190935280835260609493849084018215611bfe5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611bb6565b60006001600160a01b03821661229c57604051633bb9143360e11b815260040160405180910390fd5b506001600160a01b031660009081526008602052604090205490565b6122c0613774565b6122ca60006142ea565b565b600081815260116020908152604091829020805483518184028101840190945280845260609392830182828015611e9c57600091825260209182902080546001600160401b03168452908202830192909160089101808411611e59575094979650505050505050565b61233d613774565b6001600160a01b0382166123645760405163016b812760e71b815260040160405180910390fd5b80612389576001600160a01b03821660009081526002602052604081208190556123a8565b6001600160a01b03821660009081526002602052604090206001908190555b50816001600160a01b03167f4b5657e84cf8a17ac5587bbeb3cc2bab9826c4c67b8bad81b4849de49d37aac2826040516123e6911515815260200190565b60405180910390a25050565b6001600160a01b038216330361241b576040516375f45abd60e01b815260040160405180910390fd5b3360008181526015602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f0cff4fcf777050010027190b8061fd8bfd1de16d81b1f94e9752df1427a2623591015b60405180910390a35050565b612490613774565b61249b600182614121565b6023546124c8907f000000000000000000000000000000000000000000000000000000000000000a615bc1565b602954036124e957604051636e8bc3c360e01b815260040160405180910390fd5b602980546001908101909155611b8790839083613d84565b6060600380546111e390615b87565b6060600780546111e390615b87565b8161252981613c2f565b6000838152600d602052604090205482101561255857604051631e73178b60e11b815260040160405180910390fd5b6000838152600d6020526040812061256f91614d10565b60405183907f8ac4a0d65950c3e40448afb2260e2e0ec36ea15644d9b39e37e85472e5f9445190600090a2505050565b6001600160a01b03821633036125c857604051630b7b99b960e21b815260040160405180910390fd5b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910161247c565b60408051808201909152600080825260208201528161264b84611b8b565b511161266a5760405163da22687f60e01b815260040160405180910390fd5b6000838152600d602052604081208054849081106115f7576115f7615b18565b60008261269681613317565b6000806126a2866131b5565b509150915060006126b287612047565b6001600160a01b038416600090815260086020526040812080549293506001929091906126e0908490615b61565b909155506126f2905081600089613490565b60408051602081019091526000905261270c6000886136fb565b6127176000886140a8565b600061272288612203565b6000898152600c6020526040812091925061273d9190614d10565b6000888152600d6020526040812061275491614d10565b60008881526009602090815260408083206001600160a01b0386168452909152812080546001600160a01b031916905581518190815b81811015612955578a83106127ff578481815181106127ab576127ab615b18565b6020026020010151602001518582815181106127c9576127c9615b18565b6020908102919091010151516040516306177b2560e41b81526001600160a01b0390921660048301526024820152604401611793565b600e600086838151811061281557612815615b18565b6020026020010151602001516001600160a01b03166001600160a01b03168152602001908152602001600020600086838151811061285557612855615b18565b602002602001015160000151815260200190815260200160002060009055828b03935084818151811061288a5761288a615b18565b6020026020010151602001516001600160a01b031663b390c0ab8683815181106128b6576128b6615b18565b6020026020010151600001516001876128cf9190615b61565b6040516001600160e01b031960e085901b168152600481019290925260248201526044016020604051808303816000875af1158015612912573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129369190615c8c565b612941906001615b74565b61294b9084615b74565b925060010161278a565b5060008b8152600b602052604080822082815560010180546001600160a01b0319169055518c91906001600160a01b03881690600080516020615f80833981519152908390a4604080518781526000602082018190528d9290916001600160a01b038b1691600080516020615f60833981519152910160405180910390a460408051602081019091526000905250965050505050505b5092915050565b816129fc81613317565b612a08858585856138f5565b612a148585858561433c565b6117f65760405163bcb5663760e01b815260040160405180910390fd5b82612a3b81613c2f565b6001600160401b03808416600090815260176020908152604080832054888452601a83528184206001600160a01b039182168086529084528285208887168652845293829020825160808101845281548088168252600160401b9004909616938601939093526001830154918501919091526002909101541660608301819052909190612adb576040516317de7dd760e21b815260040160405180910390fd5b612ae6868686614438565b6000868152601a602090815260408083206001600160a01b0380871685529083528184206001600160401b0389168552835281842080546001600160801b03191681556001808201869055600290910180546001600160a01b03191690558a8552601b8452828520606087015190921685529083528184208583015185529092528220805491929091612b7a908490615b61565b92505081905550836001600160401b0316856001600160401b0316877f438e039ebbba8f290f3b5d41aaf3295eccc9b5e6b0e1d52ace700772afb7da13846040015185606001518660200151604051612bd593929190615c18565b60405180910390a4610fd3565b600080826002811115612bf757612bf7615c02565b03612c04575050601d5490565b6001826002811115612c1857612c18615c02565b03612c25575050601e5490565b5050601f5490565b6060612c38826136d5565b6000612c4383611f0b565b805190915060416000805b83816001600160401b03161015612cb057600085826001600160401b031681518110612c7c57612c7c615b18565b60200260200101519050836001600160401b0316816001600160401b03161015612ca7578093508192505b50600101612c4e565b506000612cbc876122cc565b826001600160401b031681518110612cd657612cd6615b18565b60200260200101519050612cea8782611ea8565b979650505050505050565b6023546000906001612d09600960f0615b74565b612d139190615b74565b61142f9190615bc1565b82612d278161379f565b60008481526011602052604090205482908114612d5757604051633581be1d60e11b815260040160405180910390fd5b6000858152601360205260409020612d70908585614d31565b5060405185907ff0bfd70b0068f973d58178846ca67112671ec45e060838f7de5662036bcf801790600090a26117f6565b87612dab81613c2f565b60408051808201909152600080825260208201528315612dd657612dcf8a8861262d565b9050612e0c565b612de18a8787613105565b15612dff57604051630619dc9d60e21b815260040160405180910390fd5b612e098a8861159a565b90505b612e17818787614467565b8315612e3a5760008a8152600d60205260409020612e3590886144ab565b612e74565b6001600160a01b0386166000908152600e6020908152604080832088845282528083208390558c8352600c9091529020612e7490886144ab565b6001600160a01b03891615612f5e5787612ef157604051635c46a7ef60e11b81526001600160a01b0387169063b88d4fde90612eba9030908d908a908990600401615ca5565b600060405180830381600087803b158015612ed457600080fd5b505af1158015612ee8573d6000803e3d6000fd5b50505050612f5e565b60208101518151604051630326051d60e11b81526001600160a01b039092169163064c0a3a91612f2b9130918e918e908a90600401615ce2565b600060405180830381600087803b158015612f4557600080fd5b505af1158015612f59573d6000803e3d6000fd5b505050505b6040805188815285151560208201526001600160a01b038b81161582840152915187928916918d917f02d6d6dbcb604d5e1e8c7886456e82a9cdce88b0a580071358f206b5a4d58f709181900360600190a450505050505050505050565b612fc4613774565b6001602455565b6000612fd6826136d5565b60008281526016602052604081209061130384612047565b81612ff88161379f565b6000838152601260205260409020548281111561302857604051635134ce8960e01b815260040160405180910390fd5b60005b818110156130a557600085815260126020526040812080548390811061305357613053615b18565b6000918252602080832060048304015489845260108252604080852060039094166008026101000a9091046001600160401b03168452919052902080546001600160401b03191690555060010161302b565b5060008481526012602052604081206130bd91614df2565b60405160009085907f1010837a46db9510cad56c9b63e97183557a136e9d4ddbec309ce52c99afb124908390a36114d7565b836130f981613c2f565b6117f685858585614565565b6000928352601b602090815260408085206001600160a01b0394909416855292815282842091845252902054151590565b61313e613774565b6001600160a01b03811661316557604051634ece6ecf60e01b815260040160405180910390fd5b6113d8816142ea565b613176613774565b801561319a57506001600160401b0316600090815260276020526040902060019055565b506001600160401b0316600090815260276020526040812055565b6000818152600b60209081526040808320815180830190925280548252600101546001600160a01b031691810182905282918291906132075760405163089ba7e160e41b815260040160405180910390fd5b6020810151905190959094508415159350915050565b826132278161379f565b6114d7848484614673565b6001546001600160a01b03163314801590613253575061325133610561565b155b156122ca576040516301eca16760e41b815260040160405180910390fd5b61327b8583614889565b6001600160a01b0383161580156132925750805115155b156132b057604051631035ad0760e11b815260040160405180910390fd5b6001600160401b03858116600090815260176020908152604080832080546001600160a01b0319166001600160a01b0389161790556018825280832080546001600160401b03191694891694909417909355601981529190208251610fd392840190614e17565b600080613323836131b5565b5091509150806000141580156133425750336001600160a01b03831614155b806133815750336001600160a01b038316148061336457506133648233610db5565b8061337f575033613374846112e0565b6001600160a01b0316145b155b156113ad576040516345f3c98360e11b815260040160405180910390fd5b60005b6064811015613476576000806000856001600160a01b031663fb25fb7a866040518263ffffffff1660e01b81526004016133de91815260200190565b606060405180830381865afa1580156133fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341f9190615d1c565b925092509250806134335750505050505050565b6001600160a01b0383163014801561344a57508682145b15613468576040516324543e6d60e11b815260040160405180910390fd5b5090935091506001016133a2565b50604051630349a6bd60e51b815260040160405180910390fd5b6001600160a01b0382166113ad57600060146134ae60016009615b74565b6134b89190615bc1565b8211156134c7575060006134e6565b6134d360146001615bc1565b8211156134e2575060016134e6565b5060025b602260008260028111156134fc576134fc615c02565b600281111561350d5761350d615c02565b815260208101919091526040016000208054600101905550505050565b6040805180820182528381526001600160a01b0383811660208084019182526000888152600b9091529384209251835551600190920180546001600160a01b0319169290911691909117905561358090846136fb565b6113ad6000846140a8565b6040516318d5243360e21b815285906001600160a01b0382169063635490cc906135bd90879087908790600401615d5f565b600060405180830381600087803b1580156135d757600080fd5b505af11580156135eb573d6000803e3d6000fd5b5050505082866001600160a01b0316886001600160a01b0316600080516020615f8083398151915260405160405180910390a482866001600160a01b0316886001600160a01b0316600080516020615f60833981519152888860405161365b929190918252602082015260400190565b60405180910390a450505050505050565b81516000908190815b818110156136c457846001600160401b031686828151811061369957613699615b18565b60200260200101516001600160401b0316036136bc579250600191506136ce9050565b600101613675565b5060008092509250505b9250929050565b6136de8161494f565b6113d85760405163089ba7e160e41b815260040160405180910390fd5b600061370682612047565b60008381526009602090815260408083206001600160a01b038581168086529190935281842080546001600160a01b031916938916938417905590519394508593919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a4505050565b6001546001600160a01b031633146122ca57604051631c62d58f60e11b815260040160405180910390fd5b60006137aa82612047565b9050336001600160a01b03821614806137c857506137c88133611434565b806137e35750336137d883612fcb565b6001600160a01b0316145b611b8757604051635d64832960e01b815260040160405180910390fd5b600083815260126020526040902054821061382e57604051630757d52160e01b815260040160405180910390fd5b600083815260126020526040902080548390811061384e5761384e615b18565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03166001600160401b0316816001600160401b0316146113ad576040516378eeeecf60e01b815260040160405180910390fd5b60008381526012602052604090206138c0908361496f565b60009283526010602090815260408085206001600160401b03909316855291905290912080546001600160401b031916905550565b600080613901846131b5565b5091509150856001600160a01b0316826001600160a01b0316146139385760405163e146af6f60e01b815260040160405180910390fd5b6001600160a01b03851661395f576040516338f646ff60e21b815260040160405180910390fd5b61396a868686613490565b6001600160a01b0386166000908152600860205260408120805460019290613993908490615b61565b909155506139a590508460008761352a565b6001600160a01b03851660009081526008602052604081208054600192906139ce908490615b74565b909155505060405184906001600160a01b038088169190891690600080516020615f8083398151915290600090a483856001600160a01b0316836001600160a01b0316600080516020615f60833981519152846000604051612bd5929190918252602082015260400190565b60008381526014602090815260408083206001600160401b038616845290915290205460ff1615613a7e576040516308fe3c3160e41b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604081208054613aa190615b87565b905003613ac157604051632aa5eff960e11b815260040160405180910390fd5b600083815260126020526040902054608011613af05760405163bade3a7b60e01b815260040160405180910390fd5b60008381526014602090815260408083206001600160401b038681168086529184528285208054600160ff19909116811790915588865260128552928520805493840181558552929093206004820401805460039092166008026101000a808402199092169190930217909155811615613b9d5760008381526010602090815260408083206001600160401b038681168552925290912080546001600160401b0319169183169190911790555b604080516001808252818301909252600091602080830190803683370190505090508381600081518110613bd357613bd3615b18565b602002602001018181525050816001600160401b0316836001600160401b03167f4a85a0221f784dbe75db7c29c422f474c15bde9211a98e50a30018fa8dfa937b83604051613c229190615d87565b60405180910390a36114d7565b6000613c3a82612047565b9050336001600160a01b0382161480613c585750613c588133610db5565b80613c73575033613c68836112e0565b6001600160a01b0316145b611b87576040516302728a9d60e41b815260040160405180910390fd5b600260005403613cb3576040516362bfeae960e11b815260040160405180910390fd5b6002600055565b6001600160401b03821660009081526019602090815260408083208054825181850281018501909352808352613d63938693929190830182828015613d5057602002820191906000526020600020906000905b82829054906101000a90046001600160401b03166001600160401b031681526020019060080190602082600701049283019260010382029150808411613d0d5790505b505050505061366c90919063ffffffff16565b915050806113ad57604051634ef44ed560e01b815260040160405180910390fd5b6000613d8f82614a55565b60216000846002811115613da557613da5615c02565b6002811115613db657613db6615c02565b8152602001908152602001600020546001613dd19190615b74565b613ddb9190615b74565b90508260216000846002811115613df457613df4615c02565b6002811115613e0557613e05615c02565b8152602081019190915260400160009081208054909201909155613e298483615b74565b90506000825b82811015613ed157613e51878260405180602001604052806000815250614ab4565b6014613e5f60016009615b74565b613e699190615bc1565b811115613e795760019150613e9a565b613e8560146001615bc1565b811115613e955760059150613e9a565b600991505b613ea5600482615dcb565b613eaf9083615ddf565b9150613ebd81836000613a3a565b613ec981600084614673565b600101613e2f565b50613edd600183615b61565b83876001600160a01b03167f7ac572687bf4e66a8514fc2ec464fc2644c78bcb1d80a225fc51a33e0ee38bfa87604051613f179190615dff565b60405180910390a4505050505050565b60008281526014602090815260408083206001600160401b038516845290915290205460609060ff16613f6d57604051631b9928fd60e31b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604090208054613f9090615b87565b80601f0160208091040260200160405190810160405280929190818152602001828054613fbc90615b87565b80156140095780601f10613fde57610100808354040283529160200191614009565b820191906000526020600020905b815481529060010190602001808311613fec57829003601f168201915b5050505050905092915050565b6060600061402383614b47565b60010190506000816001600160401b0381111561404257614042614f25565b6040519080825280601f01601f19166020018201604052801561406c576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461407657509392505050565b60006140b382612047565b60008381526016602090815260408083206001600160a01b038581168086529190935281842080546001600160a01b031916938916938417905590519394508593919290917fb90cc0d925ac3511ab6af2d7ca73ffcf7ec4bd871fff36b958ecf440079c463e9190a4505050565b60235460000361414457604051631117739360e21b815260040160405180910390fd5b602554600103614167576040516308a98cbd60e41b815260040160405180910390fd5b816141855760405163220328c760e11b815260040160405180910390fd5b61418e81611538565b602160008360028111156141a4576141a4615c02565b60028111156141b5576141b5615c02565b815260200190815260200160002054836141cf9190615b74565b1115611b87576040516379027f2f60e01b815260040160405180910390fd5b6001600160a01b03831660009081526028602052604090205460ff16156114d7576000848152600d60205260409020546114d790859061423090600190615b61565b8585614565565b6001600160401b038316158061425457506001600160401b038116155b15614272576040516312c33ce360e01b815260040160405180910390fd5b6001600160401b038381166000818152601c602090815260408083206001600160a01b0388168085529083529281902080546001600160401b0319169587169586179055519182527f5b5af0622001a9b735a56357ddc1abd65e6a640126498674daf9d2fb05160725910160405180910390a3505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b1561443057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290614380903390899088908890600401615ca5565b6020604051808303816000875af19250505080156143bb575060408051601f3d908101601f191682019092526143b891810190615e27565b60015b614416573d8080156143e9576040519150601f19603f3d011682016040523d82523d6000602084013e6143ee565b606091505b50805161440e5760405163bcb5663760e01b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112d8565b5060016112d8565b602b546001600160401b03908116908216036113ad5760405163030bef8760e31b815260040160405180910390fd5b82602001516001600160a01b0316826001600160a01b031614158061448d575082518114155b156113ad57604051637383f2c160e11b815260040160405180910390fd5b815482906144bb90600190615b61565b815481106144cb576144cb615b18565b90600052602060002090600202018282815481106144eb576144eb615b18565b600091825260209091208254600290920201908155600191820154910180546001600160a01b0319166001600160a01b03909216919091179055815482908061453657614536615e44565b60008281526020812060026000199093019283020190815560010180546001600160a01b031916905590555050565b6000614571858561262d565b905061457e818484614467565b6001600160a01b0383166000908152600e60209081526040808320858452909152902054156145c05760405163188a497360e01b815260040160405180910390fd5b6000858152600d602052604090206145d890856144ab565b6000858152600c6020908152604080832080546001808201835591855283852086516002909202019081558584015190820180546001600160a01b0319166001600160a01b039283161790558716808552600e8452828520878652845293829020555186815284929188917f29486b9e2ae569b440933a9b1b421467306fa21f3dcad439c262910a634963a9910160405180910390a46117f6565b61467e838383613800565b60008381526010602090815260408083206001600160401b0380861685529252822054169080821561472c576147268360116000898152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015613d5057600091825260209182902080546001600160401b03168452908202830192909160089101808411613d0d579050505050505061366c90919063ffffffff16565b90925090505b80156147ad57600086815260116020526040902080548591908490811061475557614755615b18565b600091825260208083206004830401805460039093166008026101000a6001600160401b038181021990941695841602949094179093558882526014835260408083209187168352925220805460ff19169055614838565b6000868152601360209081526040808320601183529083208054825460018181018555938652848620600480830490910180546001600160401b0394851660086003958616810261010090810a9283029288021990931691909117909255855496870186559488529587209085040180548b84169590921690950290920a9283029202191617905592505b6148438686866138a8565b826001600160401b0316846001600160401b0316877f3f2709a99f6c06b4e57bbb38eb0134332f96f51a3da314f41a515adbb28b17cc60405160405180910390a4610fd3565b6001600160401b0382166148b0576040516312c33ce360e01b815260040160405180910390fd5b6001600160401b0382166000908152600f6020526040812080546148d390615b87565b905011156148f4576040516308fe3c3160e41b815260040160405180910390fd5b6001600160401b0382166000908152600f602052604090206149168282615ea0565b506040516001600160401b038316907f3cd061096eaf881067d936308fbd8b81d060c45ab2ec910c02b953162befc10990600090a25050565b6000908152600b60205260409020600101546001600160a01b0316151590565b8154811061497c57600080fd5b8154829061498c90600190615b61565b8154811061499c5761499c615b18565b90600052602060002090600491828204019190066008029054906101000a90046001600160401b03168282815481106149d7576149d7615b18565b90600052602060002090600491828204019190066008026101000a8154816001600160401b0302191690836001600160401b0316021790555081805480614a2057614a20615e44565b60008281526020902060046000199092019182040180546001600160401b03600860038516026101000a021916905590555050565b600080826002811115614a6a57614a6a615c02565b03614a87576014614a7d60016009615b74565b610f789190615bc1565b6001826002811115614a9b57614a9b615c02565b03614aac57610f7860146001615bc1565b506000919050565b614ac18383600084614c1f565b60405182906001600160a01b03851690600090600080516020615f80833981519152908290a46040805160008082526020820181905284926001600160a01b03871692600080516020615f60833981519152910160405180910390a4614b2a600084848461433c565b6113ad5760405163bcb5663760e01b815260040160405180910390fd5b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310614b865772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310614bb2576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310614bd057662386f26fc10000830492506010015b6305f5e1008310614be8576305f5e100830492506008015b6127108310614bfc57612710830492506004015b60648310614c0e576064830492506002015b600a8310610f785760010192915050565b6001600160a01b038416614c46576040516325bd6bd360e01b815260040160405180910390fd5b614c4f8361494f565b15614c6d5760405163c5a8d37160e01b815260040160405180910390fd5b82614c8b576040516312c33ce360e01b815260040160405180910390fd5b614c9760008585613490565b6001600160a01b0384166000908152600860205260408120805460019290614cc0908490615b74565b90915550506040805180820182529283526001600160a01b0394851660208085019182526000958652600b9052932091518255509051600190910180546001600160a01b03191691909216179055565b50805460008255600202906000526020600020908101906113d89190614e8a565b82805482825590600052602060002090600301600490048101928215614de25791602002820160005b83821115614dad5783356001600160401b031683826101000a8154816001600160401b0302191690836001600160401b031602179055509260200192600801602081600701049283019260010302614d5a565b8015614de05782816101000a8154906001600160401b030219169055600801602081600701049283019260010302614dad565b505b50614dee929150614eb1565b5090565b5080546000825560030160049004906000526020600020908101906113d89190614eb1565b82805482825590600052602060002090600301600490048101928215614de25791602002820160005b83821115614dad57835183826101000a8154816001600160401b0302191690836001600160401b031602179055509260200192600801602081600701049283019260010302614e40565b5b80821115614dee57600081556001810180546001600160a01b0319169055600201614e8b565b5b80821115614dee5760008155600101614eb2565b6001600160e01b0319811681146113d857600080fd5b600060208284031215614eee57600080fd5b8135611f0481614ec6565b80356001600160401b038116811461159557600080fd5b6001600160a01b03811681146113d857600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715614f6357614f63614f25565b604052919050565b60006001600160401b03821115614f8457614f84614f25565b5060051b60200190565b60006001600160401b03831115614fa757614fa7614f25565b614fba601f8401601f1916602001614f3b565b9050828152838383011115614fce57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614ff657600080fd5b8135602061500b61500683614f6b565b614f3b565b82815260059290921b8401810191818101908684111561502a57600080fd5b8286015b8481101561504c5761503f81614ef9565b835291830191830161502e565b509695505050505050565b6000806000806080858703121561506d57600080fd5b61507685614ef9565b935060208086013561508781614f10565b93506040868101356001600160401b03808211156150a457600080fd5b818901915089601f8301126150b857600080fd5b81356150c661500682614f6b565b81815260059190911b8301850190858101908c8311156150e557600080fd5b8685015b83811015615131578035858111156151015760008081fd5b8601603f81018f136151135760008081fd5b6151238f8a8301358a8401614f8e565b8452509187019187016150e9565b5097505050606089013593508084111561514a57600080fd5b50505061515987828801614fe5565b91505092959194509250565b600082601f83011261517657600080fd5b611f0483833560208501614f8e565b600080600080600060a0868803121561519d57600080fd5b85356151a881614f10565b945060208601356151b881614f10565b9350604086013592506060860135915060808601356001600160401b038111156151e157600080fd5b6151ed88828901615165565b9150509295509295909350565b60005b838110156152155781810151838201526020016151fd565b50506000910152565b600081518084526152368160208601602086016151fa565b601f01601f19169290920160200192915050565b602081526000611f04602083018461521e565b6000806000806080858703121561527357600080fd5b843561527e81614f10565b93506020850135925061529360408601614ef9565b91506152a160608601614ef9565b905092959194509250565b6000602082840312156152be57600080fd5b5035919050565b600080604083850312156152d857600080fd5b82356152e381614f10565b946020939093013593505050565b60006020828403121561530357600080fd5b8135611f0481614f10565b80151581146113d857600080fd5b60006020828403121561532e57600080fd5b8135611f048161530e565b6000806040838503121561534c57600080fd5b823561535781614f10565b9150602083013561536781614f10565b809150509250929050565b60008060006060848603121561538757600080fd5b833592506020840135915061539e60408501614ef9565b90509250925092565b6000806000606084860312156153bc57600080fd5b83356153c781614f10565b925060208401356153d781614f10565b929592945050506040919091013590565b600080604083850312156153fb57600080fd5b50508035926020909101359150565b80356003811061159557600080fd5b60006020828403121561542b57600080fd5b611f048261540a565b815181526020808301516001600160a01b03169082015260408101610f78565b60008060006060848603121561546957600080fd5b505081359360208301359350604090920135919050565b60008060006060848603121561549557600080fd5b83356001600160401b03808211156154ac57600080fd5b818601915086601f8301126154c057600080fd5b813560206154d061500683614f6b565b82815260059290921b8401810191818101908a8411156154ef57600080fd5b948201945b8386101561550d578535825294820194908201906154f4565b9750508701359250508082111561552357600080fd5b5061553086828701614fe5565b92505061539e60408501614ef9565b600060a0828403121561555157600080fd5b60405160a081018181106001600160401b038211171561557357615573614f25565b8060405250823581526020830135602082015261559260408401614ef9565b60408201526155a360608401614ef9565b60608201526155b460808401614ef9565b60808201529392505050565b602080825282518282018190526000919060409081850190868401855b8281101561561357615603848351805182526020908101516001600160a01b0316910152565b92840192908501906001016155dd565b5091979650505050505050565b6000806040838503121561563357600080fd5b82356001600160401b0381111561564957600080fd5b8301601f8101851361565a57600080fd5b8035602061566a61500683614f6b565b82815260059290921b8301810191818101908884111561568957600080fd5b938201935b838510156156b05784356156a181614f10565b8252938201939082019061568e565b95506156bf905086820161540a565b93505050509250929050565b6000602082840312156156dd57600080fd5b611f0482614ef9565b600080604083850312156156f957600080fd5b8235915061152f60208401614ef9565b600081518084526020808501945080840160005b838110156157425781516001600160401b03168752958201959082019060010161571d565b509495945050505050565b608081526000615760608083018761521e565b6001600160401b03861660208401526001600160a01b03851660408401528281036060840152612cea8185615709565b602081526000611f046020830184615709565b6000806000606084860312156157b857600080fd5b83356157c381614f10565b92506020840135915061539e6040850161540a565b6000806000606084860312156157ed57600080fd5b833592506020840135915060408401356001600160401b0381111561581157600080fd5b61581d86828701615165565b9150509250925092565b60008060006060848603121561583c57600080fd5b61584584614ef9565b9250602084013561585581614f10565b915061539e60408501614ef9565b60008060006060848603121561587857600080fd5b83359250602084013561585581614f10565b6000806040838503121561589d57600080fd5b82356158a881614f10565b915060208301356153678161530e565b600080604083850312156158cb57600080fd5b82356158d681614f10565b915061152f6020840161540a565b6001600160e01b031991909116815260200190565b6000806000806080858703121561590f57600080fd5b843561591a81614f10565b9350602085013561592a81614f10565b92506040850135915060608501356001600160401b0381111561594c57600080fd5b61515987828801615165565b60008060006060848603121561596d57600080fd5b8335925061585560208501614ef9565b60008060006040848603121561599257600080fd5b8335925060208401356001600160401b03808211156159b057600080fd5b818601915086601f8301126159c457600080fd5b8135818111156159d357600080fd5b8760208260051b85010111156159e857600080fd5b6020830194508093505050509250925092565b600080600080600080600080610100898b031215615a1857600080fd5b883597506020890135615a2a81614f10565b965060408901359550606089013594506080890135615a4881614f10565b935060a0890135925060c0890135615a5f8161530e565b915060e08901356001600160401b03811115615a7a57600080fd5b615a868b828c01615165565b9150509295985092959890939650565b60008060008060808587031215615aac57600080fd5b84359350602085013592506040850135615ac581614f10565b9396929550929360600135925050565b600080600060608486031215615aea57600080fd5b8335925060208401356153d781614f10565b60008060408385031215615b0f57600080fd5b6158a883614ef9565b634e487b7160e01b600052603260045260246000fd5b600060208284031215615b4057600080fd5b8151611f048161530e565b634e487b7160e01b600052601160045260246000fd5b81810381811115610f7857610f78615b4b565b80820180821115610f7857610f78615b4b565b600181811c90821680615b9b57607f821691505b602082108103615bbb57634e487b7160e01b600052602260045260246000fd5b50919050565b8082028115828204841417610f7857610f78615b4b565b634e487b7160e01b600052601260045260246000fd5b600082615bfd57615bfd615bd8565b500490565b634e487b7160e01b600052602160045260246000fd5b9283526001600160a01b039190911660208301526001600160401b0316604082015260600190565b60008351615c528184602088016151fa565b835190830190615c668183602088016151fa565b01949350505050565b600060208284031215615c8157600080fd5b8151611f0481614f10565b600060208284031215615c9e57600080fd5b5051919050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615cd89083018461521e565b9695505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612cea9083018461521e565b600080600060608486031215615d3157600080fd5b8351615d3c81614f10565b602085015160408601519194509250615d548161530e565b809150509250925092565b838152826020820152606060408201526000615d7e606083018461521e565b95945050505050565b6020808252825182820181905260009190848201906040850190845b81811015615dbf57835183529284019291840191600101615da3565b50909695505050505050565b600082615dda57615dda615bd8565b500690565b6001600160401b038181168382160190808211156129eb576129eb615b4b565b6020810160038310615e2157634e487b7160e01b600052602160045260246000fd5b91905290565b600060208284031215615e3957600080fd5b8151611f0481614ec6565b634e487b7160e01b600052603160045260246000fd5b601f8211156113ad57600081815260208120601f850160051c81016020861015615e815750805b601f850160051c820191505b81811015610fd357828155600101615e8d565b81516001600160401b03811115615eb957615eb9614f25565b615ecd81615ec78454615b87565b84615e5a565b602080601f831160018114615f025760008415615eea5750858301515b600019600386901b1c1916600185901b178555610fd3565b600085815260208120601f198616915b82811015615f3157888601518255948401946001909101908401615f12565b5085821015615f4f5787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fe04444026cefd1b05506559cab59d1b865ae3ba4ed2fe5c894f04e522776c552dddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220a45cd6b3f3c131e44491ce2389ee99ab02549ade9212d098b95458e0e0b9b5e964736f6c63430008120033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5a4a685338646e686e526279626b66357377616f6270315936346f46644d35327548786357787558673159540000000000000000000000
-----Decoded View---------------
Arg [0] : collectionMetadata_ (string): ipfs://QmZJhS8dnhnRbybkf5swaobp1Y64oFdM52uHxcWxuXg1YT
Arg [1] : maxGiftsPerPhase_ (uint256): 10
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [1] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000035
Arg [3] : 697066733a2f2f516d5a4a685338646e686e526279626b66357377616f627031
Arg [4] : 5936346f46644d35327548786357787558673159540000000000000000000000
Loading...
Loading
Loading...
Loading
OVERVIEW
Snake Soldiers is an NFT collection with unique arts and soldiers distributed among 3 ranks. Each snake will be usable in a play-to-own game, where snakes will be the main characters, necessary to interact with the SerpenTerra ecosystem.Loading...
Loading
Net Worth in USD
$0.00
Net Worth in GLMR
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.