Contract Address Details

0x53120F4BbA7D9eC757eB123f1774A1e8872cD4c2

Contract Name
SpecialHorseFarm
Creator
0xe4bc3d–a61c7a at 0xfaf2eb–9d1741
Balance
0 ADIL ( )
Tokens
Fetching tokens...
Transactions
32,976 Transactions
Transfers
33,030 Transfers
Gas Used
9,236,665,350
Last Balance Update
13142285
Contract name:
SpecialHorseFarm




Optimization enabled
true
Compiler version
v0.8.2+commit.661d1103




Optimization runs
999999
Verified at
2023-05-22 07:30:04.522470Z

Constructor Arguments

000000000000000000000000cb775d2e24efe447379fd6249870922a327dec41

Arg [0] (address) : 0xcb775d2e24efe447379fd6249870922a327dec41

              

contracts/SpecialHorseFarm.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "./libraries/OwnerOperator.sol";
import "./libraries/BytesLibrary.sol";
import "./libraries/StringLibrary.sol";
import "./libraries/upgrade/PauseUpgradeSafe.sol";
import "./libraries/upgrade/OwnerOperatorUpgradeSafe.sol";

import "./interfaces/ITransporter.sol";

contract SpecialHorseFarm is ERC721Holder, OwnerOperator, Pausable {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;
    using StringLibrary for string;
    using BytesLibrary for bytes32;

    struct LeaseData {
        address owner;
        uint256[] horseId;
        uint256 blockExpired;
        string nonce;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    struct SavedLease {
        address owner;
        uint256 horseId;
        uint256 blockExpired;
    }

    struct RefundData {
        address owner;
        uint256[] horseId;
        uint256 blockExpired;
        string nonce;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    struct SavedRefund {
        address owner;
        uint256 horseId;
        uint256 blockExpired;
    }

    struct WithdrawData {
        address owner;
        uint256[] horseId;
        uint256 blockExpired;
        string nonce;
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    struct SavedWithdraw {
        address owner;
        uint256 horseId;
        uint256 blockExpired;
    }

    address public horseNFT;
    // Mapping from nft token id to owner of token
    mapping(uint256 => address) public ownerOf;

    // Mapping from sign message to checking value
    mapping(bytes32 => bool) public leaseCompleted;
    // Mapping from nonce to leaseData
    mapping(string => SavedLease) public leaseData;
    // Mapping from user address to lease count
    mapping(address => uint256) public leaseCountOf;
    // Mapping from user address and lease index to lease nonce
    mapping(address => mapping(uint256 => string)) public leaseNoneOf;

    // Mapping from sign message to checking value
    mapping(uint256 => bool) private refundCompleted;
    // Mapping from nonce to RefundData
    mapping(string => SavedRefund) private refundData;

    mapping(bytes32 => bool) public withdrawCompleted;
    // Mapping from nonce to withdrawData
    mapping(string => SavedWithdraw) public withdrawData;
    // Mapping from user address to withdraw count
    mapping(address => uint256) public withdrawCountOf;
    // Mapping from user address and withdraw index to withdraw nonce
    mapping(address => mapping(uint256 => string)) public withdrawNoneOf;

    event Lease(address indexed owner, address indexed signer, uint256[] indexed horseId, string nonce);
    event Refund(address indexed owner, uint256[] indexed horseId, string nonce);
    event Withdraw(address indexed owner, address indexed signer, uint256[] indexed horseId, string nonce);

    ITransporter public transporter;

    constructor(address token) OwnerOperator() Pausable() {
        horseNFT = token;
    }

    function pause() external virtual onlyOwner {
        _pause();
    }

    function unpause() external virtual onlyOwner {
        _unpause();
    }

    function setTransporter(address _transporter) external virtual onlyOwner {
        transporter = ITransporter(_transporter);
    }

    /**
     * @dev Refund token that user mistakenly transferred.
     */
    function withdrawToken(address token) external virtual onlyOwner {
        uint256 amount = IERC20(token).balanceOf(address(this));
        require(amount > 0, "SpecialHorseFarm: zero out amount");
        IERC20(token).safeTransfer(msg.sender, amount);
    }

    /**
     * @dev withdraw nft that user mistakenly transferred.
     */
    function withdrawNFT(address token, uint256 tokenId) external virtual onlyOwner {
        require(token != horseNFT || ownerOf[tokenId] == address(0), "SpecialHorseFarm: horse belong to contract");
        IERC721(token).safeTransferFrom(address(this), msg.sender, tokenId);
    }

    /**
     * @dev user lease horse.
     */
    function lease(LeaseData memory data) external virtual whenNotPaused {
        (bytes32 message, address signer) = _verifyLease(data);
        leaseCompleted[message] = true;
        for (uint256 i = 0; i < data.horseId.length; i++) {
            require(msg.sender == IERC721(horseNFT).ownerOf(data.horseId[i]), "SpecialHorseFarm: sender is not owner");
            leaseData[data.nonce] = SavedLease({
                owner: data.owner,
                horseId: data.horseId[i],
                blockExpired: data.blockExpired
            });
            leaseNoneOf[data.owner][leaseCountOf[data.owner]] = data.nonce;
            leaseCountOf[data.owner] = leaseCountOf[data.owner].add(1);

            ownerOf[data.horseId[i]] = data.owner;
            refundCompleted[data.horseId[i]] = false;
            transporter.safeTransferNFT721From(horseNFT, data.owner, address(this), data.horseId[i]);
        }
        emit Lease(data.owner, signer, data.horseId, data.nonce);
    }

    function _verifyLease(LeaseData memory data) internal view returns (bytes32, address) {
        bytes32 message = keccak256(
            abi.encode(address(this), "Lease", data.owner, data.horseId, data.blockExpired, data.nonce)
        );
        address signer = message.toString().recover(data.v, data.r, data.s);
        require(operators[signer], "SpecialHorseFarm: lease not verify");
        require(block.number < data.blockExpired, "SpecialHorseFarm: lease expired");
        require(!leaseCompleted[message], "SpecialHorseFarm: lease completed");
        require(leaseData[data.nonce].owner == address(0), "SpecialHorseFarm: nonce existed");
        return (message, signer);
    }

    /**
     * @dev admin Refund horse.
     */
    function HourseRefund(RefundData memory data) private whenNotPaused onlyOwner {
        require(block.number < data.blockExpired, "SpecialHorseFarm: Refund expired");
        require(refundData[data.nonce].blockExpired == 0, "SpecialHorseFarm: nonce existed");
        for (uint256 i = 0; i < data.horseId.length; i++) {
            require(ownerOf[data.horseId[i]] != address(0), "SpecialHorseFarm: horse Refunded");
            require(!refundCompleted[data.horseId[i]], "SpecialHorseFarm: Refund completed");

            refundCompleted[data.horseId[i]] = true;
            refundData[data.nonce] = SavedRefund({
                owner: data.owner,
                horseId: data.horseId[i],
                blockExpired: data.blockExpired
            });

            ownerOf[data.horseId[i]] = address(0);

            IERC721(horseNFT).safeTransferFrom(address(this), data.owner, data.horseId[i]);
        }
        emit Refund(msg.sender, data.horseId, data.nonce);
    }

    function withdraw(WithdrawData memory data) external virtual whenNotPaused {
        require(msg.sender == data.owner, "SpecialHorseFarm: sender is not owner");

        (bytes32 message, address signer) = _verifyWithdraw(data);
        for (uint256 i = 0; i < data.horseId.length; i++) {
            require(msg.sender == ownerOf[data.horseId[i]], "SpecialHorseFarm: sender is not horse owner");
            require(ownerOf[data.horseId[i]] != address(0), "SpecialHorseFarm: horse Refunded or withdrawed");
            require(!refundCompleted[data.horseId[i]], "SpecialHorseFarm: Refund completed");

            withdrawCompleted[message] = true;
            refundCompleted[data.horseId[i]] = true;
            withdrawData[data.nonce] = SavedWithdraw({
                owner: data.owner,
                horseId: data.horseId[i],
                blockExpired: data.blockExpired
            });
            withdrawNoneOf[msg.sender][withdrawCountOf[msg.sender]] = data.nonce;
            withdrawCountOf[msg.sender] = withdrawCountOf[msg.sender].add(1);

            ownerOf[data.horseId[i]] = address(0);

            IERC721(horseNFT).safeTransferFrom(address(this), msg.sender, data.horseId[i]);
        }
        emit Withdraw(msg.sender, signer, data.horseId, data.nonce);
    }

    function _verifyWithdraw(WithdrawData memory data) internal view returns (bytes32, address) {
        bytes32 message = keccak256(
            abi.encode(address(this), "Withdraw", data.owner, data.horseId, data.blockExpired, data.nonce)
        );
        address signer = message.toString().recover(data.v, data.r, data.s);
        require(operators[signer], "SpecialHorseFarm: withdraw not verify");
        require(block.number < data.blockExpired, "SpecialHorseFarm: withdraw expired");
        require(!withdrawCompleted[message], "SpecialHorseFarm: withdraw completed");
        require(withdrawData[data.nonce].blockExpired == 0, "SpecialHorseFarm: nonce existed");
        return (message, signer);
    }
}
        

@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}
          

@openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
          

@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol

// SPDX-License-Identifier: MIT

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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
          

@openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
          

@openzeppelin/contracts/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}
          

@openzeppelin/contracts/security/Pausable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
          

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
          

@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
          

@openzeppelin/contracts/token/ERC721/IERC721.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
          

@openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
          

@openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT

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);
}
          

@openzeppelin/contracts/utils/math/SafeMath.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
          

contracts/interfaces/ITransporter.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ITransporter {
    function safeTransferTokenFrom(
        address token_,
        address from_,
        address to_,
        uint256 amount_
    ) external;

    function safeTransferNFT721From(
        address token_,
        address from_,
        address to_,
        uint256 tokenId_
    ) external;

    function safeBurnNFT721From(address token_, uint256 tokenId_) external;

    function safeTransferNFT1155From(
        address token_,
        address from_,
        address to_,
        uint256 tokenId_,
        uint256 amount_
    ) external;

    function safeBurnNFT1155From(
        address token_,
        address from_,
        uint256 tokenId_,
        uint256 amount_
    ) external;

    function safeBurnBatchNFT1155From(
        address token_,
        address from_,
        uint256[] memory tokenId_,
        uint256[] memory amount_
    ) external;
}
          

contracts/libraries/BytesLibrary.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev BytesLibrary operations.
 */
library BytesLibrary {
    function toString(bytes32 value) internal pure returns (string memory) {
        bytes memory alphabet = "0123456789abcdef";
        bytes memory str = new bytes(64);
        for (uint256 i = 0; i < 32; i++) {
            str[i * 2] = alphabet[uint8(value[i] >> 4)];
            str[1 + i * 2] = alphabet[uint8(value[i] & 0x0f)];
        }
        return string(str);
    }
}
          

contracts/libraries/OwnerOperator.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract OwnerOperator is Ownable {
    mapping(address => bool) public operators;

    constructor() Ownable() {}

    modifier operatorOrOwner() {
        require(operators[msg.sender] || owner() == msg.sender, "OwnerOperator: !operator, !owner");
        _;
    }

    modifier onlyOperator() {
        require(operators[msg.sender], "OwnerOperator: !operator");
        _;
    }

    function addOperator(address operator) external virtual onlyOwner {
        require(operator != address(0), "OwnerOperator: operator is the zero address");
        operators[operator] = true;
    }

    function removeOperator(address operator) external virtual onlyOwner {
        require(operator != address(0), "OwnerOperator: operator is the zero address");
        operators[operator] = false;
    }
}
          

contracts/libraries/StringLibrary.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./UintLibrary.sol";

library StringLibrary {
    using UintLibrary for uint256;

    function append(string memory a, string memory b) internal pure returns (string memory) {
        bytes memory ba = bytes(a);
        bytes memory bb = bytes(b);
        bytes memory bab = new bytes(ba.length + bb.length);
        uint256 k = 0;
        for (uint256 i = 0; i < ba.length; i++) bab[k++] = ba[i];
        for (uint256 i = 0; i < bb.length; i++) bab[k++] = bb[i];
        return string(bab);
    }

    function append(
        string memory a,
        string memory b,
        string memory c
    ) internal pure returns (string memory) {
        bytes memory ba = bytes(a);
        bytes memory bb = bytes(b);
        bytes memory bc = bytes(c);
        bytes memory bbb = new bytes(ba.length + bb.length + bc.length);
        uint256 k = 0;
        for (uint256 i = 0; i < ba.length; i++) bbb[k++] = ba[i];
        for (uint256 i = 0; i < bb.length; i++) bbb[k++] = bb[i];
        for (uint256 i = 0; i < bc.length; i++) bbb[k++] = bc[i];
        return string(bbb);
    }

    function recover(
        string memory message,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        bytes memory msgBytes = bytes(message);
        bytes memory fullMessage = concat(
            bytes("\x19Ethereum Signed Message:\n"),
            bytes(msgBytes.length.toString()),
            msgBytes,
            new bytes(0),
            new bytes(0),
            new bytes(0),
            new bytes(0)
        );
        return ecrecover(keccak256(fullMessage), v, r, s);
    }

    function concat(
        bytes memory ba,
        bytes memory bb,
        bytes memory bc,
        bytes memory bd,
        bytes memory be,
        bytes memory bf,
        bytes memory bg
    ) internal pure returns (bytes memory) {
        bytes memory resultBytes = new bytes(ba.length + bb.length + bc.length + bd.length + be.length + bf.length + bg.length);
        uint256 k = 0;
        for (uint256 i = 0; i < ba.length; i++) resultBytes[k++] = ba[i];
        for (uint256 i = 0; i < bb.length; i++) resultBytes[k++] = bb[i];
        for (uint256 i = 0; i < bc.length; i++) resultBytes[k++] = bc[i];
        for (uint256 i = 0; i < bd.length; i++) resultBytes[k++] = bd[i];
        for (uint256 i = 0; i < be.length; i++) resultBytes[k++] = be[i];
        for (uint256 i = 0; i < bf.length; i++) resultBytes[k++] = bf[i];
        for (uint256 i = 0; i < bg.length; i++) resultBytes[k++] = bg[i];
        return resultBytes;
    }
}
          

contracts/libraries/UintLibrary.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

library UintLibrary {
    using SafeMath for uint256;

    function toString(uint256 i) internal pure returns (string memory) {
        if (i == 0) {
            return "0";
        }

        uint256 j = i;
        uint256 len;

        while (j != 0) {
            len++;
            j /= 10;
        }

        bytes memory bstr = new bytes(len);

        for (uint256 k = len; k > 0; k--) {
            bstr[k - 1] = bytes1(uint8(48 + (i % 10)));
            i /= 10;
        }

        return string(bstr);
    }

    function bp(uint256 value, uint256 bpValue) internal pure returns (uint256) {
        return value.mul(bpValue).div(10000);
    }
}
          

contracts/libraries/upgrade/ContextUpgradeSafe.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/utils/Initializable.sol";

abstract contract ContextUpgradeSafe is Initializable {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.

    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    // Reserved storage space to allow for layout changes in the future.
    uint256[50] private __gap;
}
          

contracts/libraries/upgrade/OwnableUpgradeSafe.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ContextUpgradeSafe.sol";

abstract contract OwnableUpgradeSafe is ContextUpgradeSafe {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.

    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
          

contracts/libraries/upgrade/OwnerOperatorUpgradeSafe.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./OwnableUpgradeSafe.sol";

abstract contract OwnerOperatorUpgradeSafe is OwnableUpgradeSafe {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.

    mapping(address => bool) public operators;
    event AddOperator(address indexed operator);
    event RemoveOperator(address indexed operator);

    function __OwnerOperator_init() internal initializer {
        __Ownable_init();
    }

    modifier operatorOrOwner() {
        require(operators[msg.sender] || owner() == msg.sender, "OwnerOperator: !operator, !owner");
        _;
    }

    modifier onlyOperator() {
        require(operators[msg.sender], "OwnerOperator: !operator");
        _;
    }

    function addOperator(address operator) external virtual onlyOwner {
        require(operator != address(0), "OwnerOperator: operator is the zero address");
        require(!operators[operator], "OwnerOperator: operator existed");
        operators[operator] = true;
        emit AddOperator(operator);
    }

    function removeOperator(address operator) external virtual onlyOwner {
        require(operator != address(0), "OwnerOperator: operator is the zero address");
        require(operators[operator], "OwnerOperator: operator not exist");
        operators[operator] = false;
        emit RemoveOperator(operator);
    }
}
          

contracts/libraries/upgrade/PauseUpgradeSafe.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ContextUpgradeSafe.sol";

abstract contract PauseUpgradeSafe is ContextUpgradeSafe {
    // Empty internal constructor, to prevent people from mistakenly deploying
    // an instance of this contract, which should be used via inheritance.

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pause_init() internal initializer {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"event","name":"Lease","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"signer","internalType":"address","indexed":true},{"type":"uint256[]","name":"horseId","internalType":"uint256[]","indexed":true},{"type":"string","name":"nonce","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Refund","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"uint256[]","name":"horseId","internalType":"uint256[]","indexed":true},{"type":"string","name":"nonce","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"signer","internalType":"address","indexed":true},{"type":"uint256[]","name":"horseId","internalType":"uint256[]","indexed":true},{"type":"string","name":"nonce","internalType":"string","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"horseNFT","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"lease","inputs":[{"type":"tuple","name":"data","internalType":"struct SpecialHorseFarm.LeaseData","components":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256[]","name":"horseId","internalType":"uint256[]"},{"type":"uint256","name":"blockExpired","internalType":"uint256"},{"type":"string","name":"nonce","internalType":"string"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"leaseCompleted","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"leaseCountOf","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"horseId","internalType":"uint256"},{"type":"uint256","name":"blockExpired","internalType":"uint256"}],"name":"leaseData","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"leaseNoneOf","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"operators","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTransporter","inputs":[{"type":"address","name":"_transporter","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ITransporter"}],"name":"transporter","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"tuple","name":"data","internalType":"struct SpecialHorseFarm.WithdrawData","components":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256[]","name":"horseId","internalType":"uint256[]"},{"type":"uint256","name":"blockExpired","internalType":"uint256"},{"type":"string","name":"nonce","internalType":"string"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"withdrawCompleted","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"withdrawCountOf","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"horseId","internalType":"uint256"},{"type":"uint256","name":"blockExpired","internalType":"uint256"}],"name":"withdrawData","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawNFT","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"withdrawNoneOf","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToken","inputs":[{"type":"address","name":"token","internalType":"address"}]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c8063715018a6116100ee5780639870d7fe11610097578063a8ed22a311610071578063a8ed22a314610504578063ac8a584a14610527578063e42b02121461053a578063f2fde38b1461055a576101ae565b80639870d7fe146104be57806399725af1146104d15780639c8dadae146104f1576101ae565b806389476069116100c8578063894760691461047a5780638da5cb5b1461048d57806395a2f5e3146104ab576101ae565b8063715018a6146104195780637a2ef48b146104215780638456cb5914610472576101ae565b806317c6395d1161015b5780635c975abb116101355780635c975abb14610342578063604ff5a41461034d5780636088e93a146103d05780636352211e146103e3576101ae565b806317c6395d146102dd578063336db659146102f05780633f4ba83a1461033a576101ae565b806313e7c9d81161018c57806313e7c9d81461023d578063150b7a0214610260578063176a9a80146102c8576101ae565b8063037a4a4a146101b357806304d45b49146101dc57806307d0ef971461020f575b600080fd5b6101c66101c1366004613b5e565b61056d565b6040516101d39190613e16565b60405180910390f35b6101ff6101ea366004613ba9565b60046020526000908152604090205460ff1681565b60405190151581526020016101d3565b61022f61021d366004613aa9565b600c6020526000908152604090205481565b6040519081526020016101d3565b6101ff61024b366004613aa9565b60016020526000908152604090205460ff1681565b61029761026e366004613ae1565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101d3565b6102db6102d6366004613bf4565b610612565b005b6101c66102eb366004613b5e565b610cec565b60025461031590610100900473ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d3565b6102db610d10565b60025460ff166101ff565b61039e61035b366004613bc1565b8051602081830181018051600b8252928201919093012091528054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff909116919083565b6040805173ffffffffffffffffffffffffffffffffffffffff90941684526020840192909252908201526060016101d3565b6102db6103de366004613b5e565b610d9b565b6103156103f1366004613ba9565b60036020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6102db610f89565b61039e61042f366004613bc1565b805160208183018101805160058252928201919093012091528054600182015460029092015473ffffffffffffffffffffffffffffffffffffffff909116919083565b6102db611014565b6102db610488366004613aa9565b61109d565b60005473ffffffffffffffffffffffffffffffffffffffff16610315565b6102db6104b9366004613bf4565b611275565b6102db6104cc366004613aa9565b611af1565b61022f6104df366004613aa9565b60066020526000908152604090205481565b6102db6104ff366004613aa9565b611c67565b6101ff610512366004613ba9565b600a6020526000908152604090205460ff1681565b6102db610535366004613aa9565b611d2f565b600e546103159073ffffffffffffffffffffffffffffffffffffffff1681565b6102db610568366004613aa9565b611e9f565b600d6020908152600092835260408084209091529082529020805461059190613f5d565b80601f01602080910402602001604051908101604052809291908181526020018280546105bd90613f5d565b801561060a5780601f106105df5761010080835404028352916020019161060a565b820191906000526020600020905b8154815290600101906020018083116105ed57829003601f168201915b505050505081565b60025460ff1615610684576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064015b60405180910390fd5b60008061069083611fcf565b600082815260046020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905591935091505b836020015151811015610c5f57600260019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e85602001518381518110610755577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b815260040161077b91815260200190565b60206040518083038186803b15801561079357600080fd5b505afa1580156107a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107cb9190613ac5565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610885576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f5370656369616c486f7273654661726d3a2073656e646572206973206e6f742060448201527f6f776e6572000000000000000000000000000000000000000000000000000000606482015260840161067b565b6040518060600160405280856000015173ffffffffffffffffffffffffffffffffffffffff168152602001856020015183815181106108ed577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015181526020018560400151815250600585606001516040516109169190613cf9565b9081526040805160209281900383019020835181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff918216178255848401516001830155938201516002909101556060870151875184166000908152600784528281208951909516815260068452828120548152938352922082516109b8939192919091019061382d565b50835173ffffffffffffffffffffffffffffffffffffffff166000908152600660205260409020546109eb9060016122c1565b845173ffffffffffffffffffffffffffffffffffffffff1660009081526006602090815260408220929092558551918601518051600392919085908110610a5b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006008600086602001518481518110610af2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910181015182528181019290925260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001692151592909217909155600e54600254865192870151805173ffffffffffffffffffffffffffffffffffffffff9384169463a5bc64ca946101009094049093169291309187908110610bac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b16815273ffffffffffffffffffffffffffffffffffffffff94851660048201529284166024840152921660448201526064810191909152608401600060405180830381600087803b158015610c3457600080fd5b505af1158015610c48573d6000803e3d6000fd5b505050508080610c5790613fb1565b9150506106cd565b508260200151604051610c729190613cc3565b60405180910390208173ffffffffffffffffffffffffffffffffffffffff16846000015173ffffffffffffffffffffffffffffffffffffffff167fc601abf905069e172d7a18616f010fb28b07d108a58f97364666967536f412228660600151604051610cdf9190613e16565b60405180910390a4505050565b60076020908152600092835260408084209091529082529020805461059190613f5d565b60005473ffffffffffffffffffffffffffffffffffffffff163314610d91576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b610d996122d4565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e1c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b60025473ffffffffffffffffffffffffffffffffffffffff83811661010090920416141580610e6d575060008181526003602052604090205473ffffffffffffffffffffffffffffffffffffffff16155b610ef9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5370656369616c486f7273654661726d3a20686f7273652062656c6f6e67207460448201527f6f20636f6e747261637400000000000000000000000000000000000000000000606482015260840161067b565b6040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201523360248201526044810182905273ffffffffffffffffffffffffffffffffffffffff8316906342842e0e90606401600060405180830381600087803b158015610f6d57600080fd5b505af1158015610f81573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461100a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b610d9960006123b5565b60005473ffffffffffffffffffffffffffffffffffffffff163314611095576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b610d9961242a565b60005473ffffffffffffffffffffffffffffffffffffffff16331461111e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a082319060240160206040518083038186803b15801561118657600080fd5b505afa15801561119a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111be9190613c27565b905060008111611250576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f5370656369616c486f7273654661726d3a207a65726f206f757420616d6f756e60448201527f7400000000000000000000000000000000000000000000000000000000000000606482015260840161067b565b61127173ffffffffffffffffffffffffffffffffffffffff831633836124ea565b5050565b60025460ff16156112e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161067b565b805173ffffffffffffffffffffffffffffffffffffffff163314611388576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f5370656369616c486f7273654661726d3a2073656e646572206973206e6f742060448201527f6f776e6572000000000000000000000000000000000000000000000000000000606482015260840161067b565b6000806113948361257c565b9150915060005b836020015151811015611a755760036000856020015183815181106113e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff1633146114a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f5370656369616c486f7273654661726d3a2073656e646572206973206e6f742060448201527f686f727365206f776e6572000000000000000000000000000000000000000000606482015260840161067b565b600073ffffffffffffffffffffffffffffffffffffffff166003600086602001518481518110611501577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff1614156115c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f5370656369616c486f7273654661726d3a20686f72736520526566756e64656460448201527f206f722077697468647261776564000000000000000000000000000000000000606482015260840161067b565b6008600085602001518381518110611601577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910181015182528101919091526040016000205460ff16156116ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f5370656369616c486f7273654661726d3a20526566756e6420636f6d706c657460448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161067b565b6000838152600a60209081526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600190811790915590860151805191926008929091908590811061172d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055506040518060600160405280856000015173ffffffffffffffffffffffffffffffffffffffff168152602001856020015183815181106117c2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015181526020018560400151815250600b85606001516040516117eb9190613cf9565b9081526040805160209281900383019020835181547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178155838301516001820155928101516002909301929092556060860151336000908152600d8352838120600c84528482205482528352929092208251611887939192919091019061382d565b50336000908152600c60205260409020546118a39060016122c1565b336000908152600c602090815260408220929092559085015180516003918391859081106118fa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600260019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e3033876020015185815181106119cb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60209081029190910101516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b16815273ffffffffffffffffffffffffffffffffffffffff93841660048201529290911660248301526044820152606401600060405180830381600087803b158015611a4a57600080fd5b505af1158015611a5e573d6000803e3d6000fd5b505050508080611a6d90613fb1565b91505061139b565b508260200151604051611a889190613cc3565b60405180910390208173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe33d9381fffe36a88d02e5660b8002abde502aa4d0709f51f793bca6fc4fe2368660600151604051610cdf9190613e16565b60005473ffffffffffffffffffffffffffffffffffffffff163314611b72576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b73ffffffffffffffffffffffffffffffffffffffff8116611c15576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f4f776e65724f70657261746f723a206f70657261746f7220697320746865207a60448201527f65726f2061646472657373000000000000000000000000000000000000000000606482015260840161067b565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169091179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314611ce8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b600e80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff163314611db0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b73ffffffffffffffffffffffffffffffffffffffff8116611e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f4f776e65724f70657261746f723a206f70657261746f7220697320746865207a60448201527f65726f2061646472657373000000000000000000000000000000000000000000606482015260840161067b565b73ffffffffffffffffffffffffffffffffffffffff16600090815260016020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60005473ffffffffffffffffffffffffffffffffffffffff163314611f20576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067b565b73ffffffffffffffffffffffffffffffffffffffff8116611fc3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161067b565b611fcc816123b5565b50565b6000806000308460000151856020015186604001518760600151604051602001611ffd959493929190613d15565b604051602081830303815290604052805190602001209050600061203a85608001518660a001518760c0015161203286612857565b929190612b28565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205490915060ff166120f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f5370656369616c486f7273654661726d3a206c65617365206e6f74207665726960448201527f6679000000000000000000000000000000000000000000000000000000000000606482015260840161067b565b8460400151431061215f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5370656369616c486f7273654661726d3a206c65617365206578706972656400604482015260640161067b565b60008281526004602052604090205460ff16156121fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f5370656369616c486f7273654661726d3a206c6561736520636f6d706c65746560448201527f6400000000000000000000000000000000000000000000000000000000000000606482015260840161067b565b600073ffffffffffffffffffffffffffffffffffffffff166005866060015160405161222a9190613cf9565b9081526040519081900360200190205473ffffffffffffffffffffffffffffffffffffffff16146122b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5370656369616c486f7273654661726d3a206e6f6e6365206578697374656400604482015260640161067b565b9092509050915091565b60006122cd8284613e78565b9392505050565b60025460ff16612340576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161067b565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60025460ff1615612497576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161067b565b600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861238b3390565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052612577908490612c3b565b505050565b60008060003084600001518560200151866040015187606001516040516020016125aa959493929190613da9565b60405160208183030381529060405280519060200120905060006125df85608001518660a001518760c0015161203286612857565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001602052604090205490915060ff16612697576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f5370656369616c486f7273654661726d3a207769746864726177206e6f74207660448201527f6572696679000000000000000000000000000000000000000000000000000000606482015260840161067b565b8460400151431061272a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f5370656369616c486f7273654661726d3a20776974686472617720657870697260448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161067b565b6000828152600a602052604090205460ff16156127c8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5370656369616c486f7273654661726d3a20776974686472617720636f6d706c60448201527f6574656400000000000000000000000000000000000000000000000000000000606482015260840161067b565b600b85606001516040516127dc9190613cf9565b9081526020016040518091039020600201546000146122b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5370656369616c486f7273654661726d3a206e6f6e6365206578697374656400604482015260640161067b565b604080518082018252601081527f30313233343536373839616263646566000000000000000000000000000000006020820152815182815260608181018452926000919060208201818036833701905050905060005b6020811015612b1e578260048683602081106128f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916901c60f81c60ff1681518110612957577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff00000000000000000000000000000000000000000000000000000000000000168261298a836002613ea4565b815181106129c1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535082858260208110612a2a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b825191901a600f16908110612a68577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001682612a9b836002613ea4565b612aa6906001613e78565b81518110612add577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080612b1681613fb1565b9150506128ad565b509150505b919050565b6000808590506000612ba06040518060400160405280601a81526020017f19457468657265756d205369676e6564204d6573736167653a0a000000000000815250612b738451612d47565b60408051600080825260208201818152828401828152606084019283526080840190945288939091612edc565b90506001818051906020012087878760405160008152602001604052604051612be5949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015612c07573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015198975050505050505050565b6000612c9d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166136439092919063ffffffff16565b8051909150156125775780806020019051810190612cbb9190613b89565b612577576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161067b565b606081612d88575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152612b23565b8160005b8115612db25780612d9c81613fb1565b9150612dab9050600a83613e90565b9150612d8c565b60008167ffffffffffffffff811115612df4577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e1e576020820181803683370190505b509050815b8015612ed357612e34600a87613fea565b612e3f906030613e78565b60f81b82612e4e600184613ee1565b81518110612e85577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612ebf600a87613e90565b955080612ecb81613f28565b915050612e23565b50949350505050565b6060600082518451865188518a518c518e51612ef89190613e78565b612f029190613e78565b612f0c9190613e78565b612f169190613e78565b612f209190613e78565b612f2a9190613e78565b67ffffffffffffffff811115612f69577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612f93576020820181803683370190505b5090506000805b8a51811015613088578a8181518110612fdc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff0000000000000000000000000000000000000000000000000000000000000016838361300e81613fb1565b945081518110613047577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061308081613fb1565b915050612f9a565b5060005b895181101561317a578981815181106130ce577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff0000000000000000000000000000000000000000000000000000000000000016838361310081613fb1565b945081518110613139577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061317281613fb1565b91505061308c565b5060005b885181101561326c578881815181106131c0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001683836131f281613fb1565b94508151811061322b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061326481613fb1565b91505061317e565b5060005b875181101561335e578781815181106132b2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001683836132e481613fb1565b94508151811061331d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061335681613fb1565b915050613270565b5060005b8651811015613450578681815181106133a4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001683836133d681613fb1565b94508151811061340f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061344881613fb1565b915050613362565b5060005b855181101561354257858181518110613496577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001683836134c881613fb1565b945081518110613501577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061353a81613fb1565b915050613454565b5060005b845181101561363457848181518110613588577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01602001517fff000000000000000000000000000000000000000000000000000000000000001683836135ba81613fb1565b9450815181106135f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508061362c81613fb1565b915050613546565b50909998505050505050505050565b6060613652848460008561365a565b949350505050565b6060824710156136ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161067b565b843b613754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161067b565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161377d9190613cf9565b60006040518083038185875af1925050503d80600081146137ba576040519150601f19603f3d011682016040523d82523d6000602084013e6137bf565b606091505b50915091506137cf8282866137da565b979650505050505050565b606083156137e95750816122cd565b8251156137f95782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067b9190613e16565b82805461383990613f5d565b90600052602060002090601f01602090048101928261385b57600085556138a1565b82601f1061387457805160ff19168380011785556138a1565b828001600101855582156138a1579182015b828111156138a1578251825591602001919060010190613886565b506138ad9291506138b1565b5090565b5b808211156138ad57600081556001016138b2565b600067ffffffffffffffff8311156138e0576138e061405c565b61391160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f86011601613e29565b905082815283838301111561392557600080fd5b828260208301376000602084830101529392505050565b8035612b238161408b565b600082601f830112613957578081fd5b8135602067ffffffffffffffff8211156139735761397361405c565b808202613981828201613e29565b83815282810190868401838801850189101561399b578687fd5b8693505b858410156139bd57803583526001939093019291840191840161399f565b50979650505050505050565b600082601f8301126139d9578081fd5b6122cd838335602085016138c6565b600060e082840312156139f9578081fd5b613a0360e0613e29565b9050613a0e8261393c565b8152602082013567ffffffffffffffff80821115613a2b57600080fd5b613a3785838601613947565b6020840152604084013560408401526060840135915080821115613a5a57600080fd5b50613a67848285016139c9565b606083015250613a7960808301613a98565b608082015260a082013560a082015260c082013560c082015292915050565b803560ff81168114612b2357600080fd5b600060208284031215613aba578081fd5b81356122cd8161408b565b600060208284031215613ad6578081fd5b81516122cd8161408b565b60008060008060808587031215613af6578283fd5b8435613b018161408b565b93506020850135613b118161408b565b925060408501359150606085013567ffffffffffffffff811115613b33578182fd5b8501601f81018713613b43578182fd5b613b52878235602084016138c6565b91505092959194509250565b60008060408385031215613b70578182fd5b8235613b7b8161408b565b946020939093013593505050565b600060208284031215613b9a578081fd5b815180151581146122cd578182fd5b600060208284031215613bba578081fd5b5035919050565b600060208284031215613bd2578081fd5b813567ffffffffffffffff811115613be8578182fd5b613652848285016139c9565b600060208284031215613c05578081fd5b813567ffffffffffffffff811115613c1b578182fd5b613652848285016139e8565b600060208284031215613c38578081fd5b5051919050565b6000815180845260208085019450808401835b83811015613c6e57815187529582019590820190600101613c52565b509495945050505050565b60008151808452613c91816020860160208601613ef8565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b815160009082906020808601845b83811015613ced57815185529382019390820190600101613cd1565b50929695505050505050565b60008251613d0b818460208701613ef8565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff808816835260c06020840152600560c08401527f4c6561736500000000000000000000000000000000000000000000000000000060e08401526101008188166040850152806060850152613d8281850188613c3f565b91505084608084015282810360a0840152613d9d8185613c79565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835260c06020840152600860c08401527f576974686472617700000000000000000000000000000000000000000000000060e08401526101008188166040850152806060850152613d8281850188613c3f565b6000602082526122cd6020830184613c79565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613e7057613e7061405c565b604052919050565b60008219821115613e8b57613e8b613ffe565b500190565b600082613e9f57613e9f61402d565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613edc57613edc613ffe565b500290565b600082821015613ef357613ef3613ffe565b500390565b60005b83811015613f13578181015183820152602001613efb565b83811115613f22576000848401525b50505050565b600081613f3757613f37613ffe565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b600281046001821680613f7157607f821691505b60208210811415613fab577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613fe357613fe3613ffe565b5060010190565b600082613ff957613ff961402d565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff81168114611fcc57600080fdfea2646970667358221220c3f590e3414d6cdb2dce13daacb05d58e2b3c846b4e3d39d4fb202a64f22171964736f6c63430008020033